diff options
author | Timothy Arceri <[email protected]> | 2016-06-30 14:55:40 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-06-30 16:51:25 +1000 |
commit | 1fb8c6df884c2a17cf980c4ea32db4c214903b55 (patch) | |
tree | a21b0de699816ce28de37dd61531a025cc984114 /src/mesa/main/shaderobj.c | |
parent | 378f07ccb5bff7857d87a4fe5dff0b5e83f99895 (diff) |
glsl/mesa: split gl_shader in two
There are two distinctly different uses of this struct. The first
is to store GL shader objects. The second is to store information
about a shader stage thats been linked.
The two uses actually share few fields and there is clearly confusion
about their use. For example the linked shaders map one to one with
a program so can simply be destroyed along with the program. However
previously we were calling reference counting on the linked shaders.
We were also creating linked shaders with a name even though it
is always 0 and called the driver version of the _mesa_new_shader()
function unnecessarily for GL shader objects.
Acked-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/mesa/main/shaderobj.c')
-rw-r--r-- | src/mesa/main/shaderobj.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index f3d5c2ee5ba..93fdc669f2f 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -99,7 +99,6 @@ _mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader) /** * Allocate a new gl_shader object, initialize it. - * Called via ctx->Driver.NewShader() */ struct gl_shader * _mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage) @@ -116,6 +115,22 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage) /** + * Allocate a new gl_linked_shader object. + * Called via ctx->Driver.NewShader() + */ +struct gl_linked_shader * +_mesa_new_linked_shader(gl_shader_stage stage) +{ + struct gl_linked_shader *shader; + shader = rzalloc(NULL, struct gl_linked_shader); + if (shader) { + shader->Stage = stage; + } + return shader; +} + + +/** * Delete a shader object. */ void @@ -123,6 +138,17 @@ _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh) { free((void *)sh->Source); free(sh->Label); + ralloc_free(sh); +} + + +/** + * Delete a shader object. + */ +void +_mesa_delete_linked_shader(struct gl_context *ctx, + struct gl_linked_shader *sh) +{ _mesa_reference_program(ctx, &sh->Program, NULL); ralloc_free(sh); } @@ -360,7 +386,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx, for (sh = 0; sh < MESA_SHADER_STAGES; sh++) { if (shProg->_LinkedShaders[sh] != NULL) { - _mesa_delete_shader(ctx, shProg->_LinkedShaders[sh]); + _mesa_delete_linked_shader(ctx, shProg->_LinkedShaders[sh]); shProg->_LinkedShaders[sh] = NULL; } } @@ -436,6 +462,6 @@ _mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name, void _mesa_init_shader_object_functions(struct dd_function_table *driver) { - driver->NewShader = _mesa_new_shader; + driver->NewShader = _mesa_new_linked_shader; driver->LinkShader = _mesa_ir_link_shader; } |