summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/nir
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-08-04 13:20:31 -0700
committerEric Anholt <eric@anholt.net>2016-08-19 13:11:36 -0700
commitc078c41520214baf469dd4413f868e42c2959c5e (patch)
treecd80e21860e52cac2bfdc5fc5564d9253fb93eb2 /src/gallium/auxiliary/nir
parent3f607f9e4f4a55d62088ea85192cda04a3e79a4e (diff)
downloadexternal_mesa3d-c078c41520214baf469dd4413f868e42c2959c5e.zip
external_mesa3d-c078c41520214baf469dd4413f868e42c2959c5e.tar.gz
external_mesa3d-c078c41520214baf469dd4413f868e42c2959c5e.tar.bz2
ttn: Use nir_load_front_face instead of the TGSI-style input.
This reduces the diff between GLSL-to-NIR and TGSI-to-NIR, and gives NIR more optimization to work on. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/gallium/auxiliary/nir')
-rw-r--r--src/gallium/auxiliary/nir/tgsi_to_nir.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 3d80ef0..906c643 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -339,9 +339,14 @@ ttn_emit_declaration(struct ttn_compile *c)
var->name = ralloc_asprintf(var, "in_%d", idx);
if (c->scan->processor == PIPE_SHADER_FRAGMENT) {
- var->data.location =
- tgsi_varying_semantic_to_slot(decl->Semantic.Name,
- decl->Semantic.Index);
+ if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) {
+ var->data.location = SYSTEM_VALUE_FRONT_FACE;
+ var->data.mode = nir_var_system_value;
+ } else {
+ var->data.location =
+ tgsi_varying_semantic_to_slot(decl->Semantic.Name,
+ decl->Semantic.Index);
+ }
} else {
assert(!decl->Declaration.Semantic);
var->data.location = VERT_ATTRIB_GENERIC0 + idx;
@@ -593,6 +598,25 @@ ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index,
switch (file) {
case TGSI_FILE_INPUT:
+ /* Special case: Turn the frontface varying into a load of the
+ * frontface intrinsic plus math, and appending the silly floats.
+ */
+ if (c->scan->processor == PIPE_SHADER_FRAGMENT &&
+ c->scan->input_semantic_name[index] == TGSI_SEMANTIC_FACE) {
+ nir_ssa_def *tgsi_frontface[4] = {
+ nir_bcsel(&c->build,
+ nir_load_system_value(&c->build,
+ nir_intrinsic_load_front_face, 0),
+ nir_imm_float(&c->build, 1.0),
+ nir_imm_float(&c->build, -1.0)),
+ nir_imm_float(&c->build, 0.0),
+ nir_imm_float(&c->build, 0.0),
+ nir_imm_float(&c->build, 1.0),
+ };
+
+ return nir_src_for_ssa(nir_vec(&c->build, tgsi_frontface, 4));
+ }
+
op = nir_intrinsic_load_input;
assert(!dim);
break;