Bug 1646835 - move SWGL context creation into specific SWGL RenderCompositors. r?jrmuizel draft
authorLee Salzman <lsalzman@mozilla.com>
Tue, 23 Jun 2020 23:39:55 +0000
changeset 2999962 6d92405d048a1520fcad18a260b0b1b4ef1337ea
parent 2999961 2d64d61aa4d46d5e99ffea07c6a4963ccd02b723
child 2999963 6c92d9a126da34bdc1327d0bbe9edb17b7a1ba0b
push id558590
push userreviewbot
push dateTue, 23 Jun 2020 23:40:15 +0000
treeherdertry@6c92d9a126da [default view] [failures only]
reviewersjrmuizel
bugs1646835
milestone79.0a1
Bug 1646835 - move SWGL context creation into specific SWGL RenderCompositors. r?jrmuizel Summary: Currently RendererOGL has mixed-in details of SWGL context creation which becomes messy and slightly unanticipated based on the nomenclature and structure of RendererOGL. Based on other work in bug 1646835, it becomes more natural to move this context creation into the specific SWGL RenderCompositors so that RendererOGL can be agnostic to any SWGL details. Differential Revision: https://phabricator.services.mozilla.com/D80273 Depends on D80270 Test Plan: Reviewers: jrmuizel Subscribers: Bug #: 1646835 Differential Diff: PHID-DIFF-wjtjra4r4niezhxdgpcq
gfx/webrender_bindings/RenderCompositor.cpp
gfx/webrender_bindings/RenderCompositor.h
gfx/webrender_bindings/RenderCompositorNative.cpp
gfx/webrender_bindings/RenderCompositorNative.h
gfx/webrender_bindings/RenderCompositorSWGL.cpp
gfx/webrender_bindings/RenderCompositorSWGL.h
gfx/webrender_bindings/RenderThread.cpp
gfx/webrender_bindings/RendererOGL.cpp
gfx/webrender_bindings/RendererOGL.h
gfx/webrender_bindings/WebRenderAPI.cpp
--- a/gfx/webrender_bindings/RenderCompositor.cpp
+++ b/gfx/webrender_bindings/RenderCompositor.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "RenderCompositor.h"
 
 #include "GLContext.h"
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/layers/SyncObject.h"
 #include "mozilla/webrender/RenderCompositorOGL.h"
+#include "mozilla/webrender/RenderCompositorSWGL.h"
 #include "mozilla/widget/CompositorWidget.h"
 
 #ifdef XP_WIN
 #  include "mozilla/webrender/RenderCompositorANGLE.h"
 #endif
 
 #if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID)
 #  include "mozilla/webrender/RenderCompositorEGL.h"
@@ -107,16 +108,25 @@ void wr_compositor_map_tile(void* aCompo
 void wr_compositor_unmap_tile(void* aCompositor) {
   RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
   compositor->UnmapTile();
 }
 
 /* static */
 UniquePtr<RenderCompositor> RenderCompositor::Create(
     RefPtr<widget::CompositorWidget>&& aWidget) {
+  if (gfx::gfxVars::UseSoftwareWebRender()) {
+#ifdef XP_MACOSX
+    // Mac uses NativeLayerCA
+    return RenderCompositorNativeSWGL::Create(std::move(aWidget));
+#else
+    return RenderCompositorSWGL::Create(std::move(aWidget));
+#endif
+  }
+
 #ifdef XP_WIN
   if (gfx::gfxVars::UseWebRenderANGLE()) {
     return RenderCompositorANGLE::Create(std::move(aWidget));
   }
 #endif
 
 #if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID)
   UniquePtr<RenderCompositor> eglCompositor =
@@ -137,20 +147,17 @@ UniquePtr<RenderCompositor> RenderCompos
 #endif
 }
 
 RenderCompositor::RenderCompositor(RefPtr<widget::CompositorWidget>&& aWidget)
     : mWidget(aWidget) {}
 
 RenderCompositor::~RenderCompositor() = default;
 
-bool RenderCompositor::MakeCurrent() {
-  gl::GLContext* context = gl();
-  return !context || context->MakeCurrent();
-}
+bool RenderCompositor::MakeCurrent() { return gl()->MakeCurrent(); }
 
 bool RenderCompositor::IsContextLost() {
   // XXX Add glGetGraphicsResetStatus handling for checking rendering context
   // has not been lost
   return false;
 }
 
 }  // namespace wr
