}
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);
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 -
*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]);