summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2008-02-12 16:06:51 -0700
committerBrian <brian.paul@tungstengraphics.com>2008-02-12 16:06:51 -0700
commit6d53b8f42349c507e7184aa567a4b2a4fc7b037f (patch)
tree7eab622bc8eac05929888e44c6217d3d654bc28c
parentcf949411221211a278c169e917756aa4f9aba49f (diff)
gallium: move gen-mipmap global/static vars into st_context
This fixes potential problems with multi-context programs.
-rw-r--r--src/mesa/state_tracker/st_context.h9
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c41
2 files changed, 22 insertions, 28 deletions
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index a756055898..59d1590f05 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -166,6 +166,15 @@ struct st_context
struct st_fragment_program *combined_prog;
} bitmap;
+ /** For gen/render mipmap feature */
+ struct {
+ void *blend_cso;
+ void *depthstencil_cso;
+ void *rasterizer_cso;
+ struct st_fragment_program *stfp;
+ struct st_vertex_program *stvp;
+ } gen_mipmap;
+
struct cso_cache *cache;
};
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index fd7d8cefea..b4a21fd7e2 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -48,15 +48,6 @@
-static void *blend_cso = NULL;
-static void *depthstencil_cso = NULL;
-static void *rasterizer_cso = NULL;
-
-static struct st_fragment_program *stfp = NULL;
-static struct st_vertex_program *stvp = NULL;
-
-
-
static struct st_fragment_program *
make_tex_fragment_program(GLcontext *ctx)
{
@@ -119,20 +110,18 @@ st_init_generate_mipmap(struct st_context *st)
struct pipe_rasterizer_state rasterizer;
struct pipe_depth_stencil_alpha_state depthstencil;
- assert(!blend_cso);
-
memset(&blend, 0, sizeof(blend));
blend.colormask = PIPE_MASK_RGBA;
- blend_cso = pipe->create_blend_state(pipe, &blend);
+ st->gen_mipmap.blend_cso = pipe->create_blend_state(pipe, &blend);
memset(&depthstencil, 0, sizeof(depthstencil));
- depthstencil_cso = pipe->create_depth_stencil_alpha_state(pipe, &depthstencil);
+ st->gen_mipmap.depthstencil_cso = pipe->create_depth_stencil_alpha_state(pipe, &depthstencil);
memset(&rasterizer, 0, sizeof(rasterizer));
- rasterizer_cso = pipe->create_rasterizer_state(pipe, &rasterizer);
+ st->gen_mipmap.rasterizer_cso = pipe->create_rasterizer_state(pipe, &rasterizer);
- stfp = make_tex_fragment_program(st->ctx);
- stvp = st_make_passthrough_vertex_shader(st, GL_FALSE);
+ st->gen_mipmap.stfp = make_tex_fragment_program(st->ctx);
+ st->gen_mipmap.stvp = st_make_passthrough_vertex_shader(st, GL_FALSE);
}
@@ -141,15 +130,11 @@ st_destroy_generate_mipmpap(struct st_context *st)
{
struct pipe_context *pipe = st->pipe;
- pipe->delete_blend_state(pipe, blend_cso);
- pipe->delete_depth_stencil_alpha_state(pipe, depthstencil_cso);
- pipe->delete_rasterizer_state(pipe, rasterizer_cso);
+ pipe->delete_blend_state(pipe, st->gen_mipmap.blend_cso);
+ pipe->delete_depth_stencil_alpha_state(pipe, st->gen_mipmap.depthstencil_cso);
+ pipe->delete_rasterizer_state(pipe, st->gen_mipmap.rasterizer_cso);
/* XXX free stfp, stvp */
-
- blend_cso = NULL;
- depthstencil_cso = NULL;
- rasterizer_cso = NULL;
}
@@ -263,13 +248,13 @@ st_render_mipmap(struct st_context *st,
/* bind CSOs */
- pipe->bind_blend_state(pipe, blend_cso);
- pipe->bind_depth_stencil_alpha_state(pipe, depthstencil_cso);
- pipe->bind_rasterizer_state(pipe, rasterizer_cso);
+ pipe->bind_blend_state(pipe, st->gen_mipmap.blend_cso);
+ pipe->bind_depth_stencil_alpha_state(pipe, st->gen_mipmap.depthstencil_cso);
+ pipe->bind_rasterizer_state(pipe, st->gen_mipmap.rasterizer_cso);
/* bind shaders */
- pipe->bind_fs_state(pipe, stfp->fs->data);
- pipe->bind_vs_state(pipe, stvp->cso->data);
+ pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->fs->data);
+ pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->cso->data);
/*
* XXX for small mipmap levels, it may be faster to use the software