diff options
author | Eric Anholt <[email protected]> | 2016-08-04 13:20:31 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2016-08-19 13:11:36 -0700 |
commit | c078c41520214baf469dd4413f868e42c2959c5e (patch) | |
tree | cd80e21860e52cac2bfdc5fc5564d9253fb93eb2 /src/gallium/auxiliary/nir | |
parent | 3f607f9e4f4a55d62088ea85192cda04a3e79a4e (diff) |
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 <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/nir')
-rw-r--r-- | src/gallium/auxiliary/nir/tgsi_to_nir.c | 30 |
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 3d80ef06f13..906c6436faf 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; |