[Mesa-dev] [PATCH 10/55] radeonsi: remove r600_pipe_common::invalidate_buffer

Marek Olšák maraeo at gmail.com
Mon Apr 2 04:08:03 UTC 2018


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

---
 src/gallium/drivers/radeon/r600_buffer_common.c | 12 +++++++++++-
 src/gallium/drivers/radeon/r600_pipe_common.h   |  4 ----
 src/gallium/drivers/radeonsi/si_descriptors.c   | 20 --------------------
 3 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c
index d215c9d..bc7e14b 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -254,6 +254,12 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
 	FREE(rbuffer);
 }
 
+/* Reallocate the buffer a update all resource bindings where the buffer is
+ * bound.
+ *
+ * This is used to avoid CPU-GPU synchronizations, because it makes the buffer
+ * idle by discarding its contents.
+ */
 static bool
 r600_invalidate_buffer(struct r600_common_context *rctx,
 		       struct r600_resource *rbuffer)
@@ -275,7 +281,11 @@ r600_invalidate_buffer(struct r600_common_context *rctx,
 	/* Check if mapping this buffer would cause waiting for the GPU. */
 	if (si_rings_is_buffer_referenced(rctx, rbuffer->buf, RADEON_USAGE_READWRITE) ||
 	    !rctx->ws->buffer_wait(rbuffer->buf, 0, RADEON_USAGE_READWRITE)) {
-		rctx->invalidate_buffer(&rctx->b, &rbuffer->b.b);
+		uint64_t old_va = rbuffer->gpu_address;
+
+		/* Reallocate the buffer in the same pipe_resource. */
+		si_alloc_resource(rctx->screen, rbuffer);
+		si_rebind_buffer(&rctx->b, &rbuffer->b.b, old_va);
 	} else {
 		util_range_set_empty(&rbuffer->valid_buffer_range);
 	}
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 241a0b9..2e2b80b 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -494,10 +494,6 @@ struct r600_common_context {
 
 	void (*decompress_dcc)(struct pipe_context *ctx,
 			       struct r600_texture *rtex);
-
-	/* Reallocate the buffer and update all resource bindings where
-	 * the buffer is bound, including all resource descriptors. */
-	void (*invalidate_buffer)(struct pipe_context *ctx, struct pipe_resource *buf);
 };
 
 /* r600_buffer_common.c */
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 6feeb0e..a9c1b7f 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1739,25 +1739,6 @@ void si_rebind_buffer(struct pipe_context *ctx, struct pipe_resource *buf,
 	}
 }
 
-/* Reallocate a buffer a update all resource bindings where the buffer is
- * bound.
- *
- * This is used to avoid CPU-GPU synchronizations, because it makes the buffer
- * idle by discarding its contents. Apps usually tell us when to do this using
- * map_buffer flags, for example.
- */
-static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource *buf)
-{
-	struct si_context *sctx = (struct si_context*)ctx;
-	struct r600_resource *rbuffer = r600_resource(buf);
-	uint64_t old_va = rbuffer->gpu_address;
-
-	/* Reallocate the buffer in the same pipe_resource. */
-	si_alloc_resource(sctx->screen, rbuffer);
-
-	si_rebind_buffer(ctx, buf, old_va);
-}
-
 static void si_upload_bindless_descriptor(struct si_context *sctx,
 					  unsigned desc_slot,
 					  unsigned num_dwords)
@@ -2713,7 +2694,6 @@ void si_init_all_descriptors(struct si_context *sctx)
 	sctx->b.b.create_image_handle = si_create_image_handle;
 	sctx->b.b.delete_image_handle = si_delete_image_handle;
 	sctx->b.b.make_image_handle_resident = si_make_image_handle_resident;
-	sctx->b.invalidate_buffer = si_invalidate_buffer;
 
 	/* Shader user data. */
 	si_init_atom(sctx, &sctx->shader_pointers.atom, &sctx->atoms.s.shader_pointers,
-- 
2.7.4



More information about the mesa-dev mailing list