mesa: Clean up nomenclature for pipeline stages.

Previously, we had an enum called gl_shader_type which represented
pipeline stages in the order they occur in the pipeline
(i.e. MESA_SHADER_VERTEX=0, MESA_SHADER_GEOMETRY=1, etc), and several
inconsistently named functions for converting between it and other
representations:

- _mesa_shader_type_to_string: gl_shader_type -> string
- _mesa_shader_type_to_index: GLenum (GL_*_SHADER) -> gl_shader_type
- _mesa_program_target_to_index: GLenum (GL_*_PROGRAM) -> gl_shader_type
- _mesa_shader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string

This patch tries to clean things up so that we use more consistent
terminology: the enum is now called gl_shader_stage (to emphasize that
it is in the order of pipeline stages), and the conversion functions are:

- _mesa_shader_stage_to_string: gl_shader_stage -> string
- _mesa_shader_enum_to_shader_stage: GLenum (GL_*_SHADER) -> gl_shader_stage
- _mesa_program_enum_to_shader_stage: GLenum (GL_*_PROGRAM) -> gl_shader_stage
- _mesa_progshader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string

In addition, MESA_SHADER_TYPES has been renamed to MESA_SHADER_STAGES,
for consistency with the new name for the enum.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

v2: Also rename the "target" field of _mesa_glsl_parse_state and the
"target" parameter of _mesa_shader_stage_to_string to "stage".

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Paul Berry
2014-01-07 10:11:39 -08:00
parent eda21d2a30
commit 665b8d7b6d
32 changed files with 203 additions and 203 deletions

View File

@@ -58,9 +58,9 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
: ctx(_ctx), switch_state()
{
switch (target) {
case GL_VERTEX_SHADER: this->target = MESA_SHADER_VERTEX; break;
case GL_FRAGMENT_SHADER: this->target = MESA_SHADER_FRAGMENT; break;
case GL_GEOMETRY_SHADER: this->target = MESA_SHADER_GEOMETRY; break;
case GL_VERTEX_SHADER: this->stage = MESA_SHADER_VERTEX; break;
case GL_FRAGMENT_SHADER: this->stage = MESA_SHADER_FRAGMENT; break;
case GL_GEOMETRY_SHADER: this->stage = MESA_SHADER_GEOMETRY; break;
}
this->scanner = NULL;
@@ -342,7 +342,7 @@ extern "C" {
* gl_shader->Type.
*/
const char *
_mesa_shader_enum_to_string(GLenum type)
_mesa_progshader_enum_to_string(GLenum type)
{
switch (type) {
case GL_VERTEX_SHADER:
@@ -362,13 +362,13 @@ _mesa_shader_enum_to_string(GLenum type)
} /* extern "C" */
/**
* Translate a gl_shader_type to a short shader stage name for debug printouts
* and error messages.
* Translate a gl_shader_stage to a short shader stage name for debug
* printouts and error messages.
*/
const char *
_mesa_shader_type_to_string(unsigned target)
_mesa_shader_stage_to_string(unsigned stage)
{
switch (target) {
switch (stage) {
case MESA_SHADER_VERTEX: return "vertex";
case MESA_SHADER_FRAGMENT: return "fragment";
case MESA_SHADER_GEOMETRY: return "geometry";
@@ -651,11 +651,11 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
if (behavior == extension_require) {
_mesa_glsl_error(name_locp, state, fmt,
name, _mesa_shader_type_to_string(state->target));
name, _mesa_shader_stage_to_string(state->stage));
return false;
} else {
_mesa_glsl_warning(name_locp, state, fmt,
name, _mesa_shader_type_to_string(state->target));
name, _mesa_shader_stage_to_string(state->stage));
}
}
}
@@ -1516,7 +1516,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
if (!state->error && !shader->ir->is_empty()) {
struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
&ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)];
/* Do some optimization at compile time to reduce shader IR size
* and reduce later work if the same shader is linked multiple times