--- a/gfx/webrender_bindings/RenderCompositor.h
+++ b/gfx/webrender_bindings/RenderCompositor.h
@@ -55,27 +55,23 @@ class RenderCompositor {
   // @return the last (highest) completed RenderedFrameId
   virtual RenderedFrameId GetLastCompletedFrameId() {
     return mLatestRenderFrameId.Prev();
   }
 
   // Update FrameId when WR rendering does not happen.
   virtual RenderedFrameId UpdateFrameId() { return GetNextRenderFrameId(); }
 
-  // Return a data mapping of the underlying framebuffer if possible.
-  virtual bool GetMappedBuffer(uint8_t** aData, int32_t* aStride) {
-    return false;
-  }
-
   virtual void Pause() = 0;
   virtual bool Resume() = 0;
   // Called when WR rendering is skipped
   virtual void Update() {}
 
   virtual gl::GLContext* gl() const { return nullptr; }
+  virtual void* swgl() const { return nullptr; }
 
   virtual bool MakeCurrent();
 
   virtual bool UseANGLE() const { return false; }
 
   virtual bool UseDComp() const { return false; }
 
   virtual bool UseTripleBuffering() const { return false; }
--- a/gfx/webrender_bindings/RenderCompositorNative.cpp
+++ b/gfx/webrender_bindings/RenderCompositorNative.cpp
@@ -37,17 +37,22 @@ UniquePtr<RenderCompositor> RenderCompos
   }
   return MakeUnique<RenderCompositorNativeOGL>(std::move(aWidget),
                                                std::move(gl));
 }
 
 /* static */
 UniquePtr<RenderCompositor> RenderCompositorNativeSWGL::Create(
     RefPtr<widget::CompositorWidget>&& aWidget) {
-  return MakeUnique<RenderCompositorNativeSWGL>(std::move(aWidget));
+  void* ctx = wr_swgl_create_context();
+  if (!ctx) {
+    gfxCriticalNote << "Failed SWGL context creation for WebRender";
+    return nullptr;
+  }
+  return MakeUnique<RenderCompositorNativeSWGL>(std::move(aWidget), ctx);
 }
 
 RenderCompositorNative::RenderCompositorNative(
     RefPtr<widget::CompositorWidget>&& aWidget, gl::GLContext* aGL)
     : RenderCompositor(std::move(aWidget)),
       mNativeLayerRoot(GetWidget()->GetNativeLayerRoot()) {
 #ifdef XP_MACOSX
   auto pool = RenderThread::Get()->SharedSurfacePool();
@@ -85,18 +90,29 @@ RenderCompositorNativeOGL::~RenderCompos
     mGL->fDeleteSync(mPreviousFrameDoneSync);
   }
   if (mThisFrameDoneSync) {
     mGL->fDeleteSync(mThisFrameDoneSync);
   }
 }
 
 RenderCompositorNativeSWGL::RenderCompositorNativeSWGL(
-    RefPtr<widget::CompositorWidget>&& aWidget)
-    : RenderCompositorNative(std::move(aWidget)) {}
+    RefPtr<widget::CompositorWidget>&& aWidget, void* aContext)
+    : RenderCompositorNative(std::move(aWidget)), mContext(aContext) {
+  MOZ_ASSERT(mContext);
+}
+
+RenderCompositorNativeSWGL::~RenderCompositorNativeSWGL() {
+  wr_swgl_destroy_context(mContext);
+}
+
+bool RenderCompositorNativeSWGL::MakeCurrent() {
+  wr_swgl_make_current(mContext);
+  return true;
+}
 
 bool RenderCompositorNative::BeginFrame() {
   if (!MakeCurrent()) {
     gfxCriticalNote << "Failed to make render context current, can't draw.";
     return false;
   }
 
   gfx::IntSize bufferSize = GetBufferSize().ToUnknownSize();
@@ -138,16 +154,18 @@ bool RenderCompositorNativeOGL::InitDefa
 }
 
 bool RenderCompositorNativeSWGL::InitDefaultFramebuffer(
     const gfx::IntRect& aBounds) {
   if (mNativeLayerForEntireWindow) {
     if (!MapNativeLayer(mNativeLayerForEntireWindow, aBounds, aBounds)) {
       return false;
     }
+    wr_swgl_init_default_framebuffer(mContext, aBounds.width, aBounds.height,
+                                     mLayerStride, mLayerData);
   }
   return true;
 }
 
 void RenderCompositorNativeSWGL::CancelFrame() {
   if (mNativeLayerForEntireWindow && mLayerTarget) {
     UnmapNativeLayer();
   }
@@ -362,26 +380,16 @@ bool RenderCompositorNativeSWGL::MapNati
 void RenderCompositorNativeSWGL::UnmapNativeLayer() {
   MOZ_ASSERT(mLayerTarget && mLayerData);
   mLayerTarget->ReleaseBits(mLayerData);
   mLayerTarget = nullptr;
   mLayerData = nullptr;
   mLayerStride = 0;
 }
 
-bool RenderCompositorNativeSWGL::GetMappedBuffer(uint8_t** aData,
-                                                 int32_t* aStride) {
-  if (mNativeLayerForEntireWindow && mLayerData) {
-    *aData = mLayerData;
-    *aStride = mLayerStride;
-    return true;
-  }
-  return false;
-}
-
 bool RenderCompositorNativeSWGL::MapTile(wr::NativeTileId aId,
                                          wr::DeviceIntRect aDirtyRect,
                                          wr::DeviceIntRect aValidRect,
                                          void** aData, int32_t* aStride) {
   if (mNativeLayerForEntireWindow) {
     return false;
   }
   gfx::IntRect dirtyRect(aDirtyRect.origin.x, aDirtyRect.origin.y,
--- a/gfx/webrender_bindings/RenderCompositorNative.h
+++ b/gfx/webrender_bindings/RenderCompositorNative.h
@@ -159,36 +159,41 @@ class RenderCompositorNativeOGL : public
 
 // RenderCompositorNativeSWGL is a NativeLayer compositor that only
 // deals with mapping the underlying buffer for SWGL usage of a tile.
 class RenderCompositorNativeSWGL : public RenderCompositorNative {
  public:
   static UniquePtr<RenderCompositor> Create(
       RefPtr<widget::CompositorWidget>&& aWidget);
 
-  RenderCompositorNativeSWGL(RefPtr<widget::CompositorWidget>&& aWidget);
+  RenderCompositorNativeSWGL(RefPtr<widget::CompositorWidget>&& aWidget,
+                             void* aContext);
+  virtual ~RenderCompositorNativeSWGL();
+
+  void* swgl() const override { return mContext; }
+
+  bool MakeCurrent() override;
 
   void CancelFrame() override;
 
   bool MapTile(wr::NativeTileId aId, wr::DeviceIntRect aDirtyRect,
                wr::DeviceIntRect aValidRect, void** aData,
                int32_t* aStride) override;
   void UnmapTile() override;
 
-  bool GetMappedBuffer(uint8_t** aData, int32_t* aStride) override;
-
  protected:
   bool InitDefaultFramebuffer(const gfx::IntRect& aBounds) override;
   void DoSwap() override;
 
   bool MapNativeLayer(layers::NativeLayer* aLayer,
                       const gfx::IntRect& aDirtyRect,
                       const gfx::IntRect& aValidRect);
   void UnmapNativeLayer();
 
+  void* mContext = nullptr;
   RefPtr<gfx::DrawTarget> mLayerTarget;
   uint8_t* mLayerData = nullptr;
   int32_t mLayerStride = 0;
 };
 
 }  // namespace wr
 }  // namespace mozilla
 
--- a/gfx/webrender_bindings/RenderCompositorSWGL.cpp
+++ b/gfx/webrender_bindings/RenderCompositorSWGL.cpp
@@ -9,33 +9,46 @@
 #include "mozilla/widget/CompositorWidget.h"
 
 namespace mozilla {
 namespace wr {
 
 /* static */
 UniquePtr<RenderCompositor> RenderCompositorSWGL::Create(
     RefPtr<widget::CompositorWidget>&& aWidget) {
-  return MakeUnique<RenderCompositorSWGL>(std::move(aWidget));
+  void* ctx = wr_swgl_create_context();
+  if (!ctx) {
+    gfxCriticalNote << "Failed SWGL context creation for WebRender";
+    return nullptr;
+  }
+  return MakeUnique<RenderCompositorSWGL>(std::move(aWidget), ctx);
 }
 
 RenderCompositorSWGL::RenderCompositorSWGL(
-    RefPtr<widget::CompositorWidget>&& aWidget)
-    : RenderCompositor(std::move(aWidget)) {
+    RefPtr<widget::CompositorWidget>&& aWidget, void* aContext)
+    : RenderCompositor(std::move(aWidget)), mContext(aContext) {
+  MOZ_ASSERT(mContext);
   ClearMappedBuffer();
 }
 
-RenderCompositorSWGL::~RenderCompositorSWGL() {}
+RenderCompositorSWGL::~RenderCompositorSWGL() {
+  wr_swgl_destroy_context(mContext);
+}
 
 void RenderCompositorSWGL::ClearMappedBuffer() {
   mMap.mData = nullptr;
   mMap.mStride = 0;
   mDT = nullptr;
 }
 
+bool RenderCompositorSWGL::MakeCurrent() {
+  wr_swgl_make_current(mContext);
+  return true;
+}
+
 bool RenderCompositorSWGL::BeginFrame() {
   // Request a new draw target to use from the widget...
   ClearMappedBuffer();
   LayoutDeviceIntRect bounds(LayoutDeviceIntPoint(), GetBufferSize());
   mRegion = LayoutDeviceIntRegion(bounds);
   layers::BufferMode bufferMode = layers::BufferMode::BUFFERED;
   mDT = mWidget->StartRemoteDrawingInRegion(mRegion, &bufferMode);
   if (!mDT) {
@@ -71,16 +84,20 @@ bool RenderCompositorSWGL::BeginFrame() 
     }
     if (!mSurface || !mSurface->Map(DataSourceSurface::READ_WRITE, &mMap)) {
       // We failed mapping the data surface, so need to cancel the frame.
       mWidget->EndRemoteDrawingInRegion(mDT, mRegion);
       ClearMappedBuffer();
       return false;
     }
   }
+
+  wr_swgl_make_current(mContext);
+  wr_swgl_init_default_framebuffer(mContext, bounds.width, bounds.height,
+                                   mMap.mStride, mMap.mData);
   return true;
 }
 
 void RenderCompositorSWGL::CommitMappedBuffer(
     const nsTArray<DeviceIntRect>* aDirtyRects) {
   if (!mDT) {
     return;
   }
--- a/gfx/webrender_bindings/RenderCompositorSWGL.h
+++ b/gfx/webrender_bindings/RenderCompositorSWGL.h
@@ -13,41 +13,38 @@ namespace mozilla {
 
 namespace wr {
 
 class RenderCompositorSWGL : public RenderCompositor {
  public:
   static UniquePtr<RenderCompositor> Create(
       RefPtr<widget::CompositorWidget>&& aWidget);
 
-  RenderCompositorSWGL(RefPtr<widget::CompositorWidget>&& aWidget);
+  RenderCompositorSWGL(RefPtr<widget::CompositorWidget>&& aWidget,
+                       void* aContext);
   virtual ~RenderCompositorSWGL();
 
+  void* swgl() const override { return mContext; }
+
+  bool MakeCurrent() override;
+
   bool BeginFrame() override;
   void CancelFrame() override;
   RenderedFrameId EndFrame(const nsTArray<DeviceIntRect>& aDirtyRects) final;
 
-  bool GetMappedBuffer(uint8_t** aData, int32_t* aStride) override {
-    if (mMap.mData) {
-      *aData = mMap.mData;
-      *aStride = mMap.mStride;
-      return true;
-    }
-    return false;
-  }
-
   void Pause() override;
   bool Resume() override;
 
   LayoutDeviceIntSize GetBufferSize() override;
 
   // Interface for wr::Compositor
   CompositorCapabilities GetCompositorCapabilities() override;
 
  private:
+  void* mContext = nullptr;
   RefPtr<DrawTarget> mDT;
   LayoutDeviceIntRegion mRegion;
   RefPtr<DataSourceSurface> mSurface;
   gfx::DataSourceSurface::MappedSurface mMap;
 
   void ClearMappedBuffer();
 
   void CommitMappedBuffer(const nsTArray<DeviceIntRect>* aDirtyRects = nullptr);
--- a/gfx/webrender_bindings/RenderThread.cpp
+++ b/gfx/webrender_bindings/RenderThread.cpp
@@ -772,19 +772,23 @@ RenderTextureHost* RenderThread::GetRend
   }
   return it->second;
 }
 
 void RenderThread::InitDeviceTask() {
   MOZ_ASSERT(IsInRenderThread());
   MOZ_ASSERT(!mSharedGL);
 
+  if (gfx::gfxVars::UseSoftwareWebRender()) {
+    // Ensure we don't instantiate any shared GL context when SW-WR is used.
+    return;
+  }
+
   mSharedGL = CreateGLContext();
-  if (gfx::gfxVars::UseWebRenderProgramBinaryDisk() &&
-      !gfx::gfxVars::UseSoftwareWebRender()) {
+  if (gfx::gfxVars::UseWebRenderProgramBinaryDisk()) {
     mProgramCache = MakeUnique<WebRenderProgramCache>(ThreadPool().Raw());
   }
   // Query the shared GL context to force the
   // lazy initialization to happen now.
   SharedGL();
 }
 
 void RenderThread::HandleDeviceReset(const char* aWhere, bool aNotify) {
@@ -862,17 +866,17 @@ bool RenderThread::IsHandlingWebRenderEr
 }
 
 gl::GLContext* RenderThread::SharedGL() {
   MOZ_ASSERT(IsInRenderThread());
   if (!mSharedGL) {
     mSharedGL = CreateGLContext();
     mShaders = nullptr;
   }
-  if (mSharedGL && !mShaders && !gfx::gfxVars::UseSoftwareWebRender()) {
+  if (mSharedGL && !mShaders) {
     mShaders = MakeUnique<WebRenderShaders>(mSharedGL, mProgramCache.get());
   }
 
   return mSharedGL.get();
 }
 
 void RenderThread::ClearSharedGL() {
   MOZ_ASSERT(IsInRenderThread());
--- a/gfx/webrender_bindings/RendererOGL.cpp
+++ b/gfx/webrender_bindings/RendererOGL.cpp
@@ -45,47 +45,39 @@ void wr_renderer_unlock_external_image(v
     return;
   }
   texture->Unlock();
 }
 
 RendererOGL::RendererOGL(RefPtr<RenderThread>&& aThread,
                          UniquePtr<RenderCompositor> aCompositor,
                          wr::WindowId aWindowId, wr::Renderer* aRenderer,
-                         layers::CompositorBridgeParent* aBridge,
-                         void* aSoftwareContext)
+                         layers::CompositorBridgeParent* aBridge)
     : mThread(aThread),
       mCompositor(std::move(aCompositor)),
       mRenderer(aRenderer),
       mBridge(aBridge),
       mWindowId(aWindowId),
-      mSoftwareContext(aSoftwareContext),
       mDisableNativeCompositor(false) {
   MOZ_ASSERT(mThread);
   MOZ_ASSERT(mCompositor);
   MOZ_ASSERT(mRenderer);
   MOZ_ASSERT(mBridge);
   MOZ_COUNT_CTOR(RendererOGL);
 }
 
 RendererOGL::~RendererOGL() {
   MOZ_COUNT_DTOR(RendererOGL);
-  if (mSoftwareContext) {
-    wr_swgl_make_current(mSoftwareContext);
-  }
   if (!mCompositor->MakeCurrent()) {
     gfxCriticalNote
         << "Failed to make render context current during destroying.";
     // Leak resources!
   } else {
     wr_renderer_delete(mRenderer);
   }
-  if (mSoftwareContext) {
-    wr_swgl_destroy_context(mSoftwareContext);
-  }
 }
 
 wr::WrExternalImageHandler RendererOGL::GetExternalImageHandler() {
   return wr::WrExternalImageHandler{
       this,
   };
 }
 
@@ -129,25 +121,16 @@ RenderedFrameId RendererOGL::UpdateAndRe
       RenderThread::Get()->HandleDeviceReset("BeginFrame", /* aNotify */ true);
     }
     mCompositor->GetWidget()->PostRender(&widgetContext);
     return RenderedFrameId();
   }
 
   auto size = mCompositor->GetBufferSize();
 
-  if (mSoftwareContext) {
-    wr_swgl_make_current(mSoftwareContext);
-    uint8_t* data = nullptr;
-    int32_t stride = 0;
-    mCompositor->GetMappedBuffer(&data, &stride);
-    wr_swgl_init_default_framebuffer(mSoftwareContext, size.width, size.height,
-                                     stride, data);
-  }
-
   wr_renderer_update(mRenderer);
 
   bool fullRender = mCompositor->RequestFullRender();
   // When we're rendering to an external target, we want to render everything.
   if (mCompositor->UsePartialPresent() &&
       (aReadbackBuffer.isSome() || layers::ProfilerScreenshots::IsEnabled())) {
     fullRender = true;
   }
--- a/gfx/webrender_bindings/RendererOGL.h
+++ b/gfx/webrender_bindings/RendererOGL.h
@@ -79,18 +79,17 @@ class RendererOGL {
   void SetFrameStartTime(const TimeStamp& aTime);
 
   /// This can be called on the render thread only.
   ~RendererOGL();
 
   /// This can be called on the render thread only.
   RendererOGL(RefPtr<RenderThread>&& aThread,
               UniquePtr<RenderCompositor> aCompositor, wr::WindowId aWindowId,
-              wr::Renderer* aRenderer, layers::CompositorBridgeParent* aBridge,
-              void* aSoftwareContext = nullptr);
+              wr::Renderer* aRenderer, layers::CompositorBridgeParent* aBridge);
 
   /// This can be called on the render thread only.
   void Pause();
 
   /// This can be called on the render thread only.
   bool Resume();
 
   /// This can be called on the render thread only.
@@ -113,17 +112,16 @@ class RendererOGL {
   bool EnsureAsyncScreenshot();
 
  protected:
   RefPtr<RenderThread> mThread;
   UniquePtr<RenderCompositor> mCompositor;
   wr::Renderer* mRenderer;
   layers::CompositorBridgeParent* mBridge;
   wr::WindowId mWindowId;
-  void* mSoftwareContext;
   TimeStamp mFrameStartTime;
 
   bool mDisableNativeCompositor;
 
   RendererScreenshotGrabber mScreenshotGrabber;
 };
 
 }  // namespace wr
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -65,21 +65,16 @@ class NewRenderer : public RendererEvent
       // nullptr
       return;
     }
 
     *mUseANGLE = compositor->UseANGLE();
     *mUseDComp = compositor->UseDComp();
     *mUseTripleBuffering = compositor->UseTripleBuffering();
 
-    void* swCtx = nullptr;
-    if (gfx::gfxVars::UseSoftwareWebRender()) {
-      swCtx = wr_swgl_create_context();
-    }
-
     // Only allow the panic on GL error functionality in nightly builds,
     // since it (deliberately) crashes the GPU process if any GL call
     // returns an error code.
     bool panic_on_gl_error = false;
 #ifdef NIGHTLY_BUILD
     panic_on_gl_error =
         StaticPrefs::gfx_webrender_panic_on_gl_error_AtStartup();
 #endif
@@ -98,17 +93,18 @@ class NewRenderer : public RendererEvent
             StaticPrefs::gfx_webrender_picture_caching() &&
                 supportPictureCaching,
             gfx::gfxVars::UseWebRenderScissoredCacheClears(),
 #ifdef NIGHTLY_BUILD
             StaticPrefs::gfx_webrender_start_debug_server(),
 #else
             false,
 #endif
-            swCtx, compositor->gl(), compositor->SurfaceOriginIsTopLeft(),
+            compositor->swgl(), compositor->gl(),
+            compositor->SurfaceOriginIsTopLeft(),
             aRenderThread.GetProgramCache()
                 ? aRenderThread.GetProgramCache()->Raw()
                 : nullptr,
             aRenderThread.GetShaders()
                 ? aRenderThread.GetShaders()->RawShaders()
                 : nullptr,
             aRenderThread.ThreadPool().Raw(),
             aRenderThread.ThreadPoolLP().Raw(), &WebRenderMallocSizeOf,
@@ -117,27 +113,24 @@ class NewRenderer : public RendererEvent
                                                     : nullptr,
             compositor->GetMaxUpdateRects(),
             compositor->GetMaxPartialPresentRects(),
             compositor->ShouldDrawPreviousPartialPresentRegions(), mDocHandle,
             &wrRenderer, mMaxTextureSize,
             StaticPrefs::gfx_webrender_enable_gpu_markers_AtStartup(),
             panic_on_gl_error)) {
       // wr_window_new puts a message into gfxCriticalNote if it returns false
-      if (swCtx) {
-        wr_swgl_destroy_context(swCtx);
-      }
       return;
     }
     MOZ_ASSERT(wrRenderer);
 
     RefPtr<RenderThread> thread = &aRenderThread;
     auto renderer =
         MakeUnique<RendererOGL>(std::move(thread), std::move(compositor),
-                                aWindowId, wrRenderer, mBridge, swCtx);
+                                aWindowId, wrRenderer, mBridge);
     if (wrRenderer && renderer) {
       wr::WrExternalImageHandler handler = renderer->GetExternalImageHandler();
       wr_renderer_set_external_image_handler(wrRenderer, &handler);
     }
 
     if (renderer) {
       layers::SyncObjectHost* syncObj = renderer->GetSyncObject();
       if (syncObj) {