summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-10-26 19:19:09 -0600
committerBrian <[email protected]>2007-10-26 19:19:51 -0600
commit8fed2466e4056668a76a87cf935b5fbff8ae15ca (patch)
tree81345e5b5ee66dc2dd299f5b9ce29314f2e52735 /src/mesa/pipe/softpipe
parent789d248558061fe4d65f664d6770a12b90fa2e34 (diff)
Re-implement GLSL texture sampler variables.
GLSL sampler variables indicate which texture unit to use for TEX instructions. Previously, this was baked into the fragment/vertex program and couldn't be readily changed once set. Now, SamplerUnits[] array indicates which texture unit is to be used for each sampler variable. These values are set with glUniform1i(). This is extra state that must be passed to the fragment/vertex program executor at runtime.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c1
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h1
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_fs.c1
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h3
-rw-r--r--src/mesa/pipe/softpipe/sp_state_sampler.c14
5 files changed, 20 insertions, 0 deletions
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 476d4ac01cc..58ef744f304 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -318,6 +318,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.set_feedback_state = softpipe_set_feedback_state;
softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
+ softpipe->pipe.set_sampler_units = softpipe_set_sampler_units;
softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
softpipe->pipe.set_texture_state = softpipe_set_texture_state;
softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index 3e77bd6b856..88a418d3c7d 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -95,6 +95,7 @@ struct softpipe_context {
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
+ uint sampler_units[PIPE_MAX_SAMPLERS];
unsigned dirty;
/*
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c
index 3371b109fcb..9b9504cd157 100644
--- a/src/mesa/pipe/softpipe/sp_quad_fs.c
+++ b/src/mesa/pipe/softpipe/sp_quad_fs.c
@@ -85,6 +85,7 @@ shade_quad(
/* Consts does not require 16 byte alignment. */
machine->Consts = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT];
+ machine->SamplerUnits = softpipe->sampler_units;
machine->InterpCoefs = quad->coef;
machine->Inputs[0].xyzw[0].f[0] = fx;
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index c194f0ea0db..61532bcdebb 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -99,6 +99,9 @@ void softpipe_delete_vs_state(struct pipe_context *, void *);
void softpipe_set_polygon_stipple( struct pipe_context *,
const struct pipe_poly_stipple * );
+void softpipe_set_sampler_units( struct pipe_context *,
+ uint numSamplers, const uint *units );
+
void softpipe_set_scissor_state( struct pipe_context *,
const struct pipe_scissor_state * );
diff --git a/src/mesa/pipe/softpipe/sp_state_sampler.c b/src/mesa/pipe/softpipe/sp_state_sampler.c
index c00e815f2d4..e70eabd578b 100644
--- a/src/mesa/pipe/softpipe/sp_state_sampler.c
+++ b/src/mesa/pipe/softpipe/sp_state_sampler.c
@@ -78,3 +78,17 @@ softpipe_set_texture_state(struct pipe_context *pipe,
softpipe->dirty |= SP_NEW_TEXTURE;
}
+
+
+void
+softpipe_set_sampler_units(struct pipe_context *pipe,
+ uint num_samplers, const uint *units )
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+ uint i;
+ for (i = 0; i < num_samplers; i++)
+ softpipe->sampler_units[i] = units[i];
+ softpipe->dirty |= SP_NEW_SAMPLER;
+}
+
+