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();
* 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:
* 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;
}
- 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",
* 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))
_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;
* 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 {
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)
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:
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.
}
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;
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");
}
_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 "
& 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
} 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:
"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
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'",
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,
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) {
* "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,
}
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,
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:
*
_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) {
_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,
* 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");
}
* 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");
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 =
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;
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;
}
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
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
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
* 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;
}
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;
}
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);
}
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;
}
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);
}
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);
}
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 */
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");
}
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 {
}
}
- 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;
gen.generate_varyings();
- switch (state->target) {
+ switch (state->stage) {
case MESA_SHADER_VERTEX:
gen.generate_vs_special_vars();
break;
* "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");
{
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");
| 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");
: 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;
* 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:
} /* 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";
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));
}
}
}
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
bool es_shader;
unsigned language_version;
- gl_shader_type target;
+ gl_shader_stage stage;
/**
* Number of nested struct_specifier levels
_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 */
#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);
* 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
active_atomic_counter *counters;
unsigned num_counters;
- unsigned stage_references[MESA_SHADER_TYPES];
+ unsigned stage_references[MESA_SHADER_STAGES];
unsigned size;
};
*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;
}
/* 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);
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;
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) {
}
/* 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)
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) {
}
} 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) {
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) {
{
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)
{
}
- 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;
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,
* 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)
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();
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;
}
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;
}
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;
}
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;
}
"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;
}
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
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();
cross_validate_uniforms(struct gl_shader_program *prog)
{
cross_validate_globals(prog, prog->_LinkedShaders,
- MESA_SHADER_TYPES, true);
+ MESA_SHADER_STAGES, true);
}
/**
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,
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;
}
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;
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;
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,
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,
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)
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]) {
"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));
}
}
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++;
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;
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;
}
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]);
unsigned prev;
- for (prev = 0; prev < MESA_SHADER_TYPES; prev++) {
+ for (prev = 0; prev < MESA_SHADER_STAGES; prev++) {
if (prog->_LinkedShaders[prev] != NULL)
break;
}
/* 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;
/* 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]);
}
* 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;
}
unsigned first;
- for (first = 0; first < MESA_SHADER_TYPES; first++) {
+ for (first = 0; first < MESA_SHADER_STAGES; first++) {
if (prog->_LinkedShaders[first] != NULL)
break;
}
* 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;
}
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;
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);
/* 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));
}
_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:
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;
}
}
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);
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;
}
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;
}
}
/* 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;
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
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;
/* 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
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");
}
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);
#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;
_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;
}
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
GLuint MinimumSize;
/** Shader stages making use of it. */
- GLboolean StageReferences[MESA_SHADER_TYPES];
+ GLboolean StageReferences[MESA_SHADER_STAGES];
};
/**
* 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
* \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];
};
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 */
* 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;
/* 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();
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;
} 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);
}
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);
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);
}
* 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)
{
_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);
struct gl_shader_program *shProg)
{
GLuint i;
- gl_shader_type sh;
+ gl_shader_stage sh;
assert(shProg->Type == GL_SHADER_PROGRAM_MESA);
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;
_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:
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;
}
}
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,
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;
{
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);
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) {
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)
{
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 */
*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();
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:
{
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;
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)
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);
*/
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;
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
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:
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
{
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);
* 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;
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;
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");
{
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.
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)