From 9fef149372771988d237225ac5dbec6a03c324f1 Mon Sep 17 00:00:00 2001 From: Schabrackentapir <10599849+Schabrackentapir@users.noreply.github.com> Date: Sun, 13 Feb 2022 00:11:21 +0100 Subject: [PATCH] bugfix: simpleVulkan now works on windows 10 Bugfix #1: added missing cudaExternalMemoryDedicated flag on cudaExternalMemoryHandleDesc Bugfix #2: IsWindows8OrGreater queries return false on Windows 10. Always returning Windows 10 values now (might break on older Windows versions) --- .../simpleVulkan/VulkanBaseApp.cpp | 18 ++++++++++++------ .../5_Domain_Specific/simpleVulkan/main.cpp | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.cpp b/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.cpp index e244bfe2..6c7c3cda 100644 --- a/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.cpp +++ b/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.cpp @@ -115,9 +115,12 @@ VulkanBaseApp::VulkanBaseApp(const std::string &appName, bool enableValidation) VkExternalSemaphoreHandleTypeFlagBits VulkanBaseApp::getDefaultSemaphoreHandleType() { #ifdef _WIN64 - return IsWindows8OrGreater() - ? VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT - : VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT; + // "IsWindows8orGreater" returns false on windows 10! + // https://docs.microsoft.com/en-us/windows/win32/sysinfo/version-helper-apis + //return IsWindows8OrGreater() + // ? VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT + // : VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT; + return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT; #else return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT; #endif /* _WIN64 */ @@ -125,9 +128,12 @@ VulkanBaseApp::getDefaultSemaphoreHandleType() { VkExternalMemoryHandleTypeFlagBits VulkanBaseApp::getDefaultMemHandleType() { #ifdef _WIN64 - return IsWindows8Point1OrGreater() - ? VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT - : VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT; + // "IsWindows8orGreater" returns false on windows 10! + // https://docs.microsoft.com/en-us/windows/win32/sysinfo/version-helper-apis + //return IsWindows8Point1OrGreater() + // ? VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT + // : VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT; + return VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT; #else return VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT; #endif /* _WIN64 */ diff --git a/Samples/5_Domain_Specific/simpleVulkan/main.cpp b/Samples/5_Domain_Specific/simpleVulkan/main.cpp index f676c6bc..ebdf687f 100644 --- a/Samples/5_Domain_Specific/simpleVulkan/main.cpp +++ b/Samples/5_Domain_Specific/simpleVulkan/main.cpp @@ -345,6 +345,9 @@ class VulkanCudaSineWave : public VulkanBaseApp { externalMemoryHandleDesc.size = size; + // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#importing-memory-objects-vul-int + externalMemoryHandleDesc.flags |= cudaExternalMemoryDedicated; + #ifdef _WIN64 externalMemoryHandleDesc.handle.win32.handle = (HANDLE)getMemHandle(vkMem, handleType);