radv: fix handling view index from device index

This feature is marginal but VKCTS recently got coverage and most of
the implementations were broken, including RADV.

Fixes recent tests
dEQP-VK.pipeline.pipeline_library.graphics_library.misc.other.view_index_from_device_index_.*

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30642>
This commit is contained in:
Samuel Pitoiset 2024-08-13 11:48:18 +02:00 committed by Marge Bot
parent 65f5364e47
commit cdf21c5ce5
4 changed files with 9 additions and 0 deletions

View file

@ -148,6 +148,9 @@ radv_pipeline_get_shader_key(const struct radv_device *device, const VkPipelineS
if (flags & VK_PIPELINE_CREATE_2_DISABLE_OPTIMIZATION_BIT_KHR)
key.optimisations_disabled = 1;
if (flags & VK_PIPELINE_CREATE_2_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR)
key.view_index_from_device_index = 1;
if (flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV)
key.indirect_bindable = 1;

View file

@ -2380,6 +2380,7 @@ radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cac
.lower_view_index_to_zero = !gfx_state->has_multiview_view_index,
.fix_dual_src_mrt1_export =
gfx_state->ps.epilog.mrt0_is_dual_src && instance->drirc.dual_color_blend_by_location,
.lower_view_index_to_device_index = stages[s].key.view_index_from_device_index,
};
blake3_hash key;

View file

@ -462,6 +462,9 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
NIR_PASS(_, nir, ac_nir_lower_sin_cos);
}
if (options && options->lower_view_index_to_device_index)
NIR_PASS(_, nir, nir_lower_view_index_to_device_index);
NIR_PASS(_, nir, nir_lower_system_values);
nir_lower_compute_system_values_options csv_options = {
/* Mesh shaders run as NGG which can implement local_invocation_index from

View file

@ -78,6 +78,7 @@ struct radv_shader_stage_key {
uint8_t optimisations_disabled : 1;
uint8_t keep_statistic_info : 1;
uint8_t view_index_from_device_index : 1;
/* Shader version (up to 8) to force re-compilation when RADV_BUILD_ID_OVERRIDE is enabled. */
uint8_t version : 3;
@ -111,6 +112,7 @@ struct radv_ps_epilog_key {
struct radv_spirv_to_nir_options {
uint32_t lower_view_index_to_zero : 1;
uint32_t fix_dual_src_mrt1_export : 1;
uint32_t lower_view_index_to_device_index : 1;
};
struct radv_graphics_state_key {