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.
This commit is contained in:
Derek Lesho 2022-08-08 15:40:12 -04:00 committed by Philip Rebohle
parent 0ad7a08c49
commit 57dcf73a54
1 changed files with 4 additions and 4 deletions

View File

@ -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);
}