[Mesa-dev] [PATCH 2/3] nir: Use the system-value front face for twoside lowering.
Eric Anholt
eric at anholt.net
Fri Aug 5 23:22:18 UTC 2016
GLSL-to-NIR generates system value usage, and vc4/freedreno would both
like the system value instead of the varying, so switch this pass over to
it.
---
src/compiler/nir/nir_lower_two_sided_color.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/src/compiler/nir/nir_lower_two_sided_color.c b/src/compiler/nir/nir_lower_two_sided_color.c
index 3e666691a691..5bb95f66e729 100644
--- a/src/compiler/nir/nir_lower_two_sided_color.c
+++ b/src/compiler/nir/nir_lower_two_sided_color.c
@@ -32,7 +32,6 @@
typedef struct {
nir_builder b;
nir_shader *shader;
- nir_variable *face;
struct {
nir_variable *front; /* COLn */
nir_variable *back; /* BFCn */
@@ -85,12 +84,12 @@ setup_inputs(lower_2side_state *state)
{
int maxloc = -1;
- /* find color/face inputs: */
+ /* find color inputs: */
nir_foreach_variable(var, &state->shader->inputs) {
int loc = var->data.driver_location;
/* keep track of last used driver-location.. we'll be
- * appending BCLr/FACE after last existing input:
+ * appending BCLr after last existing input:
*/
maxloc = MAX2(maxloc, loc);
@@ -101,9 +100,6 @@ setup_inputs(lower_2side_state *state)
state->colors[state->colors_count].front = var;
state->colors_count++;
break;
- case VARYING_SLOT_FACE:
- state->face = var;
- break;
}
}
@@ -111,12 +107,6 @@ setup_inputs(lower_2side_state *state)
if (state->colors_count == 0)
return -1;
- /* if we don't already have one, insert a FACE input: */
- if (!state->face) {
- state->face = create_input(state->shader, ++maxloc, VARYING_SLOT_FACE);
- state->face->data.interpolation = INTERP_MODE_FLAT;
- }
-
/* add required back-face color inputs: */
for (int i = 0; i < state->colors_count; i++) {
gl_varying_slot slot;
@@ -161,14 +151,15 @@ nir_lower_two_sided_color_block(nir_block *block,
continue;
/* replace load_input(COLn) with
- * bcsel(load_input(FACE), load_input(COLn), load_input(BFCn))
+ * bcsel(load_system_value(FACE), load_input(COLn), load_input(BFCn))
*/
b->cursor = nir_before_instr(&intr->instr);
- nir_ssa_def *face = nir_channel(b, load_input(b, state->face), 0);
+ nir_ssa_def *face = nir_load_system_value(b,
+ nir_intrinsic_load_front_face,
+ 0);
nir_ssa_def *front = load_input(b, state->colors[idx].front);
nir_ssa_def *back = load_input(b, state->colors[idx].back);
- nir_ssa_def *cond = nir_flt(b, face, nir_imm_float(b, 0.0));
- nir_ssa_def *color = nir_bcsel(b, cond, back, front);
+ nir_ssa_def *color = nir_bcsel(b, face, front, back);
assert(intr->dest.is_ssa);
nir_ssa_def_rewrite_uses(&intr->dest.ssa, nir_src_for_ssa(color));
--
2.8.1
More information about the mesa-dev
mailing list