mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-02-03 20:40:26 +01:00
vulkan-renderer: make dmabuf import dedicated allocation optional
This is not strictly always necessary depending on the implementation, so the extension requirement can be made optional. Also improve its usage by first checking whether the dedicated allocation is preferred/required by the driver, before importing with dedicated allocation. Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
This commit is contained in:
parent
6cc8f48cd8
commit
ad0f4cf94b
1 changed files with 11 additions and 2 deletions
|
|
@ -3300,7 +3300,6 @@ import_dmabuf(struct vulkan_renderer *vr,
|
|||
int fd0 = attributes->fd[0];
|
||||
|
||||
assert(vulkan_device_has(vr, EXTENSION_EXT_EXTERNAL_MEMORY_DMA_BUF));
|
||||
assert(vulkan_device_has(vr, EXTENSION_KHR_DEDICATED_ALLOCATION));
|
||||
assert(vulkan_device_has(vr, EXTENSION_KHR_EXTERNAL_MEMORY_FD));
|
||||
assert(vulkan_device_has(vr, EXTENSION_KHR_GET_MEMORY_REQUIREMENTS_2));
|
||||
|
||||
|
|
@ -3319,6 +3318,13 @@ import_dmabuf(struct vulkan_renderer *vr,
|
|||
VkMemoryRequirements2 mem_reqs = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
|
||||
};
|
||||
|
||||
VkMemoryDedicatedRequirements mem_dedicated_req = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS,
|
||||
};
|
||||
if (vulkan_device_has(vr, EXTENSION_KHR_DEDICATED_ALLOCATION))
|
||||
pnext(&mem_reqs_info, &mem_dedicated_req);
|
||||
|
||||
vr->get_image_memory_requirements2(vr->dev, &mem_reqs_info, &mem_reqs);
|
||||
|
||||
const uint32_t memory_type_bits = fd_props.memoryTypeBits &
|
||||
|
|
@ -3351,7 +3357,10 @@ import_dmabuf(struct vulkan_renderer *vr,
|
|||
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
|
||||
.image = image,
|
||||
};
|
||||
pnext(&memory_allocate_info, &memory_dedicated_info);
|
||||
if (vulkan_device_has(vr, EXTENSION_KHR_DEDICATED_ALLOCATION) &&
|
||||
(mem_dedicated_req.requiresDedicatedAllocation ||
|
||||
mem_dedicated_req.prefersDedicatedAllocation))
|
||||
pnext(&memory_allocate_info, &memory_dedicated_info);
|
||||
|
||||
result = vkAllocateMemory(vr->dev, &memory_allocate_info, NULL, memory);
|
||||
check_vk_success(result, "vkAllocateMemory");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue