Bug 1866021 - Set to MultithreadProtected during creating CompositorDevice r=gfx-reviewers,jrmuizel

Set to MultithreadProtected by gfx::DeviceManagerDx::GetImageDevice() caused a thread safe problem. MultithreadProtected needs to be set during CompositorDevice creation.

Differential Revision: https://phabricator.services.mozilla.com/D194907
This commit is contained in:
sotaro 2023-11-29 04:16:19 +00:00
parent 715feb96f9
commit c199b59dd1

View File

@ -740,6 +740,13 @@ void DeviceManagerDx::CreateCompositorDevice(FeatureState& d3d11) {
D3D11Checks::WarnOnAdapterMismatch(device);
}
RefPtr<ID3D10Multithread> multi;
HRESULT hr = device->QueryInterface(__uuidof(ID3D10Multithread),
getter_AddRefs(multi));
if (SUCCEEDED(hr) && multi) {
multi->SetMultithreadProtected(TRUE);
}
uint32_t featureLevel = device->GetFeatureLevel();
auto formatOptions = D3D11Checks::FormatOptions(device);
mCompositorDevice = device;
@ -832,6 +839,13 @@ void DeviceManagerDx::CreateWARPCompositorDevice() {
bool textureSharingWorks = D3D11Checks::DoesTextureSharingWork(device);
RefPtr<ID3D10Multithread> multi;
hr = device->QueryInterface(__uuidof(ID3D10Multithread),
getter_AddRefs(multi));
if (SUCCEEDED(hr) && multi) {
multi->SetMultithreadProtected(TRUE);
}
DXGI_ADAPTER_DESC desc;
D3D11Checks::GetDxgiDesc(device, &desc);
@ -934,7 +948,7 @@ RefPtr<ID3D11Device> DeviceManagerDx::CreateDecoderDevice(
mDecoderDevice->QueryInterface(__uuidof(ID3D10Multithread),
getter_AddRefs(multi));
if (multi) {
multi->SetMultithreadProtected(TRUE);
MOZ_ASSERT(multi->GetMultithreadProtected());
}
}
@ -1221,8 +1235,9 @@ RefPtr<ID3D11Device> DeviceManagerDx::GetImageDevice() {
if (FAILED(hr) || !multi) {
gfxWarning() << "Multithread safety interface not supported. " << hr;
return nullptr;
} else {
MOZ_ASSERT(multi->GetMultithreadProtected());
}
multi->SetMultithreadProtected(TRUE);
mImageDevice = device;