From 8fed2466e4056668a76a87cf935b5fbff8ae15ca Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 26 Oct 2007 19:19:09 -0600 Subject: 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. --- src/mesa/pipe/failover/fo_context.h | 1 + src/mesa/pipe/failover/fo_state.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) (limited to 'src/mesa/pipe/failover') diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index 7a597013ab..759b53ccbe 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -84,6 +84,7 @@ struct failover_context { struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; + uint sampler_units[PIPE_MAX_SAMPLERS]; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index f63137f591..2cd1a50b20 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -294,6 +294,19 @@ failover_set_polygon_stipple( struct pipe_context *pipe, failover->hw->set_polygon_stipple( failover->hw, stipple ); } +static void +failover_set_sampler_units( struct pipe_context *pipe, + uint num_samplers, const uint *units ) +{ + struct failover_context *failover = failover_context(pipe); + uint i; + + for (i = 0; i < num_samplers; i++) + failover->sampler_units[i] = units[i]; + failover->dirty |= FO_NEW_SAMPLER; + failover->hw->set_sampler_units(failover->hw, num_samplers, units); +} + static void * failover_create_rasterizer_state(struct pipe_context *pipe, const struct pipe_rasterizer_state *templ) @@ -470,6 +483,7 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_clear_color_state = failover_set_clear_color_state; failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; + failover->pipe.set_sampler_units = failover_set_sampler_units; failover->pipe.set_scissor_state = failover_set_scissor_state; failover->pipe.set_texture_state = failover_set_texture_state; failover->pipe.set_viewport_state = failover_set_viewport_state; -- cgit v1.2.3