summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/vc4/vc4_nir_lower_io.c14
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c13
2 files changed, 18 insertions, 9 deletions
diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_io.c b/src/gallium/drivers/vc4/vc4_nir_lower_io.c
index 261c00dc449..2b4ad9c5ea6 100644
--- a/src/gallium/drivers/vc4/vc4_nir_lower_io.c
+++ b/src/gallium/drivers/vc4/vc4_nir_lower_io.c
@@ -274,11 +274,15 @@ vc4_nir_lower_fs_input(struct vc4_compile *c, nir_builder *b,
}
if (input_var->data.location == VARYING_SLOT_FACE) {
- dests[0] = nir_fsub(b,
- nir_imm_float(b, 1.0),
- nir_fmul(b,
- nir_i2f(b, dests[0]),
- nir_imm_float(b, 2.0)));
+ /* TGSI-to-NIR's front face. Convert to using the system
+ * value boolean instead.
+ */
+ nir_ssa_def *face =
+ nir_load_system_value(b,
+ nir_intrinsic_load_front_face,
+ 0);
+ dests[0] = nir_bcsel(b, face, nir_imm_float(b, 1.0),
+ nir_imm_float(b, -1.0));
dests[1] = nir_imm_float(b, 0.0);
dests[2] = nir_imm_float(b, 0.0);
dests[3] = nir_imm_float(b, 1.0);
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 34420aaa975..0a7bcb0374c 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -1387,10 +1387,6 @@ ntq_setup_inputs(struct vc4_compile *c)
if (c->stage == QSTAGE_FRAG) {
if (var->data.location == VARYING_SLOT_POS) {
emit_fragcoord_input(c, loc);
- } else if (var->data.location == VARYING_SLOT_FACE) {
- c->inputs[loc * 4 + 0] =
- qir_ITOF(c, qir_reg(QFILE_FRAG_REV_FLAG,
- 0));
} else if (var->data.location >= VARYING_SLOT_VAR0 &&
(c->fs_key->point_sprite_mask &
(1 << (var->data.location -
@@ -1546,6 +1542,15 @@ ntq_emit_intrinsic(struct vc4_compile *c, nir_intrinsic_instr *instr)
*dest = qir_uniform(c, QUNIFORM_SAMPLE_MASK, 0);
break;
+ case nir_intrinsic_load_front_face:
+ /* The register contains 0 (front) or 1 (back), and we need to
+ * turn it into a NIR bool where true means front.
+ */
+ *dest = qir_ADD(c,
+ qir_uniform_ui(c, -1),
+ qir_reg(QFILE_FRAG_REV_FLAG, 0));
+ break;
+
case nir_intrinsic_load_input:
assert(instr->num_components == 1);
const_offset = nir_src_as_const_value(instr->src[0]);