Mesa (main): radv: Use NIR optimization to move discards to the top.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 1 19:22:57 UTC 2022
Module: Mesa
Branch: main
Commit: ff13fc381d59fc8a5b06a40b6bb857503c6e7711
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff13fc381d59fc8a5b06a40b6bb857503c6e7711
Author: Timur Kristóf <timur.kristof at gmail.com>
Date: Mon May 2 14:26:54 2022 +0200
radv: Use NIR optimization to move discards to the top.
Fossil stats on Sienna Cichlid:
Totals from 1988 (1.55% of 128653) affected shaders:
VGPRs: 68096 -> 67928 (-0.25%); split: -0.61%, +0.36%
CodeSize: 5391936 -> 5391312 (-0.01%); split: -0.11%, +0.10%
MaxWaves: 53020 -> 52946 (-0.14%); split: +0.05%, -0.19%
Instrs: 992413 -> 992509 (+0.01%); split: -0.10%, +0.11%
Latency: 8643141 -> 8789295 (+1.69%); split: -0.31%, +2.00%
InvThroughput: 1680195 -> 1680605 (+0.02%); split: -0.04%, +0.07%
SClause: 50886 -> 51318 (+0.85%); split: -0.73%, +1.57%
Copies: 57017 -> 56741 (-0.48%); split: -1.28%, +0.80%
PreSGPRs: 66766 -> 67048 (+0.42%); split: -0.24%, +0.66%
PreVGPRs: 56832 -> 56935 (+0.18%); split: -0.44%, +0.62%
Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13037>
---
src/amd/vulkan/radv_shader.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 453f954fa7d..3977ac031bb 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -214,7 +214,13 @@ radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively, bool
NIR_PASS(progress, shader, nir_opt_shrink_vectors);
NIR_PASS(progress, shader, nir_remove_dead_variables,
nir_var_function_temp | nir_var_shader_in | nir_var_shader_out, NULL);
- NIR_PASS(progress, shader, nir_opt_conditional_discard);
+
+ if (shader->info.stage == MESA_SHADER_FRAGMENT &&
+ (shader->info.fs.uses_discard || shader->info.fs.uses_demote)) {
+ NIR_PASS(progress, shader, nir_opt_conditional_discard);
+ NIR_PASS(progress, shader, nir_opt_move_discards_to_top);
+ }
+
NIR_PASS(progress, shader, nir_opt_move, nir_move_load_ubo);
}
More information about the mesa-commit
mailing list