From c6becb9574447cb8b09a5f4b61d4e09463c57fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Fri, 17 Dec 2021 17:50:35 +0100 Subject: [PATCH] radv: Note when a mesh shader writes the primitive shading rate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Timur Kristóf Reviewed-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_shader.h | 1 + src/amd/vulkan/radv_shader_info.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index 0a01b9942b2..29402fb294f 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -198,6 +198,7 @@ struct radv_vs_output_info { bool writes_viewport_index; bool writes_viewport_index_per_primitive; bool writes_primitive_shading_rate; + bool writes_primitive_shading_rate_per_primitive; bool export_prim_id; bool export_prim_id_per_primitive; bool export_clip_dists; diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index 097a81fee3a..cd7da96d133 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -552,7 +552,10 @@ gather_info_output_decl(const nir_shader *nir, const nir_variable *var, vs_info->writes_layer = true; break; case VARYING_SLOT_PRIMITIVE_SHADING_RATE: - vs_info->writes_primitive_shading_rate = true; + if (var->data.per_primitive) + vs_info->writes_primitive_shading_rate_per_primitive = true; + else + vs_info->writes_primitive_shading_rate = true; break; default: break; @@ -675,8 +678,11 @@ radv_nir_shader_info_pass(struct radv_device *device, const struct nir_shader *n outinfo->writes_layer = true; } + /* VS/TES/GS: shading rate is per-vertex, MS: it's per-primitive. */ + bool force_vrs_per_vertex = + device->force_vrs != RADV_FORCE_VRS_NONE && nir->info.stage != MESA_SHADER_MESH; bool writes_primitive_shading_rate = - outinfo->writes_primitive_shading_rate || device->force_vrs != RADV_FORCE_VRS_NONE; + outinfo->writes_primitive_shading_rate || force_vrs_per_vertex; int pos_written = 0x1; if (outinfo->writes_pointsize || outinfo->writes_viewport_index || outinfo->writes_layer ||