From 63844cd5311ccefde8297abe41789795e18c3b76 Mon Sep 17 00:00:00 2001 From: Vlad Schiller Date: Mon, 18 Sep 2023 11:18:25 +0100 Subject: [PATCH] pvr: Implement EXT_separate_stencil_usage Signed-off-by: Vlad Schiller Acked-by: Erik Faye-Lund Part-of: --- docs/features.txt | 2 +- src/imagination/vulkan/pvr_device.c | 1 + src/imagination/vulkan/pvr_formats.c | 20 +++++++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index 3892b27dec7..44843db2133 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -483,7 +483,7 @@ Vulkan 1.2 -- all DONE: anv, hk, nvk, panvk/v10+, tu, vn VK_EXT_host_query_reset DONE (anv, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_EXT_sampler_filter_minmax DONE (anv, lvp, nvk, panvk/v10+, radv, tu, vn) VK_EXT_scalar_block_layout DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, radv, tu, vn, v3dv/vc7+) - VK_EXT_separate_stencil_usage DONE (anv, dzn, hasvk, lvp, nvk, panvk, radv, tu, v3dv, vn) + VK_EXT_separate_stencil_usage DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_EXT_shader_viewport_index_layer DONE (anv, hasvk, lvp, nvk, radv, tu, vn) Vulkan 1.3 -- all DONE: anv, hk, lvp, nvk, panvk/v10+, radv, tu, vn, v3dv diff --git a/src/imagination/vulkan/pvr_device.c b/src/imagination/vulkan/pvr_device.c index 25388858871..36a362259fc 100644 --- a/src/imagination/vulkan/pvr_device.c +++ b/src/imagination/vulkan/pvr_device.c @@ -212,6 +212,7 @@ static void pvr_physical_device_get_supported_extensions( .EXT_private_data = true, .EXT_provoking_vertex = true, .EXT_queue_family_foreign = true, + .EXT_separate_stencil_usage = true, .EXT_scalar_block_layout = true, .EXT_texel_buffer_alignment = false, .EXT_tooling_info = true, diff --git a/src/imagination/vulkan/pvr_formats.c b/src/imagination/vulkan/pvr_formats.c index 6c264a0f06b..6219633826f 100644 --- a/src/imagination/vulkan/pvr_formats.c +++ b/src/imagination/vulkan/pvr_formats.c @@ -684,6 +684,9 @@ pvr_get_image_format_features2(const struct pvr_format *pvr_format, VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT; } + if (vk_format_has_stencil(vk_format)) + flags |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT; + switch (vk_format) { case VK_FORMAT_R8_UNORM: case VK_FORMAT_R8_SNORM: @@ -899,6 +902,8 @@ pvr_get_image_format_properties(struct pvr_physical_device *pdevice, /* Input attachments aren't rendered but they must have the same size * restrictions as any framebuffer attachment. */ + const VkImageStencilUsageCreateInfo *stencil_usage_info = + vk_find_struct_const(info->pNext, IMAGE_STENCIL_USAGE_CREATE_INFO); const VkImageUsageFlags render_usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | @@ -906,6 +911,8 @@ pvr_get_image_format_properties(struct pvr_physical_device *pdevice, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; const struct pvr_format *pvr_format = pvr_get_format(info->format); VkFormatFeatureFlags2 tiling_features2; + VkImageUsageFlags usage = + info->usage | (stencil_usage_info ? stencil_usage_info->stencilUsage : 0); VkResult result; if (!pvr_format) { @@ -928,8 +935,8 @@ pvr_get_image_format_properties(struct pvr_physical_device *pdevice, * specific format isn't supported based on the usage. */ if ((info->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) == 0 && - info->usage & (VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | - VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) && + usage & (VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) && pvr_format->pbe_accum_format == PVR_PBE_ACCUM_FORMAT_INVALID) { result = vk_error(pdevice, VK_ERROR_FORMAT_NOT_SUPPORTED); goto err_unsupported_format; @@ -948,8 +955,7 @@ pvr_get_image_format_properties(struct pvr_physical_device *pdevice, /* Linear tiled 3D images may only be used for transfer or blit * operations. */ - if (info->tiling == VK_IMAGE_TILING_LINEAR && - info->usage & ~transfer_usage) { + if (info->tiling == VK_IMAGE_TILING_LINEAR && usage & ~transfer_usage) { result = vk_error(pdevice, VK_ERROR_FORMAT_NOT_SUPPORTED); goto err_unsupported_format; } @@ -961,7 +967,7 @@ pvr_get_image_format_properties(struct pvr_physical_device *pdevice, } } - if (info->usage & render_usage) { + if (usage & render_usage) { const uint32_t max_render_size = rogue_get_render_size_max(&pdevice->dev_info); @@ -1095,6 +1101,10 @@ VkResult pvr_GetPhysicalDeviceImageFormatProperties2( break; case VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO: break; + case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO: + /* Nothing to do here, it's handled in pvr_get_image_format_properties + */ + break; default: vk_debug_ignored_stype(ext->sType); break;