From: Brian Paul Date: Fri, 10 Aug 2012 02:59:44 +0000 (-0600) Subject: gallium/identity: consolidate sampler, sampler_view code X-Git-Tag: accepted/2.0alpha-wayland/20121114.171706~511 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ad95b923a2bfd91677872765946b6a2f8d11260;p=profile%2Fivi%2Fmesa.git gallium/identity: consolidate sampler, sampler_view code This will simplify things when the pipe_context functions are consolidated. --- diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 794e62c..0267934 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