From 7ebd11e1d4eb0aa4374ae8d900799c84cd77b475 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Fri, 15 Apr 2022 01:26:51 +0200 Subject: [PATCH] comp/render: Add VkExternalMemoryBufferCreateInfo Fixes validation error when calling render_buffer_init_exportable VUID-vkBindBufferMemory-memory-02726(ERROR / SPEC): msgNum: -168767885 - Validation Error: [ VUID-vkBindBufferMemory-memory-02726 ] Object 0: handle = 0xe88693000000000c, type = VK_OBJECT_TYPE_BUFFER; Object 1: handle = 0xcad092000000000d, type = VK_OBJECT_TYPE_DEVICE_MEMORY; | MessageID = 0xf5f0ce73 | vkBindBufferMemory(): The VkDeviceMemory (VkDeviceMemory 0xcad092000000000d[]) has an external handleType of VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT which does not include at least one handle from VkBuffer (VkBuffer 0xe88693000000000c[]) handleType Unhandled VkExternalMemoryHandleTypeFlagBits. The Vulkan spec states: If the value of VkExportMemoryAllocateInfo::handleTypes used to allocate memory is not 0, it must include at least one of the handles set in VkExternalMemoryBufferCreateInfo::handleTypes when buffer was created (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkBindBufferMemory-memory-02726) Objects: 2 [0] 0xe88693000000000c, type: 9, name: NULL [1] 0xcad092000000000d, type: 8, name: NULL --- src/xrt/compositor/render/render_buffer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/xrt/compositor/render/render_buffer.c b/src/xrt/compositor/render/render_buffer.c index 95669da90..701bf6856 100644 --- a/src/xrt/compositor/render/render_buffer.c +++ b/src/xrt/compositor/render/render_buffer.c @@ -26,6 +26,7 @@ create_buffer(struct vk_bundle *vk, VkBufferUsageFlags usage_flags, VkMemoryPropertyFlags memory_property_flags, VkDeviceSize size, + const void *pNext_for_create, const void *pNext_for_allocate, VkBuffer *out_buffer, VkDeviceMemory *out_memory, @@ -37,6 +38,7 @@ create_buffer(struct vk_bundle *vk, // Create the buffer handle. VkBufferCreateInfo buffer_info = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, + .pNext = pNext_for_create, .size = size, .usage = usage_flags, }; @@ -133,6 +135,7 @@ render_buffer_init(struct vk_bundle *vk, usage_flags, // usage_flags memory_property_flags, // memory_property_flags size, // size + NULL, // pNext for create NULL, // pNext_for_allocate &buffer->buffer, // out_buffer &buffer->memory, // out_memory @@ -154,6 +157,11 @@ render_buffer_init_exportable(struct vk_bundle *vk, { VkResult ret; + VkExternalMemoryBufferCreateInfo export_create_info = { + .sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO, + .handleTypes = vk_csci_get_image_external_handle_type(vk), + }; + VkExportMemoryAllocateInfo export_alloc_info = { .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR, .pNext = NULL, @@ -164,6 +172,7 @@ render_buffer_init_exportable(struct vk_bundle *vk, usage_flags, // usage_flags memory_property_flags, // memory_property_flags size, // size + &export_create_info, // pNext_for_create &export_alloc_info, // pNext_for_allocate &buffer->buffer, // out_buffer &buffer->memory, // out_memory