gallium: use cso_destroy_vertex/fragment_shader() functions

Also, rearrange the st_destroy_context() code a bit to prevent some
invalid/NULL ptr derefs during tear-down.
This commit is contained in:
Brian Paul
2008-04-24 12:11:24 -06:00
parent 386102c62a
commit a770d40c3d
5 changed files with 18 additions and 13 deletions

View File

@@ -803,7 +803,7 @@ st_destroy_bitmap(struct st_context *st)
}
#endif
if (st->bitmap.vs) {
pipe->delete_vs_state(pipe, st->bitmap.vs);
cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);
st->bitmap.vs = NULL;
}

View File

@@ -98,11 +98,11 @@ st_destroy_clear(struct st_context *st)
struct pipe_context *pipe = st->pipe;
if (st->clear.fs) {
pipe->delete_fs_state(pipe, st->clear.fs);
cso_delete_fragment_shader(st->cso_context, st->clear.fs);
st->clear.fs = NULL;
}
if (st->clear.vs) {
pipe->delete_vs_state(pipe, st->clear.vs);
cso_delete_vertex_shader(st->cso_context, st->clear.vs);
st->clear.vs = NULL;
}
if (st->clear.vbuf) {

View File

@@ -39,7 +39,7 @@
#include "shader/programopt.h"
#include "shader/shader_api.h"
#include "cso_cache/cso_cache.h"
#include "cso_cache/cso_context.h"
#include "draw/draw_context.h"
#include "st_context.h"
@@ -127,7 +127,6 @@ void
st_delete_program(GLcontext *ctx, struct gl_program *prog)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
switch( prog->Target ) {
case GL_VERTEX_PROGRAM_ARB:
@@ -135,7 +134,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
if (stvp->driver_shader) {
pipe->delete_vs_state(pipe, stvp->driver_shader);
cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
stvp->driver_shader = NULL;
}
@@ -150,7 +149,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
if (stfp->driver_shader) {
pipe->delete_fs_state(pipe, stfp->driver_shader);
cso_delete_fragment_shader(st->cso_context, stfp->driver_shader);
stfp->driver_shader = NULL;
}
@@ -187,7 +186,6 @@ static void st_program_string_notify( GLcontext *ctx,
struct gl_program *prog )
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
if (target == GL_FRAGMENT_PROGRAM_ARB) {
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
@@ -195,7 +193,7 @@ static void st_program_string_notify( GLcontext *ctx,
stfp->serialNo++;
if (stfp->driver_shader) {
pipe->delete_fs_state(pipe, stfp->driver_shader);
cso_delete_fragment_shader(st->cso_context, stfp->driver_shader);
stfp->driver_shader = NULL;
}
@@ -215,7 +213,7 @@ static void st_program_string_notify( GLcontext *ctx,
stvp->serialNo++;
if (stvp->driver_shader) {
pipe->delete_vs_state(pipe, stvp->driver_shader);
cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
stvp->driver_shader = NULL;
}

View File

@@ -176,22 +176,29 @@ static void st_destroy_context_priv( struct st_context *st )
}
}
st->pipe->destroy( st->pipe );
free( st );
}
void st_destroy_context( struct st_context *st )
{
struct pipe_context *pipe = st->pipe;
struct cso_context *cso = st->cso_context;
GLcontext *ctx = st->ctx;
/* need to unbind and destroy CSO objects before anything else */
cso_destroy_context(st->cso_context);
cso_release_all(st->cso_context);
_mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache);
_mesa_free_context_data(ctx);
st_destroy_context_priv(st);
cso_destroy_context(cso);
pipe->destroy( pipe );
free(ctx);
}

View File

@@ -270,7 +270,7 @@ st_translate_vertex_program(struct st_context *st,
stvp->state.tokens = NULL;
}
if (stvp->driver_shader) {
pipe->delete_vs_state(pipe, stvp->driver_shader);
cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
stvp->driver_shader = NULL;
}