vulkan/wsi: set correct bits for host allocations/exports for images.
Lavapipe was hitting asserts in this area due to incorrect bits being
specified.
Set the handle type depending on the sw flag, and set a correct handle
type for the memory host ptrs.
v2: add image export struct to image creation (Jason)
Fixes: 895d3399f7
("lavapipe: add support for KHR_external_memory_fd")
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13615>
This commit is contained in:
parent
d66514aacc
commit
a8725ec3dc
|
@ -120,9 +120,15 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
|
||||||
struct wsi_image_create_info image_wsi_info = {
|
struct wsi_image_create_info image_wsi_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA,
|
.sType = VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA,
|
||||||
};
|
};
|
||||||
|
VkExternalMemoryImageCreateInfo ext_mem_image_create_info = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
|
||||||
|
.pNext = &image_wsi_info,
|
||||||
|
.handleTypes = wsi->sw ? VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT :
|
||||||
|
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||||
|
};
|
||||||
VkImageCreateInfo image_info = {
|
VkImageCreateInfo image_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
.pNext = &image_wsi_info,
|
.pNext = &ext_mem_image_create_info,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.imageType = VK_IMAGE_TYPE_2D,
|
.imageType = VK_IMAGE_TYPE_2D,
|
||||||
.format = pCreateInfo->imageFormat,
|
.format = pCreateInfo->imageFormat,
|
||||||
|
@ -319,7 +325,8 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
|
||||||
const VkExportMemoryAllocateInfo memory_export_info = {
|
const VkExportMemoryAllocateInfo memory_export_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO,
|
||||||
.pNext = &memory_wsi_info,
|
.pNext = &memory_wsi_info,
|
||||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
.handleTypes = wsi->sw ? VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT :
|
||||||
|
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||||
};
|
};
|
||||||
const VkMemoryDedicatedAllocateInfo memory_dedicated_info = {
|
const VkMemoryDedicatedAllocateInfo memory_dedicated_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
|
||||||
|
@ -331,6 +338,7 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
|
||||||
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT,
|
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT,
|
||||||
.pNext = &memory_dedicated_info,
|
.pNext = &memory_dedicated_info,
|
||||||
.pHostPointer = sw_host_ptr,
|
.pHostPointer = sw_host_ptr,
|
||||||
|
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT,
|
||||||
};
|
};
|
||||||
const VkMemoryAllocateInfo memory_info = {
|
const VkMemoryAllocateInfo memory_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||||
|
|
Loading…
Reference in New Issue