I'm trying to copy swapchain image to shared directX 11 texture.
I tested my code on other vendor gpus and it works except AMD where it crashes while calling vkCmdPipelineBarrier on shared VkImage.
I ran it with validation layers and only message I got is:
Validation(WARN): msg_code: 207733773: [ VUID-VkMemoryAllocateInfo-pNext-pNext ] Object: VK_NULL_HANDLE (Type = 0) | vkAllocateMemory: pAllocateInfo->pNext chain includes a structure with unexpected VkStructureType VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO; Allowed structures are [VkDedicatedAllocationMemoryAllocateInfoNV, VkExportMemoryAllocateInfo, VkExportMemoryAllocateInfoNV, VkExportMemoryWin32HandleInfoKHR, VkExportMemoryWin32HandleInfoNV, VkImportAndroidHardwareBufferInfoANDROID, VkImportMemoryFdInfoKHR, VkImportMemoryHostPointerInfoEXT, VkImportMemoryWin32HandleInfoKHR, VkImportMemoryWin32HandleInfoNV, VkMemoryAllocateFlagsInfo, VkMemoryDedicatedAllocateInfo]. This warning is based on the Valid Usage documentation for version 77 of the Vulkan header. It is possible that you are using a struct from a private extension or an extension that was added to a later version of the Vulkan header, in which case your use of pAllocateInfo->pNext is perfectly valid but is not guaranteed to work correctly with validation enabled The spec valid usage text states 'Each pNext member of any structure (including this one) in the pNext chain must be either NULL or a pointer to a valid instance of VkDedicatedAllocationMemoryAllocateInfoNV, VkExportMemoryAllocateInfo, VkExportMemoryAllocateInfoNV, VkExportMemoryWin32HandleInfoKHR, VkExportMemoryWin32HandleInfoNV, VkImportAndroidHardwareBufferInfoANDROID, VkImportMemoryFdInfoKHR, VkImportMemoryHostPointerInfoEXT, VkImportMemoryWin32HandleInfoKHR, VkImportMemoryWin32HandleInfoNV, VkMemoryAllocateFlagsInfo, or VkMemoryDedicatedAllocateInfo' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkMemoryAllocateInfo-pNext-p...)
It crashes in amdvlk32.dll. It would be nice if someone with access to its symbols could look at it
and give me a clue what is wrong.
I attached crash dump, executable and source code of working example based on cubepp from VulkanSDK
Yes all information about GPU, OS, DriverVersion, etc is inside attached via.html file
Ok I made a few fixes
VkResult result = vkGetPhysicalDeviceImageFormatProperties2KHR_ptr(physicalDevice, &imageFormatInfo, &imageFormatProperties); // does not return VK_FALSE
and in opening shared resources
if (textureDescriptor.MiscFlags & D3D11_RESOURCE_MISC_SHARED_NTHANDLE)
hr = pDevice1->OpenSharedResource1(sharedTextureHandle, __uuidof(ID3D11Resource), (void**)(&pd3d11SharedResource));
if (0 != hr)
LOG("OpenSharedResource1 failed with hr = %u\n", hr);
hr = pDevice->OpenSharedResource(sharedTextureHandle, __uuidof(ID3D11Resource), (void**)(&pd3d11SharedResource));
if (0 != hr)
LOG("OpenSharedResource failed with hr = %u\n", hr)
but it still crashes in vkCmdPipelineBarrier
Hello pjaholkowski, here's the suggested change below, i.e. dedicatedAllocationInfo.sType should be VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR instead.
--- cube.cpp 2018-08-22 17:36:16.285475800 +0800
+++ cube_v1_1.cpp 2018-08-16 20:27:37.047253800 +0800
@@ -496,7 +496,7 @@
memoryInfo.allocationSize = memoryRequirements.size;
- dedicatedAllocationInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR;
+ dedicatedAllocationInfo.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR;
dedicatedAllocationInfo.pNext = nullptr;
dedicatedAllocationInfo.buffer = VK_NULL_HANDLE;
The reason why NV card (i assume you're using NV card) works is NV driver does not set flag VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_KHR in externalMemoryProperties.externalMemoryFeatures, then your application on NV card would go different path using vkGetImageMemoryRequirements() and vkBindImageMemory(), however, if on AMD card, the other path would go with vkGetImageMemoryRequirements2KHR() and vkBindImageMemory2KHR(), the wrong flag impacts the 2nd path only.
Thanks a lot and sorry for wasting your time.
That warning message from validation layer clearly states what is wrong and I was
pretty sure that I checked that. I'm confused right now because I don't understand what happened
Sorry once again.