v3dv: enable shaderStorageImageReadWithoutFormat

Note that as we are enabling the feature, we need to set the
VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT_KHR for any format
that supports STORAGE_IMAGE_BIT, from spec:

   "An implementation that supports
   VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT for any format from the given
   list of formats and supports shaderStorageImageReadWithoutFormat
   must support VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT
   for that same format if Vulkan 1.3 or the
   VK_KHR_format_feature_flags2 extension is supported."

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20744>
This commit is contained in:
Alejandro Piñeiro 2023-01-14 00:41:24 +01:00 committed by Marge Bot
parent b56be4c37e
commit 50bb7745ca
3 changed files with 14 additions and 4 deletions

View file

@ -1121,7 +1121,7 @@ v3dv_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
.shaderImageGatherExtended = false,
.shaderStorageImageExtendedFormats = true,
.shaderStorageImageMultisample = false,
.shaderStorageImageReadWithoutFormat = false,
.shaderStorageImageReadWithoutFormat = true,
.shaderStorageImageWriteWithoutFormat = false,
.shaderUniformBufferArrayDynamicIndexing = false,
.shaderSampledImageArrayDynamicIndexing = false,

View file

@ -164,14 +164,16 @@ image_format_plane_features(struct v3dv_physical_device *pdevice,
if (tiling != VK_IMAGE_TILING_LINEAR) {
if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN && desc->is_array) {
flags |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT;
flags |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT |
VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT_KHR;
if (desc->nr_channels == 1 && vk_format_is_int(vk_format))
flags |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT;
} else if (vk_format == VK_FORMAT_A2B10G10R10_UNORM_PACK32 ||
vk_format == VK_FORMAT_A2B10G10R10_UINT_PACK32 ||
vk_format == VK_FORMAT_B10G11R11_UFLOAT_PACK32) {
/* To comply with shaderStorageImageExtendedFormats */
flags |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT;
flags |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT |
VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT_KHR;
}
}
@ -279,8 +281,15 @@ buffer_format_features(VkFormat vk_format, const struct v3dv_format *v3dv_format
desc->is_array) {
flags |= VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT;
if (v3dv_format->planes[0].tex_type != TEXTURE_DATA_FORMAT_NO) {
/* STORAGE_READ_WITHOUT_FORMAT can also be applied for buffers. From spec:
* "VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT specifies
* that image views or buffer views created with this format can
* be used as storage images for read operations without
* specifying a format."
*/
flags |= VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT |
VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT;
VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT |
VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT_KHR;
}
} else if (vk_format == VK_FORMAT_A2B10G10R10_UNORM_PACK32) {
flags |= VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT |

View file

@ -174,6 +174,7 @@ static const struct spirv_to_nir_options default_spirv_options = {
.vk_memory_model_device_scope = true,
.physical_storage_buffer_address = true,
.workgroup_memory_explicit_layout = true,
.image_read_without_format = true,
},
.ubo_addr_format = nir_address_format_32bit_index_offset,
.ssbo_addr_format = nir_address_format_32bit_index_offset,