* Brian Paul
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "sp_context.h"
#include "sp_state.h"
#include "sp_texture.h"
-#include "sp_tile_cache.h"
+#include "sp_tex_tile_cache.h"
#include "draw/draw_context.h"
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);
- softpipe->texture[unit] = softpipe_texture(texture); /* ptr, not struct */
+ 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_tex_tile_cache_set_texture(softpipe->tex_cache[i], tex);
+ }
- sp_tile_cache_set_texture(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 );
+}
+
+