diff options
author | Zack Rusin <[email protected]> | 2013-03-26 17:53:27 -0700 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2013-03-27 03:53:02 -0700 |
commit | d066133a7637864bde46b8118778c526826583a6 (patch) | |
tree | 96853c80ffec9a82804935c18ccd80df42d0af9e /src/gallium/drivers | |
parent | 186a6bffdd5792c78dab0be8f986c8c1b0a83db3 (diff) |
llvmpipe/draw: Fix texture sampling in geometry shaders
We weren't correctly propagating the samplers and sampler views
when they were related to geometry shaders.
Signed-off-by: Zack Rusin <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_context.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_draw_arrays.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state.h | 8 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_sampler.c | 54 |
5 files changed, 62 insertions, 9 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 25b1cd06319..fa675eab7e1 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -81,6 +81,10 @@ static void llvmpipe_destroy( struct pipe_context *pipe ) pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_VERTEX][i], NULL); } + for (i = 0; i < Elements(llvmpipe->sampler_views[0]); i++) { + pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_GEOMETRY][i], NULL); + } + for (i = 0; i < Elements(llvmpipe->constants); i++) { for (j = 0; j < Elements(llvmpipe->constants[i]); j++) { pipe_resource_reference(&llvmpipe->constants[i][j].buffer, NULL); diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index 9ccb67bdd1f..6ee7b99f478 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -82,6 +82,7 @@ struct llvmpipe_context { struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; struct pipe_index_buffer index_buffer; struct pipe_resource *mapped_vs_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS]; + struct pipe_resource *mapped_gs_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS]; unsigned num_samplers[PIPE_SHADER_TYPES]; unsigned num_sampler_views[PIPE_SHADER_TYPES]; diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index eaa9ba3b130..ae00c49d490 100644 --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -98,6 +98,9 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) llvmpipe_prepare_vertex_sampling(lp, lp->num_sampler_views[PIPE_SHADER_VERTEX], lp->sampler_views[PIPE_SHADER_VERTEX]); + llvmpipe_prepare_geometry_sampling(lp, + lp->num_sampler_views[PIPE_SHADER_GEOMETRY], + lp->sampler_views[PIPE_SHADER_GEOMETRY]); /* draw! */ draw_vbo(draw, info); @@ -114,6 +117,7 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) draw_set_mapped_so_targets(draw, 0, NULL); llvmpipe_cleanup_vertex_sampling(lp); + llvmpipe_cleanup_geometry_sampling(lp); /* * TODO: Flush only when a user vertex/index buffer is present diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index 94a21a0158b..1f27d70415e 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -141,4 +141,12 @@ void llvmpipe_cleanup_vertex_sampling(struct llvmpipe_context *ctx); +void +llvmpipe_prepare_geometry_sampling(struct llvmpipe_context *ctx, + unsigned num, + struct pipe_sampler_view **views); +void +llvmpipe_cleanup_geometry_sampling(struct llvmpipe_context *ctx); + + #endif diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index 7441973bda2..6498d130e06 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -250,14 +250,15 @@ llvmpipe_delete_sampler_state(struct pipe_context *pipe, } -/** - * Called during state validation when LP_NEW_SAMPLER_VIEW is set. - */ -void -llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp, - unsigned num, - struct pipe_sampler_view **views) +static void +prepare_shader_sampling( + struct llvmpipe_context *lp, + unsigned num, + struct pipe_sampler_view **views, + unsigned shader_type, + struct pipe_resource *mapped_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS]) { + unsigned i; uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS]; uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS]; @@ -282,7 +283,7 @@ llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp, /* We're referencing the texture's internal data, so save a * reference to it. */ - pipe_resource_reference(&lp->mapped_vs_tex[i], tex); + pipe_resource_reference(&mapped_tex[i], tex); if (!lp_tex->dt) { /* regular texture - setup array of mipmap level offsets */ @@ -357,7 +358,7 @@ llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp, assert(addr); } draw_set_mapped_texture(lp->draw, - PIPE_SHADER_VERTEX, + shader_type, i, width0, tex->height0, num_layers, first_level, last_level, @@ -366,6 +367,19 @@ llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp, } } } + + +/** + * Called during state validation when LP_NEW_SAMPLER_VIEW is set. + */ +void +llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp, + unsigned num, + struct pipe_sampler_view **views) +{ + prepare_shader_sampling(lp, num, views, PIPE_SHADER_VERTEX, + lp->mapped_vs_tex); +} void llvmpipe_cleanup_vertex_sampling(struct llvmpipe_context *ctx) @@ -376,6 +390,28 @@ llvmpipe_cleanup_vertex_sampling(struct llvmpipe_context *ctx) } } + +/** + * Called during state validation when LP_NEW_SAMPLER_VIEW is set. + */ +void +llvmpipe_prepare_geometry_sampling(struct llvmpipe_context *lp, + unsigned num, + struct pipe_sampler_view **views) +{ + prepare_shader_sampling(lp, num, views, PIPE_SHADER_GEOMETRY, + lp->mapped_gs_tex); +} + +void +llvmpipe_cleanup_geometry_sampling(struct llvmpipe_context *ctx) +{ + unsigned i; + for (i = 0; i < Elements(ctx->mapped_gs_tex); i++) { + pipe_resource_reference(&ctx->mapped_gs_tex[i], NULL); + } +} + void llvmpipe_init_sampler_funcs(struct llvmpipe_context *llvmpipe) { |