Bug 1287653 - Minor fixes in D3D11Checks. - r=mattwoodrow

MozReview-Commit-ID: l8VkUewdhA
This commit is contained in:
Jeff Gilbert 2016-07-17 13:54:23 -07:00
parent ac277e5603
commit 0ded0eabcd

View File

@ -90,8 +90,8 @@ D3D11Checks::DoesRenderTargetViewNeedRecreating(ID3D11Device *aDevice)
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
desc.MiscFlags = 0; desc.MiscFlags = 0;
desc.BindFlags = 0; desc.BindFlags = 0;
ID3D11Texture2D* cpuTexture; RefPtr<ID3D11Texture2D> cpuTexture;
hr = aDevice->CreateTexture2D(&desc, NULL, &cpuTexture); hr = aDevice->CreateTexture2D(&desc, NULL, getter_AddRefs(cpuTexture));
if (FAILED(hr)) { if (FAILED(hr)) {
gfxCriticalNote << "DoesRecreatingCreateCPUTextureFailed"; gfxCriticalNote << "DoesRecreatingCreateCPUTextureFailed";
return false; return false;
@ -107,7 +107,7 @@ D3D11Checks::DoesRenderTargetViewNeedRecreating(ID3D11Device *aDevice)
} }
int resultColor = *(int*)mapped.pData; int resultColor = *(int*)mapped.pData;
deviceContext->Unmap(cpuTexture, 0); deviceContext->Unmap(cpuTexture, 0);
cpuTexture->Release(); cpuTexture = nullptr;
// XXX on some drivers resultColor will not have changed to // XXX on some drivers resultColor will not have changed to
// match the clear // match the clear
@ -311,19 +311,20 @@ DoesTextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT format, UINT bi
// Copy to the cpu texture so that we can readback // Copy to the cpu texture so that we can readback
deviceContext->CopyResource(cpuTexture, sharedTexture); deviceContext->CopyResource(cpuTexture, sharedTexture);
// We only need to hold on to the mutex during the copy.
sharedMutex->ReleaseSync(0);
D3D11_MAPPED_SUBRESOURCE mapped; D3D11_MAPPED_SUBRESOURCE mapped;
int resultColor = 0; uint32_t resultColor = 0;
if (SUCCEEDED(deviceContext->Map(cpuTexture, 0, D3D11_MAP_READ, 0, &mapped))) { if (SUCCEEDED(deviceContext->Map(cpuTexture, 0, D3D11_MAP_READ, 0, &mapped))) {
// read the texture // read the texture
resultColor = *(int*)mapped.pData; resultColor = *(uint32_t*)mapped.pData;
deviceContext->Unmap(cpuTexture, 0); deviceContext->Unmap(cpuTexture, 0);
} else { } else {
gfxCriticalError() << "DoesD3D11TextureSharingWork_MapFailed"; gfxCriticalError() << "DoesD3D11TextureSharingWork_MapFailed";
return false; return false;
} }
sharedMutex->ReleaseSync(0);
// check that the color we put in is the color we get out // check that the color we put in is the color we get out
if (resultColor != color[0]) { if (resultColor != color[0]) {
// Shared surfaces seem to be broken on dual AMD & Intel HW when using the // Shared surfaces seem to be broken on dual AMD & Intel HW when using the