diff options
author | Timothy Arceri <[email protected]> | 2016-06-05 13:17:51 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-06-16 10:45:35 +1000 |
commit | 31dee99e052902bc08ddbb1009748dc982ac3211 (patch) | |
tree | 47e631d7bcd04cc59429b971ce8d685b6cce787b /src/mesa/main/shaderapi.c | |
parent | bb1292e2261fa591cf66de443a1b0d4eb7f65cb2 (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/shaderapi.c')
-rw-r--r-- | src/mesa/main/shaderapi.c | 20 |
1 files changed, 11 insertions, 9 deletions
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); } } } |