Module: Mesa Branch: staging/22.2 Commit: e35dd22c6d086dac1decf5c21d18bb3b5a9d3ff7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e35dd22c6d086dac1decf5c21d18bb3b5a9d3ff7
Author: Samuel Pitoiset <[email protected]> Date: Mon Aug 8 15:18:18 2022 +0200 radv: fix gathering XFB info if there is dead outputs The driver should still gather XFB info even if all XFB outputs are dead, otherwise the pipeline can't find the streamout shader. RADV should use vk_spirv_to_nir() at some point to reduce code duplication during SPIRV->NIR compilation. This fixes new dEQP-VK.transform_feedback.simple.*. Cc: mesa-stable Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Mike Blumenkrantz <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17939> (cherry picked from commit e95531e101f0ba61d28195fe38414e411bf418b3) --- .pick_status.json | 2 +- src/amd/vulkan/radv_shader.c | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 39dbed95863..ac1352b5164 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -13,7 +13,7 @@ "description": "radv: fix gathering XFB info if there is dead outputs", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index d389238a033..961c44a6fc2 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -654,6 +654,16 @@ lower_sincos(struct nir_builder *b, nir_instr *instr, void *_) return sincos->op == nir_op_fsin ? nir_fsin_amd(b, src) : nir_fcos_amd(b, src); } +static bool +is_not_xfb_output(nir_variable *var, void *data) +{ + if (var->data.mode != nir_var_shader_out) + return true; + + return !var->data.explicit_xfb_buffer && + !var->data.explicit_xfb_stride; +} + nir_shader * radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_pipeline_stage *stage, const struct radv_pipeline_key *key) @@ -837,9 +847,12 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_pipeline_ .use_layer_id_sysval = false, }); + nir_remove_dead_variables_options dead_vars_opts = { + .can_remove_var = is_not_xfb_output, + }; NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_shader_in | nir_var_shader_out | nir_var_system_value | nir_var_mem_shared, - NULL); + &dead_vars_opts); /* Variables can make nir_propagate_invariant more conservative * than it needs to be. @@ -851,6 +864,11 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_pipeline_ NIR_PASS(_, nir, nir_lower_clip_cull_distance_arrays); + if (nir->info.stage == MESA_SHADER_VERTEX || + nir->info.stage == MESA_SHADER_TESS_EVAL || + nir->info.stage == MESA_SHADER_GEOMETRY) + NIR_PASS_V(nir, nir_shader_gather_xfb_info); + NIR_PASS(_, nir, nir_lower_discard_or_demote, key->ps.lower_discard_to_demote); nir_lower_doubles_options lower_doubles = nir->options->lower_doubles_options; @@ -1038,10 +1056,6 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_pipeline_ radv_optimize_nir(nir, false, false); } - if (nir->info.stage == MESA_SHADER_VERTEX || - nir->info.stage == MESA_SHADER_TESS_EVAL || - nir->info.stage == MESA_SHADER_GEOMETRY) - NIR_PASS_V(nir, nir_shader_gather_xfb_info); return nir; }
