diff options
author | Brian <[email protected]> | 2007-08-23 08:53:43 +0100 |
---|---|---|
committer | Brian <[email protected]> | 2007-08-23 08:53:43 +0100 |
commit | 4b654d41da08b3b5475144c027e97a3ae7ab5696 (patch) | |
tree | 2b19565434268fad9c767e6f39553fffafca7fcf /src/mesa/shader | |
parent | dbef6158c6c19a28dc96a96357c9ed9bd9422b88 (diff) |
For _mesa_share_state(), update the context's references to the new share group's objects (Shane Blackett)
Diffstat (limited to 'src/mesa/shader')
-rw-r--r-- | src/mesa/shader/program.c | 43 | ||||
-rw-r--r-- | src/mesa/shader/program.h | 3 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 1f227390afd..2097c395918 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -118,6 +118,49 @@ _mesa_free_program_data(GLcontext *ctx) } +/** + * Update the default program objects in the given context to reference those + * specified in the shared state and release those referencing the old + * shared state. + */ +void +_mesa_update_default_objects_program(GLcontext *ctx) +{ +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program + if (ctx->VertexProgram.Current) { + ctx->VertexProgram.Current->Base.RefCount--; + if (ctx->VertexProgram.Current->Base.RefCount <= 0) + ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base)); + } + ctx->VertexProgram.Current = (struct gl_vertex_program *) ctx->Shared->DefaultVertexProgram; + assert(ctx->VertexProgram.Current); + ctx->VertexProgram.Current->Base.RefCount++; +#endif + +#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program + if (ctx->FragmentProgram.Current) { + ctx->FragmentProgram.Current->Base.RefCount--; + if (ctx->FragmentProgram.Current->Base.RefCount <= 0) + ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base)); + } + ctx->FragmentProgram.Current = (struct gl_fragment_program *) ctx->Shared->DefaultFragmentProgram; + assert(ctx->FragmentProgram.Current); + ctx->FragmentProgram.Current->Base.RefCount++; +#endif + + /* XXX probably move this stuff */ +#if FEATURE_ATI_fragment_shader + if (ctx->ATIFragmentShader.Current) { + ctx->ATIFragmentShader.Current->RefCount--; + if (ctx->ATIFragmentShader.Current->RefCount <= 0) { + _mesa_free(ctx->ATIFragmentShader.Current); + } + } + ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) ctx->Shared->DefaultFragmentShader; + assert(ctx->ATIFragmentShader.Current); + ctx->ATIFragmentShader.Current->RefCount++; +#endif +} /** diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index 52704856ab0..ea2c8c30508 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -57,6 +57,9 @@ extern void _mesa_free_program_data(GLcontext *ctx); extern void +_mesa_update_default_objects_program(GLcontext *ctx); + +extern void _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string); extern const GLubyte * |