From ba48f47ebf7f017db0507b92a3ca83e404dc586c Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 14 Jul 2012 16:23:42 +0200 Subject: r600g: consolidate code for setting sampler views and fix bugs in the process Issues fixed: - set_vs_sampler_views for evergreen is now properly implemented. - Added the missing inval_texture_cache call for evergreen. - have_depth_texture was sometimes incorrectly set to false on evergreen even if there were depth textures in other shader stages. To fix this, set it to true once and never set it to false again. It's stupid, but it matches the r600 code. The proper fix is left to another patch. - Optimizaton: The sampler views which aren't changed aren't updated. --- src/gallium/drivers/r600/r600_state_common.c | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/gallium/drivers/r600/r600_state_common.c') diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 84c7d5e5e6d..76a28ff0210 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -457,6 +457,53 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count, r600_vertex_buffers_dirty(rctx); } +void r600_set_sampler_views(struct r600_context *rctx, + struct r600_textures_info *dst, + unsigned count, + struct pipe_sampler_view **views, + void (*set_resource)(struct r600_context*, struct r600_pipe_resource_state*, unsigned)) +{ + struct r600_pipe_sampler_view **rviews = (struct r600_pipe_sampler_view **)views; + unsigned i; + + if (count) + r600_inval_texture_cache(rctx); + + for (i = 0; i < count; i++) { + if (rviews[i] == dst->views[i]) { + continue; + } + + if (rviews[i]) { + if (((struct r600_resource_texture *)rviews[i]->base.texture)->is_depth) + rctx->have_depth_texture = true; + + /* Changing from array to non-arrays textures and vice + * versa requires updating TEX_ARRAY_OVERRIDE on R6xx-R7xx. */ + if (rctx->chip_class <= R700 && + (rviews[i]->base.texture->target == PIPE_TEXTURE_1D_ARRAY || + rviews[i]->base.texture->target == PIPE_TEXTURE_2D_ARRAY) != dst->is_array_sampler[i]) { + dst->samplers_dirty = true; + } + + set_resource(rctx, &rviews[i]->state, i + R600_MAX_CONST_BUFFERS); + } else { + set_resource(rctx, NULL, i + R600_MAX_CONST_BUFFERS); + } + + pipe_sampler_view_reference((struct pipe_sampler_view **)&dst->views[i], views[i]); + } + + for (i = count; i < dst->n_views; i++) { + if (dst->views[i]) { + set_resource(rctx, NULL, i + R600_MAX_CONST_BUFFERS); + pipe_sampler_view_reference((struct pipe_sampler_view **)&dst->views[i], NULL); + } + } + + dst->n_views = count; +} + void *r600_create_vertex_elements(struct pipe_context *ctx, unsigned count, const struct pipe_vertex_element *elements) -- cgit v1.2.3