[Mesa-dev] [PATCH 02/10] radeonsi: always restore sampler states when unbinding sampler views

Marek Olšák maraeo at gmail.com
Fri Dec 2 20:39:21 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

Cc: 13.0 12.0 <mesa-stable at lists.freedesktop.org>
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 097ffcd..8777f36 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -406,27 +406,27 @@ void si_set_mutable_tex_desc_fields(struct r600_texture *tex,
 }
 
 static void si_set_sampler_view(struct si_context *sctx,
 				unsigned shader,
 				unsigned slot, struct pipe_sampler_view *view,
 				bool disallow_early_out)
 {
 	struct si_sampler_views *views = &sctx->samplers[shader].views;
 	struct si_sampler_view *rview = (struct si_sampler_view*)view;
 	struct si_descriptors *descs = si_sampler_descriptors(sctx, shader);
+	uint32_t *desc = descs->list + slot * 16;
 
 	if (views->views[slot] == view && !disallow_early_out)
 		return;
 
 	if (view) {
 		struct r600_texture *rtex = (struct r600_texture *)view->texture;
-		uint32_t *desc = descs->list + slot * 16;
 
 		assert(rtex); /* views with texture == NULL aren't supported */
 		pipe_sampler_view_reference(&views->views[slot], view);
 		memcpy(desc, rview->state, 8*4);
 
 		if (rtex->resource.b.b.target == PIPE_BUFFER) {
 			rtex->resource.bind_history |= PIPE_BIND_SAMPLER_VIEW;
 
 			si_set_buf_desc_address(&rtex->resource,
 						view->u.buf.offset,
@@ -461,23 +461,28 @@ static void si_set_sampler_view(struct si_context *sctx,
 
 		views->enabled_mask |= 1u << slot;
 
 		/* Since this can flush, it must be done after enabled_mask is
 		 * updated. */
 		si_sampler_view_add_buffer(sctx, view->texture,
 					   RADEON_USAGE_READ,
 					   rview->is_stencil_sampler, true);
 	} else {
 		pipe_sampler_view_reference(&views->views[slot], NULL);
-		memcpy(descs->list + slot*16, null_texture_descriptor, 8*4);
+		memcpy(desc, null_texture_descriptor, 8*4);
 		/* Only clear the lower dwords of FMASK. */
-		memcpy(descs->list + slot*16 + 8, null_texture_descriptor, 4*4);
+		memcpy(desc + 8, null_texture_descriptor, 4*4);
+		/* Re-set the sampler state if we are transitioning from FMASK. */
+		if (views->sampler_states[slot])
+			memcpy(desc + 12,
+			       views->sampler_states[slot], 4*4);
+
 		views->enabled_mask &= ~(1u << slot);
 	}
 
 	descs->dirty_mask |= 1u << slot;
 	sctx->descriptors_dirty |= 1u << si_sampler_descriptors_idx(shader);
 }
 
 static bool is_compressed_colortex(struct r600_texture *rtex)
 {
 	return rtex->cmask.size || rtex->fmask.size ||
-- 
2.7.4



More information about the mesa-dev mailing list