Mesa (master): tgsi_to_nir: Extract ttn_emulate_tgsi_front_face into its own function.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Mar 5 19:14:04 UTC 2019
Module: Mesa
Branch: master
Commit: f748fa47f84397490bba5c51466f769b18e96f35
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f748fa47f84397490bba5c51466f769b18e96f35
Author: Timur Kristóf <timur.kristof at gmail.com>
Date: Fri Feb 8 22:11:08 2019 +0100
tgsi_to_nir: Extract ttn_emulate_tgsi_front_face into its own function.
We'll need to use the same logic in other places, so it makes sense to
have a separate function for this.
Signed-Off-By: Timur Kristóf <timur.kristof at gmail.com>
Tested-by: Andre Heider <a.heider at gmail.com>
Tested-by: Rob Clark <robdclark at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
---
src/gallium/auxiliary/nir/tgsi_to_nir.c | 34 +++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 67058b398ae..8efae63b639 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -440,6 +440,25 @@ ttn_array_deref(struct ttn_compile *c, nir_variable *var, unsigned offset,
return nir_build_deref_array(&c->build, deref, index);
}
+/* Special case: Turn the frontface varying into a load of the
+ * frontface intrinsic plus math, and appending the silly floats.
+ */
+static nir_ssa_def *
+ttn_emulate_tgsi_front_face(struct ttn_compile *c)
+{
+ nir_ssa_def *tgsi_frontface[4] = {
+ nir_bcsel(&c->build,
+ nir_load_front_face(&c->build, 1),
+ 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_vec(&c->build, tgsi_frontface, 4);
+}
+
static nir_src
ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index,
struct tgsi_ind_register *indirect,
@@ -514,22 +533,9 @@ ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index,
}
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_front_face(&c->build, 1),
- 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));
+ return nir_src_for_ssa(ttn_emulate_tgsi_front_face(c));
} else {
/* Indirection on input arrays isn't supported by TTN. */
assert(!dim);
More information about the mesa-commit
mailing list