summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/failover
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2008-03-05 10:50:14 +0100
committerKeith Whitwell <[email protected]>2008-03-05 10:56:49 +0100
commit4528287e040415c2071012d02f20979ff995c754 (patch)
tree9fbbd0d785c4e9a45ff7c53a8254312bd5ff7bb6 /src/gallium/drivers/failover
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/failover')
-rw-r--r--src/gallium/drivers/failover/fo_context.h7
-rw-r--r--src/gallium/drivers/failover/fo_state.c59
-rw-r--r--src/gallium/drivers/failover/fo_state_emit.c18
3 files changed, 50 insertions, 34 deletions
diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h
index 1dc87291c9f..8f3ad3ee798 100644
--- a/src/gallium/drivers/failover/fo_context.h
+++ b/src/gallium/drivers/failover/fo_context.h
@@ -87,12 +87,15 @@ struct failover_context {
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
+ void *sw_sampler_state[PIPE_MAX_SAMPLERS];
+ void *hw_sampler_state[PIPE_MAX_SAMPLERS];
+
unsigned dirty;
- unsigned dirty_sampler;
- unsigned dirty_texture;
unsigned dirty_vertex_buffer;
unsigned dirty_vertex_element;
+ unsigned num_samplers;
+ unsigned num_textures;
unsigned mode;
struct pipe_context *hw;
diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c
index 0fc5568da11..11eec2714eb 100644
--- a/src/gallium/drivers/failover/fo_state.c
+++ b/src/gallium/drivers/failover/fo_state.c
@@ -28,6 +28,8 @@
/* Authors: Keith Whitwell <[email protected]>
*/
+#include "pipe/p_inlines.h"
+
#include "fo_context.h"
@@ -322,18 +324,27 @@ failover_create_sampler_state(struct pipe_context *pipe,
}
static void
-failover_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
+failover_bind_sampler_states(struct pipe_context *pipe,
+ unsigned num, void **sampler)
{
struct failover_context *failover = failover_context(pipe);
struct fo_state *state = (struct fo_state*)sampler;
- failover->sampler[unit] = state;
+ uint i;
+ assert(num <= PIPE_MAX_SAMPLERS);
+ /* Check for no-op */
+ if (num == failover->num_samplers &&
+ !memcmp(failover->sampler, sampler, num * sizeof(void *)))
+ return;
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+ failover->sw_sampler_state[i] = i < num ? state[i].sw_state : NULL;
+ failover->hw_sampler_state[i] = i < num ? state[i].hw_state : NULL;
+ }
failover->dirty |= FO_NEW_SAMPLER;
- failover->dirty_sampler |= (1<<unit);
- failover->sw->bind_sampler_state(failover->sw, unit,
- state->sw_state);
- failover->hw->bind_sampler_state(failover->hw, unit,
- state->hw_state);
+ failover->num_samplers = num;
+ failover->sw->bind_sampler_states(failover->sw, num,
+ failover->sw_sampler_state);
+ failover->hw->bind_sampler_states(failover->hw, num,
+ failover->hw_sampler_state);
}
static void
@@ -351,17 +362,29 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler)
static void
-failover_set_sampler_texture(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
+failover_set_sampler_textures(struct pipe_context *pipe,
+ unsigned num,
+ struct pipe_texture **texture)
{
struct failover_context *failover = failover_context(pipe);
-
- failover->texture[unit] = texture;
+ uint i;
+
+ assert(num <= PIPE_MAX_SAMPLERS);
+
+ /* Check for no-op */
+ if (num == failover->num_textures &&
+ !memcmp(failover->texture, texture, num * sizeof(struct pipe_texture *)))
+ return;
+ for (i = 0; i < num; i++)
+ pipe_texture_reference((struct pipe_texture **) &failover->texture[i],
+ texture[i]);
+ for (i = num; i < failover->num_textures; i++)
+ pipe_texture_reference((struct pipe_texture **) &failover->texture[i],
+ NULL);
failover->dirty |= FO_NEW_TEXTURE;
- failover->dirty_texture |= (1<<unit);
- failover->sw->set_sampler_texture( failover->sw, unit, texture );
- failover->hw->set_sampler_texture( failover->hw, unit, texture );
+ failover->num_textures = num;
+ failover->sw->set_sampler_textures( failover->sw, num, texture );
+ failover->hw->set_sampler_textures( failover->hw, num, texture );
}
@@ -429,7 +452,7 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.bind_blend_state = failover_bind_blend_state;
failover->pipe.delete_blend_state = failover_delete_blend_state;
failover->pipe.create_sampler_state = failover_create_sampler_state;
- failover->pipe.bind_sampler_state = failover_bind_sampler_state;
+ failover->pipe.bind_sampler_states = failover_bind_sampler_states;
failover->pipe.delete_sampler_state = failover_delete_sampler_state;
failover->pipe.create_depth_stencil_alpha_state = failover_create_depth_stencil_state;
failover->pipe.bind_depth_stencil_alpha_state = failover_bind_depth_stencil_state;
@@ -449,7 +472,7 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
failover->pipe.set_scissor_state = failover_set_scissor_state;
- failover->pipe.set_sampler_texture = failover_set_sampler_texture;
+ failover->pipe.set_sampler_textures = failover_set_sampler_textures;
failover->pipe.set_viewport_state = failover_set_viewport_state;
failover->pipe.set_vertex_buffer = failover_set_vertex_buffer;
failover->pipe.set_vertex_element = failover_set_vertex_element;
diff --git a/src/gallium/drivers/failover/fo_state_emit.c b/src/gallium/drivers/failover/fo_state_emit.c
index c663dd49476..3de931e04eb 100644
--- a/src/gallium/drivers/failover/fo_state_emit.c
+++ b/src/gallium/drivers/failover/fo_state_emit.c
@@ -94,21 +94,13 @@ failover_state_emit( struct failover_context *failover )
failover->sw->set_viewport_state( failover->sw, &failover->viewport );
if (failover->dirty & FO_NEW_SAMPLER) {
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- if (failover->dirty_sampler & (1<<i)) {
- failover->sw->bind_sampler_state( failover->sw, i,
- failover->sampler[i]->sw_state );
- }
- }
+ failover->sw->bind_sampler_states( failover->sw, failover->num_samplers,
+ failover->sw_sampler_state );
}
if (failover->dirty & FO_NEW_TEXTURE) {
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- if (failover->dirty_texture & (1<<i)) {
- failover->sw->set_sampler_texture( failover->sw, i,
- failover->texture[i] );
- }
- }
+ failover->sw->set_sampler_textures( failover->sw, failover->num_textures,
+ failover->texture );
}
if (failover->dirty & FO_NEW_VERTEX_BUFFER) {
@@ -132,6 +124,4 @@ failover_state_emit( struct failover_context *failover )
failover->dirty = 0;
failover->dirty_vertex_element = 0;
failover->dirty_vertex_buffer = 0;
- failover->dirty_texture = 0;
- failover->dirty_sampler = 0;
}