From ef73a1d1ae3ea4f98f343f86bb67ffcad34077aa Mon Sep 17 00:00:00 2001 From: saurabhnv <156190705+saurabhnv@users.noreply.github.com> Date: Tue, 5 Nov 2024 23:39:07 +0530 Subject: [PATCH] Import Vulkan resources via named NT handle (#1895) Add coverage to import Vulkan resources (memory and semaphore) in Windows via named NT handles. If no name is given during resource creation, then use NT handles for import. If a name is given, have an option to either use that name or get the NT handle and use that for import. Resolves KhronosGroup/OpenCL-Docs#943 --- .../vulkan_wrapper/opencl_vulkan_wrapper.cpp | 107 ++++++++++++--- .../common/vulkan_wrapper/vulkan_wrapper.cpp | 128 ++++++++++++------ .../common/vulkan_wrapper/vulkan_wrapper.hpp | 10 +- .../vulkan_wrapper/vulkan_wrapper_types.hpp | 9 +- 4 files changed, 184 insertions(+), 70 deletions(-) diff --git a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp index 9fd3071c..b4330e92 100644 --- a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp @@ -607,19 +607,20 @@ clExternalMemory::clExternalMemory( #ifdef _WIN32 log_info("Opaque file descriptors are not supported on Windows\n"); ASSERT(0); -#endif +#else fd = (int)deviceMemory->getHandle(externalMemoryHandleType); err = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); extMemProperties.push_back( (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); extMemProperties.push_back((cl_mem_properties)fd); +#endif break; case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: #ifndef _WIN32 + log_info("Opaque NT handles are only supported on Windows\n"); ASSERT(0); #else - log_info(" Opaque NT handles are only supported on Windows\n"); handle = deviceMemory->getHandle(externalMemoryHandleType); err = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); @@ -628,11 +629,35 @@ clExternalMemory::clExternalMemory( extMemProperties.push_back((cl_mem_properties)handle); #endif break; - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME: { #ifndef _WIN32 + log_info("Opaque NT handles are only supported on Windows\n"); ASSERT(0); #else + const std::wstring &name = deviceMemory->getName(); + if (name.size()) + { + err = check_external_memory_handle_type( + devList[0], + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR); + extMemProperties.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR); + extMemProperties.push_back((cl_mem_properties)name.c_str()); + } + else + { + throw std::runtime_error("Unsupported operation: import via " + "name but no name provided\n"); + } +#endif + } + break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: +#ifndef _WIN32 log_info("Opaque D3DKMT handles are only supported on Windows\n"); + ASSERT(0); +#else handle = deviceMemory->getHandle(externalMemoryHandleType); err = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); @@ -643,13 +668,13 @@ clExternalMemory::clExternalMemory( #endif break; default: - ASSERT(0); log_error("Unsupported external memory handle type\n"); + ASSERT(0); break; } if (CL_SUCCESS != err) { - throw std::runtime_error("Unsupported external memory type\n "); + throw std::runtime_error("Unsupported external memory type\n"); } extMemProperties.push_back( @@ -664,7 +689,7 @@ clExternalMemory::clExternalMemory( if (CL_SUCCESS != err) { log_error("clCreateBufferWithProperties failed with %d\n", err); - throw std::runtime_error("clCreateBufferWithProperties failed "); + throw std::runtime_error("clCreateBufferWithProperties failed\n"); } } clExternalMemoryImage::clExternalMemoryImage( @@ -704,7 +729,6 @@ clExternalMemoryImage::clExternalMemoryImage( { #ifdef _WIN32 case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: - log_info("Opaque NT handles are only supported on Windows\n"); handle = deviceMemory.getHandle(externalMemoryHandleType); errcode_ret = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); @@ -712,8 +736,26 @@ clExternalMemoryImage::clExternalMemoryImage( (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); extMemProperties1.push_back((cl_mem_properties)handle); break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME: { + const std::wstring &name = deviceMemory.getName(); + if (name.size()) + { + errcode_ret = check_external_memory_handle_type( + devList[0], + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR); + extMemProperties1.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR); + extMemProperties1.push_back((cl_mem_properties)name.c_str()); + } + else + { + throw std::runtime_error("Unsupported operation: import via " + "name but no name provided\n"); + } + } + break; case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: - log_info("Opaque D3DKMT handles are only supported on Windows\n"); handle = deviceMemory.getHandle(externalMemoryHandleType); errcode_ret = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); @@ -733,14 +775,15 @@ clExternalMemoryImage::clExternalMemoryImage( break; #endif default: - ASSERT(0); log_error("Unsupported external memory handle type\n"); + ASSERT(0); break; } if (CL_SUCCESS != errcode_ret) { - throw std::runtime_error("Unsupported external memory type\n "); + throw std::runtime_error("Unsupported external memory type\n"); } + // Set cl_image_desc size_t clImageFormatSize; cl_image_desc image_desc; @@ -753,7 +796,7 @@ clExternalMemoryImage::clExternalMemoryImage( &VulkanImageCreateInfo, image2D.getSize(), &img_format, &image_desc); if (CL_SUCCESS != errcode_ret) { - throw std::runtime_error("getCLImageInfoFromVkImageInfo failed!!!"); + throw std::runtime_error("getCLImageInfoFromVkImageInfo failed\n"); } // If OpenCL will assume linear, query the Vulkan image's row pitch, @@ -776,7 +819,7 @@ clExternalMemoryImage::clExternalMemoryImage( &image_desc, NULL, &errcode_ret); if (CL_SUCCESS != errcode_ret) { - throw std::runtime_error("clCreateImageWithProperties failed!!!"); + throw std::runtime_error("clCreateImageWithProperties failed\n"); } } @@ -824,21 +867,24 @@ clExternalImportableSemaphore::clExternalImportableSemaphore( switch (externalSemaphoreHandleType) { case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD: +#ifdef _WIN32 + log_info("Opaque file descriptors are not supported on Windows\n"); + ASSERT(0); +#else fd = (int)semaphore.getHandle(externalSemaphoreHandleType); err = check_external_semaphore_handle_type( devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); sema_props.push_back( (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); sema_props.push_back((cl_semaphore_properties_khr)fd); +#endif break; case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT: #ifndef _WIN32 + log_info("Opaque NT handles are only supported on Windows\n"); ASSERT(0); #else - log_info(" Opaque NT handles are only supported on Windows\n"); - handle = semaphore.getName().size() - ? NULL - : semaphore.getHandle(externalSemaphoreHandleType); + handle = semaphore.getHandle(externalSemaphoreHandleType); err = check_external_semaphore_handle_type( devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR); sema_props.push_back((cl_semaphore_properties_khr) @@ -846,11 +892,34 @@ clExternalImportableSemaphore::clExternalImportableSemaphore( sema_props.push_back((cl_semaphore_properties_khr)handle); #endif break; - case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT: + case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME: { #ifndef _WIN32 + log_info("Opaque NT handles are only supported on Windows\n"); + ASSERT(0); +#else + const std::wstring &name = semaphore.getName(); + if (name.size()) + { + err = check_external_semaphore_handle_type( + devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR); + sema_props.push_back( + (cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR); + sema_props.push_back((cl_semaphore_properties_khr)name.c_str()); + } + else + { + throw std::runtime_error("Unsupported operation: import via " + "name but no name provided\n"); + } +#endif + } + break; + case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT: +#ifndef _WIN32 + log_info("Opaque D3DKMT handles are only supported on Windows\n"); ASSERT(0); #else - log_info(" Opaque D3DKMT handles are only supported on Windows\n"); handle = semaphore.getHandle(externalSemaphoreHandleType); err = check_external_semaphore_handle_type( devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR); @@ -868,8 +937,8 @@ clExternalImportableSemaphore::clExternalImportableSemaphore( sema_props.push_back(static_cast(-1)); break; default: - ASSERT(0); log_error("Unsupported external memory handle type\n"); + ASSERT(0); break; } if (CL_SUCCESS != err) diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp index 116fb6e9..6c31a35d 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp @@ -1976,35 +1976,51 @@ public: ~WindowsSecurityAttributes(); }; - WindowsSecurityAttributes::WindowsSecurityAttributes() { +#define CHECK(ok, msg) \ + if (!ok) \ + { \ + throw std::runtime_error(msg); \ + } + + BOOL ok; + HANDLE tokenHandle; + + ok = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &tokenHandle); + CHECK(ok, "Failed to open process access token"); + + DWORD tokenInformationLength = 0; + GetTokenInformation(tokenHandle, TokenDefaultDacl, NULL, 0, + &tokenInformationLength); + CHECK(tokenInformationLength, + "Failed to retrieve TokenDefaultDacl info buffer length"); + m_winPSecurityDescriptor = (PSECURITY_DESCRIPTOR)calloc( - 1, SECURITY_DESCRIPTOR_MIN_LENGTH + 2 * sizeof(void **)); - // CHECK_NEQ(m_winPSecurityDescriptor, (PSECURITY_DESCRIPTOR)NULL); - PSID *ppSID = (PSID *)((PBYTE)m_winPSecurityDescriptor - + SECURITY_DESCRIPTOR_MIN_LENGTH); - PACL *ppACL = (PACL *)((PBYTE)ppSID + sizeof(PSID *)); - InitializeSecurityDescriptor(m_winPSecurityDescriptor, - SECURITY_DESCRIPTOR_REVISION); - SID_IDENTIFIER_AUTHORITY sidIdentifierAuthority = - SECURITY_WORLD_SID_AUTHORITY; - AllocateAndInitializeSid(&sidIdentifierAuthority, 1, SECURITY_WORLD_RID, 0, - 0, 0, 0, 0, 0, 0, ppSID); - EXPLICIT_ACCESS explicitAccess; - ZeroMemory(&explicitAccess, sizeof(EXPLICIT_ACCESS)); - explicitAccess.grfAccessPermissions = - STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL; - explicitAccess.grfAccessMode = SET_ACCESS; - explicitAccess.grfInheritance = INHERIT_ONLY; - explicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID; - explicitAccess.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; - explicitAccess.Trustee.ptstrName = (LPTSTR)*ppSID; - SetEntriesInAcl(1, &explicitAccess, NULL, ppACL); - SetSecurityDescriptorDacl(m_winPSecurityDescriptor, TRUE, *ppACL, FALSE); + 1, SECURITY_DESCRIPTOR_MIN_LENGTH + tokenInformationLength); + assert(m_winPSecurityDescriptor != (PSECURITY_DESCRIPTOR)NULL); + + TOKEN_DEFAULT_DACL *pTokenDefaultDacl = + reinterpret_cast( + (PBYTE)m_winPSecurityDescriptor + SECURITY_DESCRIPTOR_MIN_LENGTH); + ok = GetTokenInformation(tokenHandle, TokenDefaultDacl, pTokenDefaultDacl, + tokenInformationLength, &tokenInformationLength); + CHECK(ok, "Failed to retrieve TokenDefaultDacl info of access token"); + + ok = InitializeSecurityDescriptor(m_winPSecurityDescriptor, + SECURITY_DESCRIPTOR_REVISION); + CHECK(ok, "Failed to init security descriptor"); + + ok = SetSecurityDescriptorDacl(m_winPSecurityDescriptor, TRUE, + pTokenDefaultDacl->DefaultDacl, FALSE); + CHECK(ok, "Failed to set DACL info for given security descriptor"); + m_winSecurityAttributes.nLength = sizeof(m_winSecurityAttributes); m_winSecurityAttributes.lpSecurityDescriptor = m_winPSecurityDescriptor; m_winSecurityAttributes.bInheritHandle = TRUE; + + CloseHandle(tokenHandle); +#undef CHECK_WIN } SECURITY_ATTRIBUTES *WindowsSecurityAttributes::operator&() @@ -2014,17 +2030,6 @@ SECURITY_ATTRIBUTES *WindowsSecurityAttributes::operator&() WindowsSecurityAttributes::~WindowsSecurityAttributes() { - PSID *ppSID = (PSID *)((PBYTE)m_winPSecurityDescriptor - + SECURITY_DESCRIPTOR_MIN_LENGTH); - PACL *ppACL = (PACL *)((PBYTE)ppSID + sizeof(PSID *)); - if (*ppSID) - { - FreeSid(*ppSID); - } - if (*ppACL) - { - LocalFree(*ppACL); - } free(m_winPSecurityDescriptor); } @@ -2039,8 +2044,9 @@ VulkanDeviceMemory::VulkanDeviceMemory(const VulkanDeviceMemory &deviceMemory) VulkanDeviceMemory::VulkanDeviceMemory( const VulkanDevice &device, uint64_t size, const VulkanMemoryType &memoryType, - VulkanExternalMemoryHandleType externalMemoryHandleType, const void *name) - : m_device(device), m_size(size), m_isDedicated(false) + VulkanExternalMemoryHandleType externalMemoryHandleType, + const std::wstring name) + : m_device(device), m_size(size), m_isDedicated(false), m_name(name) { #if defined(_WIN32) || defined(_WIN64) WindowsSecurityAttributes winSecurityAttributes; @@ -2052,8 +2058,15 @@ VulkanDeviceMemory::VulkanDeviceMemory( vkExportMemoryWin32HandleInfoKHR.pAttributes = &winSecurityAttributes; vkExportMemoryWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE; - vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)name; + vkExportMemoryWin32HandleInfoKHR.name = NULL; + if (externalMemoryHandleType + == VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME) + { + vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)m_name.c_str(); + externalMemoryHandleType = + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT; + } #endif VkExportMemoryAllocateInfoKHR vkExportMemoryAllocateInfoKHR = {}; @@ -2083,9 +2096,10 @@ VulkanDeviceMemory::VulkanDeviceMemory( VulkanDeviceMemory::VulkanDeviceMemory( const VulkanDevice &device, const VulkanImage &image, const VulkanMemoryType &memoryType, - VulkanExternalMemoryHandleType externalMemoryHandleType, const void *name) + VulkanExternalMemoryHandleType externalMemoryHandleType, + const std::wstring name) : m_device(device), m_size(image.getSize()), - m_isDedicated(image.isDedicated()) + m_isDedicated(image.isDedicated()), m_name(name) { #if defined(_WIN32) || defined(_WIN64) WindowsSecurityAttributes winSecurityAttributes; @@ -2097,8 +2111,15 @@ VulkanDeviceMemory::VulkanDeviceMemory( vkExportMemoryWin32HandleInfoKHR.pAttributes = &winSecurityAttributes; vkExportMemoryWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE; - vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)name; + vkExportMemoryWin32HandleInfoKHR.name = NULL; + if (externalMemoryHandleType + == VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME) + { + vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)m_name.c_str(); + externalMemoryHandleType = + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT; + } #endif VkExportMemoryAllocateInfoKHR vkExportMemoryAllocateInfoKHR = {}; @@ -2145,9 +2166,10 @@ VulkanDeviceMemory::VulkanDeviceMemory( VulkanDeviceMemory::VulkanDeviceMemory( const VulkanDevice &device, const VulkanBuffer &buffer, const VulkanMemoryType &memoryType, - VulkanExternalMemoryHandleType externalMemoryHandleType, const void *name) + VulkanExternalMemoryHandleType externalMemoryHandleType, + const std::wstring name) : m_device(device), m_size(buffer.getSize()), - m_isDedicated(buffer.isDedicated()) + m_isDedicated(buffer.isDedicated()), m_name(name) { #if defined(_WIN32) || defined(_WIN64) WindowsSecurityAttributes winSecurityAttributes; @@ -2159,8 +2181,15 @@ VulkanDeviceMemory::VulkanDeviceMemory( vkExportMemoryWin32HandleInfoKHR.pAttributes = &winSecurityAttributes; vkExportMemoryWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE; - vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)name; + vkExportMemoryWin32HandleInfoKHR.name = NULL; + if (externalMemoryHandleType + == VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME) + { + vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)m_name.c_str(); + externalMemoryHandleType = + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT; + } #endif VkExportMemoryAllocateInfoKHR vkExportMemoryAllocateInfoKHR = {}; @@ -2291,6 +2320,8 @@ void VulkanDeviceMemory::bindImage(const VulkanImage &image, uint64_t offset) vkBindImageMemory(m_device, image, m_vkDeviceMemory, offset); } +const std::wstring &VulkanDeviceMemory::getName() const { return m_name; } + VulkanDeviceMemory::operator VkDeviceMemory() const { return m_vkDeviceMemory; } //////////////////////////////////// @@ -2318,8 +2349,15 @@ VulkanSemaphore::VulkanSemaphore( vkExportSemaphoreWin32HandleInfoKHR.pAttributes = &winSecurityAttributes; vkExportSemaphoreWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE; - vkExportSemaphoreWin32HandleInfoKHR.name = - m_name.size() ? (LPCWSTR)m_name.c_str() : NULL; + vkExportSemaphoreWin32HandleInfoKHR.name = NULL; + + if (externalSemaphoreHandleType + == VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME) + { + vkExportSemaphoreWin32HandleInfoKHR.name = (LPCWSTR)m_name.c_str(); + externalSemaphoreHandleType = + VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT; + } #endif VkExportSemaphoreCreateInfoKHR vkExportSemaphoreCreateInfoKHR = {}; diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp index 8f9fb980..b528f4aa 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp @@ -22,6 +22,7 @@ #include "vulkan_list_map.hpp" #include "vulkan_api_list.hpp" #include +#include class VulkanInstance { friend const VulkanInstance &getVulkanInstance(); @@ -581,7 +582,7 @@ protected: VkDeviceMemory m_vkDeviceMemory; uint64_t m_size; bool m_isDedicated; - + const std::wstring m_name; VulkanDeviceMemory(const VulkanDeviceMemory &deviceMemory); @@ -590,17 +591,17 @@ public: const VulkanMemoryType &memoryType, VulkanExternalMemoryHandleType externalMemoryHandleType = VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE, - const void *name = NULL); + const std::wstring name = L""); VulkanDeviceMemory(const VulkanDevice &device, const VulkanImage &image, const VulkanMemoryType &memoryType, VulkanExternalMemoryHandleType externalMemoryHandleType = VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE, - const void *name = NULL); + const std::wstring name = L""); VulkanDeviceMemory(const VulkanDevice &device, const VulkanBuffer &buffer, const VulkanMemoryType &memoryType, VulkanExternalMemoryHandleType externalMemoryHandleType = VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE, - const void *name = NULL); + const std::wstring name = L""); virtual ~VulkanDeviceMemory(); uint64_t getSize() const; #ifdef _WIN32 @@ -615,6 +616,7 @@ public: void unmap(); void bindBuffer(const VulkanBuffer &buffer, uint64_t offset = 0); void bindImage(const VulkanImage &image, uint64_t offset = 0); + const std::wstring &getName() const; operator VkDeviceMemory() const; }; diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper_types.hpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper_types.hpp index 5164ade5..4180e12b 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper_types.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper_types.hpp @@ -22,6 +22,7 @@ #define VULKAN_MIN_BUFFER_OFFSET_COPY_ALIGNMENT 4 #define VULKAN_REMAINING_MIP_LEVELS VK_REMAINING_MIP_LEVELS #define VULKAN_REMAINING_ARRAY_LAYERS VK_REMAINING_ARRAY_LAYERS +#define VULKAN_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME_BIT 0x10000000 class VulkanInstance; class VulkanPhysicalDevice; @@ -159,7 +160,9 @@ enum VulkanExternalMemoryHandleType VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR, VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_KMT = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR - | VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR + | VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR, + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME = + VULKAN_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME_BIT }; enum VulkanExternalSemaphoreHandleType @@ -172,7 +175,9 @@ enum VulkanExternalSemaphoreHandleType VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR, VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD = - VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR, + VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME = + VULKAN_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME_BIT }; enum VulkanBufferUsage