summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-08-05 11:21:56 -0700
committerEric Anholt <eric@anholt.net>2016-08-19 13:11:36 -0700
commit3f607f9e4f4a55d62088ea85192cda04a3e79a4e (patch)
treed2b78a1626f97b4ca98ea0f1ff8e64ca0a7878ff /src/compiler
parented92241d7848a5f08360240795869d72b68054a3 (diff)
downloadexternal_mesa3d-3f607f9e4f4a55d62088ea85192cda04a3e79a4e.tar.gz
external_mesa3d-3f607f9e4f4a55d62088ea85192cda04a3e79a4e.tar.bz2
external_mesa3d-3f607f9e4f4a55d62088ea85192cda04a3e79a4e.zip
nir: Use the system-value front face for twoside lowering.
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. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_lower_two_sided_color.c23
1 files 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 3e666691a6..5bb95f66e7 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));