KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.33k stars 647 forks source link

Fix OpenGL interop sample #1122

Closed triggerhuang-gpu closed 2 months ago

triggerhuang-gpu commented 3 months ago

On Vulkan side, the memory behind an interop image should be a dedicated allocation. And on the OpenGL side, we also need to explicitly set the memory object with GL_DEDICATED_MEMORY_OBJECT_EXT falg.

Without this modification, there should be validation errors like:

Validation Error: [ VUID-VkMemoryAllocateInfo-pNext-00639 ] Object 0: handle = 0x603cd90000000044, type = VK_OBJECT_TYPE_IMAGE; Object 1: handle = 0x8cc1d80000000045, type = VK_OBJECT_TYPE_DEVICE_MEMORY; | MessageID = 0xfd0fdaf4 | vkBindImageMemory(): memory (VkDeviceMemory 0x8cc1d80000000045[]) has VkExportMemoryAllocateInfo::handleTypes with the VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT flag set, which requires dedicated allocation for the image created with format (VK_FORMAT_R8G8B8A8_UNORM), type (VK_IMAGE_TYPE_2D), tiling (VK_IMAGE_TILING_OPTIMAL), usage (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT), flags (VkImageCreateFlags(0)), but the memory is allocated without dedicated allocation support. The Vulkan spec states: If the pNext chain includes a VkExportMemoryAllocateInfo structure, and any of the handle types specified in VkExportMemoryAllocateInfo::handleTypes require a dedicated allocation, as reported by vkGetPhysicalDeviceImageFormatProperties2 in VkExternalImageFormatProperties::externalMemoryProperties.externalMemoryFeatures, or by vkGetPhysicalDeviceExternalBufferProperties in VkExternalBufferProperties::externalMemoryProperties.externalMemoryFeatures, the pNext chain must include a VkMemoryDedicatedAllocateInfo or VkDedicatedAllocationMemoryAllocateInfoNV structure with either its image or buffer member set to a value other than VK_NULL_HANDLE (https://vulkan.lunarg.com/doc/view/1.3.283.0/linux/1.3-extensions/vkspec.html#VUID-VkMemoryAllocateInfo-pNext-00639)

Description

Please include a summary of the change, new sample or fixed issue. Please also include relevant motivation and context. Please read the contribution guidelines

Fixes #

General Checklist:

Please ensure the following points are checked:

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist:

CLAassistant commented 3 months ago

CLA assistant check
All committers have signed the CLA.

asuessenbach commented 3 months ago

I don't get such a validation layer error (on Win10, using Nvidia GPU). Is that a Linux thing? Nevertheless, your change looks correct. But you should resolve the failing Quality Check.

triggerhuang-gpu commented 3 months ago

I don't get such a validation layer error (on Win10, using Nvidia GPU). Is that a Linux thing? Nevertheless, your change looks correct. But you should resolve the failing Quality Check.

Thanks for the comments. Yes, I am running this case on Linux Ubuntu22.04 + AMDGPU. Let me check how to resolve the failing Quality Check

triggerhuang-gpu commented 3 months ago

Hello @asuessenbach , I have resolved all the failing Quality Checks, would you please help to continuing the review procedure

triggerhuang-gpu commented 2 months ago

Hello @SaschaWillems , @gary-sweet , would you please help review this patch?