Mesa (master): tgsi_to_nir: Improve interpolation modes.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Mar 5 19:14:04 UTC 2019
Module: Mesa
Branch: master
Commit: 770faf546d14db6a8eced0da406e48a32fabf551
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=770faf546d14db6a8eced0da406e48a32fabf551
Author: Timur Kristóf <timur.kristof at gmail.com>
Date: Tue Feb 19 10:11:36 2019 +0100
tgsi_to_nir: Improve interpolation modes.
This patch extracts the interpolation mode translation
into a separate function called ttn_translate_interp_mode,
adds support for TGSI_INTERPOLATE_COLOR which was missing,
and also sets the proper interpolation mode to output
variables, which were not set previously.
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 | 36 +++++++++++++++++++--------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 7984cea5a7b..016e2b46f08 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -180,6 +180,23 @@ ttn_src_for_dest(nir_builder *b, nir_alu_dest *dest)
return nir_fmov_alu(b, src, 4);
}
+static enum glsl_interp_mode
+ttn_translate_interp_mode(unsigned tgsi_interp)
+{
+ switch (tgsi_interp) {
+ case TGSI_INTERPOLATE_CONSTANT:
+ return INTERP_MODE_FLAT;
+ case TGSI_INTERPOLATE_LINEAR:
+ return INTERP_MODE_NOPERSPECTIVE;
+ case TGSI_INTERPOLATE_PERSPECTIVE:
+ return INTERP_MODE_SMOOTH;
+ case TGSI_INTERPOLATE_COLOR:
+ return INTERP_MODE_SMOOTH;
+ default:
+ unreachable("bad TGSI interpolation mode");
+ }
+}
+
static void
ttn_emit_declaration(struct ttn_compile *c)
{
@@ -314,21 +331,8 @@ ttn_emit_declaration(struct ttn_compile *c)
var->data.location = VERT_ATTRIB_GENERIC0 + idx;
}
var->data.index = 0;
-
- /* We definitely need to translate the interpolation field, because
- * nir_print will decode it.
- */
- switch (decl->Interp.Interpolate) {
- case TGSI_INTERPOLATE_CONSTANT:
- var->data.interpolation = INTERP_MODE_FLAT;
- break;
- case TGSI_INTERPOLATE_LINEAR:
- var->data.interpolation = INTERP_MODE_NOPERSPECTIVE;
- break;
- case TGSI_INTERPOLATE_PERSPECTIVE:
- var->data.interpolation = INTERP_MODE_SMOOTH;
- break;
- }
+ var->data.interpolation =
+ ttn_translate_interp_mode(decl->Interp.Interpolate);
exec_list_push_tail(&b->shader->inputs, &var->node);
c->inputs[idx] = var;
@@ -352,6 +356,8 @@ ttn_emit_declaration(struct ttn_compile *c)
var->data.mode = nir_var_shader_out;
var->name = ralloc_asprintf(var, "out_%d", idx);
var->data.index = 0;
+ var->data.interpolation =
+ ttn_translate_interp_mode(decl->Interp.Interpolate);
if (c->scan->processor == PIPE_SHADER_FRAGMENT) {
switch (semantic_name) {
More information about the mesa-commit
mailing list