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 <frank.binns@imgtec.com>
Reviewed-by: Simon Perretta <simon.perretta@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37726>
This commit is contained in:
Frank Binns 2024-03-19 09:28:16 +00:00 committed by Marge Bot
parent d62fdc0a2e
commit 09c131df0c
5 changed files with 54 additions and 20 deletions

View file

@ -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)

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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);