зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1289640 - Part 2: Stop using the D3D11 immediate context to upload texture data in IMFYCbCrImage and stick to threadsafe APIs so that we can use the content device. r=Bas
This commit is contained in:
Родитель
8917dc3ec5
Коммит
a9cb9eb75a
|
@ -226,7 +226,7 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<ID3D11Device> device =
|
RefPtr<ID3D11Device> device =
|
||||||
gfx::DeviceManagerD3D11::Get()->GetImageBridgeDevice();
|
gfx::DeviceManagerD3D11::Get()->GetContentDevice();
|
||||||
|
|
||||||
LayersBackend backend = aClient->GetForwarder()->GetCompositorBackendType();
|
LayersBackend backend = aClient->GetForwarder()->GetCompositorBackendType();
|
||||||
if (!device || backend != LayersBackend::LAYERS_D3D11) {
|
if (!device || backend != LayersBackend::LAYERS_D3D11) {
|
||||||
|
@ -237,8 +237,10 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<ID3D11DeviceContext> ctx;
|
if (mData.mYStride < 0 || mData.mCbCrStride < 0) {
|
||||||
device->GetImmediateContext(getter_AddRefs(ctx));
|
// D3D11 only supports unsigned stride values.
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_R8_UNORM,
|
CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_R8_UNORM,
|
||||||
mData.mYSize.width, mData.mYSize.height, 1, 1);
|
mData.mYSize.width, mData.mYSize.height, 1, 1);
|
||||||
|
@ -246,31 +248,29 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
|
||||||
newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
|
newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
|
||||||
|
|
||||||
RefPtr<ID3D11Texture2D> textureY;
|
RefPtr<ID3D11Texture2D> textureY;
|
||||||
HRESULT hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureY));
|
D3D11_SUBRESOURCE_DATA yData = { mData.mYChannel, (UINT)mData.mYStride, 0 };
|
||||||
|
HRESULT hr = device->CreateTexture2D(&newDesc, &yData, getter_AddRefs(textureY));
|
||||||
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
|
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
|
||||||
|
|
||||||
newDesc.Width = mData.mCbCrSize.width;
|
newDesc.Width = mData.mCbCrSize.width;
|
||||||
newDesc.Height = mData.mCbCrSize.height;
|
newDesc.Height = mData.mCbCrSize.height;
|
||||||
|
|
||||||
RefPtr<ID3D11Texture2D> textureCb;
|
RefPtr<ID3D11Texture2D> textureCb;
|
||||||
hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCb));
|
D3D11_SUBRESOURCE_DATA cbData = { mData.mCbChannel, (UINT)mData.mCbCrStride, 0 };
|
||||||
|
hr = device->CreateTexture2D(&newDesc, &cbData, getter_AddRefs(textureCb));
|
||||||
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
|
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
|
||||||
|
|
||||||
RefPtr<ID3D11Texture2D> textureCr;
|
RefPtr<ID3D11Texture2D> textureCr;
|
||||||
hr = device->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCr));
|
D3D11_SUBRESOURCE_DATA crData = { mData.mCrChannel, (UINT)mData.mCbCrStride, 0 };
|
||||||
|
hr = device->CreateTexture2D(&newDesc, &crData, getter_AddRefs(textureCr));
|
||||||
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
|
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
|
||||||
|
|
||||||
|
// Even though the textures we created are meant to be protected by a keyed mutex,
|
||||||
|
// it appears that D3D doesn't include the initial memory upload within this
|
||||||
|
// synchronization. Add an empty lock/unlock pair since that appears to
|
||||||
|
// be sufficient to make sure we synchronize.
|
||||||
{
|
{
|
||||||
AutoLockTexture lockY(textureY);
|
|
||||||
AutoLockTexture lockCb(textureCb);
|
|
||||||
AutoLockTexture lockCr(textureCr);
|
AutoLockTexture lockCr(textureCr);
|
||||||
|
|
||||||
ctx->UpdateSubresource(textureY, 0, nullptr, mData.mYChannel,
|
|
||||||
mData.mYStride, mData.mYStride * mData.mYSize.height);
|
|
||||||
ctx->UpdateSubresource(textureCb, 0, nullptr, mData.mCbChannel,
|
|
||||||
mData.mCbCrStride, mData.mCbCrStride * mData.mCbCrSize.height);
|
|
||||||
ctx->UpdateSubresource(textureCr, 0, nullptr, mData.mCrChannel,
|
|
||||||
mData.mCbCrStride, mData.mCbCrStride * mData.mCbCrSize.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mTextureClient = TextureClient::CreateWithData(
|
mTextureClient = TextureClient::CreateWithData(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче