panvk: implement VK_EXT_separate_stencil_usage
Needed for Vulkan 1.2. The only real improvement from this is that in some situations we can skip creating texture descriptors for image views that have a more restrictive usage for either the depth or stencil aspect. Signed-off-by: Benjamin Lee <benjamin.lee@collabora.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33392>
This commit is contained in:
@@ -479,7 +479,7 @@ Vulkan 1.2 -- all DONE: anv, nvk, 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/gfx7+, tu, vn, v3dv/vc7+)
|
||||
VK_EXT_separate_stencil_usage DONE (anv, dzn, hasvk, lvp, nvk, radv, tu, v3dv, vn)
|
||||
VK_EXT_separate_stencil_usage DONE (anv, dzn, hasvk, lvp, nvk, panvk, radv, tu, v3dv, vn)
|
||||
VK_EXT_shader_viewport_index_layer DONE (anv, hasvk, lvp, nvk, radv, tu, vn)
|
||||
|
||||
Vulkan 1.3 -- all DONE: anv, lvp, nvk, radv, tu, vn, v3dv
|
||||
|
||||
@@ -3,3 +3,4 @@ storagePushConstant16 on panvk
|
||||
storageInputOutput16 on panvk
|
||||
VK_KHR_depth_stencil_resolve on panvk
|
||||
VK_KHR_separate_depth_stencil_layouts on panvk
|
||||
VK_EXT_separate_stencil_usage on panvk
|
||||
|
||||
@@ -251,46 +251,47 @@ static void
|
||||
panvk_image_pre_mod_select_meta_adjustments(struct panvk_image *image)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(image->vk.format);
|
||||
const VkImageUsageFlags all_usage =
|
||||
image->vk.usage | image->vk.stencil_usage;
|
||||
|
||||
/* We do image blit/resolve with vk_meta, so when an image is flagged as
|
||||
* being a potential transfer source, we also need to add the sampled usage.
|
||||
*/
|
||||
if (image->vk.usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) {
|
||||
if (image->vk.usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT)
|
||||
image->vk.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||
image->vk.stencil_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
}
|
||||
if (image->vk.stencil_usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT)
|
||||
image->vk.stencil_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
|
||||
/* Similarly, image that can be a transfer destination can be attached
|
||||
* as a color or depth-stencil attachment by vk_meta. */
|
||||
if (image->vk.usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) {
|
||||
/* Similarly, image that can be a transfer destination can be attached
|
||||
* as a color or depth-stencil attachment by vk_meta. */
|
||||
if (aspects & VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||
image->vk.usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||
image->vk.stencil_usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
if (aspects & VK_IMAGE_ASPECT_COLOR_BIT) {
|
||||
image->vk.usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
image->vk.usage |= VK_IMAGE_USAGE_STORAGE_BIT;
|
||||
}
|
||||
|
||||
/* vk_meta creates 2D array views of 3D images. */
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D)
|
||||
image->vk.create_flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT;
|
||||
}
|
||||
|
||||
if (image->vk.stencil_usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT)
|
||||
image->vk.stencil_usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
/* vk_meta creates 2D array views of 3D images. */
|
||||
if (all_usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT &&
|
||||
image->vk.image_type == VK_IMAGE_TYPE_3D)
|
||||
image->vk.create_flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT;
|
||||
|
||||
/* Needed for resolve operations. */
|
||||
if (image->vk.usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
|
||||
image->vk.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
|
||||
if (image->vk.usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
|
||||
if (aspects & VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||
image->vk.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
if (image->vk.usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT &&
|
||||
aspects & VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||
image->vk.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
|
||||
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||
image->vk.stencil_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
}
|
||||
if (image->vk.stencil_usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)
|
||||
image->vk.stencil_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
|
||||
if ((image->vk.usage &
|
||||
(VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT)) &&
|
||||
|
||||
@@ -246,6 +246,7 @@ get_device_extensions(const struct panvk_physical_device *device,
|
||||
.EXT_queue_family_foreign = true,
|
||||
.EXT_sampler_filter_minmax = arch >= 10,
|
||||
.EXT_scalar_block_layout = true,
|
||||
.EXT_separate_stencil_usage = true,
|
||||
.EXT_shader_module_identifier = true,
|
||||
.EXT_subgroup_size_control = arch >= 10, /* requires vk1.1 */
|
||||
.EXT_tooling_info = true,
|
||||
@@ -1272,6 +1273,12 @@ get_image_format_properties(struct panvk_physical_device *physical_device,
|
||||
|
||||
get_format_properties(physical_device, info->format, &format_props);
|
||||
|
||||
const VkImageStencilUsageCreateInfo *stencil_usage_info =
|
||||
vk_find_struct_const(info->pNext, IMAGE_STENCIL_USAGE_CREATE_INFO);
|
||||
VkImageUsageFlags stencil_usage =
|
||||
stencil_usage_info ? stencil_usage_info->stencilUsage : info->usage;
|
||||
VkImageUsageFlags all_usage = info->usage | stencil_usage;
|
||||
|
||||
switch (info->tiling) {
|
||||
case VK_IMAGE_TILING_LINEAR:
|
||||
format_feature_flags = format_props.linearTilingFeatures;
|
||||
@@ -1339,7 +1346,7 @@ get_image_format_properties(struct panvk_physical_device *physical_device,
|
||||
(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
|
||||
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) &&
|
||||
!(info->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
|
||||
!(info->usage & VK_IMAGE_USAGE_STORAGE_BIT)) {
|
||||
!(all_usage & VK_IMAGE_USAGE_STORAGE_BIT)) {
|
||||
sampleCounts |= VK_SAMPLE_COUNT_4_BIT;
|
||||
}
|
||||
|
||||
@@ -1355,28 +1362,28 @@ get_image_format_properties(struct panvk_physical_device *physical_device,
|
||||
* There is one exception to this below for storage.
|
||||
*/
|
||||
if (!(info->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT)) {
|
||||
if (info->usage & VK_IMAGE_USAGE_SAMPLED_BIT) {
|
||||
if (all_usage & VK_IMAGE_USAGE_SAMPLED_BIT) {
|
||||
if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) {
|
||||
goto unsupported;
|
||||
}
|
||||
}
|
||||
|
||||
if (info->usage & VK_IMAGE_USAGE_STORAGE_BIT) {
|
||||
if (all_usage & VK_IMAGE_USAGE_STORAGE_BIT) {
|
||||
if (!(format_feature_flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)) {
|
||||
goto unsupported;
|
||||
}
|
||||
}
|
||||
|
||||
if (info->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT ||
|
||||
((info->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) &&
|
||||
if (all_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT ||
|
||||
((all_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) &&
|
||||
!vk_format_is_depth_or_stencil(info->format))) {
|
||||
if (!(format_feature_flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) {
|
||||
goto unsupported;
|
||||
}
|
||||
}
|
||||
|
||||
if ((info->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ||
|
||||
((info->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) &&
|
||||
if ((all_usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ||
|
||||
((all_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) &&
|
||||
vk_format_is_depth_or_stencil(info->format))) {
|
||||
if (!(format_feature_flags &
|
||||
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) {
|
||||
|
||||
Reference in New Issue
Block a user