cell: sync up with sampler/texture state-setting changes
authorBrian <brian.paul@tungstengraphics.com>
Mon, 10 Mar 2008 22:43:36 +0000 (16:43 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Mon, 10 Mar 2008 22:43:36 +0000 (16:43 -0600)
src/gallium/drivers/cell/ppu/cell_context.h
src/gallium/drivers/cell/ppu/cell_pipe_state.c
src/gallium/drivers/cell/ppu/cell_state_emit.c

index bf27289..c568922 100644 (file)
@@ -63,6 +63,7 @@ struct cell_context
 
    const struct pipe_blend_state *blend;
    const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+   uint num_samplers;
    const struct pipe_depth_stencil_alpha_state   *depth_stencil;
    const struct pipe_rasterizer_state *rasterizer;
    const struct cell_vertex_shader_state *vs;
@@ -75,6 +76,7 @@ struct cell_context
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
    struct cell_texture *texture[PIPE_MAX_SAMPLERS];
+   uint num_textures;
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
    struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
index 075e0a0..025ed3b 100644 (file)
@@ -210,15 +210,19 @@ cell_create_sampler_state(struct pipe_context *pipe,
 
 
 static void
-cell_bind_sampler_state(struct pipe_context *pipe,
-                            unsigned unit, void *sampler)
+cell_bind_sampler_states(struct pipe_context *pipe,
+                         unsigned num, void **samplers)
 {
    struct cell_context *cell = cell_context(pipe);
 
    draw_flush(cell->draw);
 
    assert(unit < PIPE_MAX_SAMPLERS);
-   cell->sampler[unit] = (struct pipe_sampler_state *)sampler;
+
+   memcpy(cell->sampler, samplers, num * sizeof(void *));
+   memset(&cell->sampler[num], 0, (PIPE_MAX_SAMPLERS - num) *
+          sizeof(void *));
+   cell->num_samplers = num;
 
    cell->dirty |= CELL_NEW_SAMPLER;
 }
@@ -234,16 +238,24 @@ cell_delete_sampler_state(struct pipe_context *pipe,
 
 
 static void
-cell_set_sampler_texture(struct pipe_context *pipe,
-                         unsigned sampler,
-                         struct pipe_texture *texture)
+cell_set_sampler_textures(struct pipe_context *pipe,
+                          unsigned num, struct pipe_texture **texture)
 {
    struct cell_context *cell = cell_context(pipe);
+   uint i;
+
+   /* Check for no-op */
+   if (num == cell->num_textures &&
+       !memcmp(cell->texture, texture, num * sizeof(struct pipe_texture *)))
+      return;
 
    draw_flush(cell->draw);
 
-   pipe_texture_reference((struct pipe_texture **) &cell->texture[sampler],
-                          texture);
+   for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+      struct pipe_texture *tex = i < num ? texture[i] : NULL;
+
+      pipe_texture_reference((struct pipe_texture **) &cell->texture[i], tex);
+   }
 
    cell_update_texture_mapping(cell);
 
@@ -300,10 +312,10 @@ cell_init_state_functions(struct cell_context *cell)
    cell->pipe.delete_blend_state = cell_delete_blend_state;
 
    cell->pipe.create_sampler_state = cell_create_sampler_state;
-   cell->pipe.bind_sampler_state   = cell_bind_sampler_state;
+   cell->pipe.bind_sampler_states = cell_bind_sampler_states;
    cell->pipe.delete_sampler_state = cell_delete_sampler_state;
 
-   cell->pipe.set_sampler_texture = cell_set_sampler_texture;
+   cell->pipe.set_sampler_textures = cell_set_sampler_textures;
 
    cell->pipe.create_depth_stencil_alpha_state = cell_create_depth_stencil_alpha_state;
    cell->pipe.bind_depth_stencil_alpha_state   = cell_bind_depth_stencil_alpha_state;
index 49c0d13..670eb26 100644 (file)
@@ -77,8 +77,10 @@ cell_emit_state(struct cell_context *cell)
    }
 
    if (cell->dirty & CELL_NEW_SAMPLER) {
-      emit_state_cmd(cell, CELL_CMD_STATE_SAMPLER,
-                     cell->sampler[0], sizeof(struct pipe_sampler_state));
+      if (cell->sampler[0]) {
+         emit_state_cmd(cell, CELL_CMD_STATE_SAMPLER,
+                        cell->sampler[0], sizeof(struct pipe_sampler_state));
+      }
    }
 
    if (cell->dirty & CELL_NEW_TEXTURE) {