Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / gallium / drivers / softpipe / sp_state_sampler.c
index 18669a1c6ef9445417f2ff5c7ee4015e69574d75..033288a0aa379391387bf4a6504bb672daaaf7be 100644 (file)
@@ -50,45 +50,69 @@ 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);
+   unsigned i;
+
+   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;
+   for (i = 0; i < num; ++i)
+      softpipe->sampler[i] = sampler[i];
+   for (i = num; i < PIPE_MAX_SAMPLERS; ++i)
+      softpipe->sampler[i] = NULL;
+
+   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(pipe, &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 );
+}
+
+