From c3af68dc5022715cc8f126b7df12f3f5248aefe7 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 11 Dec 2007 14:39:37 +0000 Subject: gallium: remove set_sampler_units interface The effect of this mapping can be acheived by the state tracker and setting up the pipe texture state pointers to incorporate its affects. --- src/mesa/state_tracker/st_atom_sampler.c | 15 +-------------- src/mesa/state_tracker/st_atom_texture.c | 32 ++++++++++++++++++++----------- src/mesa/state_tracker/st_cb_drawpixels.c | 4 ++-- src/mesa/state_tracker/st_cb_texture.c | 4 ++-- src/mesa/state_tracker/st_cb_texture.h | 3 ++- src/mesa/state_tracker/st_context.h | 2 +- 6 files changed, 29 insertions(+), 31 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 67a9159069..052b6dd144 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -172,26 +172,13 @@ update_samplers(struct st_context *st) st->pipe->bind_sampler_state(st->pipe, u, cso->data); } } - - - /* mapping from sampler vars to texture units */ - { - struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current; - uint sample_units[PIPE_MAX_SAMPLERS]; - uint s; - for (s = 0; s < PIPE_MAX_SAMPLERS; s++) { - sample_units[s] = fprog->Base.SamplerUnits[s]; - } - - st->pipe->set_sampler_units(st->pipe, PIPE_MAX_SAMPLERS, sample_units); - } } const struct st_tracked_state st_update_sampler = { .name = "st_update_sampler", .dirty = { - .mesa = _NEW_TEXTURE | _NEW_PROGRAM, + .mesa = _NEW_TEXTURE, .st = 0, }, .update = update_samplers diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index c4e5af02d5..fb21d29c40 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -46,20 +46,24 @@ static void update_textures(struct st_context *st) { - GLuint u; + GLuint s; - for (u = 0; u < st->ctx->Const.MaxTextureImageUnits; u++) { + /* ST_NEW_FRAGMENT_PROGRAM + */ + struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current; + + for (s = 0; s < st->ctx->Const.MaxTextureCoordUnits; s++) { + GLuint su = fprog->Base.SamplerUnits[s]; + struct gl_texture_object *texObj - = st->ctx->Texture.Unit[u]._Current; + = st->ctx->Texture.Unit[su]._Current; + struct pipe_texture *pt; + if (texObj) { GLboolean flush, retval; - retval = st_finalize_texture(st->ctx, st->pipe, u, &flush); -#if 0 - printf("finalize_texture returned %d, flush = %d\n", - retval, flush); -#endif + retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush); pt = st_get_texobj_texture(texObj); } @@ -67,8 +71,14 @@ update_textures(struct st_context *st) pt = NULL; } - st->state.texture[u] = pt; - st->pipe->set_texture_state(st->pipe, u, pt); + /* XXX: need to ensure that textures are unbound/removed from + * this table before being deleted, otherwise the pointer + * comparison below could fail. + */ + if (st->state.sampler_texture[s] != pt) { + st->state.sampler_texture[s] = pt; + st->pipe->set_sampler_texture(st->pipe, s, pt); + } } } @@ -77,7 +87,7 @@ const struct st_tracked_state st_update_texture = { .name = "st_update_texture", .dirty = { .mesa = _NEW_TEXTURE, - .st = 0, + .st = ST_NEW_FRAGMENT_PROGRAM, }, .update = update_textures }; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 0179000353..5d4c443c01 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -697,7 +697,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* texture state: */ { - pipe->set_texture_state(pipe, unit, pt); + pipe->set_sampler_texture(pipe, unit, pt); } /* Compute window coords (y=0=bottom) with pixel zoom. @@ -719,7 +719,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data); 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->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]); pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 2c93a2f3dd..39dd21dc59 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1412,10 +1412,10 @@ copy_image_data_to_texture(struct st_context *st, */ GLboolean st_finalize_texture(GLcontext *ctx, - struct pipe_context *pipe, GLuint unit, + struct pipe_context *pipe, + struct gl_texture_object *tObj, GLboolean *needFlush) { - struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current; struct st_texture_object *stObj = st_texture_object(tObj); int comp_byte = 0; int cpp; diff --git a/src/mesa/state_tracker/st_cb_texture.h b/src/mesa/state_tracker/st_cb_texture.h index 7f8082b029..878256ec26 100644 --- a/src/mesa/state_tracker/st_cb_texture.h +++ b/src/mesa/state_tracker/st_cb_texture.h @@ -8,7 +8,8 @@ st_get_texobj_texture(struct gl_texture_object *texObj); extern GLboolean st_finalize_texture(GLcontext *ctx, - struct pipe_context *pipe, GLuint unit, + struct pipe_context *pipe, + struct gl_texture_object *tObj, GLboolean *needFlush); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 4855961d09..87646b3c71 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -106,7 +106,7 @@ struct st_context struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; struct pipe_framebuffer_state framebuffer; - struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; + struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS]; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct pipe_viewport_state viewport; -- cgit v1.2.3