summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-06-05 13:17:51 +1000
committerTimothy Arceri <[email protected]>2016-06-16 10:45:35 +1000
commit31dee99e052902bc08ddbb1009748dc982ac3211 (patch)
tree47e631d7bcd04cc59429b971ce8d685b6cce787b /src/mesa/main
parentbb1292e2261fa591cf66de443a1b0d4eb7f65cb2 (diff)
mesa/glsl: stop using GL shader type internally
Instead use the internal gl_shader_stage enum everywhere. This makes things more consistent and gets rid of unnecessary conversions. Ideally it would be nice to remove the Type field from gl_shader altogether but currently it is used to differentiate between gl_shader and gl_shader_program in the ShaderObjects hash table. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/dd.h2
-rw-r--r--src/mesa/main/ff_fragment_shader.cpp2
-rw-r--r--src/mesa/main/shaderapi.c20
-rw-r--r--src/mesa/main/shaderobj.c6
4 files changed, 15 insertions, 15 deletions
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index de149431572..f918bb6f717 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -784,7 +784,7 @@ struct dd_function_table {
*/
/*@{*/
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);
/*@}*/
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 26bf1625878..4977225220a 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1199,7 +1199,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
_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);
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 9d440a0fd03..00caa1b4459 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -291,7 +291,7 @@ attach_shader(struct gl_context *ctx, GLuint program, GLuint 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:
*
@@ -334,7 +334,9 @@ create_shader(struct gl_context *ctx, GLenum type)
_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);
@@ -456,11 +458,11 @@ detach_shader(struct gl_context *ctx, GLuint program, GLuint shader)
#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
@@ -1117,9 +1119,9 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
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);
}
}
}
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 189317c3a46..8283555740b 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -99,14 +99,12 @@ _mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader)
* 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);
}