Commit 665b8d7b authored by Paul Berry's avatar Paul Berry

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: default avatarKenneth 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: default avatarBrian Paul <brianp@vmware.com>
parent eda21d2a
This diff is collapsed.
......@@ -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);
}
......
......@@ -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;
......
......@@ -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");
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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();
......
......@@ -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
......
......@@ -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]);