From 1d1d8adee6a10e504dadd596b53170fa4b7bebd4 Mon Sep 17 00:00:00 2001 From: Derek Lesho Date: Sat, 12 Mar 2022 21:25:31 +0100 Subject: [PATCH] [d3d9] Fix shared handle check for exporting images Co-authored-by: Philip Rebohle --- src/d3d9/d3d9_common_texture.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/d3d9/d3d9_common_texture.cpp b/src/d3d9/d3d9_common_texture.cpp index 66a34c1e..20b73f70 100644 --- a/src/d3d9/d3d9_common_texture.cpp +++ b/src/d3d9/d3d9_common_texture.cpp @@ -241,13 +241,14 @@ namespace dxvk { imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; imageInfo.layout = VK_IMAGE_LAYOUT_GENERAL; imageInfo.shared = m_desc.IsBackBuffer; + if (pSharedHandle) { imageInfo.sharing.type = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT; - if (*pSharedHandle) { - imageInfo.shared = true; - imageInfo.sharing.mode = *pSharedHandle == INVALID_HANDLE_VALUE ? DxvkSharedHandleMode::Export : DxvkSharedHandleMode::Import; - imageInfo.sharing.handle = *pSharedHandle; - } + imageInfo.sharing.mode = (*pSharedHandle == INVALID_HANDLE_VALUE || *pSharedHandle == nullptr) + ? DxvkSharedHandleMode::Export + : DxvkSharedHandleMode::Import; + imageInfo.sharing.type = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT; + imageInfo.sharing.handle = *pSharedHandle; // TODO: validate metadata? }