gallium: clean-up glDraw/CopyPixels shaders when destroying context
This commit is contained in:
@@ -164,14 +164,16 @@ static struct st_fragment_program *
|
|||||||
make_fragment_shader_z(struct st_context *st)
|
make_fragment_shader_z(struct st_context *st)
|
||||||
{
|
{
|
||||||
GLcontext *ctx = st->ctx;
|
GLcontext *ctx = st->ctx;
|
||||||
/* only make programs once and re-use */
|
|
||||||
static struct st_fragment_program *stfp = NULL;
|
|
||||||
struct gl_program *p;
|
struct gl_program *p;
|
||||||
GLuint ic = 0;
|
GLuint ic = 0;
|
||||||
|
|
||||||
if (stfp)
|
if (st->drawpix.z_shader) {
|
||||||
return stfp;
|
return st->drawpix.z_shader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create shader now
|
||||||
|
*/
|
||||||
p = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
|
p = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -213,10 +215,10 @@ make_fragment_shader_z(struct st_context *st)
|
|||||||
p->OutputsWritten = (1 << FRAG_RESULT_COLR) | (1 << FRAG_RESULT_DEPR);
|
p->OutputsWritten = (1 << FRAG_RESULT_COLR) | (1 << FRAG_RESULT_DEPR);
|
||||||
p->SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
|
p->SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
|
||||||
|
|
||||||
stfp = (struct st_fragment_program *) p;
|
st->drawpix.z_shader = (struct st_fragment_program *) p;
|
||||||
st_translate_fragment_program(st, stfp, NULL);
|
st_translate_fragment_program(st, st->drawpix.z_shader, NULL);
|
||||||
|
|
||||||
return stfp;
|
return st->drawpix.z_shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,16 +230,17 @@ make_fragment_shader_z(struct st_context *st)
|
|||||||
static struct st_vertex_program *
|
static struct st_vertex_program *
|
||||||
st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor)
|
st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor)
|
||||||
{
|
{
|
||||||
/* only make programs once and re-use */
|
|
||||||
static struct st_vertex_program *progs[2] = { NULL, NULL };
|
|
||||||
GLcontext *ctx = st->ctx;
|
GLcontext *ctx = st->ctx;
|
||||||
struct st_vertex_program *stvp;
|
struct st_vertex_program *stvp;
|
||||||
struct gl_program *p;
|
struct gl_program *p;
|
||||||
GLuint ic = 0;
|
GLuint ic = 0;
|
||||||
|
|
||||||
if (progs[passColor])
|
if (st->drawpix.vert_shaders[passColor])
|
||||||
return progs[passColor];
|
return st->drawpix.vert_shaders[passColor];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create shader now
|
||||||
|
*/
|
||||||
p = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
|
p = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -293,7 +296,7 @@ st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor)
|
|||||||
stvp = (struct st_vertex_program *) p;
|
stvp = (struct st_vertex_program *) p;
|
||||||
st_translate_vertex_program(st, stvp, NULL);
|
st_translate_vertex_program(st, stvp, NULL);
|
||||||
|
|
||||||
progs[passColor] = stvp;
|
st->drawpix.vert_shaders[passColor] = stvp;
|
||||||
|
|
||||||
return stvp;
|
return stvp;
|
||||||
}
|
}
|
||||||
@@ -1042,3 +1045,15 @@ void st_init_drawpixels_functions(struct dd_function_table *functions)
|
|||||||
functions->DrawPixels = st_DrawPixels;
|
functions->DrawPixels = st_DrawPixels;
|
||||||
functions->CopyPixels = st_CopyPixels;
|
functions->CopyPixels = st_CopyPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
st_destroy_drawpix(struct st_context *st)
|
||||||
|
{
|
||||||
|
st_reference_fragprog(st, &st->drawpix.z_shader, NULL);
|
||||||
|
st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL);
|
||||||
|
st_reference_vertprog(st, &st->drawpix.vert_shaders[0], NULL);
|
||||||
|
st_reference_vertprog(st, &st->drawpix.vert_shaders[1], NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -32,5 +32,8 @@
|
|||||||
|
|
||||||
extern void st_init_drawpixels_functions(struct dd_function_table *functions);
|
extern void st_init_drawpixels_functions(struct dd_function_table *functions);
|
||||||
|
|
||||||
|
extern void
|
||||||
|
st_destroy_drawpix(struct st_context *st);
|
||||||
|
|
||||||
|
|
||||||
#endif /* ST_CB_DRAWPIXELS_H */
|
#endif /* ST_CB_DRAWPIXELS_H */
|
||||||
|
@@ -168,6 +168,7 @@ static void st_destroy_context_priv( struct st_context *st )
|
|||||||
st_destroy_bitmap(st);
|
st_destroy_bitmap(st);
|
||||||
st_destroy_blit(st);
|
st_destroy_blit(st);
|
||||||
st_destroy_clear(st);
|
st_destroy_clear(st);
|
||||||
|
st_destroy_drawpix(st);
|
||||||
|
|
||||||
_vbo_DestroyContext(st->ctx);
|
_vbo_DestroyContext(st->ctx);
|
||||||
|
|
||||||
|
@@ -152,6 +152,12 @@ struct st_context
|
|||||||
struct bitmap_cache *cache;
|
struct bitmap_cache *cache;
|
||||||
} bitmap;
|
} bitmap;
|
||||||
|
|
||||||
|
/** for glDraw/CopyPixels */
|
||||||
|
struct {
|
||||||
|
struct st_fragment_program *z_shader;
|
||||||
|
struct st_vertex_program *vert_shaders[2];
|
||||||
|
} drawpix;
|
||||||
|
|
||||||
/** for glClear */
|
/** for glClear */
|
||||||
struct {
|
struct {
|
||||||
struct pipe_shader_state vert_shader;
|
struct pipe_shader_state vert_shader;
|
||||||
|
Reference in New Issue
Block a user