set_shader_inout_layout(struct gl_shader *shader,
struct _mesa_glsl_parse_state *state)
{
- if (shader->Type != GL_GEOMETRY_SHADER) {
+ if (shader->Stage != MESA_SHADER_GEOMETRY) {
/* Should have been prevented by the parser. */
assert(!state->gs_input_prim_type_specified);
assert(!state->out_qualifier->flags.i);
if (!state->error && !shader->ir->is_empty()) {
struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)];
+ &ctx->ShaderCompilerOptions[shader->Stage];
/* Do some optimization at compile time to reduce shader IR size
* and reduce later work if the same shader is linked multiple times
const gl_shader *consumer)
{
interface_block_definitions definitions;
- const bool extra_array_level = consumer->Type == GL_GEOMETRY_SHADER;
+ const bool extra_array_level = consumer->Stage == MESA_SHADER_GEOMETRY;
/* Add input interfaces from the consumer to the symbol table. */
foreach_list(node, consumer->ir) {
const unsigned producer_base = VARYING_SLOT_VAR0;
const unsigned consumer_base = VARYING_SLOT_VAR0;
varying_matches matches(ctx->Const.DisableVaryingPacking,
- consumer && consumer->Type == GL_FRAGMENT_SHADER);
+ consumer && consumer->Stage == MESA_SHADER_FRAGMENT);
hash_table *tfeedback_candidates
= hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);
hash_table *consumer_inputs
linker_error(prog, "%s shader varying %s not written "
"by %s shader\n.",
- _mesa_progshader_enum_to_string(consumer->Type),
+ _mesa_shader_stage_to_string(consumer->Stage),
var->name,
- _mesa_progshader_enum_to_string(producer->Type));
+ _mesa_shader_stage_to_string(producer->Stage));
}
/* An 'in' variable is only really a shader input if its
}
unsigned max_output_components;
- switch (producer->Type) {
- case GL_VERTEX_SHADER:
+ switch (producer->Stage) {
+ case MESA_SHADER_VERTEX:
max_output_components = ctx->Const.VertexProgram.MaxOutputComponents;
break;
- case GL_GEOMETRY_SHADER:
+ case MESA_SHADER_GEOMETRY:
max_output_components = ctx->Const.GeometryProgram.MaxOutputComponents;
break;
- case GL_FRAGMENT_SHADER:
+ case MESA_SHADER_FRAGMENT:
default:
assert(!"Should not get here.");
return false;
}
unsigned max_input_components;
- switch (consumer->Type) {
- case GL_GEOMETRY_SHADER:
+ switch (consumer->Stage) {
+ case MESA_SHADER_GEOMETRY:
max_input_components = ctx->Const.GeometryProgram.MaxInputComponents;
break;
- case GL_FRAGMENT_SHADER:
+ case MESA_SHADER_FRAGMENT:
max_input_components = ctx->Const.FragmentProgram.MaxInputComponents;
break;
- case GL_VERTEX_SHADER:
+ case MESA_SHADER_VERTEX:
default:
assert(!"Should not get here.");
return false;
if (clip_vertex.variable_found() && clip_distance.variable_found()) {
linker_error(prog, "%s shader writes to both `gl_ClipVertex' "
"and `gl_ClipDistance'\n",
- _mesa_progshader_enum_to_string(shader->Type));
+ _mesa_shader_stage_to_string(shader->Stage));
return;
}
*UsesClipDistance = clip_distance.variable_found();
/* No in/out qualifiers defined for anything but GLSL 1.50+
* geometry shaders so far.
*/
- if (linked_shader->Type != GL_GEOMETRY_SHADER || prog->Version < 150)
+ if (linked_shader->Stage != MESA_SHADER_GEOMETRY || prog->Version < 150)
return;
/* From the GLSL 1.50 spec, page 46:
if (main == NULL) {
linker_error(prog, "%s shader lacks `main'\n",
- _mesa_progshader_enum_to_string(shader_list[0]->Type));
+ _mesa_shader_stage_to_string(shader_list[0]->Stage));
return NULL;
}
validate_ir_tree(linked->ir);
/* Set the size of geometry shader input arrays */
- if (linked->Type == GL_GEOMETRY_SHADER) {
+ if (linked->Stage == MESA_SHADER_GEOMETRY) {
unsigned num_vertices = vertices_per_prim(prog->Geom.InputType);
geom_array_resize_visitor input_resize_visitor(num_vertices, prog);
foreach_iter(exec_list_iterator, iter, *linked->ir) {
goto done;
}
- switch (prog->Shaders[i]->Type) {
- case GL_VERTEX_SHADER:
+ switch (prog->Shaders[i]->Stage) {
+ case MESA_SHADER_VERTEX:
vert_shader_list[num_vert_shaders] = prog->Shaders[i];
num_vert_shaders++;
break;
- case GL_FRAGMENT_SHADER:
+ case MESA_SHADER_FRAGMENT:
frag_shader_list[num_frag_shaders] = prog->Shaders[i];
num_frag_shaders++;
break;
- case GL_GEOMETRY_SHADER:
+ case MESA_SHADER_GEOMETRY:
geom_shader_list[num_geom_shaders] = prog->Shaders[i];
num_geom_shaders++;
break;
gs_input_vertices, &new_instructions);
visitor.run(instructions);
if (mode == ir_var_shader_out) {
- if (shader->Type == GL_GEOMETRY_SHADER) {
+ if (shader->Stage == MESA_SHADER_GEOMETRY) {
/* For geometry shaders, outputs need to be lowered before each call
* to EmitVertex()
*/
tfeedback_decl *tfeedback_decls)
{
/* Lower the gl_FragData array to separate variables. */
- if (consumer && consumer->Type == GL_FRAGMENT_SHADER) {
+ if (consumer && consumer->Stage == MESA_SHADER_FRAGMENT) {
lower_fragdata_array(consumer->ir);
}
* This doesn't prevent elimination of the gl_TexCoord elements which
* are not read by the fragment shader. We want to eliminate those anyway.
*/
- if (consumer->Type == GL_FRAGMENT_SHADER) {
+ if (consumer->Stage == MESA_SHADER_FRAGMENT) {
producer_info.texcoord_usage = (1 << MAX_TEXTURE_COORD_UNITS) - 1;
}
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("\n");
printf("GLSL IR for linked %s program %d:\n",
- _mesa_progshader_enum_to_string(shader->base.Type), shProg->Name);
+ _mesa_shader_stage_to_string(shader->base.Stage),
+ shProg->Name);
_mesa_print_ir(shader->base.ir, NULL);
printf("\n");
}
continue;
printf("GLSL %s shader %d source for linked program %d:\n",
- _mesa_progshader_enum_to_string(sh->Type),
+ _mesa_shader_stage_to_string(sh->Stage),
i,
shProg->Name);
printf("%s", sh->Source);
brw_create_constant_surface(brw, bo, binding->Offset,
bo->size - binding->Offset,
&surf_offsets[i],
- shader->Type == GL_FRAGMENT_SHADER);
+ shader->Stage == MESA_SHADER_FRAGMENT);
}
if (shader->NumUniformBlocks)
if (!sh)
return;
- options = &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(sh->Type)];
+ options = &ctx->ShaderCompilerOptions[sh->Stage];
/* 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_progshader_enum_to_string(sh->Type), sh->Name);
+ _mesa_shader_stage_to_string(sh->Stage), 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_progshader_enum_to_string(sh->Type), sh->Name);
+ _mesa_shader_stage_to_string(sh->Stage), 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_progshader_enum_to_string(shProg->Shaders[i]->Type),
+ _mesa_shader_stage_to_string(shProg->Shaders[i]->Stage),
shProg->Shaders[i]->Name,
shProg->Shaders[i]->SourceChecksum);
}
struct gl_program_parameter_list
*params)
{
- add_uniform_to_shader add(shader_program, params,
- _mesa_shader_enum_to_shader_stage(sh->Type));
+ add_uniform_to_shader add(shader_program, params, sh->Stage);
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_progshader_enum_to_string(shader->Type);
+ const char *target_string = _mesa_shader_stage_to_string(shader->Stage);
struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)];
+ &ctx->ShaderCompilerOptions[shader->Stage];
- switch (shader->Type) {
- case GL_VERTEX_SHADER:
+ switch (shader->Stage) {
+ case MESA_SHADER_VERTEX:
target = GL_VERTEX_PROGRAM_ARB;
break;
- case GL_FRAGMENT_SHADER:
+ case MESA_SHADER_FRAGMENT:
target = GL_FRAGMENT_PROGRAM_ARB;
break;
- case GL_GEOMETRY_SHADER:
+ case MESA_SHADER_GEOMETRY:
target = GL_GEOMETRY_PROGRAM_NV;
break;
default:
bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir;
const struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type)];
+ &ctx->ShaderCompilerOptions[prog->_LinkedShaders[i]->Stage];
do {
progress = false;
void
_mesa_write_shader_to_file(const struct gl_shader *shader)
{
- const char *type;
+ const char *type = "????";
char filename[100];
FILE *f;
- if (shader->Type == GL_FRAGMENT_SHADER)
+ switch (shader->Stage) {
+ case MESA_SHADER_FRAGMENT:
type = "frag";
- else if (shader->Type == GL_VERTEX_SHADER)
+ break;
+ case MESA_SHADER_VERTEX:
type = "vert";
- else
+ break;
+ case MESA_SHADER_GEOMETRY:
type = "geom";
+ break;
+ }
_mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type);
f = fopen(filename, "w");
char filename[100];
FILE *f;
- if (shader->Type == GL_FRAGMENT_SHADER)
+ if (shader->Stage == MESA_SHADER_FRAGMENT)
type = "frag";
else
type = "vert";