_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;
_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:
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");
}
_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) {
_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,
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:
} /* 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";
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));
}
}
}
_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 */
#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);
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;
}
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;
}
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;
}
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;
}
"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;
}
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
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;
}
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("\n");
printf("GLSL IR for linked %s program %d:\n",
- _mesa_glsl_shader_target_name(shader->base.Type), shProg->Name);
+ _mesa_shader_enum_to_string(shader->base.Type), shProg->Name);
_mesa_print_ir(shader->base.ir, NULL);
printf("\n");
}
continue;
printf("GLSL %s shader %d source for linked program %d:\n",
- _mesa_glsl_shader_target_name(sh->Type),
+ _mesa_shader_enum_to_string(sh->Type),
i,
shProg->Name);
printf("%s", sh->Source);
} else {
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("GLSL source for %s shader %d:\n",
- _mesa_glsl_shader_target_name(sh->Type), sh->Name);
+ _mesa_shader_enum_to_string(sh->Type), sh->Name);
printf("%s\n", sh->Source);
}
if (!sh->CompileStatus) {
if (ctx->Shader.Flags & GLSL_DUMP_ON_ERROR) {
fprintf(stderr, "GLSL source for %s shader %d:\n",
- _mesa_glsl_shader_target_name(sh->Type), sh->Name);
+ _mesa_shader_enum_to_string(sh->Type), sh->Name);
fprintf(stderr, "%s\n", sh->Source);
fprintf(stderr, "Info Log:\n%s\n", sh->InfoLog);
fflush(stderr);
printf("Mesa: glUseProgram(%u)\n", shProg->Name);
for (i = 0; i < shProg->NumShaders; i++) {
printf(" %s shader %u, checksum %u\n",
- _mesa_glsl_shader_target_name(shProg->Shaders[i]->Type),
+ _mesa_shader_enum_to_string(shProg->Shaders[i]->Type),
shProg->Shaders[i]->Name,
shProg->Shaders[i]->SourceChecksum);
}
const struct gl_program *const prog = shProg->_LinkedShaders[i]->Program;
printf("Program %d %s shader parameters:\n",
- shProg->Name, _mesa_glsl_shader_target_name(prog->Target));
+ shProg->Name, _mesa_shader_enum_to_string(prog->Target));
for (unsigned j = 0; j < prog->Parameters->NumParameters; j++) {
printf("%s: %p %f %f %f %f\n",
prog->Parameters->Parameters[j].Name,
int i;
struct gl_program *prog;
GLenum target;
- const char *target_string = _mesa_glsl_shader_target_name(shader->Type);
+ const char *target_string = _mesa_shader_enum_to_string(shader->Type);
struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("\n");
printf("GLSL IR for linked %s program %d:\n",
- _mesa_glsl_shader_target_name(shader->Type),
+ _mesa_shader_enum_to_string(shader->Type),
shader_program->Name);
_mesa_print_ir(shader->ir, NULL);
printf("\n");