Mesa (master): gallium/tgsi: add helper tgsi_get_interp_mode
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 24 19:25:32 UTC 2020
Module: Mesa
Branch: master
Commit: 440aab95c3deac65d1ece587ff33ae7c3bb507cd
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=440aab95c3deac65d1ece587ff33ae7c3bb507cd
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sat Aug 22 06:28:52 2020 -0400
gallium/tgsi: add helper tgsi_get_interp_mode
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6442>
---
src/gallium/auxiliary/tgsi/tgsi_from_mesa.c | 17 +++++++++++++++++
src/gallium/auxiliary/tgsi/tgsi_from_mesa.h | 3 +++
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 24 +++---------------------
3 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
index 29fa68da9f0..a7641c11592 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
@@ -290,3 +290,20 @@ tgsi_get_sysval_semantic(unsigned sysval)
unreachable("Unexpected system value to TGSI");
}
}
+
+enum tgsi_interpolate_mode
+tgsi_get_interp_mode(enum glsl_interp_mode mode, bool color)
+{
+ switch (mode) {
+ case INTERP_MODE_NONE:
+ return color ? TGSI_INTERPOLATE_COLOR : TGSI_INTERPOLATE_PERSPECTIVE;
+ case INTERP_MODE_FLAT:
+ return TGSI_INTERPOLATE_CONSTANT;
+ case INTERP_MODE_NOPERSPECTIVE:
+ return TGSI_INTERPOLATE_LINEAR;
+ case INTERP_MODE_SMOOTH:
+ return TGSI_INTERPOLATE_PERSPECTIVE;
+ default:
+ unreachable("unknown interpolation mode");
+ }
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.h b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.h
index 92f08e2211a..e3f1456d88a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.h
@@ -55,6 +55,9 @@ tgsi_get_gl_frag_result_semantic(gl_frag_result frag_result,
enum tgsi_semantic
tgsi_get_sysval_semantic(unsigned sysval);
+enum tgsi_interpolate_mode
+tgsi_get_interp_mode(enum glsl_interp_mode mode, bool color);
+
static inline enum pipe_shader_type
pipe_shader_type_from_mesa(gl_shader_stage stage)
{
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 7d8f6fc3b25..0fb30bb3b2d 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6554,26 +6554,6 @@ sort_inout_decls_by_slot(struct inout_decl *decls,
std::sort(decls, decls + count, sorter);
}
-static enum tgsi_interpolate_mode
-st_translate_interp(enum glsl_interp_mode glsl_qual, GLuint varying)
-{
- switch (glsl_qual) {
- case INTERP_MODE_NONE:
- if (varying == VARYING_SLOT_COL0 || varying == VARYING_SLOT_COL1)
- return TGSI_INTERPOLATE_COLOR;
- return TGSI_INTERPOLATE_PERSPECTIVE;
- case INTERP_MODE_SMOOTH:
- return TGSI_INTERPOLATE_PERSPECTIVE;
- case INTERP_MODE_FLAT:
- return TGSI_INTERPOLATE_CONSTANT;
- case INTERP_MODE_NOPERSPECTIVE:
- return TGSI_INTERPOLATE_LINEAR;
- default:
- assert(0 && "unexpected interp mode in st_translate_interp()");
- return TGSI_INTERPOLATE_PERSPECTIVE;
- }
-}
-
/**
* Translate intermediate IR (glsl_to_tgsi_instruction) to TGSI format.
* \param program the program to translate
@@ -6682,7 +6662,9 @@ st_translate_program(
assert(interpMode);
interp_mode = interpMode[slot] != TGSI_INTERPOLATE_COUNT ?
(enum tgsi_interpolate_mode) interpMode[slot] :
- st_translate_interp(decl->interp, inputSlotToAttr[slot]);
+ tgsi_get_interp_mode(decl->interp,
+ inputSlotToAttr[slot] == VARYING_SLOT_COL0 ||
+ inputSlotToAttr[slot] == VARYING_SLOT_COL1);
interp_location = (enum tgsi_interpolate_loc) decl->interp_loc;
}
More information about the mesa-commit
mailing list