Mesa (master): zink: add lengthy comment and remove assert from discard_if ntv pass
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jul 13 21:25:35 UTC 2020
Module: Mesa
Branch: master
Commit: 359c9384837f332edb3140f43675c761341b8bcd
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=359c9384837f332edb3140f43675c761341b8bcd
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Sun Jun 14 17:24:29 2020 -0400
zink: add lengthy comment and remove assert from discard_if ntv pass
as in the comment, while we may want to try verifying that discard will be
the last instruction in a block, it's a bit problematic given that other nir
passes we're doing may insert instructions after a discard as part of e.g.,
nir_opt_dead_cf in the process of removing another block
fixes shaders at glsl-fs-discard-04
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5852>
---
src/gallium/drivers/zink/zink_compiler.c | 45 ++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index 65d4a2e3390..33e7631130b 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -52,8 +52,49 @@ lower_discard_if_instr(nir_intrinsic_instr *instr, nir_builder *b)
nir_instr_remove(&instr->instr);
return true;
}
- assert(instr->intrinsic != nir_intrinsic_discard ||
- nir_block_last_instr(instr->instr.block) == &instr->instr);
+ /* a shader like this (shaders at glsl-fs-discard-04):
+
+ uniform int j, k;
+
+ void main()
+ {
+ for (int i = 0; i < j; i++) {
+ if (i > k)
+ continue;
+ discard;
+ }
+ gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);
+ }
+
+
+
+ will generate nir like:
+
+ loop {
+ //snip
+ if ssa_11 {
+ block block_5:
+ / preds: block_4 /
+ vec1 32 ssa_17 = iadd ssa_50, ssa_31
+ / succs: block_7 /
+ } else {
+ block block_6:
+ / preds: block_4 /
+ intrinsic discard () () <-- not last instruction
+ vec1 32 ssa_23 = iadd ssa_50, ssa_31 <-- dead code loop itr increment
+ / succs: block_7 /
+ }
+ //snip
+ }
+
+ which means that we can't assert like this:
+
+ assert(instr->intrinsic != nir_intrinsic_discard ||
+ nir_block_last_instr(instr->instr.block) == &instr->instr);
+
+
+ and it's unnecessary anyway since post-vtn optimizing will dce the instructions following the discard
+ */
return false;
}
More information about the mesa-commit
mailing list