mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 07:38:10 +02:00
vc4: Switch to using nir_load_front_face.
This will be generated by glsl_to_nir, and it turns out that this is a more code-efficient path than the floating point math, anyway. No change on shader-db, but drops an instruction in piglit's glsl-fs-frontfacing.
This commit is contained in:
parent
0700e4c0c7
commit
62087cb9b8
2 changed files with 18 additions and 9 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue