From: Marek Olšák Date: Sat, 22 Aug 2020 10:28:52 +0000 (-0400) Subject: gallium/tgsi: add helper tgsi_get_interp_mode X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=440aab95c3deac65d1ece587ff33ae7c3bb507cd;p=mesa.git gallium/tgsi: add helper tgsi_get_interp_mode Reviewed-by: Eric Anholt Part-of: --- 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; }