From ea6f035ae90895bd4ee3247408eb179dfdf96d22 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 2 Aug 2012 13:02:40 -0600 Subject: gallium: consolidate CSO sampler and sampler_view functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge the vertex/fragment versions of the cso_set/save/restore_samplers() functions. Now we pass the shader stage (PIPE_SHADER_x) to the function to indicate vertex/fragment/geometry samplers. For example: cso_single_sampler(cso, PIPE_SHADER_FRAGMENT, unit, sampler); This results in quite a bit of code reduction, fewer CSO functions and support for geometry shaders. Reviewed-by: Marek Olšák --- src/gallium/auxiliary/postprocess/pp_colors.c | 6 +++--- src/gallium/auxiliary/postprocess/pp_init.c | 2 +- src/gallium/auxiliary/postprocess/pp_mlaa.c | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/gallium/auxiliary/postprocess') diff --git a/src/gallium/auxiliary/postprocess/pp_colors.c b/src/gallium/auxiliary/postprocess/pp_colors.c index 36bb1f552f5..1773e53bfba 100644 --- a/src/gallium/auxiliary/postprocess/pp_colors.c +++ b/src/gallium/auxiliary/postprocess/pp_colors.c @@ -43,9 +43,9 @@ pp_nocolor(struct pp_queue_t *ppq, struct pipe_resource *in, pp_filter_set_fb(p); pp_filter_misc_state(p); - cso_single_sampler(p->cso, 0, &p->sampler_point); - cso_single_sampler_done(p->cso); - cso_set_fragment_sampler_views(p->cso, 1, &p->view); + cso_single_sampler(p->cso, PIPE_SHADER_FRAGMENT, 0, &p->sampler_point); + cso_single_sampler_done(p->cso, PIPE_SHADER_FRAGMENT); + cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 1, &p->view); cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]); cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][1]); diff --git a/src/gallium/auxiliary/postprocess/pp_init.c b/src/gallium/auxiliary/postprocess/pp_init.c index e2068c25e5b..2dc29ac5b4b 100644 --- a/src/gallium/auxiliary/postprocess/pp_init.c +++ b/src/gallium/auxiliary/postprocess/pp_init.c @@ -152,7 +152,7 @@ pp_free(struct pp_queue_t *ppq) util_destroy_blit(ppq->p->blitctx); - cso_set_fragment_sampler_views(ppq->p->cso, 0, NULL); + cso_set_sampler_views(ppq->p->cso, PIPE_SHADER_FRAGMENT, 0, NULL); cso_release_all(ppq->p->cso); for (i = 0; i < ppq->n_filters; i++) { diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c b/src/gallium/auxiliary/postprocess/pp_mlaa.c index 951b76f0e89..297f3e443c1 100644 --- a/src/gallium/auxiliary/postprocess/pp_mlaa.c +++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c @@ -125,9 +125,9 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, p->pipe->clear(p->pipe, PIPE_CLEAR_STENCIL | PIPE_CLEAR_COLOR, &p->clear_color, 0, 0); - cso_single_sampler(p->cso, 0, &p->sampler_point); - cso_single_sampler_done(p->cso); - cso_set_fragment_sampler_views(p->cso, 1, &p->view); + cso_single_sampler(p->cso, PIPE_SHADER_FRAGMENT, 0, &p->sampler_point); + cso_single_sampler_done(p->cso, PIPE_SHADER_FRAGMENT); + cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 1, &p->view); cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */ cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][2]); @@ -152,13 +152,13 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, pp_filter_set_clear_fb(p); - cso_single_sampler(p->cso, 0, &p->sampler_point); - cso_single_sampler(p->cso, 1, &p->sampler_point); - cso_single_sampler(p->cso, 2, &p->sampler); - cso_single_sampler_done(p->cso); + cso_single_sampler(p->cso, PIPE_SHADER_FRAGMENT, 0, &p->sampler_point); + cso_single_sampler(p->cso, PIPE_SHADER_FRAGMENT, 1, &p->sampler_point); + cso_single_sampler(p->cso, PIPE_SHADER_FRAGMENT, 2, &p->sampler); + cso_single_sampler_done(p->cso, PIPE_SHADER_FRAGMENT); arr[0] = p->view; - cso_set_fragment_sampler_views(p->cso, 3, arr); + cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 3, arr); cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]); /* passvs */ cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][3]); @@ -184,12 +184,12 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, u_sampler_view_default_template(&v_tmp, in, in->format); arr[0] = p->pipe->create_sampler_view(p->pipe, in, &v_tmp); - cso_single_sampler(p->cso, 0, &p->sampler_point); - cso_single_sampler(p->cso, 1, &p->sampler_point); - cso_single_sampler_done(p->cso); + cso_single_sampler(p->cso, PIPE_SHADER_FRAGMENT, 0, &p->sampler_point); + cso_single_sampler(p->cso, PIPE_SHADER_FRAGMENT, 1, &p->sampler_point); + cso_single_sampler_done(p->cso, PIPE_SHADER_FRAGMENT); arr[1] = p->view; - cso_set_fragment_sampler_views(p->cso, 2, arr); + cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 2, arr); cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */ cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][4]); -- cgit v1.2.3