glsl: move interpolation_string() to linker_util

Moving it here allows us to use in in the NIR linker too.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25371>
This commit is contained in:
Timothy Arceri 2023-09-25 10:04:24 +10:00 committed by Marge Bot
parent 337c32cb3a
commit 78b9f1053f
5 changed files with 29 additions and 30 deletions

View file

@ -59,6 +59,7 @@
#include "main/shaderobj.h"
#include "ir.h"
#include "ir_builder.h"
#include "linker_util.h"
#include "builtin_functions.h"
using namespace ir_builder;

View file

@ -2084,21 +2084,6 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
}
}
const char *
interpolation_string(unsigned interpolation)
{
switch (interpolation) {
case INTERP_MODE_NONE: return "no";
case INTERP_MODE_SMOOTH: return "smooth";
case INTERP_MODE_FLAT: return "flat";
case INTERP_MODE_NOPERSPECTIVE: return "noperspective";
}
assert(!"Should not get here.");
return "";
}
const char *const ir_variable::warn_extension_table[] = {
"",
"GL_ARB_shader_stencil_export",

View file

@ -398,21 +398,6 @@ struct ir_state_slot {
};
/**
* Get the string value for an interpolation qualifier
*
* \return The string that would be used in a shader to specify \c
* mode will be returned.
*
* This function is used to generate error messages of the form "shader
* uses %s interpolation qualifier", so in the case where there is no
* interpolation qualifier, it returns "no".
*
* This function should only be used on a shader input or output variable.
*/
const char *interpolation_string(unsigned interpolation);
class ir_variable : public ir_instruction {
public:
ir_variable(const struct glsl_type *, const char *, ir_variable_mode);

View file

@ -438,3 +438,17 @@ link_util_mark_array_elements_referenced(const struct array_deref_range *dr,
_mark_array_elements_referenced(dr, count, 1, 0, bits);
}
const char *
interpolation_string(unsigned interpolation)
{
switch (interpolation) {
case INTERP_MODE_NONE: return "no";
case INTERP_MODE_SMOOTH: return "smooth";
case INTERP_MODE_FLAT: return "flat";
case INTERP_MODE_NOPERSPECTIVE: return "noperspective";
}
assert(!"Should not get here.");
return "";
}

View file

@ -111,6 +111,20 @@ link_util_mark_array_elements_referenced(const struct array_deref_range *dr,
unsigned count, unsigned array_depth,
BITSET_WORD *bits);
/**
* Get the string value for an interpolation qualifier
*
* \return The string that would be used in a shader to specify \c
* mode will be returned.
*
* This function is used to generate error messages of the form "shader
* uses %s interpolation qualifier", so in the case where there is no
* interpolation qualifier, it returns "no".
*
* This function should only be used on a shader input or output variable.
*/
const char *interpolation_string(unsigned interpolation);
#ifdef __cplusplus
}
#endif