summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-08-09 20:59:44 -0600
committerBrian Paul <[email protected]>2012-08-16 09:01:31 -0600
commita2c1df4c9a7375bc5306e8cfd07a9f7087759a96 (patch)
tree92691c4d7786bd2decc45a393f4b5b2e496e685f
parentbef196c7929606bb8c7e9c06fe83a90fc0d95f09 (diff)
draw: index samplers and sampler_view state by shader type
So that we can handle GS state and other types of shaders in the future.
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c34
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c16
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h13
3 files changed, 34 insertions, 29 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 3c9c7f1690e..9ca4191aee2 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -760,16 +760,15 @@ draw_set_sampler_views(struct draw_context *draw,
{
unsigned i;
- if (shader_stage == PIPE_SHADER_VERTEX) {
- debug_assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+ debug_assert(num <= Elements(draw->sampler_views));
+ debug_assert(shader_stage <= PIPE_SHADER_TYPES);
- for (i = 0; i < num; ++i)
- draw->sampler_views[i] = views[i];
- for (i = num; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
- draw->sampler_views[i] = NULL;
+ for (i = 0; i < num; ++i)
+ draw->sampler_views[shader_stage][i] = views[i];
+ for (i = num; i < Elements(draw->sampler_views); ++i)
+ draw->sampler_views[shader_stage][i] = NULL;
- draw->num_sampler_views = num;
- }
+ draw->num_sampler_views[shader_stage] = num;
}
void
@@ -780,21 +779,20 @@ draw_set_samplers(struct draw_context *draw,
{
unsigned i;
- if (shader_stage == PIPE_SHADER_VERTEX) {
- debug_assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+ debug_assert(num <= Elements(draw->samplers));
+ debug_assert(shader_stage <= PIPE_SHADER_TYPES);
- for (i = 0; i < num; ++i)
- draw->samplers[i] = samplers[i];
- for (i = num; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
- draw->samplers[i] = NULL;
+ for (i = 0; i < num; ++i)
+ draw->samplers[shader_stage][i] = samplers[i];
+ for (i = num; i < Elements(draw->samplers); ++i)
+ draw->samplers[shader_stage][i] = NULL;
- draw->num_samplers = num;
+ draw->num_samplers[shader_stage] = num;
#ifdef HAVE_LLVM
- if (draw->llvm)
- draw_llvm_set_sampler_state(draw);
+ if (draw->llvm && shader_stage == PIPE_SHADER_VERTEX)
+ draw_llvm_set_sampler_state(draw);
#endif
- }
}
void
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 3400661fb29..133aa5f6983 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1351,8 +1351,8 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
for (i = 0 ; i < key->nr_samplers; i++) {
lp_sampler_static_state(&sampler[i],
- llvm->draw->sampler_views[i],
- llvm->draw->samplers[i]);
+ llvm->draw->sampler_views[PIPE_SHADER_VERTEX][i],
+ llvm->draw->samplers[PIPE_SHADER_VERTEX][i]);
}
return key;
@@ -1394,14 +1394,16 @@ draw_llvm_set_sampler_state(struct draw_context *draw)
{
unsigned i;
- for (i = 0; i < draw->num_samplers; i++) {
+ for (i = 0; i < draw->num_samplers[PIPE_SHADER_VERTEX]; i++) {
struct draw_jit_texture *jit_tex = &draw->llvm->jit_context.textures[i];
if (draw->samplers[i]) {
- jit_tex->min_lod = draw->samplers[i]->min_lod;
- jit_tex->max_lod = draw->samplers[i]->max_lod;
- jit_tex->lod_bias = draw->samplers[i]->lod_bias;
- COPY_4V(jit_tex->border_color, draw->samplers[i]->border_color.f);
+ const struct pipe_sampler_state *s
+ = draw->samplers[PIPE_SHADER_VERTEX][i];
+ jit_tex->min_lod = s->min_lod;
+ jit_tex->max_lod = s->max_lod;
+ jit_tex->lod_bias = s->lod_bias;
+ COPY_4V(jit_tex->border_color, s->border_color.f);
}
}
}
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 6a085be27fc..c2af0f36bca 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -308,10 +308,15 @@ struct draw_context
struct draw_llvm *llvm;
#endif
- struct pipe_sampler_view *sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
- unsigned num_sampler_views;
- const struct pipe_sampler_state *samplers[PIPE_MAX_VERTEX_SAMPLERS];
- unsigned num_samplers;
+ /** Texture sampler and sampler view state.
+ * Note that we have arrays indexed by shader type. At this time
+ * we only handle vertex and geometry shaders in the draw module, but
+ * there may be more in the future (ex: hull and tessellation).
+ */
+ struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+ unsigned num_sampler_views[PIPE_SHADER_TYPES];
+ const struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+ unsigned num_samplers[PIPE_SHADER_TYPES];
void *driver_private;
};