diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index ae74bb29c126..853fb2710361 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -1598,8 +1598,6 @@ bool DoesD3D11DeviceWork(ID3D11Device *device) return true; } -#define TEXTURE_SIZE 32 - // See bug 1083071. On some drivers, Direct3D 11 CreateShaderResourceView fails // with E_OUTOFMEMORY. bool DoesD3D11TextureSharingWork(ID3D11Device *device) @@ -1618,10 +1616,25 @@ bool DoesD3D11TextureSharingWork(ID3D11Device *device) return true; } + if (GetModuleHandleW(L"atidxx32.dll")) { + nsCOMPtr gfxInfo = do_GetService("@mozilla.org/gfx/info;1"); + if (gfxInfo) { + nsString vendorID, vendorID2; + gfxInfo->GetAdapterVendorID(vendorID); + gfxInfo->GetAdapterVendorID2(vendorID2); + if (vendorID.EqualsLiteral("0x8086") && vendorID2.IsEmpty()) { +#if defined(MOZ_CRASHREPORTER) + CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Unexpected Intel/AMD dual-GPU setup\n")); +#endif + return false; + } + } + } + RefPtr texture; D3D11_TEXTURE2D_DESC desc; - desc.Width = TEXTURE_SIZE; - desc.Height = TEXTURE_SIZE; + desc.Width = 32; + desc.Height = 32; desc.MipLevels = 1; desc.ArraySize = 1; desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; @@ -1631,16 +1644,7 @@ bool DoesD3D11TextureSharingWork(ID3D11Device *device) desc.CPUAccessFlags = 0; desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX; desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; - - int color[TEXTURE_SIZE * TEXTURE_SIZE]; - D3D11_SUBRESOURCE_DATA data; - data.pSysMem = color; - data.SysMemPitch = TEXTURE_SIZE * 4; - data.SysMemSlicePitch = 0; - for (int i = 0; i < sizeof(color)/sizeof(color[0]); i++) { - color[i] = 0xff00ffff; - } - if (FAILED(device->CreateTexture2D(&desc, &data, byRef(texture)))) { + if (FAILED(device->CreateTexture2D(&desc, NULL, byRef(texture)))) { return false; } @@ -1670,47 +1674,6 @@ bool DoesD3D11TextureSharingWork(ID3D11Device *device) return false; } - desc.Usage = D3D11_USAGE_STAGING; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.MiscFlags = 0; - desc.BindFlags = 0; - - RefPtr cpuTexture; - if (FAILED(device->CreateTexture2D(&desc, &data, byRef(cpuTexture)))) { - return false; - } - - nsRefPtr sharedMutex; - nsRefPtr deviceContext; - sharedResource->QueryInterface(__uuidof(IDXGIKeyedMutex), getter_AddRefs(sharedMutex)); - device->GetImmediateContext(getter_AddRefs(deviceContext)); - if (FAILED(sharedMutex->AcquireSync(0, 30*1000))) { -#if defined(MOZ_CRASHREPORTER) - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Keyed Mutex timeout\n")); -#endif - // only wait for 30 seconds - return false; - } - - int resultColor; - deviceContext->CopyResource(cpuTexture, sharedTexture); - - D3D11_MAPPED_SUBRESOURCE mapped; - deviceContext->Map(cpuTexture, 0, D3D11_MAP_READ, 0, &mapped); - resultColor = *(int*)mapped.pData; - deviceContext->Unmap(cpuTexture, 0); - - sharedMutex->ReleaseSync(0); - - if (resultColor != color[0]) { - // Shared surfaces seem to be broken on dual AMD & Intel HW when using the - // AMD GPU -#if defined(MOZ_CRASHREPORTER) - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Shared Surfaces don't work\n")); -#endif - return false; - } - RefPtr sharedView; // This if(FAILED()) is the one that actually fails on systems affected by bug 1083071.