summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-12-17 12:13:11 -0800
committerPaul Berry <[email protected]>2013-12-30 11:21:08 -0800
commit26707abe5635e99814603a0f4895865e977cf267 (patch)
treebe2b80723c8fef82c7cb50f0f290ee3927eb79b5 /src/glsl
parentf425d56ba41382be04366d011536ee78a03a2f33 (diff)
Rename overloads of _mesa_glsl_shader_target_name().
Previously, _mesa_glsl_shader_target_name() had an overload for GLenum and an overload for the gl_shader_type enum, each of which behaved differently. However, since GLenum is a synonym for unsigned int, and unsigned ints are often used in place of gl_shader_type (e.g. in loop indices), there was a big risk of calling the wrong overload by mistake. This patch gives the two overloads different names so that it's always clear which one we mean to call. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/ast_to_hir.cpp10
-rw-r--r--src/glsl/glsl_parser_extras.cpp17
-rw-r--r--src/glsl/glsl_parser_extras.h7
-rw-r--r--src/glsl/link_varyings.cpp24
-rw-r--r--src/glsl/linker.cpp2
5 files changed, 30 insertions, 30 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 3bc181e8785..91810f985bf 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2110,7 +2110,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
_mesa_glsl_error(loc, state,
"%s cannot be given an explicit location in %s shader",
mode_string(var),
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
} else {
var->data.explicit_location = true;
@@ -2188,7 +2188,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
_mesa_glsl_error(loc, state,
"`attribute' variables may not be declared in the "
"%s shader",
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
}
/* Section 6.1.1 (Function Calling Conventions) of the GLSL 1.10 spec says:
@@ -2599,7 +2599,7 @@ process_initializer(ir_variable *var, ast_declaration *decl,
if ((var->data.mode == ir_var_shader_in) && (state->current_function == NULL)) {
_mesa_glsl_error(& initializer_loc, state,
"cannot initialize %s shader input / %s",
- _mesa_glsl_shader_target_name(state->target),
+ _mesa_shader_type_to_string(state->target),
(state->target == MESA_SHADER_VERTEX)
? "attribute" : "varying");
}
@@ -4890,7 +4890,7 @@ ast_interface_block::hir(exec_list *instructions,
_mesa_glsl_error(&loc, state,
"redeclaration of gl_PerVertex input not allowed "
"in the %s shader",
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
}
if (this->instance_name == NULL ||
strcmp(this->instance_name, "gl_in") != 0 || !this->is_array) {
@@ -4907,7 +4907,7 @@ ast_interface_block::hir(exec_list *instructions,
_mesa_glsl_error(&loc, state,
"redeclaration of gl_PerVertex output not "
"allowed in the %s shader",
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
}
if (this->instance_name != NULL) {
_mesa_glsl_error(&loc, state,
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 5f19368d856..fc9a8b20411 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -334,16 +334,15 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
extern "C" {
/**
- * The most common use of _mesa_glsl_shader_target_name(), which is
- * shared with C code in Mesa core to translate a GLenum to a short
- * shader stage name in debug printouts.
+ * Translate a GLenum to a short shader stage name for debug printouts and
+ * error messages.
*
* It recognizes the PROGRAM variants of the names so it can be used
* with a struct gl_program->Target, not just a struct
* gl_shader->Type.
*/
const char *
-_mesa_glsl_shader_target_name(GLenum type)
+_mesa_shader_enum_to_string(GLenum type)
{
switch (type) {
case GL_VERTEX_SHADER:
@@ -363,11 +362,11 @@ _mesa_glsl_shader_target_name(GLenum type)
} /* extern "C" */
/**
- * Overloaded C++ variant usable within the compiler for translating
- * our internal enum into short stage names.
+ * Translate a gl_shader_type to a short shader stage name for debug printouts
+ * and error messages.
*/
const char *
-_mesa_glsl_shader_target_name(gl_shader_type target)
+_mesa_shader_type_to_string(unsigned target)
{
switch (target) {
case MESA_SHADER_VERTEX: return "vertex";
@@ -651,11 +650,11 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
if (behavior == extension_require) {
_mesa_glsl_error(name_locp, state, fmt,
- name, _mesa_glsl_shader_target_name(state->target));
+ name, _mesa_shader_type_to_string(state->target));
return false;
} else {
_mesa_glsl_warning(name_locp, state, fmt,
- name, _mesa_glsl_shader_target_name(state->target));
+ name, _mesa_shader_type_to_string(state->target));
}
}
}
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 622ddbac726..7b013fa6dee 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -422,10 +422,11 @@ extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
_mesa_glsl_parse_state *state);
/**
- * Get the textual name of the specified shader target
+ * Get the textual name of the specified shader target (which is a
+ * gl_shader_type).
*/
extern const char *
-_mesa_glsl_shader_target_name(gl_shader_type target);
+_mesa_shader_type_to_string(unsigned target);
#endif /* __cplusplus */
@@ -439,7 +440,7 @@ extern "C" {
#endif
extern const char *
-_mesa_glsl_shader_target_name(GLenum type);
+_mesa_shader_enum_to_string(GLenum type);
extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, struct gl_context *gl_ctx);
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 229a4cb8584..98f902ca4ef 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -82,10 +82,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
linker_error(prog,
"%s shader output `%s' declared as type `%s', "
"but %s shader input declared as type `%s'\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
output->type->name,
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
input->type->name);
return;
}
@@ -97,10 +97,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
linker_error(prog,
"%s shader output `%s' %s centroid qualifier, "
"but %s shader input %s centroid qualifier\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
(output->data.centroid) ? "has" : "lacks",
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
(input->data.centroid) ? "has" : "lacks");
return;
}
@@ -109,10 +109,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
linker_error(prog,
"%s shader output `%s' %s sample qualifier, "
"but %s shader input %s sample qualifier\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
(output->data.sample) ? "has" : "lacks",
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
(input->data.sample) ? "has" : "lacks");
return;
}
@@ -121,10 +121,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
linker_error(prog,
"%s shader output `%s' %s invariant qualifier, "
"but %s shader input %s invariant qualifier\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
(output->data.invariant) ? "has" : "lacks",
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
(input->data.invariant) ? "has" : "lacks");
return;
}
@@ -135,10 +135,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
"interpolation qualifier, "
"but %s shader input specifies %s "
"interpolation qualifier\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
interpolation_string(output->data.interpolation),
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
interpolation_string(input->data.interpolation));
return;
}
@@ -1217,9 +1217,9 @@ assign_varying_locations(struct gl_context *ctx,
linker_error(prog, "%s shader varying %s not written "
"by %s shader\n.",
- _mesa_glsl_shader_target_name(consumer->Type),
+ _mesa_shader_enum_to_string(consumer->Type),
var->name,
- _mesa_glsl_shader_target_name(producer->Type));
+ _mesa_shader_enum_to_string(producer->Type));
}
/* An 'in' variable is only really a shader input if its
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index a6133ea9cb5..f6d7a909550 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1375,7 +1375,7 @@ link_intrastage_shaders(void *mem_ctx,
if (main == NULL) {
linker_error(prog, "%s shader lacks `main'\n",
- _mesa_glsl_shader_target_name(shader_list[0]->Type));
+ _mesa_shader_enum_to_string(shader_list[0]->Type));
return NULL;
}