vkr: do not force VkExternalMemoryBufferCreateInfo

Still incorrect, but is probably not as bad.

Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Acked-by: Ryan Neph <ryanneph@google.com>
macos/master
Chia-I Wu 3 years ago
parent d709ebb5e2
commit bbcf44958d
  1. 49
      src/venus/vkr_buffer.c

@ -12,29 +12,32 @@ static void
vkr_dispatch_vkCreateBuffer(struct vn_dispatch_context *dispatch, vkr_dispatch_vkCreateBuffer(struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateBuffer *args) struct vn_command_vkCreateBuffer *args)
{ {
struct vkr_context *ctx = dispatch->data; /* XXX If VkExternalMemoryBufferCreateInfo is chained by the app, all is
* good. If it is not chained, we might still bind an external memory to
struct vkr_device *dev = vkr_device_from_handle(args->device); * the buffer, because vkr_dispatch_vkAllocateMemory makes any HOST_VISIBLE
* memory external. That is a spec violation.
#ifdef FORCE_ENABLE_DMABUF *
VkExternalMemoryBufferCreateInfo local_external_info; * We could unconditionally chain VkExternalMemoryBufferCreateInfo. Or we
if (dev->physical_device->EXT_external_memory_dma_buf) { * could call vkGetPhysicalDeviceExternalBufferProperties and fail
VkExternalMemoryBufferCreateInfo *external_info = vkr_find_pnext( * vkCreateBuffer if the buffer does not support external memory. But we
args->pCreateInfo->pNext, VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO); * would still end up with spec violation either way, while having a higher
if (external_info) { * chance of causing compatibility issues.
external_info->handleTypes |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT; *
} else { * In practice, drivers usually ignore VkExternalMemoryBufferCreateInfo, or
local_external_info = (const VkExternalMemoryBufferCreateInfo){ * use it to filter out memory types in VkMemoryRequirements that do not
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO, * support external memory. Binding an external memory to a buffer created
.pNext = args->pCreateInfo->pNext, * without VkExternalMemoryBufferCreateInfo usually works.
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, *
}; * To formalize this, we are potentially looking for an extension that
((VkBufferCreateInfo *)args->pCreateInfo)->pNext = &local_external_info; * supports exporting memories without making them external. Because they
} * are not external, they can be bound to buffers created without
} * VkExternalMemoryBufferCreateInfo. And because they are not external, we
#endif * need something that is not vkGetPhysicalDeviceExternalBufferProperties
* to determine the exportability. See
vkr_buffer_create_and_add(ctx, args); * vkr_physical_device_init_memory_properties as well.
*/
vkr_buffer_create_and_add(dispatch->data, args);
} }
static void static void

Loading…
Cancel
Save