From 09c131df0cbb763f84789973bd22c6f54fe48f9b Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Tue, 19 Mar 2024 09:28:16 +0000 Subject: [PATCH] pvr: support VK_KHR_device_group VK_KHR_device_group has some interactions with other extensions that requires some additional bits and pieces to be supported. One such interaction is with VK_KHR_swapchain. Signed-off-by: Frank Binns Reviewed-by: Simon Perretta Part-of: --- docs/features.txt | 2 +- docs/relnotes/new_features.txt | 1 + src/imagination/vulkan/pvr_device.c | 16 +++-------- src/imagination/vulkan/pvr_device.h | 12 ++++++++ src/imagination/vulkan/pvr_image.c | 43 ++++++++++++++++++++++++----- 5 files changed, 54 insertions(+), 20 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index baeb4b9a95f..acb89291fe6 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -439,7 +439,7 @@ Vulkan 1.1 -- all DONE: anv, hk, lvp, nvk, panvk/v10+, pvr, radv, tu, vn VK_KHR_bind_memory2 DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_KHR_dedicated_allocation DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_KHR_descriptor_update_template DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) - VK_KHR_device_group DONE (anv, dzn, hasvk, lvp, nvk, panvk, tu, v3dv, vn) + VK_KHR_device_group DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, tu, v3dv, vn) VK_KHR_device_group_creation DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, tu, v3dv, vn) VK_KHR_external_fence DONE (anv, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_KHR_external_fence_capabilities DONE (anv, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index 9a6984af0c4..705fb6eca03 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -82,3 +82,4 @@ VK_EXT_shader_replicated_composites on pvr VK_KHR_device_group_creation on pvr VK_KHR_map_memory2 on pvr VK_EXT_map_memory_placed on pvr +VK_KHR_device_group on pvr diff --git a/src/imagination/vulkan/pvr_device.c b/src/imagination/vulkan/pvr_device.c index 92d7cb2fcfb..426a6bc18a4 100644 --- a/src/imagination/vulkan/pvr_device.c +++ b/src/imagination/vulkan/pvr_device.c @@ -109,18 +109,6 @@ */ #define PVR_GLOBAL_FREE_LIST_GROW_THRESHOLD 13U -#if defined(VK_USE_PLATFORM_DISPLAY_KHR) -# define PVR_USE_WSI_PLATFORM_DISPLAY true -#else -# define PVR_USE_WSI_PLATFORM_DISPLAY false -#endif - -#if PVR_USE_WSI_PLATFORM_DISPLAY -# define PVR_USE_WSI_PLATFORM true -#else -# define PVR_USE_WSI_PLATFORM false -#endif - /* Amount of padding required for VkBuffers to ensure we don't read beyond * a page boundary. */ @@ -190,6 +178,7 @@ static void pvr_physical_device_get_supported_extensions( .KHR_dedicated_allocation = true, .KHR_depth_stencil_resolve = true, .KHR_descriptor_update_template = true, + .KHR_device_group = true, .KHR_driver_properties = true, .KHR_external_fence = true, .KHR_external_fence_fd = true, @@ -2625,6 +2614,9 @@ VkResult pvr_AllocateMemory(VkDevice _device, * allocations that won't be suballocated to multiple resources. */ break; + case VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO: + /* We're not yet using any of the flags provided. */ + break; default: vk_debug_ignored_stype(ext->sType); break; diff --git a/src/imagination/vulkan/pvr_device.h b/src/imagination/vulkan/pvr_device.h index 6099bea173b..d18abf10074 100644 --- a/src/imagination/vulkan/pvr_device.h +++ b/src/imagination/vulkan/pvr_device.h @@ -30,6 +30,18 @@ #include "pvr_spm.h" #include "pvr_usc.h" +#if defined(VK_USE_PLATFORM_DISPLAY_KHR) +# define PVR_USE_WSI_PLATFORM_DISPLAY true +#else +# define PVR_USE_WSI_PLATFORM_DISPLAY false +#endif + +#if PVR_USE_WSI_PLATFORM_DISPLAY +# define PVR_USE_WSI_PLATFORM true +#else +# define PVR_USE_WSI_PLATFORM false +#endif + typedef struct _pco_ctx pco_ctx; struct pvr_instance; diff --git a/src/imagination/vulkan/pvr_image.c b/src/imagination/vulkan/pvr_image.c index 211252a98a4..b37df6c7e3c 100644 --- a/src/imagination/vulkan/pvr_image.c +++ b/src/imagination/vulkan/pvr_image.c @@ -160,6 +160,17 @@ VkResult pvr_CreateImage(VkDevice _device, VK_FROM_HANDLE(pvr_device, device, _device); struct pvr_image *image; +#if defined(PVR_USE_WSI_PLATFORM) + const VkImageSwapchainCreateInfoKHR *swapchain_info = + vk_find_struct_const(pCreateInfo->pNext, IMAGE_SWAPCHAIN_CREATE_INFO_KHR); + if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) { + return wsi_common_create_swapchain_image(&device->pdevice->wsi_device, + pCreateInfo, + swapchain_info->swapchain, + pImage); + } +#endif + image = vk_image_create(&device->vk, pCreateInfo, pAllocator, sizeof(*image)); if (!image) @@ -238,14 +249,32 @@ VkResult pvr_BindImageMemory2(VkDevice _device, for (i = 0; i < bindInfoCount; i++) { VK_FROM_HANDLE(pvr_device_memory, mem, pBindInfos[i].memory); VK_FROM_HANDLE(pvr_image, image, pBindInfos[i].image); + VkDeviceSize offset = pBindInfos[i].memoryOffset; + VkResult result; - VkResult result = pvr_bind_memory(device, - mem, - pBindInfos[i].memoryOffset, - image->size, - image->alignment, - &image->vma, - &image->dev_addr); +#if defined(PVR_USE_WSI_PLATFORM) + const VkBindImageMemorySwapchainInfoKHR *swapchain_info = + vk_find_struct_const(pBindInfos[i].pNext, + BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR); + + if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) { + VkDeviceMemory _swapchain_memory = + wsi_common_get_memory(swapchain_info->swapchain, + swapchain_info->imageIndex); + VK_FROM_HANDLE(pvr_device_memory, swapchain_memory, _swapchain_memory); + + mem = swapchain_memory; + offset = 0; + } +#endif + + result = pvr_bind_memory(device, + mem, + offset, + image->size, + image->alignment, + &image->vma, + &image->dev_addr); if (result != VK_SUCCESS) { while (i--) { VK_FROM_HANDLE(pvr_image, image, pBindInfos[i].image);