From: Paul Berry Date: Tue, 7 Jan 2014 18:11:39 +0000 (-0800) Subject: mesa: Clean up nomenclature for pipeline stages. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=665b8d7b6d8eae03c9dc0ef1a744fe59d9cc6cb6;p=mesa.git 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 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 --- diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 91810f985bf..3e79f1a8ed5 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1860,7 +1860,7 @@ ast_fully_specified_type::glsl_type(const char **name, if (type->base_type == GLSL_TYPE_FLOAT && state->es_shader - && state->target == MESA_SHADER_FRAGMENT + && state->stage == MESA_SHADER_FRAGMENT && this->qualifier.precision == ast_precision_none && state->symbols->get_variable("#default precision") == NULL) { YYLTYPE loc = this->get_location(); @@ -1882,7 +1882,7 @@ ast_fully_specified_type::glsl_type(const char **name, * this function will produce undefined results. */ static bool -is_varying_var(ir_variable *var, gl_shader_type target) +is_varying_var(ir_variable *var, gl_shader_stage target) { switch (target) { case MESA_SHADER_VERTEX: @@ -1984,7 +1984,7 @@ validate_binding_qualifier(struct _mesa_glsl_parse_state *state, * through binding + N - 1 must be within this range." */ unsigned limit = 0; - switch (state->target) { + switch (state->stage) { case MESA_SHADER_VERTEX: limit = ctx->Const.VertexProgram.MaxTextureImageUnits; break; @@ -2049,8 +2049,8 @@ interpret_interpolation_qualifier(const struct ast_type_qualifier *qual, } - if ((state->target == MESA_SHADER_VERTEX && mode == ir_var_shader_in) || - (state->target == MESA_SHADER_FRAGMENT && mode == ir_var_shader_out)) { + if ((state->stage == MESA_SHADER_VERTEX && mode == ir_var_shader_in) || + (state->stage == MESA_SHADER_FRAGMENT && mode == ir_var_shader_out)) { _mesa_glsl_error(loc, state, "interpolation qualifier `%s' cannot be applied to " "vertex shader inputs or fragment shader outputs", @@ -2076,7 +2076,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual, * In the fragment shader only shader outputs can be given explicit * locations. */ - switch (state->target) { + switch (state->stage) { case MESA_SHADER_VERTEX: if (var->data.mode == ir_var_shader_in) { if (!state->check_explicit_attrib_location_allowed(loc, var)) @@ -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_shader_type_to_string(state->target)); + _mesa_shader_stage_to_string(state->stage)); } else { var->data.explicit_location = true; @@ -2122,7 +2122,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual, * ensures that negative values stay negative. */ if (qual->location >= 0) { - var->data.location = (state->target == MESA_SHADER_VERTEX) + var->data.location = (state->stage == MESA_SHADER_VERTEX) ? (qual->location + VERT_ATTRIB_GENERIC0) : (qual->location + FRAG_RESULT_DATA0); } else { @@ -2174,7 +2174,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, if (qual->flags.q.constant || qual->flags.q.attribute || qual->flags.q.uniform - || (qual->flags.q.varying && (state->target == MESA_SHADER_FRAGMENT))) + || (qual->flags.q.varying && (state->stage == MESA_SHADER_FRAGMENT))) var->data.read_only = 1; if (qual->flags.q.centroid) @@ -2183,12 +2183,12 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, if (qual->flags.q.sample) var->data.sample = 1; - if (qual->flags.q.attribute && state->target != MESA_SHADER_VERTEX) { + if (qual->flags.q.attribute && state->stage != MESA_SHADER_VERTEX) { var->type = glsl_type::error_type; _mesa_glsl_error(loc, state, "`attribute' variables may not be declared in the " "%s shader", - _mesa_shader_type_to_string(state->target)); + _mesa_shader_stage_to_string(state->stage)); } /* Section 6.1.1 (Function Calling Conventions) of the GLSL 1.10 spec says: @@ -2214,16 +2214,16 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, else if (qual->flags.q.in) var->data.mode = is_parameter ? ir_var_function_in : ir_var_shader_in; else if (qual->flags.q.attribute - || (qual->flags.q.varying && (state->target == MESA_SHADER_FRAGMENT))) + || (qual->flags.q.varying && (state->stage == MESA_SHADER_FRAGMENT))) var->data.mode = ir_var_shader_in; else if (qual->flags.q.out) var->data.mode = is_parameter ? ir_var_function_out : ir_var_shader_out; - else if (qual->flags.q.varying && (state->target == MESA_SHADER_VERTEX)) + else if (qual->flags.q.varying && (state->stage == MESA_SHADER_VERTEX)) var->data.mode = ir_var_shader_out; else if (qual->flags.q.uniform) var->data.mode = ir_var_uniform; - if (!is_parameter && is_varying_var(var, state->target)) { + if (!is_parameter && is_varying_var(var, state->stage)) { /* This variable is being used to link data between shader stages (in * pre-glsl-1.30 parlance, it's a "varying"). Check that it has a type * that is allowed for such purposes. @@ -2272,7 +2272,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, } if (state->all_invariant && (state->current_function == NULL)) { - switch (state->target) { + switch (state->stage) { case MESA_SHADER_VERTEX: if (var->data.mode == ir_var_shader_out) var->data.invariant = true; @@ -2599,8 +2599,8 @@ 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_shader_type_to_string(state->target), - (state->target == MESA_SHADER_VERTEX) + _mesa_shader_stage_to_string(state->stage), + (state->stage == MESA_SHADER_VERTEX) ? "attribute" : "varying"); } @@ -2844,12 +2844,12 @@ ast_declarator_list::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "undeclared variable `%s' cannot be marked " "invariant", decl->identifier); - } else if ((state->target == MESA_SHADER_VERTEX) + } else if ((state->stage == MESA_SHADER_VERTEX) && (earlier->data.mode != ir_var_shader_out)) { _mesa_glsl_error(& loc, state, "`%s' cannot be marked invariant, vertex shader " "outputs only", decl->identifier); - } else if ((state->target == MESA_SHADER_FRAGMENT) + } else if ((state->stage == MESA_SHADER_FRAGMENT) && (earlier->data.mode != ir_var_shader_in)) { _mesa_glsl_error(& loc, state, "`%s' cannot be marked invariant, fragment shader " @@ -3034,12 +3034,12 @@ ast_declarator_list::hir(exec_list *instructions, & loc, false); if (this->type->qualifier.flags.q.invariant) { - if ((state->target == MESA_SHADER_VERTEX) && + if ((state->stage == MESA_SHADER_VERTEX) && var->data.mode != ir_var_shader_out) { _mesa_glsl_error(& loc, state, "`%s' cannot be marked invariant, vertex shader " "outputs only", var->name); - } else if ((state->target == MESA_SHADER_FRAGMENT) && + } else if ((state->stage == MESA_SHADER_FRAGMENT) && var->data.mode != ir_var_shader_in) { /* FINISHME: Note that this doesn't work for invariant on * a function signature inval @@ -3080,7 +3080,7 @@ ast_declarator_list::hir(exec_list *instructions, } else if (var->data.mode == ir_var_shader_in) { var->data.read_only = true; - if (state->target == MESA_SHADER_VERTEX) { + if (state->stage == MESA_SHADER_VERTEX) { bool error_emitted = false; /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: @@ -3135,7 +3135,7 @@ ast_declarator_list::hir(exec_list *instructions, "cannot have array type")) { error_emitted = true; } - } else if (state->target == MESA_SHADER_GEOMETRY) { + } else if (state->stage == MESA_SHADER_GEOMETRY) { /* From section 4.3.4 (Inputs) of the GLSL 1.50 spec: * * Geometry shader input variables get the per-vertex values @@ -3185,10 +3185,10 @@ ast_declarator_list::hir(exec_list *instructions, if (state->is_version(130, 300) && var->type->contains_integer() && var->data.interpolation != INTERP_QUALIFIER_FLAT && - ((state->target == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_in) - || (state->target == MESA_SHADER_VERTEX && var->data.mode == ir_var_shader_out + ((state->stage == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_in) + || (state->stage == MESA_SHADER_VERTEX && var->data.mode == ir_var_shader_out && state->es_shader))) { - const char *var_type = (state->target == MESA_SHADER_VERTEX) ? + const char *var_type = (state->stage == MESA_SHADER_VERTEX) ? "vertex output" : "fragment input"; _mesa_glsl_error(&loc, state, "if a %s is (or contains) " "an integer, then it must be qualified with 'flat'", @@ -3244,7 +3244,7 @@ ast_declarator_list::hir(exec_list *instructions, const char *i = this->type->qualifier.interpolation_string(); assert(i != NULL); - switch (state->target) { + switch (state->stage) { case MESA_SHADER_VERTEX: if (this->type->qualifier.flags.q.in) { _mesa_glsl_error(&loc, state, @@ -3275,13 +3275,13 @@ ast_declarator_list::hir(exec_list *instructions, if (state->is_version(130, 300) && this->type->qualifier.flags.q.centroid && this->type->qualifier.flags.q.in - && state->target == MESA_SHADER_VERTEX) { + && state->stage == MESA_SHADER_VERTEX) { _mesa_glsl_error(&loc, state, "'centroid in' cannot be used in a vertex shader"); } - if (state->target == MESA_SHADER_VERTEX + if (state->stage == MESA_SHADER_VERTEX && this->type->qualifier.flags.q.sample && this->type->qualifier.flags.q.in) { @@ -3296,7 +3296,7 @@ ast_declarator_list::hir(exec_list *instructions, * "It is an error to use auxiliary storage qualifiers or interpolation * qualifiers on an output in a fragment shader." */ - if (state->target == MESA_SHADER_FRAGMENT && + if (state->stage == MESA_SHADER_FRAGMENT && this->type->qualifier.flags.q.out && this->type->qualifier.has_auxiliary_storage()) { _mesa_glsl_error(&loc, state, @@ -3954,7 +3954,7 @@ ast_jump_statement::hir(exec_list *instructions, } case ast_discard: - if (state->target != MESA_SHADER_FRAGMENT) { + if (state->stage != MESA_SHADER_FRAGMENT) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, @@ -4492,7 +4492,7 @@ ast_type_specifier::hir(exec_list *instructions, if (type->base_type == GLSL_TYPE_FLOAT && state->es_shader - && state->target == MESA_SHADER_FRAGMENT) { + && state->stage == MESA_SHADER_FRAGMENT) { /* Section 4.5.3 (Default Precision Qualifiers) of the GLSL ES 1.00 * spec says: * @@ -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_shader_type_to_string(state->target)); + _mesa_shader_stage_to_string(state->stage)); } 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_shader_type_to_string(state->target)); + _mesa_shader_stage_to_string(state->stage)); } if (this->instance_name != NULL) { _mesa_glsl_error(&loc, state, @@ -4995,7 +4995,7 @@ ast_interface_block::hir(exec_list *instructions, * variable (or input block, see interface blocks below) needs to be * declared as an array. */ - if (state->target == MESA_SHADER_GEOMETRY && !this->is_array && + if (state->stage == MESA_SHADER_GEOMETRY && !this->is_array && var_mode == ir_var_shader_in) { _mesa_glsl_error(&loc, state, "geometry shader inputs must be arrays"); } @@ -5050,7 +5050,7 @@ ast_interface_block::hir(exec_list *instructions, * geometry shader input. */ if (this->array_size == NULL && - (state->target != MESA_SHADER_GEOMETRY || !this->layout.flags.q.in)) { + (state->stage != MESA_SHADER_GEOMETRY || !this->layout.flags.q.in)) { _mesa_glsl_error(&loc, state, "only geometry shader inputs may be unsized " "instance block arrays"); @@ -5069,7 +5069,7 @@ ast_interface_block::hir(exec_list *instructions, var_mode); } - if (state->target == MESA_SHADER_GEOMETRY && var_mode == ir_var_shader_in) + if (state->stage == MESA_SHADER_GEOMETRY && var_mode == ir_var_shader_in) handle_geometry_shader_input_decl(state, loc, var); if (ir_variable *earlier = @@ -5265,7 +5265,7 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, else if (strcmp(var->name, "gl_FragData") == 0) gl_FragData_assigned = true; else if (strncmp(var->name, "gl_", 3) != 0) { - if (state->target == MESA_SHADER_FRAGMENT && + if (state->stage == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_out) { user_defined_fs_output_assigned = true; user_defined_fs_output = var; diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 10127f38ee8..2207fe14f12 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -77,7 +77,7 @@ always_available(const _mesa_glsl_parse_state *state) static bool compatibility_vs_only(const _mesa_glsl_parse_state *state) { - return state->target == MESA_SHADER_VERTEX && + return state->stage == MESA_SHADER_VERTEX && state->language_version <= 130 && !state->es_shader; } @@ -85,13 +85,13 @@ compatibility_vs_only(const _mesa_glsl_parse_state *state) static bool fs_only(const _mesa_glsl_parse_state *state) { - return state->target == MESA_SHADER_FRAGMENT; + return state->stage == MESA_SHADER_FRAGMENT; } static bool gs_only(const _mesa_glsl_parse_state *state) { - return state->target == MESA_SHADER_GEOMETRY; + return state->stage == MESA_SHADER_GEOMETRY; } static bool @@ -103,7 +103,7 @@ v110(const _mesa_glsl_parse_state *state) static bool v110_fs_only(const _mesa_glsl_parse_state *state) { - return !state->es_shader && state->target == MESA_SHADER_FRAGMENT; + return !state->es_shader && state->stage == MESA_SHADER_FRAGMENT; } static bool @@ -122,7 +122,7 @@ static bool v130_fs_only(const _mesa_glsl_parse_state *state) { return state->is_version(130, 300) && - state->target == MESA_SHADER_FRAGMENT; + state->stage == MESA_SHADER_FRAGMENT; } static bool @@ -155,7 +155,7 @@ lod_exists_in_stage(const _mesa_glsl_parse_state *state) * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we * don't need to explicitly check state->es_shader. */ - return state->target == MESA_SHADER_VERTEX || + return state->stage == MESA_SHADER_VERTEX || state->is_version(130, 300) || state->ARB_shader_texture_lod_enable; } @@ -223,7 +223,7 @@ texture_array_lod(const _mesa_glsl_parse_state *state) static bool fs_texture_array(const _mesa_glsl_parse_state *state) { - return state->target == MESA_SHADER_FRAGMENT && + return state->stage == MESA_SHADER_FRAGMENT && state->EXT_texture_array_enable; } @@ -243,7 +243,7 @@ texture_multisample(const _mesa_glsl_parse_state *state) static bool fs_texture_cube_map_array(const _mesa_glsl_parse_state *state) { - return state->target == MESA_SHADER_FRAGMENT && + return state->stage == MESA_SHADER_FRAGMENT && (state->is_version(400, 0) || state->ARB_texture_cube_map_array_enable); } @@ -265,7 +265,7 @@ texture_query_levels(const _mesa_glsl_parse_state *state) static bool texture_query_lod(const _mesa_glsl_parse_state *state) { - return state->target == MESA_SHADER_FRAGMENT && + return state->stage == MESA_SHADER_FRAGMENT && state->ARB_texture_query_lod_enable; } @@ -292,7 +292,7 @@ texture_gather_only(const _mesa_glsl_parse_state *state) static bool fs_oes_derivatives(const _mesa_glsl_parse_state *state) { - return state->target == MESA_SHADER_FRAGMENT && + return state->stage == MESA_SHADER_FRAGMENT && (state->is_version(110, 300) || state->OES_standard_derivatives_enable); } @@ -318,7 +318,7 @@ tex3d(const _mesa_glsl_parse_state *state) static bool fs_tex3d(const _mesa_glsl_parse_state *state) { - return state->target == MESA_SHADER_FRAGMENT && + return state->stage == MESA_SHADER_FRAGMENT && (!state->es_shader || state->OES_texture_3D_enable); } diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index ff9acb8d0d0..1a9489e53da 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -876,7 +876,7 @@ builtin_variable_generator::add_varying(int slot, const glsl_type *type, const char *name, const char *name_as_gs_input) { - switch (state->target) { + switch (state->stage) { case MESA_SHADER_GEOMETRY: this->per_vertex_in.add_field(slot, type, name); /* FALLTHROUGH */ @@ -901,7 +901,7 @@ builtin_variable_generator::generate_varyings() add_varying(loc, type, name, name "In") /* gl_Position and gl_PointSize are not visible from fragment shaders. */ - if (state->target != MESA_SHADER_FRAGMENT) { + if (state->stage != MESA_SHADER_FRAGMENT) { ADD_VARYING(VARYING_SLOT_POS, vec4_t, "gl_Position"); ADD_VARYING(VARYING_SLOT_PSIZ, float_t, "gl_PointSize"); } @@ -914,7 +914,7 @@ builtin_variable_generator::generate_varyings() if (compatibility) { ADD_VARYING(VARYING_SLOT_TEX0, array(vec4_t, 0), "gl_TexCoord"); ADD_VARYING(VARYING_SLOT_FOGC, float_t, "gl_FogFragCoord"); - if (state->target == MESA_SHADER_FRAGMENT) { + if (state->stage == MESA_SHADER_FRAGMENT) { ADD_VARYING(VARYING_SLOT_COL0, vec4_t, "gl_Color"); ADD_VARYING(VARYING_SLOT_COL1, vec4_t, "gl_SecondaryColor"); } else { @@ -926,13 +926,13 @@ builtin_variable_generator::generate_varyings() } } - if (state->target == MESA_SHADER_GEOMETRY) { + if (state->stage == MESA_SHADER_GEOMETRY) { const glsl_type *per_vertex_in_type = this->per_vertex_in.construct_interface_instance(); add_variable("gl_in", array(per_vertex_in_type, 0), ir_var_shader_in, -1); } - if (state->target == MESA_SHADER_VERTEX || state->target == MESA_SHADER_GEOMETRY) { + if (state->stage == MESA_SHADER_VERTEX || state->stage == MESA_SHADER_GEOMETRY) { const glsl_type *per_vertex_out_type = this->per_vertex_out.construct_interface_instance(); const glsl_struct_field *fields = per_vertex_out_type->fields.structure; @@ -963,7 +963,7 @@ _mesa_glsl_initialize_variables(exec_list *instructions, gen.generate_varyings(); - switch (state->target) { + switch (state->stage) { case MESA_SHADER_VERTEX: gen.generate_vs_special_vars(); break; diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 39767609d20..1c56d6f145a 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -2219,11 +2219,11 @@ basic_interface_block: * "It is illegal to have an input block in a vertex shader * or an output block in a fragment shader" */ - if ((state->target == MESA_SHADER_VERTEX) && $1.flags.q.in) { + if ((state->stage == MESA_SHADER_VERTEX) && $1.flags.q.in) { _mesa_glsl_error(& @1, state, "`in' interface block is not allowed for " "a vertex shader"); - } else if ((state->target == MESA_SHADER_FRAGMENT) && $1.flags.q.out) { + } else if ((state->stage == MESA_SHADER_FRAGMENT) && $1.flags.q.out) { _mesa_glsl_error(& @1, state, "`out' interface block is not allowed for " "a fragment shader"); @@ -2377,7 +2377,7 @@ layout_defaults: { void *ctx = state; $$ = NULL; - if (state->target != MESA_SHADER_GEOMETRY) { + if (state->stage != MESA_SHADER_GEOMETRY) { _mesa_glsl_error(& @1, state, "input layout qualifiers only valid in " "geometry shaders"); @@ -2405,7 +2405,7 @@ layout_defaults: | layout_qualifier OUT_TOK ';' { - if (state->target != MESA_SHADER_GEOMETRY) { + if (state->stage != MESA_SHADER_GEOMETRY) { _mesa_glsl_error(& @1, state, "out layout qualifiers only valid in " "geometry shaders"); diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index e839caf9ad2..8a9526c471f 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -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 diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 0e281ae203e..8e0ae3bd7e0 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -165,7 +165,7 @@ struct _mesa_glsl_parse_state { bool es_shader; unsigned language_version; - gl_shader_type target; + gl_shader_stage stage; /** * Number of nested struct_specifier levels @@ -424,11 +424,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 (which is a - * gl_shader_type). + * Get the textual name of the specified shader stage (which is a + * gl_shader_stage). */ extern const char * -_mesa_shader_type_to_string(unsigned target); +_mesa_shader_stage_to_string(unsigned stage); #endif /* __cplusplus */ @@ -442,7 +442,7 @@ extern "C" { #endif extern const char * -_mesa_shader_enum_to_string(GLenum type); +_mesa_progshader_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/ir_uniform.h b/src/glsl/ir_uniform.h index 13faab7c0a1..f678c2c5c4d 100644 --- a/src/glsl/ir_uniform.h +++ b/src/glsl/ir_uniform.h @@ -116,7 +116,7 @@ struct gl_uniform_storage { * Whether this sampler is used in this shader stage. */ bool active; - } sampler[MESA_SHADER_TYPES]; + } sampler[MESA_SHADER_STAGES]; /** * Storage used by the driver for the uniform diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp index 603329c503b..bfa09a3bca6 100644 --- a/src/glsl/link_atomics.cpp +++ b/src/glsl/link_atomics.cpp @@ -64,7 +64,7 @@ namespace { active_atomic_counter *counters; unsigned num_counters; - unsigned stage_references[MESA_SHADER_TYPES]; + unsigned stage_references[MESA_SHADER_STAGES]; unsigned size; }; @@ -96,7 +96,7 @@ namespace { *num_buffers = 0; - for (unsigned i = 0; i < MESA_SHADER_TYPES; ++i) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) { struct gl_shader *sh = prog->_LinkedShaders[i]; if (sh == NULL) continue; @@ -199,7 +199,7 @@ link_assign_atomic_counter_resources(struct gl_context *ctx, } /* Assign stage-specific fields. */ - for (unsigned j = 0; j < MESA_SHADER_TYPES; ++j) + for (unsigned j = 0; j < MESA_SHADER_STAGES; ++j) mab.StageReferences[j] = (ab.stage_references[j] ? GL_TRUE : GL_FALSE); @@ -219,18 +219,18 @@ link_check_atomic_counter_resources(struct gl_context *ctx, ctx->Const.GeometryProgram.MaxAtomicCounters, ctx->Const.FragmentProgram.MaxAtomicCounters }; - STATIC_ASSERT(Elements(max_atomic_counters) == MESA_SHADER_TYPES); + STATIC_ASSERT(Elements(max_atomic_counters) == MESA_SHADER_STAGES); const unsigned max_atomic_buffers[] = { ctx->Const.VertexProgram.MaxAtomicBuffers, ctx->Const.GeometryProgram.MaxAtomicBuffers, ctx->Const.FragmentProgram.MaxAtomicBuffers }; - STATIC_ASSERT(Elements(max_atomic_buffers) == MESA_SHADER_TYPES); + STATIC_ASSERT(Elements(max_atomic_buffers) == MESA_SHADER_STAGES); unsigned num_buffers; active_atomic_buffer *const abs = find_active_atomic_counters(ctx, prog, &num_buffers); - unsigned atomic_counters[MESA_SHADER_TYPES] = {}; - unsigned atomic_buffers[MESA_SHADER_TYPES] = {}; + unsigned atomic_counters[MESA_SHADER_STAGES] = {}; + unsigned atomic_buffers[MESA_SHADER_STAGES] = {}; unsigned total_atomic_counters = 0; unsigned total_atomic_buffers = 0; @@ -243,7 +243,7 @@ link_check_atomic_counter_resources(struct gl_context *ctx, if (abs[i].size == 0) continue; - for (unsigned j = 0; j < MESA_SHADER_TYPES; ++j) { + for (unsigned j = 0; j < MESA_SHADER_STAGES; ++j) { const unsigned n = abs[i].stage_references[j]; if (n) { @@ -256,14 +256,14 @@ link_check_atomic_counter_resources(struct gl_context *ctx, } /* Check that they are within the supported limits. */ - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (atomic_counters[i] > max_atomic_counters[i]) linker_error(prog, "Too many %s shader atomic counters", - _mesa_shader_type_to_string(i)); + _mesa_shader_stage_to_string(i)); if (atomic_buffers[i] > max_atomic_buffers[i]) linker_error(prog, "Too many %s shader atomic counter buffers", - _mesa_shader_type_to_string(i)); + _mesa_shader_stage_to_string(i)); } if (total_atomic_counters > ctx->Const.MaxCombinedAtomicCounters) diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp index 04daa1760a0..7d5c1472dae 100644 --- a/src/glsl/link_uniform_initializers.cpp +++ b/src/glsl/link_uniform_initializers.cpp @@ -106,7 +106,7 @@ set_uniform_binding(void *mem_ctx, gl_shader_program *prog, storage->storage[i].i = binding + i; } - for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) { gl_shader *shader = prog->_LinkedShaders[sh]; if (shader && storage->sampler[sh].active) { @@ -119,7 +119,7 @@ set_uniform_binding(void *mem_ctx, gl_shader_program *prog, } } else if (storage->block_index != -1) { /* This is a field of a UBO. val is the binding index. */ - for (int i = 0; i < MESA_SHADER_TYPES; i++) { + for (int i = 0; i < MESA_SHADER_STAGES; i++) { int stage_index = prog->UniformBlockStageIndex[i][storage->block_index]; if (stage_index != -1) { @@ -194,7 +194,7 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog, val->type->components()); if (storage->type->is_sampler()) { - for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) { gl_shader *shader = prog->_LinkedShaders[sh]; if (shader && storage->sampler[sh].active) { @@ -215,7 +215,7 @@ link_set_uniform_initializers(struct gl_shader_program *prog) { void *mem_ctx = NULL; - for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_shader *shader = prog->_LinkedShaders[i]; if (shader == NULL) diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index bda6e4ffb3b..1c97e195781 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -356,9 +356,9 @@ public: { } - void start_shader(gl_shader_type shader_type) + void start_shader(gl_shader_stage shader_type) { - assert(shader_type < MESA_SHADER_TYPES); + assert(shader_type < MESA_SHADER_STAGES); this->shader_type = shader_type; this->shader_samplers_used = 0; @@ -429,7 +429,7 @@ public: int ubo_block_index; int ubo_byte_offset; bool ubo_row_major; - gl_shader_type shader_type; + gl_shader_stage shader_type; private: void handle_samplers(const glsl_type *base_type, @@ -741,7 +741,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog) * glGetUniformLocation. */ count_uniform_size uniform_size(prog->UniformHash); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_shader *sh = prog->_LinkedShaders[i]; if (sh == NULL) @@ -809,11 +809,11 @@ link_assign_uniform_locations(struct gl_shader_program *prog) parcel_out_uniform_storage parcel(prog->UniformHash, uniforms, data); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; - parcel.start_shader((gl_shader_type)i); + parcel.start_shader((gl_shader_stage)i); foreach_list(node, prog->_LinkedShaders[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp index 98f902ca4ef..ab40d458563 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_shader_enum_to_string(producer_type), + _mesa_progshader_enum_to_string(producer_type), output->name, output->type->name, - _mesa_shader_enum_to_string(consumer_type), + _mesa_progshader_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_shader_enum_to_string(producer_type), + _mesa_progshader_enum_to_string(producer_type), output->name, (output->data.centroid) ? "has" : "lacks", - _mesa_shader_enum_to_string(consumer_type), + _mesa_progshader_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_shader_enum_to_string(producer_type), + _mesa_progshader_enum_to_string(producer_type), output->name, (output->data.sample) ? "has" : "lacks", - _mesa_shader_enum_to_string(consumer_type), + _mesa_progshader_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_shader_enum_to_string(producer_type), + _mesa_progshader_enum_to_string(producer_type), output->name, (output->data.invariant) ? "has" : "lacks", - _mesa_shader_enum_to_string(consumer_type), + _mesa_progshader_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_shader_enum_to_string(producer_type), + _mesa_progshader_enum_to_string(producer_type), output->name, interpolation_string(output->data.interpolation), - _mesa_shader_enum_to_string(consumer_type), + _mesa_progshader_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_shader_enum_to_string(consumer->Type), + _mesa_progshader_enum_to_string(consumer->Type), var->name, - _mesa_shader_enum_to_string(producer->Type)); + _mesa_progshader_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 a81e107372b..428a044e9b8 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -438,7 +438,7 @@ analyze_clip_usage(struct gl_shader_program *prog, if (clip_vertex.variable_found() && clip_distance.variable_found()) { linker_error(prog, "%s shader writes to both `gl_ClipVertex' " "and `gl_ClipDistance'\n", - _mesa_shader_enum_to_string(shader->Type)); + _mesa_progshader_enum_to_string(shader->Type)); return; } *UsesClipDistance = clip_distance.variable_found(); @@ -786,7 +786,7 @@ void cross_validate_uniforms(struct gl_shader_program *prog) { cross_validate_globals(prog, prog->_LinkedShaders, - MESA_SHADER_TYPES, true); + MESA_SHADER_STAGES, true); } /** @@ -797,12 +797,12 @@ static bool interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog) { unsigned max_num_uniform_blocks = 0; - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i]) max_num_uniform_blocks += prog->_LinkedShaders[i]->NumUniformBlocks; } - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_shader *sh = prog->_LinkedShaders[i]; prog->UniformBlockStageIndex[i] = ralloc_array(prog, int, @@ -1376,7 +1376,7 @@ link_intrastage_shaders(void *mem_ctx, if (main == NULL) { linker_error(prog, "%s shader lacks `main'\n", - _mesa_shader_enum_to_string(shader_list[0]->Type)); + _mesa_progshader_enum_to_string(shader_list[0]->Type)); return NULL; } @@ -1488,7 +1488,7 @@ link_intrastage_shaders(void *mem_ctx, static void update_array_sizes(struct gl_shader_program *prog) { - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; @@ -1511,7 +1511,7 @@ update_array_sizes(struct gl_shader_program *prog) continue; unsigned int size = var->data.max_array_access; - for (unsigned j = 0; j < MESA_SHADER_TYPES; j++) { + for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) { if (prog->_LinkedShaders[j] == NULL) continue; @@ -1899,7 +1899,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog) ctx->Const.GeometryProgram.MaxTextureImageUnits, ctx->Const.FragmentProgram.MaxTextureImageUnits }; - STATIC_ASSERT(Elements(max_samplers) == MESA_SHADER_TYPES); + STATIC_ASSERT(Elements(max_samplers) == MESA_SHADER_STAGES); const unsigned max_default_uniform_components[] = { ctx->Const.VertexProgram.MaxUniformComponents, @@ -1907,7 +1907,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog) ctx->Const.FragmentProgram.MaxUniformComponents }; STATIC_ASSERT(Elements(max_default_uniform_components) == - MESA_SHADER_TYPES); + MESA_SHADER_STAGES); const unsigned max_combined_uniform_components[] = { ctx->Const.VertexProgram.MaxCombinedUniformComponents, @@ -1915,16 +1915,16 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog) ctx->Const.FragmentProgram.MaxCombinedUniformComponents }; STATIC_ASSERT(Elements(max_combined_uniform_components) == - MESA_SHADER_TYPES); + MESA_SHADER_STAGES); const unsigned max_uniform_blocks[] = { ctx->Const.VertexProgram.MaxUniformBlocks, ctx->Const.GeometryProgram.MaxUniformBlocks, ctx->Const.FragmentProgram.MaxUniformBlocks }; - STATIC_ASSERT(Elements(max_uniform_blocks) == MESA_SHADER_TYPES); + STATIC_ASSERT(Elements(max_uniform_blocks) == MESA_SHADER_STAGES); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_shader *sh = prog->_LinkedShaders[i]; if (sh == NULL) @@ -1932,7 +1932,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog) if (sh->num_samplers > max_samplers[i]) { linker_error(prog, "Too many %s shader texture samplers", - _mesa_shader_type_to_string(i)); + _mesa_shader_stage_to_string(i)); } if (sh->num_uniform_components > max_default_uniform_components[i]) { @@ -1941,11 +1941,11 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog) "components, but the driver will try to optimize " "them out; this is non-portable out-of-spec " "behavior\n", - _mesa_shader_type_to_string(i)); + _mesa_shader_stage_to_string(i)); } else { linker_error(prog, "Too many %s shader default uniform block " "components", - _mesa_shader_type_to_string(i)); + _mesa_shader_stage_to_string(i)); } } @@ -1955,19 +1955,19 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog) linker_warning(prog, "Too many %s shader uniform components, " "but the driver will try to optimize them out; " "this is non-portable out-of-spec behavior\n", - _mesa_shader_type_to_string(i)); + _mesa_shader_stage_to_string(i)); } else { linker_error(prog, "Too many %s shader uniform components", - _mesa_shader_type_to_string(i)); + _mesa_shader_stage_to_string(i)); } } } - unsigned blocks[MESA_SHADER_TYPES] = {0}; + unsigned blocks[MESA_SHADER_STAGES] = {0}; unsigned total_uniform_blocks = 0; for (unsigned i = 0; i < prog->NumUniformBlocks; i++) { - for (unsigned j = 0; j < MESA_SHADER_TYPES; j++) { + for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) { if (prog->UniformBlockStageIndex[j][i] != -1) { blocks[j]++; total_uniform_blocks++; @@ -1979,10 +1979,10 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog) prog->NumUniformBlocks, ctx->Const.MaxCombinedUniformBlocks); } else { - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (blocks[i] > max_uniform_blocks[i]) { linker_error(prog, "Too many %s uniform blocks (%d/%d)", - _mesa_shader_type_to_string(i), + _mesa_shader_stage_to_string(i), blocks[i], max_uniform_blocks[i]); break; @@ -2010,7 +2010,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) ralloc_free(prog->UniformBlocks); prog->UniformBlocks = NULL; prog->NumUniformBlocks = 0; - for (int i = 0; i < MESA_SHADER_TYPES; i++) { + for (int i = 0; i < MESA_SHADER_STAGES; i++) { ralloc_free(prog->UniformBlockStageIndex[i]); prog->UniformBlockStageIndex[i] = NULL; } @@ -2085,7 +2085,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) goto done; } - for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] != NULL) ctx->Driver.DeleteShader(ctx, prog->_LinkedShaders[i]); @@ -2154,7 +2154,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) unsigned prev; - for (prev = 0; prev < MESA_SHADER_TYPES; prev++) { + for (prev = 0; prev < MESA_SHADER_STAGES; prev++) { if (prog->_LinkedShaders[prev] != NULL) break; } @@ -2162,7 +2162,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Validate the inputs of each stage with the output of the preceding * stage. */ - for (unsigned i = prev + 1; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = prev + 1; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; @@ -2182,11 +2182,11 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Cross-validate uniform blocks between shader stages */ validate_interstage_uniform_blocks(prog, prog->_LinkedShaders, - MESA_SHADER_TYPES); + MESA_SHADER_STAGES); if (!prog->LinkStatus) goto done; - for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] != NULL) lower_named_interface_blocks(mem_ctx, prog->_LinkedShaders[i]); } @@ -2211,7 +2211,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) * uniforms, and varyings. Later optimization could possibly make * some of that unused. */ - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; @@ -2257,7 +2257,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) } unsigned first; - for (first = 0; first < MESA_SHADER_TYPES; first++) { + for (first = 0; first < MESA_SHADER_STAGES; first++) { if (prog->_LinkedShaders[first] != NULL) break; } @@ -2289,7 +2289,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) * eliminated if they are (transitively) not used in a later stage. */ int last, next; - for (last = MESA_SHADER_TYPES-1; last >= 0; last--) { + for (last = MESA_SHADER_STAGES-1; last >= 0; last--) { if (prog->_LinkedShaders[last] != NULL) break; } @@ -2404,7 +2404,7 @@ done: free(frag_shader_list); free(geom_shader_list); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index aa188b1f158..2f59848adbf 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -388,7 +388,7 @@ main(int argc, char **argv) printf("Info log for linking:\n%s\n", whole_program->InfoLog); } - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) ralloc_free(whole_program->_LinkedShaders[i]); ralloc_free(whole_program); diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index cbff6d18228..73dfe5c38be 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -148,6 +148,6 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) /* Default pragma settings */ options.DefaultPragmas.Optimize = true; - for (int sh = 0; sh < MESA_SHADER_TYPES; ++sh) + for (int sh = 0; sh < MESA_SHADER_STAGES; ++sh) memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); } diff --git a/src/glsl/standalone_scaffolding.h b/src/glsl/standalone_scaffolding.h index 9f4818a8a33..327fef2df15 100644 --- a/src/glsl/standalone_scaffolding.h +++ b/src/glsl/standalone_scaffolding.h @@ -48,8 +48,8 @@ extern "C" void _mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id, const char *msg, int len); -static inline gl_shader_type -_mesa_shader_type_to_index(GLenum v) +static inline gl_shader_stage +_mesa_shader_enum_to_shader_stage(GLenum v) { switch (v) { case GL_VERTEX_SHADER: @@ -59,7 +59,7 @@ _mesa_shader_type_to_index(GLenum v) case GL_GEOMETRY_SHADER: return MESA_SHADER_GEOMETRY; default: - assert(!"bad value in _mesa_shader_type_to_index()"); + assert(!"bad value in _mesa_shader_enum_to_shader_stage()"); return MESA_SHADER_VERTEX; } } diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp index 67e2ab2b15c..01f6f9585f0 100644 --- a/src/glsl/test_optpass.cpp +++ b/src/glsl/test_optpass.cpp @@ -242,7 +242,7 @@ int test_optpass(int argc, char **argv) if (!state->error) { GLboolean progress; const 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 { progress = do_optimization_passes(shader->ir, &argv[optind], argc - optind, quiet != 0, options); diff --git a/src/glsl/tests/set_uniform_initializer_tests.cpp b/src/glsl/tests/set_uniform_initializer_tests.cpp index 5c6d4a51491..be202b3d57e 100644 --- a/src/glsl/tests/set_uniform_initializer_tests.cpp +++ b/src/glsl/tests/set_uniform_initializer_tests.cpp @@ -116,7 +116,7 @@ establish_uniform_storage(struct gl_shader_program *prog, unsigned num_storage, prog->UniformStorage[index_to_set].type = type; prog->UniformStorage[index_to_set].array_elements = array_size; prog->UniformStorage[index_to_set].initialized = false; - for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) { prog->UniformStorage[index_to_set].sampler[sh].index = ~0; prog->UniformStorage[index_to_set].sampler[sh].active = false; } @@ -137,7 +137,7 @@ establish_uniform_storage(struct gl_shader_program *prog, unsigned num_storage, prog->UniformStorage[i].type = glsl_type::void_type; prog->UniformStorage[i].array_elements = 0; prog->UniformStorage[i].initialized = false; - for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) { prog->UniformStorage[i].sampler[sh].index = ~0; prog->UniformStorage[i].sampler[sh].active = false; } diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 78c06fcd680..8d202a2d425 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -463,7 +463,7 @@ brw_initialize_context_constants(struct brw_context *brw) } /* We want the GLSL compiler to emit code that uses condition codes */ - for (int i = 0; i < MESA_SHADER_TYPES; i++) { + for (int i = 0; i < MESA_SHADER_STAGES; i++) { ctx->ShaderCompilerOptions[i].MaxIfDepth = brw->gen < 6 ? 16 : UINT_MAX; ctx->ShaderCompilerOptions[i].EmitCondCodes = true; ctx->ShaderCompilerOptions[i].EmitNoNoise = true; diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 3f59c804ca5..a40df6d17a4 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -82,7 +82,7 @@ brw_shader_precompile(struct gl_context *ctx, struct gl_shader_program *prog) static void brw_lower_packing_builtins(struct brw_context *brw, - gl_shader_type shader_type, + gl_shader_stage shader_type, exec_list *ir) { int ops = LOWER_PACK_SNORM_2x16 @@ -132,7 +132,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) return false; prog->Parameters = _mesa_new_parameter_list(); - _mesa_copy_linked_program_data((gl_shader_type) stage, shProg, prog); + _mesa_copy_linked_program_data((gl_shader_stage) stage, shProg, prog); void *mem_ctx = ralloc_context(NULL); bool progress; @@ -145,7 +145,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) /* lower_packing_builtins() inserts arithmetic instructions, so it * must precede lower_instructions(). */ - brw_lower_packing_builtins(brw, (gl_shader_type) stage, shader->ir); + brw_lower_packing_builtins(brw, (gl_shader_stage) stage, shader->ir); do_mat_op_to_vec(shader->ir); const int bitfield_insert = brw->gen >= 7 ? BITFIELD_INSERT_TO_BFM_BFI @@ -261,7 +261,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) if (ctx->Shader.Flags & GLSL_DUMP) { printf("\n"); printf("GLSL IR for linked %s program %d:\n", - _mesa_shader_enum_to_string(shader->base.Type), shProg->Name); + _mesa_progshader_enum_to_string(shader->base.Type), shProg->Name); _mesa_print_ir(shader->base.ir, NULL); printf("\n"); } @@ -274,7 +274,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) continue; printf("GLSL %s shader %d source for linked program %d:\n", - _mesa_shader_enum_to_string(sh->Type), + _mesa_progshader_enum_to_string(sh->Type), i, shProg->Name); printf("%s", sh->Source); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 658499fa4e3..76e2eccfd5c 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1851,14 +1851,14 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) #ifdef DEBUG if (ctx->Shader.Flags & GLSL_LOG) { - struct gl_shader_program *shProg[MESA_SHADER_TYPES]; - gl_shader_type i; + struct gl_shader_program *shProg[MESA_SHADER_STAGES]; + gl_shader_stage i; shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram; shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentGeometryProgram; shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentFragmentProgram; - for (i = 0; i < MESA_SHADER_TYPES; i++) { + for (i = 0; i < MESA_SHADER_STAGES; i++) { if (shProg[i] == NULL || shProg[i]->_Used || shProg[i]->_LinkedShaders[i] == NULL) continue; @@ -1875,7 +1875,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) _mesa_append_uniforms_to_file(shProg[i]->_LinkedShaders[i]); } - for (i = 0; i < MESA_SHADER_TYPES; i++) { + for (i = 0; i < MESA_SHADER_STAGES; i++) { if (shProg[i] != NULL) shProg[i]->_Used = GL_TRUE; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a5294b01858..9e2083c53bb 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2399,9 +2399,9 @@ typedef enum MESA_SHADER_VERTEX = 0, MESA_SHADER_GEOMETRY = 1, MESA_SHADER_FRAGMENT = 2, -} gl_shader_type; +} gl_shader_stage; -#define MESA_SHADER_TYPES (MESA_SHADER_FRAGMENT + 1) +#define MESA_SHADER_STAGES (MESA_SHADER_FRAGMENT + 1) struct gl_uniform_buffer_variable @@ -2482,7 +2482,7 @@ struct gl_active_atomic_buffer GLuint MinimumSize; /** Shader stages making use of it. */ - GLboolean StageReferences[MESA_SHADER_TYPES]; + GLboolean StageReferences[MESA_SHADER_STAGES]; }; /** @@ -2620,7 +2620,7 @@ struct gl_shader_program * This is used to maintain the Binding values of the stage's UniformBlocks[] * and to answer the GL_UNIFORM_BLOCK_REFERENCED_BY_*_SHADER queries. */ - int *UniformBlockStageIndex[MESA_SHADER_TYPES]; + int *UniformBlockStageIndex[MESA_SHADER_STAGES]; /** * Map of active uniform names to locations @@ -2650,7 +2650,7 @@ struct gl_shader_program * \c MESA_SHADER_* defines. Entries for non-existent stages will be * \c NULL. */ - struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES]; + struct gl_shader *_LinkedShaders[MESA_SHADER_STAGES]; }; @@ -3907,7 +3907,7 @@ struct gl_context struct gl_ati_fragment_shader_state ATIFragmentShader; struct gl_shader_state Shader; /**< GLSL shader object state */ - struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES]; + struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES]; struct gl_query_state Query; /**< occlusion, timer queries */ diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 57511e83e43..fc76f232eee 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -108,7 +108,7 @@ _mesa_init_shader_state(struct gl_context *ctx) * are generated by the GLSL compiler. */ struct gl_shader_compiler_options options; - gl_shader_type sh; + gl_shader_stage sh; memset(&options, 0, sizeof(options)); options.MaxUnrollIterations = 32; @@ -117,7 +117,7 @@ _mesa_init_shader_state(struct gl_context *ctx) /* Default pragma settings */ options.DefaultPragmas.Optimize = GL_TRUE; - for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) + for (sh = 0; sh < MESA_SHADER_STAGES; ++sh) memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); ctx->Shader.Flags = get_shader_flags(); @@ -778,7 +778,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) if (!sh) return; - options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)]; + options = &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(sh->Type)]; /* set default pragma state for shader */ sh->Pragmas = options->DefaultPragmas; @@ -791,7 +791,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) } else { if (ctx->Shader.Flags & GLSL_DUMP) { printf("GLSL source for %s shader %d:\n", - _mesa_shader_enum_to_string(sh->Type), sh->Name); + _mesa_progshader_enum_to_string(sh->Type), sh->Name); printf("%s\n", sh->Source); } @@ -823,7 +823,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) if (!sh->CompileStatus) { if (ctx->Shader.Flags & GLSL_DUMP_ON_ERROR) { fprintf(stderr, "GLSL source for %s shader %d:\n", - _mesa_shader_enum_to_string(sh->Type), sh->Name); + _mesa_progshader_enum_to_string(sh->Type), sh->Name); fprintf(stderr, "%s\n", sh->Source); fprintf(stderr, "Info Log:\n%s\n", sh->InfoLog); fflush(stderr); @@ -898,7 +898,7 @@ print_shader_info(const struct gl_shader_program *shProg) printf("Mesa: glUseProgram(%u)\n", shProg->Name); for (i = 0; i < shProg->NumShaders; i++) { printf(" %s shader %u, checksum %u\n", - _mesa_shader_enum_to_string(shProg->Shaders[i]->Type), + _mesa_progshader_enum_to_string(shProg->Shaders[i]->Type), shProg->Shaders[i]->Name, shProg->Shaders[i]->SourceChecksum); } @@ -1836,7 +1836,7 @@ _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string) * object to a specific gl_program object. */ void -_mesa_copy_linked_program_data(gl_shader_type type, +_mesa_copy_linked_program_data(gl_shader_stage type, const struct gl_shader_program *src, struct gl_program *dst) { diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h index fe58e7de9bd..4822e32c270 100644 --- a/src/mesa/main/shaderapi.h +++ b/src/mesa/main/shaderapi.h @@ -211,7 +211,7 @@ extern GLuint GLAPIENTRY _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string); extern void -_mesa_copy_linked_program_data(gl_shader_type type, +_mesa_copy_linked_program_data(gl_shader_stage type, const struct gl_shader_program *src, struct gl_program *dst); diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index 0d794ad9693..3076fb425c9 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -307,7 +307,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx, struct gl_shader_program *shProg) { GLuint i; - gl_shader_type sh; + gl_shader_stage sh; assert(shProg->Type == GL_SHADER_PROGRAM_MESA); @@ -346,7 +346,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx, shProg->TransformFeedback.NumVarying = 0; - for (sh = 0; sh < MESA_SHADER_TYPES; sh++) { + for (sh = 0; sh < MESA_SHADER_STAGES; sh++) { if (shProg->_LinkedShaders[sh] != NULL) { ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[sh]); shProg->_LinkedShaders[sh] = NULL; diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h index 155058d7187..517557088b8 100644 --- a/src/mesa/main/shaderobj.h +++ b/src/mesa/main/shaderobj.h @@ -101,8 +101,8 @@ extern void _mesa_free_shader_state(struct gl_context *ctx); -static inline gl_shader_type -_mesa_shader_type_to_index(GLenum v) +static inline gl_shader_stage +_mesa_shader_enum_to_shader_stage(GLenum v) { switch (v) { case GL_VERTEX_SHADER: @@ -112,7 +112,7 @@ _mesa_shader_type_to_index(GLenum v) case GL_GEOMETRY_SHADER: return MESA_SHADER_GEOMETRY; default: - ASSERT(0 && "bad value in _mesa_shader_type_to_index()"); + ASSERT(0 && "bad value in _mesa_shader_enum_to_shader_stage()"); return MESA_SHADER_VERTEX; } } diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 61bcbcb8afd..d90193e03a5 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -445,14 +445,14 @@ log_uniform(const void *values, enum glsl_base_type basicType, static void log_program_parameters(const struct gl_shader_program *shProg) { - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (shProg->_LinkedShaders[i] == NULL) continue; const struct gl_program *const prog = shProg->_LinkedShaders[i]->Program; printf("Program %d %s shader parameters:\n", - shProg->Name, _mesa_shader_enum_to_string(prog->Target)); + shProg->Name, _mesa_progshader_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, @@ -784,7 +784,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, int i; bool flushed = false; - for (i = 0; i < MESA_SHADER_TYPES; i++) { + for (i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_shader *const sh = shProg->_LinkedShaders[i]; int j; diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 17e24f6788d..071d668f3bd 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -68,7 +68,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg, { GLuint s; struct gl_shader *shader = - shProg->_LinkedShaders[_mesa_program_target_to_index(prog->Target)]; + shProg->_LinkedShaders[_mesa_program_enum_to_shader_stage(prog->Target)]; assert(shader); @@ -642,7 +642,7 @@ _mesa_UniformBlockBinding(GLuint program, shProg->UniformBlocks[uniformBlockIndex].Binding = uniformBlockBinding; - for (i = 0; i < MESA_SHADER_TYPES; i++) { + for (i = 0; i < MESA_SHADER_STAGES; i++) { int stage_index = shProg->UniformBlockStageIndex[i][uniformBlockIndex]; if (stage_index != -1) { diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index beb0c093b5e..ae4a6e2dec6 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2392,7 +2392,7 @@ class add_uniform_to_shader : public program_resource_visitor { public: add_uniform_to_shader(struct gl_shader_program *shader_program, struct gl_program_parameter_list *params, - gl_shader_type shader_type) + gl_shader_stage shader_type) : shader_program(shader_program), params(params), idx(-1), shader_type(shader_type) { @@ -2414,7 +2414,7 @@ private: struct gl_shader_program *shader_program; struct gl_program_parameter_list *params; int idx; - gl_shader_type shader_type; + gl_shader_stage shader_type; }; } /* anonymous namespace */ @@ -2494,7 +2494,7 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program *params) { add_uniform_to_shader add(shader_program, params, - _mesa_shader_type_to_index(sh->Type)); + _mesa_shader_enum_to_shader_stage(sh->Type)); foreach_list(node, sh->ir) { ir_variable *var = ((ir_instruction *) node)->as_variable(); @@ -2801,9 +2801,9 @@ get_mesa_program(struct gl_context *ctx, int i; struct gl_program *prog; GLenum target; - const char *target_string = _mesa_shader_enum_to_string(shader->Type); + const char *target_string = _mesa_progshader_enum_to_string(shader->Type); 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)]; switch (shader->Type) { case GL_VERTEX_SHADER: @@ -3000,14 +3000,14 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) { assert(prog->LinkStatus); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; bool progress; exec_list *ir = prog->_LinkedShaders[i]->ir; const struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)]; + &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type)]; do { progress = false; @@ -3055,7 +3055,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) validate_ir_tree(ir); } - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_program *linked_prog; if (prog->_LinkedShaders[i] == NULL) @@ -3064,7 +3064,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]); if (linked_prog) { - _mesa_copy_linked_program_data((gl_shader_type) i, prog, linked_prog); + _mesa_copy_linked_program_data((gl_shader_stage) i, prog, linked_prog); _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, linked_prog); diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index cdf1c03fa91..45748fdc93c 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -891,7 +891,7 @@ _mesa_find_free_register(const GLboolean used[], */ GLboolean _mesa_valid_register_index(const struct gl_context *ctx, - gl_shader_type shaderType, + gl_shader_stage shaderType, gl_register_file file, GLint index) { const struct gl_program_constants *c; diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h index baff473764d..4015b4c202b 100644 --- a/src/mesa/program/program.h +++ b/src/mesa/program/program.h @@ -181,7 +181,7 @@ _mesa_find_free_register(const GLboolean used[], extern GLboolean _mesa_valid_register_index(const struct gl_context *ctx, - gl_shader_type shaderType, + gl_shader_stage shaderType, gl_register_file file, GLint index); extern void @@ -192,7 +192,7 @@ _mesa_get_min_invocations_per_fragment(struct gl_context *ctx, const struct gl_fragment_program *prog); static inline GLuint -_mesa_program_target_to_index(GLenum v) +_mesa_program_enum_to_shader_stage(GLenum v) { switch (v) { case GL_VERTEX_PROGRAM_ARB: @@ -215,8 +215,8 @@ _mesa_program_index_to_target(GLuint i) GL_GEOMETRY_PROGRAM_NV, GL_FRAGMENT_PROGRAM_ARB }; - STATIC_ASSERT(Elements(enums) == MESA_SHADER_TYPES); - if(i >= MESA_SHADER_TYPES) { + STATIC_ASSERT(Elements(enums) == MESA_SHADER_STAGES); + if(i >= MESA_SHADER_STAGES) { assert(!"Unexpected program index"); return 0; } else diff --git a/src/mesa/program/sampler.cpp b/src/mesa/program/sampler.cpp index 9b941273092..e6532be84d3 100644 --- a/src/mesa/program/sampler.cpp +++ b/src/mesa/program/sampler.cpp @@ -111,7 +111,7 @@ _mesa_get_sampler_uniform_value(class ir_dereference *sampler, { get_sampler_name getname(sampler, shader_program); - GLuint shader = _mesa_program_target_to_index(prog->Target); + GLuint shader = _mesa_program_enum_to_shader_stage(prog->Target); sampler->accept(&getname); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index eb12426a544..b2131ed48b3 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4996,7 +4996,7 @@ st_translate_program( * prog->ParameterValues to get reallocated (e.g., anything that adds a * program constant) has to happen before creating this linkage. */ - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (program->shader_program->_LinkedShaders[i] == NULL) continue; @@ -5037,7 +5037,7 @@ get_mesa_program(struct gl_context *ctx, GLenum target; bool progress; 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)]; struct pipe_screen *pscreen = ctx->st->pipe->screen; unsigned ptarget; @@ -5143,7 +5143,7 @@ get_mesa_program(struct gl_context *ctx, if (ctx->Shader.Flags & GLSL_DUMP) { printf("\n"); printf("GLSL IR for linked %s program %d:\n", - _mesa_shader_enum_to_string(shader->Type), + _mesa_progshader_enum_to_string(shader->Type), shader_program->Name); _mesa_print_ir(shader->ir, NULL); printf("\n"); @@ -5236,14 +5236,14 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) { assert(prog->LinkStatus); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; bool progress; exec_list *ir = prog->_LinkedShaders[i]->ir; const struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)]; + &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type)]; /* If there are forms of indirect addressing that the driver * cannot handle, perform the lowering pass. @@ -5306,7 +5306,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) validate_ir_tree(ir); } - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_program *linked_prog; if (prog->_LinkedShaders[i] == NULL)