summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/softpipe/sp_state_sampler.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-03-05 10:50:14 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2008-03-05 10:56:49 +0100
commit4528287e040415c2071012d02f20979ff995c754 (patch)
tree9fbbd0d785c4e9a45ff7c53a8254312bd5ff7bb6 /src/gallium/drivers/softpipe/sp_state_sampler.c
parentb1922de9f3478869c6788ef4e954c06c20e7aa9c (diff)
gallium: michel's patch to rework texture/sampler binding interface
Bind all the samplers/textures at once rather than piecemeal. This is easier for drivers to understand.
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_state_sampler.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 1d6dd17d1d..7cf85b9207 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -50,45 +50,67 @@ softpipe_create_sampler_state(struct pipe_context *pipe,
return mem_dup(sampler, sizeof(*sampler));
}
+
void
-softpipe_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
+softpipe_bind_sampler_states(struct pipe_context *pipe,
+ unsigned num, void **sampler)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
+ assert(num <= PIPE_MAX_SAMPLERS);
+
+ /* Check for no-op */
+ if (num == softpipe->num_samplers &&
+ !memcmp(softpipe->sampler, sampler, num * sizeof(void *)))
+ return;
+
draw_flush(softpipe->draw);
- assert(unit < PIPE_MAX_SAMPLERS);
- softpipe->sampler[unit] = (struct pipe_sampler_state *)sampler;
+ memcpy(softpipe->sampler, sampler, num * sizeof(void *));
+ memset(&softpipe->sampler[num], 0, (PIPE_MAX_SAMPLERS - num) *
+ sizeof(void *));
+
+ softpipe->num_samplers = num;
softpipe->dirty |= SP_NEW_SAMPLER;
}
void
-softpipe_delete_sampler_state(struct pipe_context *pipe,
- void *sampler)
+softpipe_set_sampler_textures(struct pipe_context *pipe,
+ unsigned num, struct pipe_texture **texture)
{
- FREE( sampler );
-}
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+ uint i;
+ assert(num <= PIPE_MAX_SAMPLERS);
-void
-softpipe_set_sampler_texture(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
+ /* Check for no-op */
+ if (num == softpipe->num_textures &&
+ !memcmp(softpipe->texture, texture, num * sizeof(struct pipe_texture *)))
+ return;
draw_flush(softpipe->draw);
- assert(unit < PIPE_MAX_SAMPLERS);
- pipe_texture_reference(&softpipe->texture[unit], texture);
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+ struct pipe_texture *tex = i < num ? texture[i] : NULL;
+
+ pipe_texture_reference(&softpipe->texture[i], tex);
+ sp_tile_cache_set_texture(pipe, softpipe->tex_cache[i], tex);
+ }
- sp_tile_cache_set_texture(pipe, softpipe->tex_cache[unit], texture);
+ softpipe->num_textures = num;
softpipe->dirty |= SP_NEW_TEXTURE;
}
+void
+softpipe_delete_sampler_state(struct pipe_context *pipe,
+ void *sampler)
+{
+ FREE( sampler );
+}
+
+