From 27d500a844f7479747893ea70af6f296ea8e9d6a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 12 Sep 2013 15:06:23 -0600 Subject: draw: use pipe_context::bind_sampler_states() if non-null --- src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 51 +++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_pipe_pstipple.c') diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index 65f3125..5e501d7 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -101,6 +101,9 @@ struct pstip_stage void (*driver_bind_fragment_sampler_states)(struct pipe_context *, unsigned, void **); + void (*driver_bind_sampler_states)(struct pipe_context *, unsigned, + unsigned, unsigned, void **); + void (*driver_set_sampler_views)(struct pipe_context *, unsigned, struct pipe_sampler_view **); @@ -547,7 +550,14 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header) assert(num_samplers <= PIPE_MAX_SAMPLERS); draw->suspend_flushing = TRUE; - pstip->driver_bind_fragment_sampler_states(pipe, num_samplers, pstip->state.samplers); + + if (pstip->driver_bind_sampler_states) + pstip->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, + num_samplers, pstip->state.samplers); + else + pstip->driver_bind_fragment_sampler_states(pipe, num_samplers, + pstip->state.samplers); + pstip->driver_set_sampler_views(pipe, num_samplers, pstip->state.sampler_views); draw->suspend_flushing = FALSE; @@ -570,8 +580,15 @@ pstip_flush(struct draw_stage *stage, unsigned flags) /* restore original frag shader, texture, sampler state */ draw->suspend_flushing = TRUE; pstip->driver_bind_fs_state(pipe, pstip->fs ? pstip->fs->driver_fs : NULL); - pstip->driver_bind_fragment_sampler_states(pipe, pstip->num_samplers, - pstip->state.samplers); + + if (pstip->driver_bind_sampler_states) + pstip->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, + pstip->num_samplers, + pstip->state.samplers); + else + pstip->driver_bind_fragment_sampler_states(pipe, pstip->num_samplers, + pstip->state.samplers); + pstip->driver_set_sampler_views(pipe, pstip->num_sampler_views, pstip->state.sampler_views); @@ -701,6 +718,30 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs) static void +pstip_bind_sampler_states(struct pipe_context *pipe, unsigned shader, + unsigned start, unsigned num, void **sampler) +{ + struct pstip_stage *pstip = pstip_stage_from_pipe(pipe); + uint i; + + assert(start == 0); + + if (shader == PIPE_SHADER_FRAGMENT) { + /* save current */ + memcpy(pstip->state.samplers, sampler, num * sizeof(void *)); + for (i = num; i < PIPE_MAX_SAMPLERS; i++) { + pstip->state.samplers[i] = NULL; + } + pstip->num_samplers = num; + } + + /* pass-through */ + pstip->driver_bind_sampler_states(pstip->pipe, shader, start, num, sampler); +} + + +/* XXX deprecated / remove */ +static void pstip_bind_fragment_sampler_states(struct pipe_context *pipe, unsigned num, void **sampler) { @@ -719,6 +760,7 @@ pstip_bind_fragment_sampler_states(struct pipe_context *pipe, } + static void pstip_set_sampler_views(struct pipe_context *pipe, unsigned num, @@ -792,6 +834,7 @@ draw_install_pstipple_stage(struct draw_context *draw, pstip->driver_bind_fs_state = pipe->bind_fs_state; pstip->driver_delete_fs_state = pipe->delete_fs_state; + pstip->driver_bind_sampler_states = pipe->bind_sampler_states; pstip->driver_bind_fragment_sampler_states = pipe->bind_fragment_sampler_states; pstip->driver_set_sampler_views = pipe->set_fragment_sampler_views; pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple; @@ -801,6 +844,8 @@ draw_install_pstipple_stage(struct draw_context *draw, pipe->bind_fs_state = pstip_bind_fs_state; pipe->delete_fs_state = pstip_delete_fs_state; + if (pipe->bind_sampler_states) + pipe->bind_sampler_states = pstip_bind_sampler_states; pipe->bind_fragment_sampler_states = pstip_bind_fragment_sampler_states; pipe->set_fragment_sampler_views = pstip_set_sampler_views; pipe->set_polygon_stipple = pstip_set_polygon_stipple; -- cgit v1.1