From 07cc276a105db66241481585212ed701a408b917 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 7 Apr 2024 23:29:39 +0200 Subject: [PATCH] Issue #2470 - Check for failure of getting IDXGIKeyedMutex. --- gfx/thebes/D3D11Checks.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gfx/thebes/D3D11Checks.cpp b/gfx/thebes/D3D11Checks.cpp index b5be58ff53..9619884472 100644 --- a/gfx/thebes/D3D11Checks.cpp +++ b/gfx/thebes/D3D11Checks.cpp @@ -246,7 +246,11 @@ DoesTextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT format, UINT bi } RefPtr 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))) { gfxCriticalError() << "DoesD3D11TextureSharingWork_SourceMutexTimeout"; // only wait for 30 seconds @@ -306,9 +310,12 @@ DoesTextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT format, UINT bi } RefPtr sharedMutex; - sharedResource->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)getter_AddRefs(sharedMutex)); - { - HRESULT hr; + hr = sharedResource->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)getter_AddRefs(sharedMutex)); + if (FAILED(hr) || !sharedMutex) { + gfxCriticalNote << "Failed to acquire IDXGIKeyedMutex; texture sharing disabled."; + return false; + } + { // Scope for mutex lock. AutoTextureLock lock(sharedMutex, hr, 30*1000); if (FAILED(hr)) { gfxCriticalError() << "DoesD3D11TextureSharingWork_AcquireSyncTimeout";