diff options
author | Zack Rusin <[email protected]> | 2007-09-20 10:07:10 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2007-09-20 10:07:10 -0400 |
commit | 7a06c026ad24b74048f6d125383faf25deb1dfbb (patch) | |
tree | e6422224c0da110d2d2e2349377c29ddc976684f /src/mesa/state_tracker | |
parent | a6c0c5532f7bfa50ae54c36cf4d74ad4b9f926f8 (diff) |
Fix failover state binding and convert the sampler to use the new
state constant state object semantics.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_sampler.c | 10 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cache.c | 22 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cache.h | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 7 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 2 |
5 files changed, 23 insertions, 20 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 994d3691d8b..23ccd55a057 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -123,6 +123,7 @@ update_samplers(struct st_context *st) const struct gl_texture_object *texobj = st->ctx->Texture.Unit[u]._Current; struct pipe_sampler_state sampler; + const struct cso_sampler *cso; memset(&sampler, 0, sizeof(sampler)); @@ -143,13 +144,12 @@ update_samplers(struct st_context *st) /* XXX more sampler state here */ } - const struct pipe_sampler_state *cached_sampler = - st_cached_sampler_state(st, &sampler); + cso = st_cached_sampler_state(st, &sampler); - if (cached_sampler != st->state.sampler[u]) { + if (cso != st->state.sampler[u]) { /* state has changed */ - st->state.sampler[u] = cached_sampler; - st->pipe->bind_sampler_state(st->pipe, u, cached_sampler); + st->state.sampler[u] = cso; + st->pipe->bind_sampler_state(st->pipe, u, cso->data); } } } diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index c1ec130b321..007a2311e98 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -61,21 +61,23 @@ const struct cso_blend * st_cached_blend_state(struct st_context *st, return ((struct cso_blend *)cso_hash_iter_data(iter)); } -struct pipe_sampler_state * st_cached_sampler_state( - struct st_context *st, - const struct pipe_sampler_state *sampler) +const struct cso_sampler * +st_cached_sampler_state(struct st_context *st, + const struct pipe_sampler_state *templ) { - unsigned hash_key = cso_construct_key((void*)sampler, sizeof(struct pipe_sampler_state)); + unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state)); struct cso_hash_iter iter = cso_find_state_template(st->cache, hash_key, CSO_SAMPLER, - (void*)sampler); + (void*)templ); if (cso_hash_iter_is_null(iter)) { - const struct pipe_sampler_state *created_state = st->pipe->create_sampler_state( - st->pipe, sampler); - iter = cso_insert_state(st->cache, hash_key, CSO_SAMPLER, - (void*)created_state); + struct cso_sampler *cso = malloc(sizeof(struct cso_sampler)); + memcpy(&cso->state, templ, sizeof(struct pipe_sampler_state)); + cso->data = st->pipe->create_sampler_state(st->pipe, templ); + if (!cso->data) + cso->data = &cso->state; + iter = cso_insert_state(st->cache, hash_key, CSO_SAMPLER, cso); } - return (struct pipe_sampler_state*)(cso_hash_iter_data(iter)); + return (struct cso_sampler*)(cso_hash_iter_data(iter)); } const struct cso_depth_stencil * diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index 167d9ec11a7..483af6fdb43 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -43,7 +43,7 @@ const struct cso_blend * st_cached_blend_state(struct st_context *st, const struct pipe_blend_state *blend); -struct pipe_sampler_state * +const struct cso_sampler * st_cached_sampler_state(struct st_context *st, const struct pipe_sampler_state *sampler); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 95810b7baf1..d814e341575 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -345,6 +345,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* texture sampling state: */ { struct pipe_sampler_state sampler; + const struct cso_sampler *cso; memset(&sampler, 0, sizeof(sampler)); sampler.wrap_s = PIPE_TEX_WRAP_REPEAT; sampler.wrap_t = PIPE_TEX_WRAP_REPEAT; @@ -352,8 +353,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; - const struct pipe_sampler_state *state = st_cached_sampler_state(ctx->st, &sampler); - pipe->bind_sampler_state(pipe, unit, state); + cso = st_cached_sampler_state(ctx->st, &sampler); + pipe->bind_sampler_state(pipe, unit, cso->data); } /* viewport state: viewport matching window dims */ @@ -396,7 +397,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, pipe->bind_fs_state(pipe, ctx->st->state.fs->data); pipe->bind_vs_state(pipe, ctx->st->state.vs->data); pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]); - pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]); + pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); free_mipmap_tree(pipe, mt); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index b82cf242731..8a57227c84f 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -76,7 +76,7 @@ struct st_context */ struct { const struct cso_blend *blend; - const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct cso_sampler *sampler[PIPE_MAX_SAMPLERS]; const struct cso_depth_stencil *depth_stencil; const struct cso_rasterizer *rasterizer; const struct cso_fragment_shader *fs; |