diff options
author | Brian Paul <[email protected]> | 2009-08-21 12:11:44 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-08-21 12:44:04 -0600 |
commit | a29447c33d44b3427e0c40a761067c0cc6e71c39 (patch) | |
tree | d9ffe18d8d6797787aa39d444b54dc9e6af60ad7 /src/gallium | |
parent | 87ec83afd58536c31bf02c307f1d5488abc84861 (diff) |
softpipe: per-unit sampler varients
Can't share sampler varients across multiple tex units because the texture
pointer is in the sampler varient. That prevents different textures per unit.
Fixes progs/demos/multiarb, progs/glsl/samplers, etc.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_state_sampler.c | 24 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.h | 3 |
3 files changed, 25 insertions, 5 deletions
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index 714e6380487..53210812f40 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -123,9 +123,19 @@ softpipe_set_sampler_textures(struct pipe_context *pipe, } - +/** + * Find/create an sp_sampler_varient object for sampling the given texture, + * sampler and tex unit. + * + * Note that the tex unit is significant. We can't re-use a sampler + * varient for multiple texture units because the sampler varient contains + * the texture object pointer. If the texture object pointer were stored + * somewhere outside the sampler varient, we could re-use samplers for + * multiple texture units. + */ static struct sp_sampler_varient * -get_sampler_varient( struct sp_sampler *sampler, +get_sampler_varient( unsigned unit, + struct sp_sampler *sampler, struct pipe_texture *texture, unsigned processor ) { @@ -133,9 +143,13 @@ get_sampler_varient( struct sp_sampler *sampler, struct sp_sampler_varient *v = NULL; union sp_sampler_key key; + /* if this fails, widen the key.unit field and update this assertion */ + assert(PIPE_MAX_SAMPLERS <= 16); + key.bits.target = sp_texture->base.target; key.bits.is_pot = sp_texture->pot; key.bits.processor = processor; + key.bits.unit = unit; key.bits.pad = 0; if (sampler->current && @@ -174,7 +188,8 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe) for (i = 0; i <= softpipe->vs->max_sampler; i++) { if (softpipe->sampler[i]) { softpipe->tgsi.vert_samplers_list[i] = - get_sampler_varient( sp_sampler(softpipe->sampler[i]), + get_sampler_varient( i, + sp_sampler(softpipe->sampler[i]), softpipe->texture[i], TGSI_PROCESSOR_VERTEX ); @@ -187,7 +202,8 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe) for (i = 0; i <= softpipe->fs->info.file_max[TGSI_FILE_SAMPLER]; i++) { if (softpipe->sampler[i]) { softpipe->tgsi.frag_samplers_list[i] = - get_sampler_varient( sp_sampler(softpipe->sampler[i]), + get_sampler_varient( i, + sp_sampler(softpipe->sampler[i]), softpipe->texture[i], TGSI_PROCESSOR_FRAGMENT ); diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index f3710037082..8f3dc12d0fa 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -1545,6 +1545,9 @@ static filter_func get_img_filter( const union sp_sampler_key key, } +/** + * Bind the given texture object and texture cache to the sampler varient. + */ void sp_sampler_varient_bind_texture( struct sp_sampler_varient *samp, struct softpipe_tile_cache *tex_cache, diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.h b/src/gallium/drivers/softpipe/sp_tex_sample.h index 26f80eb88a8..f6cd57ec0ac 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.h +++ b/src/gallium/drivers/softpipe/sp_tex_sample.h @@ -62,7 +62,8 @@ union sp_sampler_key { unsigned target:3; unsigned is_pot:1; unsigned processor:2; - unsigned pad:26; + unsigned unit:4; + unsigned pad:22; } bits; unsigned value; }; |