From 57dcf73a5447e57dfd4c2051fdf29b9302b33206 Mon Sep 17 00:00:00 2001 From: Derek Lesho Date: Mon, 8 Aug 2022 15:40:12 -0400 Subject: [PATCH] d3d11: Fix shared textures that export both NT and KMT handles. We should always create the DxvkImage with the KMT handle type, so that the call later to openKmtHandle succeeds. Also, don't free sharedHandle when exporting an NT handle. --- src/d3d11/d3d11_texture.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d3d11/d3d11_texture.cpp b/src/d3d11/d3d11_texture.cpp index e1846559..1c88c655 100644 --- a/src/d3d11/d3d11_texture.cpp +++ b/src/d3d11/d3d11_texture.cpp @@ -51,9 +51,9 @@ namespace dxvk { imageInfo.shared = true; imageInfo.sharing.mode = hSharedHandle == INVALID_HANDLE_VALUE ? DxvkSharedHandleMode::Export : DxvkSharedHandleMode::Import; - imageInfo.sharing.type = m_desc.MiscFlags & D3D11_RESOURCE_MISC_SHARED_NTHANDLE - ? VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT - : VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT; + imageInfo.sharing.type = (m_desc.MiscFlags & D3D11_RESOURCE_MISC_SHARED) + ? VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT + : VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT; imageInfo.sharing.handle = hSharedHandle; } @@ -627,7 +627,7 @@ namespace dxvk { Logger::warn("D3D11: Failed to write shared resource info for a texture"); } - if (hSharedHandle != INVALID_HANDLE_VALUE) + if ((m_desc.MiscFlags & D3D11_RESOURCE_MISC_SHARED) && hSharedHandle != INVALID_HANDLE_VALUE) CloseHandle(hSharedHandle); }