From: Paul Berry Date: Tue, 22 Oct 2013 21:48:08 +0000 (-0700) Subject: glsl: Pull interpolation_string() out of ir_variable. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f65feb5335331ed0960d3fd62a70d0d0aaf23ab7;p=mesa.git glsl: Pull interpolation_string() out of ir_variable. Future patches will need to call this function when there isn't an ir_varible present to refer to. Reviewed-by: Kenneth Graunke Reviewed-by: Ian Romanick Reviewed-by: Matt Turner --- diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index b644b22c7ad..908816701b0 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2111,7 +2111,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, _mesa_glsl_error(loc, state, "interpolation qualifier `%s' can only be applied to " "shader inputs or outputs.", - var->interpolation_string()); + interpolation_string(var->interpolation)); } @@ -2120,7 +2120,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, _mesa_glsl_error(loc, state, "interpolation qualifier `%s' cannot be applied to " "vertex shader inputs or fragment shader outputs", - var->interpolation_string()); + interpolation_string(var->interpolation)); } } diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 54a8e400c16..c682e3ed536 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1616,9 +1616,9 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, const char * -ir_variable::interpolation_string() const +interpolation_string(unsigned interpolation) { - switch (this->interpolation) { + switch (interpolation) { case INTERP_QUALIFIER_NONE: return "no"; case INTERP_QUALIFIER_SMOOTH: return "smooth"; case INTERP_QUALIFIER_FLAT: return "flat"; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index aac8cbb7dbe..c4c00552ac3 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -312,6 +312,22 @@ struct ir_state_slot { int swizzle; }; + +/** + * 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); @@ -331,20 +347,6 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - /** - * Get the string value for the 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() const; - /** * Determine how this variable should be interpolated based on its * interpolation qualifier (if present), whether it is gl_Color or diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp index c503645fda1..be36b5f8f6b 100644 --- a/src/glsl/link_varyings.cpp +++ b/src/glsl/link_varyings.cpp @@ -125,9 +125,9 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog, "interpolation qualifier\n", _mesa_glsl_shader_target_name(producer_type), output->name, - output->interpolation_string(), + interpolation_string(output->interpolation), _mesa_glsl_shader_target_name(consumer_type), - input->interpolation_string()); + interpolation_string(input->interpolation)); return; } }