[35/55] radeonsi: pass sctx to si_rebind_buffer and clean up

Submitted by Marek Olšák on April 2, 2018, 4:08 a.m.

Details

Message ID 1522642128-15348-36-git-send-email-maraeo@gmail.com
State Accepted
Commit 2a62e5eec92bc98c8c20e0b72cab4e14d112b2a4
Headers show
Series "RadeonSI Mega cleanup" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Marek Olšák April 2, 2018, 4:08 a.m.
From: Marek Olšák <marek.olsak@amd.com>

---
 src/gallium/drivers/radeon/r600_buffer_common.c |  5 +++--
 src/gallium/drivers/radeonsi/si_descriptors.c   | 16 ++++++----------
 src/gallium/drivers/radeonsi/si_state.h         |  2 +-
 3 files changed, 10 insertions(+), 13 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c
index 5a0e157..e54670a 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -286,7 +286,7 @@  si_invalidate_buffer(struct si_context *sctx,
 
 		/* Reallocate the buffer in the same pipe_resource. */
 		si_alloc_resource(sctx->screen, rbuffer);
-		si_rebind_buffer(&sctx->b.b, &rbuffer->b.b, old_va);
+		si_rebind_buffer(sctx, &rbuffer->b.b, old_va);
 	} else {
 		util_range_set_empty(&rbuffer->valid_buffer_range);
 	}
@@ -299,6 +299,7 @@  void si_replace_buffer_storage(struct pipe_context *ctx,
 				 struct pipe_resource *dst,
 				 struct pipe_resource *src)
 {
+	struct si_context *sctx = (struct si_context*)ctx;
 	struct r600_resource *rdst = r600_resource(dst);
 	struct r600_resource *rsrc = r600_resource(src);
 	uint64_t old_gpu_address = rdst->gpu_address;
@@ -316,7 +317,7 @@  void si_replace_buffer_storage(struct pipe_context *ctx,
 	assert(rdst->bo_alignment == rsrc->bo_alignment);
 	assert(rdst->domains == rsrc->domains);
 
-	si_rebind_buffer(ctx, dst, old_gpu_address);
+	si_rebind_buffer(sctx, dst, old_gpu_address);
 }
 
 static void si_invalidate_resource(struct pipe_context *ctx,
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 75c11a2..3460c13 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1416,8 +1416,7 @@  void si_set_ring_buffer(struct pipe_context *ctx, uint slot,
 	sctx->descriptors_dirty |= 1u << SI_DESCS_RW_BUFFERS;
 }
 
-static void si_desc_reset_buffer_offset(struct pipe_context *ctx,
-					uint32_t *desc, uint64_t old_buf_va,
+static void si_desc_reset_buffer_offset(uint32_t *desc, uint64_t old_buf_va,
 					struct pipe_resource *new_buf)
 {
 	/* Retrieve the buffer offset from the descriptor. */
@@ -1525,8 +1524,7 @@  static void si_reset_buffer_resources(struct si_context *sctx,
 	while (mask) {
 		unsigned i = u_bit_scan(&mask);
 		if (buffers->buffers[i] == buf) {
-			si_desc_reset_buffer_offset(&sctx->b.b,
-						    descs->list + i*4,
+			si_desc_reset_buffer_offset(descs->list + i*4,
 						    old_va, buf);
 			sctx->descriptors_dirty |= 1u << descriptors_idx;
 
@@ -1540,10 +1538,9 @@  static void si_reset_buffer_resources(struct si_context *sctx,
 /* Update all resource bindings where the buffer is bound, including
  * all resource descriptors. This is invalidate_buffer without
  * the invalidation. */
-void si_rebind_buffer(struct pipe_context *ctx, struct pipe_resource *buf,
+void si_rebind_buffer(struct si_context *sctx, struct pipe_resource *buf,
 		      uint64_t old_va)
 {
-	struct si_context *sctx = (struct si_context*)ctx;
 	struct r600_resource *rbuffer = r600_resource(buf);
 	unsigned i, shader;
 	unsigned num_elems = sctx->vertex_elements ?
@@ -1582,7 +1579,7 @@  void si_rebind_buffer(struct pipe_context *ctx, struct pipe_resource *buf,
 			if (buffers->buffers[i] != buf)
 				continue;
 
-			si_desc_reset_buffer_offset(ctx, descs->list + i*4,
+			si_desc_reset_buffer_offset(descs->list + i*4,
 						    old_va, buf);
 			sctx->descriptors_dirty |= 1u << SI_DESCS_RW_BUFFERS;
 
@@ -1634,8 +1631,7 @@  void si_rebind_buffer(struct pipe_context *ctx, struct pipe_resource *buf,
 				if (samplers->views[i]->texture == buf) {
 					unsigned desc_slot = si_get_sampler_slot(i);
 
-					si_desc_reset_buffer_offset(ctx,
-								    descs->list +
+					si_desc_reset_buffer_offset(descs->list +
 								    desc_slot * 16 + 4,
 								    old_va, buf);
 					sctx->descriptors_dirty |=
@@ -1668,7 +1664,7 @@  void si_rebind_buffer(struct pipe_context *ctx, struct pipe_resource *buf,
 						si_mark_image_range_valid(&images->views[i]);
 
 					si_desc_reset_buffer_offset(
-						ctx, descs->list + desc_slot * 8 + 4,
+						descs->list + desc_slot * 8 + 4,
 						old_va, buf);
 					sctx->descriptors_dirty |=
 						1u << si_sampler_and_image_descriptors_idx(shader);
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index 7cddcf8..4410966 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -363,7 +363,7 @@  struct pb_slab *si_bindless_descriptor_slab_alloc(void *priv, unsigned heap,
 						  unsigned entry_size,
 						  unsigned group_index);
 void si_bindless_descriptor_slab_free(void *priv, struct pb_slab *pslab);
-void si_rebind_buffer(struct pipe_context *ctx, struct pipe_resource *buf,
+void si_rebind_buffer(struct si_context *sctx, struct pipe_resource *buf,
 		      uint64_t old_va);
 /* si_state.c */
 struct si_shader_selector;