diff options
author | Brian Paul <[email protected]> | 2012-08-09 20:59:44 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-08-16 09:01:31 -0600 |
commit | 0ad95b923a2bfd91677872765946b6a2f8d11260 (patch) | |
tree | d343e1dcf71b422efed5b9c73cc9704a2d23a326 /src | |
parent | f3c3aff6efed49b7740a144f767c713cb22561e2 (diff) |
gallium/identity: consolidate sampler, sampler_view code
This will simplify things when the pipe_context functions are consolidated.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/identity/id_context.c | 86 |
1 files changed, 54 insertions, 32 deletions
diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 794e62ca1f2..026793484db 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -159,16 +159,36 @@ identity_create_sampler_state(struct pipe_context *_pipe, } static void +identity_bind_sampler_states(struct pipe_context *_pipe, + unsigned shader, + unsigned num_samplers, + void **samplers) +{ + struct identity_context *id_pipe = identity_context(_pipe); + struct pipe_context *pipe = id_pipe->pipe; + + switch (shader) { + case PIPE_SHADER_VERTEX: + pipe->bind_vertex_sampler_states(pipe, num_samplers, samplers); + break; + case PIPE_SHADER_GEOMETRY: + pipe->bind_geometry_sampler_states(pipe, num_samplers, samplers); + break; + case PIPE_SHADER_FRAGMENT: + pipe->bind_fragment_sampler_states(pipe, num_samplers, samplers); + break; + default: + debug_error("Unexpected shader in identity_bind_sampler_states()"); + } +} + +static void identity_bind_fragment_sampler_states(struct pipe_context *_pipe, unsigned num_samplers, void **samplers) { - struct identity_context *id_pipe = identity_context(_pipe); - struct pipe_context *pipe = id_pipe->pipe; - - pipe->bind_fragment_sampler_states(pipe, - num_samplers, - samplers); + identity_bind_sampler_states(_pipe, PIPE_SHADER_FRAGMENT, + num_samplers, samplers); } static void @@ -176,12 +196,8 @@ identity_bind_vertex_sampler_states(struct pipe_context *_pipe, unsigned num_samplers, void **samplers) { - struct identity_context *id_pipe = identity_context(_pipe); - struct pipe_context *pipe = id_pipe->pipe; - - pipe->bind_vertex_sampler_states(pipe, - num_samplers, - samplers); + identity_bind_sampler_states(_pipe, PIPE_SHADER_VERTEX, + num_samplers, samplers); } static void @@ -488,9 +504,10 @@ identity_set_viewport_state(struct pipe_context *_pipe, } static void -identity_set_fragment_sampler_views(struct pipe_context *_pipe, - unsigned num, - struct pipe_sampler_view **_views) +identity_set_sampler_views(struct pipe_context *_pipe, + unsigned shader, + unsigned num, + struct pipe_sampler_view **_views) { struct identity_context *id_pipe = identity_context(_pipe); struct pipe_context *pipe = id_pipe->pipe; @@ -507,7 +524,27 @@ identity_set_fragment_sampler_views(struct pipe_context *_pipe, views = unwrapped_views; } - pipe->set_fragment_sampler_views(pipe, num, views); + switch (shader) { + case PIPE_SHADER_VERTEX: + pipe->set_vertex_sampler_views(pipe, num, views); + break; + case PIPE_SHADER_GEOMETRY: + pipe->set_geometry_sampler_views(pipe, num, views); + break; + case PIPE_SHADER_FRAGMENT: + pipe->set_fragment_sampler_views(pipe, num, views); + break; + default: + debug_error("Unexpected shader in identity_set_sampler_views()"); + } +} + +static void +identity_set_fragment_sampler_views(struct pipe_context *_pipe, + unsigned num, + struct pipe_sampler_view **_views) +{ + identity_set_sampler_views(_pipe, PIPE_SHADER_FRAGMENT, num, _views); } static void @@ -515,22 +552,7 @@ identity_set_vertex_sampler_views(struct pipe_context *_pipe, unsigned num, struct pipe_sampler_view **_views) { - struct identity_context *id_pipe = identity_context(_pipe); - struct pipe_context *pipe = id_pipe->pipe; - struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_view **views = NULL; - unsigned i; - - if (_views) { - for (i = 0; i < num; i++) - unwrapped_views[i] = identity_sampler_view_unwrap(_views[i]); - for (; i < Elements(unwrapped_views); i++) - unwrapped_views[i] = NULL; - - views = unwrapped_views; - } - - pipe->set_vertex_sampler_views(pipe, num, views); + identity_set_sampler_views(_pipe, PIPE_SHADER_VERTEX, num, _views); } static void |