Bug 1397040: During D3D11TextureData::Create lock the device multithread mutex explicitly when accessing the device. r=mattwoodrow
MozReview-Commit-ID: Ip1c8jnJE7r
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -480,16 +480,24 @@ D3D11TextureData::Create(IntSize aSize,
if (srcSurf && !DeviceManagerDx::Get()->HasCrashyInitData()) {
uploadData.pSysMem = sourceMap.mData;
uploadData.SysMemPitch = sourceMap.mStride;
uploadData.SysMemSlicePitch = 0; // unused
uploadDataPtr = &uploadData;
}
+ // See bug 1397040
+ RefPtr<ID3D10Multithread> mt;
+ device->QueryInterface((ID3D10Multithread**)getter_AddRefs(mt));
+
+ if (mt) {
+ mt->Enter();
+ }
+
RefPtr<ID3D11Texture2D> texture11;
HRESULT hr = device->CreateTexture2D(&newDesc, uploadDataPtr, getter_AddRefs(texture11));
if (FAILED(hr) || !texture11) {
gfxCriticalNote << "[D3D11] 2 CreateTexture2D failure Size: " << aSize
<< "texture11: " << texture11 << " Code: " << gfx::hexa(hr);
return nullptr;
}
@@ -516,16 +524,21 @@ D3D11TextureData::Create(IntSize aSize,
if (aSurface && newDesc.MiscFlags == D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX) {
if (!LockD3DTexture(texture11.get())) {
return nullptr;
}
UnlockD3DTexture(texture11.get());
}
texture11->SetPrivateDataInterface(sD3D11TextureUsage,
new TextureMemoryMeasurer(newDesc.Width * newDesc.Height * 4));
+
+ if (mt) {
+ mt->Leave();
+ }
+
return new D3D11TextureData(texture11, aSize, aFormat,
aFlags & ALLOC_CLEAR_BUFFER,
aFlags & ALLOC_CLEAR_BUFFER_WHITE,
aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT);
}
DXGITextureData*
D3D11TextureData::Create(IntSize aSize, SurfaceFormat aFormat,