Bug 1322741 - Make sure ID3D11Device is up-to-date in SyncObjectD3D11. r=dvander
authorvincentliu <vliu@mozilla.com>
Wed, 18 Jan 2017 10:12:42 +0800
changeset 374760 871dc9ef34239b3d407f11dda31232b7caba6506
parent 374759 0bf730c7d8cb01d0c8474d71dfffa84849c6d2be
child 374761 1eeaa7ae6b3afdd7726fff211e9da814d5202575
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1322741
milestone53.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 1322741 - Make sure ID3D11Device is up-to-date in SyncObjectD3D11. r=dvander --- gfx/layers/client/ClientLayerManager.cpp | 3 ++- gfx/layers/client/TextureClient.h | 1 + gfx/layers/d3d11/TextureD3D11.cpp | 11 +++++++++++ gfx/layers/d3d11/TextureD3D11.h | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-)
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/TextureClient.h
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d11/TextureD3D11.h
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -655,17 +655,18 @@ ClientLayerManager::StopFrameTimeRecordi
 void
 ClientLayerManager::ForwardTransaction(bool aScheduleComposite)
 {
   TimeStamp start = TimeStamp::Now();
 
   // Skip the synchronization for buffer since we also skip the painting during
   // device-reset status.
   if (!gfxPlatform::GetPlatform()->DidRenderingDeviceReset()) {
-    if (mForwarder->GetSyncObject()) {
+    if (mForwarder->GetSyncObject() &&
+        mForwarder->GetSyncObject()->IsSyncObjectValid()) {
       mForwarder->GetSyncObject()->FinalizeFrame();
     }
   }
 
   mPhase = PHASE_FORWARD;
 
   mLatestTransactionId = mTransactionIdAllocator->GetTransactionId();
   TimeStamp transactionStart;
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -106,16 +106,17 @@ public:
   static already_AddRefed<SyncObject> CreateSyncObject(SyncHandle aHandle);
 
   enum class SyncType {
     D3D11,
   };
 
   virtual SyncType GetSyncType() = 0;
   virtual void FinalizeFrame() = 0;
+  virtual bool IsSyncObjectValid() = 0;
 
 protected:
   SyncObject() { }
 };
 
 /**
  * This class may be used to asynchronously receive an update when the content
  * drawn to this texture client is available for reading in CPU memory. This
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -1193,16 +1193,17 @@ IntSize
 CompositingRenderTargetD3D11::GetSize() const
 {
   return TextureSourceD3D11::GetSize();
 }
 
 SyncObjectD3D11::SyncObjectD3D11(SyncHandle aSyncHandle)
  : mSyncHandle(aSyncHandle)
 {
+  mD3D11Device = DeviceManagerDx::Get()->GetContentDevice();
 }
 
 bool
 SyncObjectD3D11::Init()
 {
   if (mKeyedMutex) {
     return true;
   }
@@ -1234,16 +1235,26 @@ SyncObjectD3D11::Init()
 }
 
 void
 SyncObjectD3D11::RegisterTexture(ID3D11Texture2D* aTexture)
 {
   mD3D11SyncedTextures.push_back(aTexture);
 }
 
+bool
+SyncObjectD3D11::IsSyncObjectValid()
+{
+  RefPtr<ID3D11Device> dev = DeviceManagerDx::Get()->GetContentDevice();
+  if (!dev || (dev != mD3D11Device)) {
+    return false;
+  }
+  return true;
+}
+
 void
 SyncObjectD3D11::FinalizeFrame()
 {
   if (!mD3D11SyncedTextures.size()) {
     return;
   }
   if (!Init()) {
     return;
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -410,26 +410,28 @@ private:
   RefPtr<ID3D11RenderTargetView> mRTView;
 };
 
 class SyncObjectD3D11 : public SyncObject
 {
 public:
   explicit SyncObjectD3D11(SyncHandle aSyncHandle);
   virtual void FinalizeFrame();
+  virtual bool IsSyncObjectValid();
 
   virtual SyncType GetSyncType() { return SyncType::D3D11; }
 
   void RegisterTexture(ID3D11Texture2D* aTexture);
 
 private:
   bool Init();
 
 private:
   SyncHandle mSyncHandle;
+  RefPtr<ID3D11Device> mD3D11Device;
   RefPtr<ID3D11Texture2D> mD3D11Texture;
   RefPtr<IDXGIKeyedMutex> mKeyedMutex;
   std::vector<ID3D11Texture2D*> mD3D11SyncedTextures;
 };
 
 inline uint32_t GetMaxTextureSizeForFeatureLevel(D3D_FEATURE_LEVEL aFeatureLevel)
 {
   int32_t maxTextureSize;