summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe
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
commitc969cb1447a0dc0da3cd8016f3e86dcfb381643f (patch)
treed035bdcca442b83509eb634db5ea0f05f4881c8d /src/gallium/drivers/llvmpipe
parent25a42f39e362322dbac836c29b76b3104bbfe6f4 (diff)
llvmpipe: add 'start' parameter to bind_sampler_states/views()
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_sampler.c67
1 files changed, 45 insertions, 22 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
index 8e30b5c634a..0be900ed299 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
@@ -67,26 +67,37 @@ llvmpipe_create_sampler_state(struct pipe_context *pipe,
static void
llvmpipe_bind_sampler_states(struct pipe_context *pipe,
unsigned shader,
- unsigned num, void **samplers)
+ unsigned start,
+ unsigned num,
+ void **samplers)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
unsigned i;
- assert(num <= PIPE_MAX_SAMPLERS);
+ assert(shader < PIPE_SHADER_TYPES);
+ assert(start + num <= Elements(llvmpipe->samplers[shader]));
/* Check for no-op */
- if (num == llvmpipe->num_samplers[shader] &&
- !memcmp(llvmpipe->samplers[shader], samplers, num * sizeof(void *)))
+ if (start + num <= llvmpipe->num_samplers[shader] &&
+ !memcmp(llvmpipe->samplers[shader] + start, samplers,
+ num * sizeof(void *))) {
return;
+ }
draw_flush(llvmpipe->draw);
- for (i = 0; i < num; ++i)
- llvmpipe->samplers[shader][i] = samplers[i];
- for (i = num; i < PIPE_MAX_SAMPLERS; ++i)
- llvmpipe->samplers[shader][i] = NULL;
+ /* set the new samplers */
+ for (i = 0; i < num; i++) {
+ llvmpipe->samplers[shader][start + i] = samplers[i];
+ }
- llvmpipe->num_samplers[shader] = num;
+ /* find highest non-null samplers[] entry */
+ {
+ unsigned j = MAX2(llvmpipe->num_samplers[shader], start + num);
+ while (j > 0 && llvmpipe->samplers[shader][j - 1] == NULL)
+ j--;
+ llvmpipe->num_samplers[shader] = j;
+ }
if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) {
draw_set_samplers(llvmpipe->draw,
@@ -103,7 +114,7 @@ static void
llvmpipe_bind_fragment_sampler_states(struct pipe_context *pipe,
unsigned num, void **samplers)
{
- llvmpipe_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, num, samplers);
+ llvmpipe_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, num, samplers);
}
@@ -111,7 +122,7 @@ static void
llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
unsigned num, void **samplers)
{
- llvmpipe_bind_sampler_states(pipe, PIPE_SHADER_VERTEX, num, samplers);
+ llvmpipe_bind_sampler_states(pipe, PIPE_SHADER_VERTEX, 0, num, samplers);
}
@@ -119,12 +130,13 @@ static void
llvmpipe_bind_geometry_sampler_states(struct pipe_context *pipe,
unsigned num, void **samplers)
{
- llvmpipe_bind_sampler_states(pipe, PIPE_SHADER_GEOMETRY, num, samplers);
+ llvmpipe_bind_sampler_states(pipe, PIPE_SHADER_GEOMETRY, 0, num, samplers);
}
static void
llvmpipe_set_sampler_views(struct pipe_context *pipe,
unsigned shader,
+ unsigned start,
unsigned num,
struct pipe_sampler_view **views)
{
@@ -133,20 +145,31 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe,
assert(num <= PIPE_MAX_SAMPLERS);
+ assert(shader < PIPE_SHADER_TYPES);
+ assert(start + num <= Elements(llvmpipe->sampler_views[shader]));
+
/* Check for no-op */
- if (num == llvmpipe->num_sampler_views[shader] &&
- !memcmp(llvmpipe->sampler_views[shader], views, num * sizeof(struct pipe_sampler_view *)))
+ if (start + num <= llvmpipe->num_sampler_views[shader] &&
+ !memcmp(llvmpipe->sampler_views[shader] + start, views,
+ num * sizeof(struct pipe_sampler_view *))) {
return;
+ }
draw_flush(llvmpipe->draw);
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- struct pipe_sampler_view *view = i < num ? views[i] : NULL;
-
- pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][i], view);
+ /* set the new sampler views */
+ for (i = 0; i < num; i++) {
+ pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i],
+ views[i]);
}
- llvmpipe->num_sampler_views[shader] = num;
+ /* find highest non-null sampler_views[] entry */
+ {
+ unsigned j = MAX2(llvmpipe->num_sampler_views[shader], start + num);
+ while (j > 0 && llvmpipe->sampler_views[shader][j - 1] == NULL)
+ j--;
+ llvmpipe->num_sampler_views[shader] = j;
+ }
if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) {
draw_set_sampler_views(llvmpipe->draw,
@@ -164,7 +187,7 @@ llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe,
unsigned num,
struct pipe_sampler_view **views)
{
- llvmpipe_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, num, views);
+ llvmpipe_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, views);
}
@@ -173,7 +196,7 @@ llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe,
unsigned num,
struct pipe_sampler_view **views)
{
- llvmpipe_set_sampler_views(pipe, PIPE_SHADER_VERTEX, num, views);
+ llvmpipe_set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, num, views);
}
@@ -182,7 +205,7 @@ llvmpipe_set_geometry_sampler_views(struct pipe_context *pipe,
unsigned num,
struct pipe_sampler_view **views)
{
- llvmpipe_set_sampler_views(pipe, PIPE_SHADER_GEOMETRY, num, views);
+ llvmpipe_set_sampler_views(pipe, PIPE_SHADER_GEOMETRY, 0, num, views);
}
static struct pipe_sampler_view *