From 2f3cb1804e15ff7a481e8b4921508d4041b50801 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 3 Mar 2019 08:43:06 -0800 Subject: [PATCH] libobs-d3d11: Reset handle and re-lock if texture rebuilt If a texture has to be rebuilt due to a driver reset and is a keyed mutex shared texture, make sure to reacquire the shared handle and acquire the lock. --- libobs-d3d11/d3d11-rebuild.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libobs-d3d11/d3d11-rebuild.cpp b/libobs-d3d11/d3d11-rebuild.cpp index bdce20c95..6912cf764 100644 --- a/libobs-d3d11/d3d11-rebuild.cpp +++ b/libobs-d3d11/d3d11-rebuild.cpp @@ -89,6 +89,15 @@ void gs_texture_2d::Rebuild(ID3D11Device *dev) if (FAILED(hr)) throw HRError("Failed to create GDI surface", hr); } + + acquired = false; + + if ((td.MiscFlags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX) != 0) { + ComQIPtr dxgi_res(texture); + if (dxgi_res) + GetSharedHandle(dxgi_res); + device_texture_acquire_sync(this, 0, INFINITE); + } } void gs_texture_2d::RebuildNV12_Y(ID3D11Device *dev) @@ -108,6 +117,15 @@ void gs_texture_2d::RebuildNV12_Y(ID3D11Device *dev) InitRenderTargets(); tex_uv->RebuildNV12_UV(dev); + + acquired = false; + + if ((td.MiscFlags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX) != 0) { + ComQIPtr dxgi_res(texture); + if (dxgi_res) + GetSharedHandle(dxgi_res); + device_texture_acquire_sync(this, 0, INFINITE); + } } void gs_texture_2d::RebuildNV12_UV(ID3D11Device *dev)