Bug 1287653 - Minor fixes in D3D11Checks. - r=mattwoodrow
authorJeff Gilbert <jgilbert@mozilla.com>
Sun, 17 Jul 2016 13:54:23 -0700
changeset 351465 e39ccca212f0c78cdd7e74c8dba37cc141dfc860
parent 351464 749f1c8bf7b9a88d658802c273eb404bac201409
child 351466 2ea9b966bda7565692871475b493d83e20a1c414
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1287653
milestone51.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 1287653 - Minor fixes in D3D11Checks. - r=mattwoodrow MozReview-Commit-ID: l8VkUewdhA
gfx/thebes/D3D11Checks.cpp
--- a/gfx/thebes/D3D11Checks.cpp
+++ b/gfx/thebes/D3D11Checks.cpp
@@ -85,34 +85,34 @@ D3D11Checks::DoesRenderTargetViewNeedRec
     deviceContext->ClearRenderTargetView(offscreenRTView, color2);
     D3D11_TEXTURE2D_DESC desc;
 
     offscreenTexture->GetDesc(&desc);
     desc.Usage = D3D11_USAGE_STAGING;
     desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
     desc.MiscFlags = 0;
     desc.BindFlags = 0;
-    ID3D11Texture2D* cpuTexture;
-    hr = aDevice->CreateTexture2D(&desc, NULL, &cpuTexture);
+    RefPtr<ID3D11Texture2D> cpuTexture;
+    hr = aDevice->CreateTexture2D(&desc, NULL, getter_AddRefs(cpuTexture));
     if (FAILED(hr)) {
         gfxCriticalNote << "DoesRecreatingCreateCPUTextureFailed";
         return false;
     }
 
     deviceContext->CopyResource(cpuTexture, offscreenTexture);
 
     D3D11_MAPPED_SUBRESOURCE mapped;
     hr = deviceContext->Map(cpuTexture, 0, D3D11_MAP_READ, 0, &mapped);
     if (FAILED(hr)) {
         gfxCriticalNote << "DoesRecreatingMapFailed " << hexa(hr);
         return false;
     }
     int resultColor = *(int*)mapped.pData;
     deviceContext->Unmap(cpuTexture, 0);
-    cpuTexture->Release();
+    cpuTexture = nullptr;
 
     // XXX on some drivers resultColor will not have changed to
     // match the clear
     if (resultColor != 0xffffff00) {
         gfxCriticalNote << "RenderTargetViewNeedsRecreating";
         result = true;
     }
 
@@ -306,29 +306,30 @@ DoesTextureSharingWorkInternal(ID3D11Dev
     gfxCriticalError() << "DoesD3D11TextureSharingWork_AcquireSyncTimeout";
     // only wait for 30 seconds
     return false;
   }
 
   // Copy to the cpu texture so that we can readback
   deviceContext->CopyResource(cpuTexture, sharedTexture);
 
+  // We only need to hold on to the mutex during the copy.
+  sharedMutex->ReleaseSync(0);
+
   D3D11_MAPPED_SUBRESOURCE mapped;
-  int resultColor = 0;
+  uint32_t resultColor = 0;
   if (SUCCEEDED(deviceContext->Map(cpuTexture, 0, D3D11_MAP_READ, 0, &mapped))) {
     // read the texture
-    resultColor = *(int*)mapped.pData;
+    resultColor = *(uint32_t*)mapped.pData;
     deviceContext->Unmap(cpuTexture, 0);
   } else {
     gfxCriticalError() << "DoesD3D11TextureSharingWork_MapFailed";
     return false;
   }
 
-  sharedMutex->ReleaseSync(0);
-
   // check that the color we put in is the color we get out
   if (resultColor != color[0]) {
     // Shared surfaces seem to be broken on dual AMD & Intel HW when using the
     // AMD GPU
     gfxCriticalNote << "DoesD3D11TextureSharingWork_ColorMismatch";
     return false;
   }