From: Brian Paul Date: Sat, 4 Aug 2012 14:46:42 +0000 (-0600) Subject: llvmpipe: combine vertex/fragment sampler state into an array X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b3538d356316b282d6408f710f2df5f06bf315f5;p=mesa.git llvmpipe: combine vertex/fragment sampler state into an array This will allow code consolidation in the next patch. Reviewed-by: José Fonseca --- diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 07cea9158c3..7d0ca1f8cd8 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -70,11 +70,11 @@ static void llvmpipe_destroy( struct pipe_context *pipe ) pipe_surface_reference(&llvmpipe->framebuffer.zsbuf, NULL); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], NULL); + pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT][i], NULL); } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { - pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], NULL); + pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_VERTEX][i], NULL); } for (i = 0; i < Elements(llvmpipe->constants); i++) { diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index d0220e188cf..f8610ae8f0c 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -57,8 +57,8 @@ struct llvmpipe_context { /** Constant state objects */ const struct pipe_blend_state *blend; - const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_state *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; + const struct pipe_depth_stencil_alpha_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; struct lp_fragment_shader *fs; @@ -75,8 +75,8 @@ struct llvmpipe_context { struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; + struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; struct pipe_index_buffer index_buffer; @@ -88,10 +88,9 @@ struct llvmpipe_context { } so_target; struct pipe_resource *mapped_vs_tex[PIPE_MAX_VERTEX_SAMPLERS]; - unsigned num_samplers; - unsigned num_fragment_sampler_views; - unsigned num_vertex_samplers; - unsigned num_vertex_sampler_views; + unsigned num_samplers[PIPE_SHADER_TYPES]; + unsigned num_sampler_views[PIPE_SHADER_TYPES]; + unsigned num_vertex_buffers; unsigned dirty; /**< Mask of LP_NEW_x flags */ diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index 96259d7144f..f37b3ca1cea 100644 --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -85,8 +85,8 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } llvmpipe_prepare_vertex_sampling(lp, - lp->num_vertex_sampler_views, - lp->vertex_sampler_views); + lp->num_sampler_views[PIPE_SHADER_VERTEX], + lp->sampler_views[PIPE_SHADER_VERTEX]); /* draw! */ draw_vbo(draw, info); diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 4f7d116d486..e5c84bbacdc 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -712,7 +712,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup, void lp_setup_set_fragment_sampler_state(struct lp_setup_context *setup, unsigned num, - const struct pipe_sampler_state **samplers) + struct pipe_sampler_state **samplers) { unsigned i; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index 8655259d27c..78b41451e92 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -127,7 +127,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup, void lp_setup_set_fragment_sampler_state(struct lp_setup_context *setup, unsigned num, - const struct pipe_sampler_state **samplers); + struct pipe_sampler_state **samplers); unsigned lp_setup_is_resource_referenced( const struct lp_setup_context *setup, diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index a8b3142d8cf..056e163f074 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -178,13 +178,13 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) if (llvmpipe->dirty & (LP_NEW_SAMPLER_VIEW)) lp_setup_set_fragment_sampler_views(llvmpipe->setup, - llvmpipe->num_fragment_sampler_views, - llvmpipe->fragment_sampler_views); + llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT], + llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT]); if (llvmpipe->dirty & (LP_NEW_SAMPLER)) lp_setup_set_fragment_sampler_state(llvmpipe->setup, - llvmpipe->num_samplers, - llvmpipe->sampler); + llvmpipe->num_samplers[PIPE_SHADER_FRAGMENT], + llvmpipe->samplers[PIPE_SHADER_FRAGMENT]); llvmpipe->dirty = 0; } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 374544fcf70..da20dedde3e 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1645,8 +1645,8 @@ make_variant_key(struct llvmpipe_context *lp, for(i = 0; i < key->nr_samplers; ++i) { if(shader->info.base.file_mask[TGSI_FILE_SAMPLER] & (1 << i)) { lp_sampler_static_state(&key->sampler[i], - lp->fragment_sampler_views[i], - lp->sampler[i]); + lp->sampler_views[PIPE_SHADER_FRAGMENT][i], + lp->samplers[PIPE_SHADER_FRAGMENT][i]); } } } diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index df9fb89cc8e..145153809cf 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -74,18 +74,18 @@ llvmpipe_bind_sampler_states(struct pipe_context *pipe, assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == llvmpipe->num_samplers && - !memcmp(llvmpipe->sampler, sampler, num * sizeof(void *))) + if (num == llvmpipe->num_samplers[PIPE_SHADER_FRAGMENT] && + !memcmp(llvmpipe->samplers[PIPE_SHADER_FRAGMENT], sampler, num * sizeof(void *))) return; draw_flush(llvmpipe->draw); for (i = 0; i < num; ++i) - llvmpipe->sampler[i] = sampler[i]; + llvmpipe->samplers[PIPE_SHADER_FRAGMENT][i] = sampler[i]; for (i = num; i < PIPE_MAX_SAMPLERS; ++i) - llvmpipe->sampler[i] = NULL; + llvmpipe->samplers[PIPE_SHADER_FRAGMENT][i] = NULL; - llvmpipe->num_samplers = num; + llvmpipe->num_samplers[PIPE_SHADER_FRAGMENT] = num; llvmpipe->dirty |= LP_NEW_SAMPLER; } @@ -102,22 +102,22 @@ llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe, assert(num_samplers <= PIPE_MAX_VERTEX_SAMPLERS); /* Check for no-op */ - if (num_samplers == llvmpipe->num_vertex_samplers && - !memcmp(llvmpipe->vertex_samplers, samplers, num_samplers * sizeof(void *))) + if (num_samplers == llvmpipe->num_samplers[PIPE_SHADER_VERTEX] && + !memcmp(llvmpipe->samplers[PIPE_SHADER_VERTEX], samplers, num_samplers * sizeof(void *))) return; draw_flush(llvmpipe->draw); for (i = 0; i < num_samplers; ++i) - llvmpipe->vertex_samplers[i] = samplers[i]; + llvmpipe->samplers[PIPE_SHADER_VERTEX][i] = samplers[i]; for (i = num_samplers; i < PIPE_MAX_VERTEX_SAMPLERS; ++i) - llvmpipe->vertex_samplers[i] = NULL; + llvmpipe->samplers[PIPE_SHADER_VERTEX][i] = NULL; - llvmpipe->num_vertex_samplers = num_samplers; + llvmpipe->num_samplers[PIPE_SHADER_VERTEX] = num_samplers; draw_set_samplers(llvmpipe->draw, - llvmpipe->vertex_samplers, - llvmpipe->num_vertex_samplers); + llvmpipe->samplers[PIPE_SHADER_VERTEX], + llvmpipe->num_samplers[PIPE_SHADER_VERTEX]); llvmpipe->dirty |= LP_NEW_SAMPLER; } @@ -141,8 +141,8 @@ llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe, assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == llvmpipe->num_fragment_sampler_views && - !memcmp(llvmpipe->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) + if (num == llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT] && + !memcmp(llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT], views, num * sizeof(struct pipe_sampler_view *))) return; draw_flush(llvmpipe->draw); @@ -150,10 +150,10 @@ llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { struct pipe_sampler_view *view = i < num ? views[i] : NULL; - pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], view); + pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT][i], view); } - llvmpipe->num_fragment_sampler_views = num; + llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT] = num; llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; } @@ -170,8 +170,8 @@ llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe, assert(num <= PIPE_MAX_VERTEX_SAMPLERS); /* Check for no-op */ - if (num == llvmpipe->num_vertex_sampler_views && - !memcmp(llvmpipe->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) { + if (num == llvmpipe->num_sampler_views[PIPE_SHADER_VERTEX] && + !memcmp(llvmpipe->sampler_views[PIPE_SHADER_VERTEX], views, num * sizeof(struct pipe_sampler_view *))) { return; } @@ -180,14 +180,14 @@ llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { struct pipe_sampler_view *view = i < num ? views[i] : NULL; - pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], view); + pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_VERTEX][i], view); } - llvmpipe->num_vertex_sampler_views = num; + llvmpipe->num_sampler_views[PIPE_SHADER_VERTEX] = num; draw_set_sampler_views(llvmpipe->draw, - llvmpipe->vertex_sampler_views, - llvmpipe->num_vertex_sampler_views); + llvmpipe->sampler_views[PIPE_SHADER_VERTEX], + llvmpipe->num_sampler_views[PIPE_SHADER_VERTEX]); llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; }