cancel
Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

pjaholkowski
Journeyman III

Vulkan Copying to directx 11 shared texture

Hi

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...)

(null)

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

0 Likes
9 Replies
xhuang
Staff

Hello pjaholkowski​, may i know your driver release version?

0 Likes

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)

{

    //VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT

    hr = pDevice1->OpenSharedResource1(sharedTextureHandle, __uuidof(ID3D11Resource), (void**)(&pd3d11SharedResource));

    if (0 != hr)

        LOG("OpenSharedResource1 failed with hr = %u\n", hr);

}

else

{

    //VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT

    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

0 Likes

Thanks! Will report to the right team to investigate this issue and will keep you updated.

0 Likes

Hi pjaholkowski​, could you  also share your source code of the latest binary?  That'll be usefully for us for debugging the problem. Thanks.

0 Likes

Here you go

0 Likes

Thanks. Will get back to you if we could find something. Appreciate your report!

--

Best Regards

Shimmer Huang

0 Likes

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;

     VkMemoryDedicatedAllocateInfoKHR dedicatedAllocationInfo;

-    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.

0 Likes

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.

0 Likes

Thank you, we'd like to help as much as possible.

If you have any question/issue, do not hesitate to post here.

0 Likes