Issue #2470 - Check for failure of getting IDXGIKeyedMutex.

This commit is contained in:
Moonchild 2024-04-07 23:29:39 +02:00 • committed by roytam1
commit 07cc276a10

View file

@ -246,7 +246,11 @@ DoesTextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT format, UINT bi
} }
RefPtr<IDXGIKeyedMutex> sourceSharedMutex; RefPtr<IDXGIKeyedMutex> sourceSharedMutex;
texture->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)getter_AddRefs(sourceSharedMutex)); HRESULT hr = texture->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)getter_AddRefs(sourceSharedMutex));
if (FAILED(hr) || !sourceSharedMutex) {
gfxCriticalNote << "Failed to acquire IDXGIKeyedMutex; texture sharing disabled.";
return false;
}
if (FAILED(sourceSharedMutex->AcquireSync(0, 30*1000))) { if (FAILED(sourceSharedMutex->AcquireSync(0, 30*1000))) {
gfxCriticalError() << "DoesD3D11TextureSharingWork_SourceMutexTimeout"; gfxCriticalError() << "DoesD3D11TextureSharingWork_SourceMutexTimeout";
// only wait for 30 seconds // only wait for 30 seconds
@ -306,9 +310,12 @@ DoesTextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT format, UINT bi
} }
RefPtr<IDXGIKeyedMutex> sharedMutex; RefPtr<IDXGIKeyedMutex> sharedMutex;
sharedResource->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)getter_AddRefs(sharedMutex)); hr = sharedResource->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)getter_AddRefs(sharedMutex));
{ if (FAILED(hr) || !sharedMutex) {
HRESULT hr; gfxCriticalNote << "Failed to acquire IDXGIKeyedMutex; texture sharing disabled.";
return false;
}
{ // Scope for mutex lock.
AutoTextureLock lock(sharedMutex, hr, 30*1000); AutoTextureLock lock(sharedMutex, hr, 30*1000);
if (FAILED(hr)) { if (FAILED(hr)) {
gfxCriticalError() << "DoesD3D11TextureSharingWork_AcquireSyncTimeout"; gfxCriticalError() << "DoesD3D11TextureSharingWork_AcquireSyncTimeout";