Bug 1405110 - P1. Lock device when allocating D3D11 surface. r?mattwoodrow
MozReview-Commit-ID: 8qWPIj3hdZW
--- a/gfx/layers/D3D11YCbCrImage.cpp
+++ b/gfx/layers/D3D11YCbCrImage.cpp
@@ -284,19 +284,34 @@ D3D11YCbCrRecycleAllocator::Allocate(Sur
gfx::IntSize YSize = mYSize.refOr(aSize);
gfx::IntSize CbCrSize =
mCbCrSize.refOr(gfx::IntSize(YSize.width, YSize.height));
CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_R8_UNORM, YSize.width, YSize.height,
1, 1);
newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
+ RefPtr<ID3D10Multithread> mt;
+ HRESULT hr = mDevice->QueryInterface(
+ (ID3D10Multithread**)getter_AddRefs(mt));
+
+ if (FAILED(hr) || !mt) {
+ gfxCriticalError() << "Multithread safety interface not supported. " << hr;
+ return nullptr;
+ }
+
+ if (!mt->GetMultithreadProtected()) {
+ gfxCriticalError() << "Device used not marked as multithread-safe.";
+ return nullptr;
+ }
+
+ D3D11MTAutoEnter mtAutoEnter(mt.forget());
+
RefPtr<ID3D11Texture2D> textureY;
- HRESULT hr =
- mDevice->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureY));
+ hr = mDevice->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureY));
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
newDesc.Width = CbCrSize.width;
newDesc.Height = CbCrSize.height;
RefPtr<ID3D11Texture2D> textureCb;
hr = mDevice->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCb));
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);