Bug 1467055 - Do not reuse D3D11Textures when CompositorDevice or ContentDevice is updated r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Wed, 13 Jun 2018 06:45:52 -0700
changeset 479149 27da7e98059ba703ea66ecd3f020516374887ff5
parent 479148 f1c3ce3f10c3c93b0dd5e7dba98b3f602b82279f
child 479150 aea9119b2797e84f95449c5fb26fe14bcc853f09
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1467055
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1467055 - Do not reuse D3D11Textures when CompositorDevice or ContentDevice is updated r=nical
gfx/layers/D3D11ShareHandleImage.cpp
gfx/layers/D3D11ShareHandleImage.h
--- a/gfx/layers/D3D11ShareHandleImage.cpp
+++ b/gfx/layers/D3D11ShareHandleImage.cpp
@@ -193,16 +193,24 @@ D3D11RecycleAllocator::Allocate(gfx::Sur
                                             aTextureFlags, aAllocFlags,
                                             mDevice, mSurfaceAllocator->GetTextureForwarder());
 }
 
 already_AddRefed<TextureClient>
 D3D11RecycleAllocator::CreateOrRecycleClient(gfx::SurfaceFormat aFormat,
                                              const gfx::IntSize& aSize)
 {
+  // When CompositorDevice or ContentDevice is updated,
+  // we could not reuse old D3D11Textures. It could cause video flickering.
+  RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetImageDevice();
+  if (!!mImageDevice && mImageDevice != device) {
+    ShrinkToMinimumSize();
+  }
+  mImageDevice = device;
+
   TextureAllocationFlags allocFlags = TextureAllocationFlags::ALLOC_DEFAULT;
   if (gfxPrefs::PDMWMFUseSyncTexture() || mDevice == DeviceManagerDx::Get()->GetCompositorDevice()) {
     // If our device is the compositor device, we don't need any synchronization in practice.
     allocFlags = TextureAllocationFlags::ALLOC_MANUAL_SYNCHRONIZATION;
   }
   RefPtr<TextureClient> textureClient =
     CreateOrRecycle(aFormat,
                     aSize,
--- a/gfx/layers/D3D11ShareHandleImage.h
+++ b/gfx/layers/D3D11ShareHandleImage.h
@@ -34,16 +34,20 @@ protected:
   virtual already_AddRefed<TextureClient> Allocate(
     gfx::SurfaceFormat aFormat,
     gfx::IntSize aSize,
     BackendSelector aSelector,
     TextureFlags aTextureFlags,
     TextureAllocationFlags aAllocFlags) override;
 
   RefPtr<ID3D11Device> mDevice;
+  /**
+   * Used for checking if CompositorDevice/ContentDevice is updated.
+   */
+  RefPtr<ID3D11Device> mImageDevice;
 };
 
 // Image class that wraps a ID3D11Texture2D. This class copies the image
 // passed into SetData(), so that it can be accessed from other D3D devices.
 // This class also manages the synchronization of the copy, to ensure the
 // resource is ready to use.
 class D3D11ShareHandleImage final : public Image {
 public: