summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-02-23 23:47:00 -0800
committerKenneth Graunke <[email protected]>2015-02-24 15:24:52 -0800
commit8e62bd52f8296a220bd4542abd6fdcdfc41a388c (patch)
treed1133977b722131519b6a08b311f7a3febea24f6 /src/glsl/nir
parent23d42b46e306d4104e534842f6dec3500d331cae (diff)
nir: Introduce nir_intrinsic_discard_if.
This is a conditional discard, which takes a boolean source. Note that we don't generate ir_discard::condition today, so this shouldn't break drivers (since none implement this intrinsic yet). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/nir')
-rw-r--r--src/glsl/nir/glsl_to_nir.cpp10
-rw-r--r--src/glsl/nir/nir_intrinsics.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index 544d0d93282..adef19c80a2 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -563,8 +563,14 @@ nir_visitor::visit(ir_discard *ir)
* discards will be immediately followed by a return.
*/
- nir_intrinsic_instr *discard =
- nir_intrinsic_instr_create(this->shader, nir_intrinsic_discard);
+ nir_intrinsic_instr *discard;
+ if (ir->condition) {
+ discard = nir_intrinsic_instr_create(this->shader,
+ nir_intrinsic_discard_if);
+ discard->src[0] = evaluate_rvalue(ir->condition);
+ } else {
+ discard = nir_intrinsic_instr_create(this->shader, nir_intrinsic_discard);
+ }
nir_instr_insert_after_cf_list(this->cf_node_list, &discard->instr);
}
diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h
index d94866c8597..3bf102fc15c 100644
--- a/src/glsl/nir/nir_intrinsics.h
+++ b/src/glsl/nir/nir_intrinsics.h
@@ -68,6 +68,8 @@ INTRINSIC(interp_var_at_offset, 1, ARR(2), true, 0, 1, 0,
#define BARRIER(name) INTRINSIC(name, 0, ARR(), false, 0, 0, 0, 0)
BARRIER(discard)
+/** A conditional discard, with a single boolean source. */
+INTRINSIC(discard_if, 1, ARR(1), false, 0, 0, 0, 0)
INTRINSIC(emit_vertex, 0, ARR(), false, 0, 0, 1, 0)
INTRINSIC(end_primitive, 0, ARR(), false, 0, 0, 1, 0)