* GLSL utility code that could be linked against any stage, so just
* arbitrarily pick GL_VERTEX_SHADER.
*/
- shader = _mesa_new_shader(NULL, 0, GL_VERTEX_SHADER);
+ shader = _mesa_new_shader(NULL, 0, MESA_SHADER_VERTEX);
shader->symbols = new(mem_ctx) glsl_symbol_table;
gl_ModelViewProjectionMatrix =
* within a patch and can be used as shared memory.
*/
if (input_var || (prog->SeparateShader && consumer == NULL) ||
- producer->Type == GL_TESS_CONTROL_SHADER) {
+ producer->Stage == MESA_SHADER_TESS_CTRL) {
matches.record(output_var, input_var);
}
return NULL;
}
- gl_shader *linked = ctx->Driver.NewShader(NULL, 0, main->Type);
+ gl_shader *linked = ctx->Driver.NewShader(NULL, 0, shader_list[0]->Stage);
linked->ir = new(linked) exec_list;
clone_ir_list(mem_ctx, linked->ir, main->ir);
continue;
shader->Program = rzalloc(shader, gl_program);
- init_gl_program(shader->Program, shader->Type);
+ init_gl_program(shader->Program, shader->Stage);
}
}
}
struct gl_shader *
-_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
+_mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
{
struct gl_shader *shader;
(void) ctx;
- assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
+ assert(stage == MESA_SHADER_FRAGMENT || stage == MESA_SHADER_VERTEX);
shader = rzalloc(NULL, struct gl_shader);
if (shader) {
- shader->Type = type;
- shader->Stage = _mesa_shader_enum_to_shader_stage(type);
+ shader->Stage = stage;
shader->Name = name;
shader->RefCount = 1;
}
struct gl_shader *sh);
extern "C" struct gl_shader *
-_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
+_mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage);
extern "C" void
_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
level, layer, false, __func__);
}
-struct gl_shader *
-_mesa_meta_compile_shader_with_debug(struct gl_context *ctx, GLenum target,
- const GLcharARB *source)
+static struct gl_shader *
+meta_compile_shader_with_debug(struct gl_context *ctx, gl_shader_stage stage,
+ const GLcharARB *source)
{
const GLuint name = ~0;
struct gl_shader *sh;
- sh = ctx->Driver.NewShader(ctx, name, target);
+ sh = ctx->Driver.NewShader(ctx, name, stage);
sh->Source = strdup(source);
sh->CompileStatus = false;
_mesa_compile_shader(ctx, sh);
sh_prog->NumShaders = 2;
sh_prog->Shaders = malloc(2 * sizeof(struct gl_shader *));
sh_prog->Shaders[0] =
- _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source);
+ meta_compile_shader_with_debug(ctx, MESA_SHADER_VERTEX, vs_source);
sh_prog->Shaders[1] =
- _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source);
+ meta_compile_shader_with_debug(ctx, MESA_SHADER_FRAGMENT, fs_source);
_mesa_meta_link_program_with_debug(ctx, sh_prog);
void
_mesa_meta_drawbuffers_from_bitfield(GLbitfield bits);
-struct gl_shader *
-_mesa_meta_compile_shader_with_debug(struct gl_context *ctx, GLenum target,
- const GLcharARB *source);
-
-
void
_mesa_meta_link_program_with_debug(struct gl_context *ctx,
struct gl_shader_program *sh_prog);
}
extern "C" struct gl_shader *
-brw_new_shader(struct gl_context *ctx, GLuint name, GLuint type)
+brw_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
{
struct brw_shader *shader;
shader = rzalloc(NULL, struct brw_shader);
if (shader) {
- shader->base.Type = type;
- shader->base.Stage = _mesa_shader_enum_to_shader_stage(type);
+ shader->base.Stage = stage;
shader->base.Name = name;
_mesa_init_shader(ctx, &shader->base);
}
struct gl_program *prog);
GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
-struct gl_shader *brw_new_shader(struct gl_context *ctx, GLuint name, GLuint type);
+struct gl_shader *brw_new_shader(struct gl_context *ctx, GLuint name,
+ gl_shader_stage stage);
int type_size_scalar(const struct glsl_type *type);
int type_size_vec4(const struct glsl_type *type);
*/
/*@{*/
struct gl_shader *(*NewShader)(struct gl_context *ctx,
- GLuint name, GLenum type);
+ GLuint name, gl_shader_stage stage);
void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg);
/*@}*/
_mesa_glsl_parse_state *state;
p.mem_ctx = ralloc_context(NULL);
- p.shader = ctx->Driver.NewShader(ctx, 0, GL_FRAGMENT_SHADER);
+ p.shader = ctx->Driver.NewShader(ctx, 0, MESA_SHADER_FRAGMENT);
p.shader->ir = new(p.shader) exec_list;
state = new(p.shader) _mesa_glsl_parse_state(ctx, MESA_SHADER_FRAGMENT,
p.shader);
_mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader");
return;
} else if (same_type_disallowed &&
- shProg->Shaders[i]->Type == sh->Type) {
+ shProg->Shaders[i]->Stage == sh->Stage) {
/* Shader with the same type is already attached to this program,
* OpenGL ES 2.0 and 3.0 specs say:
*
_mesa_HashLockMutex(ctx->Shared->ShaderObjects);
name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1);
- sh = ctx->Driver.NewShader(ctx, name, type);
+ sh = ctx->Driver.NewShader(ctx, name,
+ _mesa_shader_enum_to_shader_stage(type));
+ sh->Type = type;
_mesa_HashInsertLocked(ctx->Shared->ShaderObjects, name, sh);
_mesa_HashUnlockMutex(ctx->Shared->ShaderObjects);
#ifdef DEBUG
/* sanity check - make sure the new list's entries are sensible */
for (j = 0; j < shProg->NumShaders; j++) {
- assert(shProg->Shaders[j]->Type == GL_VERTEX_SHADER ||
- shProg->Shaders[j]->Type == GL_TESS_CONTROL_SHADER ||
- shProg->Shaders[j]->Type == GL_TESS_EVALUATION_SHADER ||
- shProg->Shaders[j]->Type == GL_GEOMETRY_SHADER ||
- shProg->Shaders[j]->Type == GL_FRAGMENT_SHADER);
+ assert(shProg->Shaders[j]->Stage == MESA_SHADER_VERTEX ||
+ shProg->Shaders[j]->Stage == MESA_SHADER_TESS_CTRL ||
+ shProg->Shaders[j]->Stage == MESA_SHADER_TESS_EVAL ||
+ shProg->Shaders[j]->Stage == MESA_SHADER_GEOMETRY ||
+ shProg->Shaders[j]->Stage == MESA_SHADER_FRAGMENT);
assert(shProg->Shaders[j]->RefCount > 0);
}
#endif
shProg->LinkStatus ? "Success" : "Failed");
for (i = 0; i < shProg->NumShaders; i++) {
- printf(" shader %u, type 0x%x\n",
+ printf(" shader %u, stage %u\n",
shProg->Shaders[i]->Name,
- shProg->Shaders[i]->Type);
+ shProg->Shaders[i]->Stage);
}
}
}
* Called via ctx->Driver.NewShader()
*/
struct gl_shader *
-_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
+_mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
{
struct gl_shader *shader;
- assert(_mesa_validate_shader_target(ctx, type));
shader = rzalloc(NULL, struct gl_shader);
if (shader) {
- shader->Type = type;
- shader->Stage = _mesa_shader_enum_to_shader_stage(type);
+ shader->Stage = stage;
shader->Name = name;
_mesa_init_shader(ctx, shader);
}
struct st_vertex_program *stvp;
struct st_fragment_program *stfp;
- switch (shader->Type) {
- case GL_VERTEX_SHADER:
+ switch (shader->Stage) {
+ case MESA_SHADER_VERTEX:
stvp = (struct st_vertex_program *)prog;
stvp->shader_program = shader_program;
break;
- case GL_FRAGMENT_SHADER:
+ case MESA_SHADER_FRAGMENT:
stfp = (struct st_fragment_program *)prog;
stfp->shader_program = shader_program;
break;
GLenum target = _mesa_shader_stage_to_program(shader->Stage);
bool progress;
struct gl_shader_compiler_options *options =
- &ctx->Const.ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)];
+ &ctx->Const.ShaderCompilerOptions[shader->Stage];
struct pipe_screen *pscreen = ctx->st->pipe->screen;
unsigned ptarget = st_shader_stage_to_ptarget(shader->Stage);
/* Perform optimizations on the instructions in the glsl_to_tgsi_visitor. */
v->simplify_cmp();
- if (shader->Type != GL_TESS_CONTROL_SHADER &&
- shader->Type != GL_TESS_EVALUATION_SHADER)
+ if (shader->Stage != MESA_SHADER_TESS_CTRL &&
+ shader->Stage != MESA_SHADER_TESS_EVAL)
v->copy_propagate();
while (v->eliminate_dead_code());
shader->ir = NULL;
/* This must be done before the uniform storage is associated. */
- if (shader->Type == GL_FRAGMENT_SHADER &&
+ if (shader->Stage == MESA_SHADER_FRAGMENT &&
(prog->InputsRead & VARYING_BIT_POS ||
prog->SystemValuesRead & (1 << SYSTEM_VALUE_FRAG_COORD))) {
static const gl_state_index wposTransformState[STATE_LENGTH] = {
struct st_tesseval_program *sttep;
struct st_compute_program *stcp;
- switch (shader->Type) {
- case GL_VERTEX_SHADER:
+ switch (shader->Stage) {
+ case MESA_SHADER_VERTEX:
stvp = (struct st_vertex_program *)prog;
stvp->glsl_to_tgsi = v;
break;
- case GL_FRAGMENT_SHADER:
+ case MESA_SHADER_FRAGMENT:
stfp = (struct st_fragment_program *)prog;
stfp->glsl_to_tgsi = v;
break;
- case GL_GEOMETRY_SHADER:
+ case MESA_SHADER_GEOMETRY:
stgp = (struct st_geometry_program *)prog;
stgp->glsl_to_tgsi = v;
break;
- case GL_TESS_CONTROL_SHADER:
+ case MESA_SHADER_TESS_CTRL:
sttcp = (struct st_tessctrl_program *)prog;
sttcp->glsl_to_tgsi = v;
break;
- case GL_TESS_EVALUATION_SHADER:
+ case MESA_SHADER_TESS_EVAL:
sttep = (struct st_tesseval_program *)prog;
sttep->glsl_to_tgsi = v;
break;
- case GL_COMPUTE_SHADER:
+ case MESA_SHADER_COMPUTE:
stcp = (struct st_compute_program *)prog;
stcp->glsl_to_tgsi = v;
break;
pscreen->get_shader_param(pscreen, ptarget, PIPE_SHADER_CAP_PREFERRED_IR);
if (preferred_ir == PIPE_SHADER_IR_NIR) {
/* TODO only for GLSL VS/FS for now: */
- switch (shader->Type) {
- case GL_VERTEX_SHADER:
- case GL_FRAGMENT_SHADER:
+ switch (shader->Stage) {
+ case MESA_SHADER_VERTEX:
+ case MESA_SHADER_FRAGMENT:
return st_nir_get_mesa_program(ctx, shader_program, shader);
default:
break;
bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir;
- gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type);
+ gl_shader_stage stage = prog->_LinkedShaders[i]->Stage;
const struct gl_shader_compiler_options *options =
&ctx->Const.ShaderCompilerOptions[stage];
unsigned ptarget = st_shader_stage_to_ptarget(stage);