[Mesa-dev] [PATCH 06/30] radeon: add support for allocating immediate buffer.

Dave Airlie airlied at gmail.com
Thu Mar 31 07:03:35 UTC 2016


From: Dave Airlie <airlied at redhat.com>

The evergreen RAT operations require a buffer to store the results
of the operations to, this buffer should be allocated while images
are in use.

This adds a pointer/creation/cleanup functions to the common code
to use this buffer later.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/drivers/radeon/r600_buffer_common.c |  2 ++
 src/gallium/drivers/radeon/r600_pipe_common.h   | 10 ++++++++++
 src/gallium/drivers/radeon/r600_texture.c       | 10 ++++++++++
 3 files changed, 22 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c
index 33ba0fb..e396ab5 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -205,6 +205,7 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
 	struct r600_resource *rbuffer = r600_resource(buf);
 
 	util_range_destroy(&rbuffer->valid_buffer_range);
+	pipe_resource_reference((struct pipe_resource**)&rbuffer->immed_buffer, NULL);
 	pb_reference(&rbuffer->buf, NULL);
 	FREE(rbuffer);
 }
@@ -465,6 +466,7 @@ r600_alloc_buffer_struct(struct pipe_screen *screen,
 	rbuffer->buf = NULL;
 	rbuffer->TC_L2_dirty = false;
 	rbuffer->is_shared = false;
+	rbuffer->immed_buffer = NULL;
 	util_range_init(&rbuffer->valid_buffer_range);
 	return rbuffer;
 }
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 381ad21..4b4f1b1 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -172,6 +172,12 @@ struct r600_resource {
 	/* Whether the resource has been exported via resource_get_handle. */
 	bool				is_shared;
 	unsigned			external_usage; /* PIPE_HANDLE_USAGE_* */
+
+	/*
+	 * EG/Cayman only - for RAT operations hw need an immediate buffer
+	 * to store results in.
+	 */
+	struct r600_resource            *immed_buffer;
 };
 
 struct r600_transfer {
@@ -611,6 +617,10 @@ void r600_texture_disable_dcc(struct r600_common_screen *rscreen,
 void r600_init_screen_texture_functions(struct r600_common_screen *rscreen);
 void r600_init_context_texture_functions(struct r600_common_context *rctx);
 
+void eg_resource_alloc_immed(struct r600_common_screen *rscreen,
+			     struct r600_resource *res,
+			     unsigned immed_size);
+
 /* cayman_msaa.c */
 extern const uint32_t eg_sample_locs_2x[4];
 extern const unsigned eg_max_dist_2x;
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 83fc002..d117c10 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -391,6 +391,7 @@ static void r600_texture_destroy(struct pipe_screen *screen,
 	if (rtex->cmask_buffer != &rtex->resource) {
 	    pipe_resource_reference((struct pipe_resource**)&rtex->cmask_buffer, NULL);
 	}
+	pipe_resource_reference((struct pipe_resource**)&resource->immed_buffer, NULL);
 	pb_reference(&resource->buf, NULL);
 	FREE(rtex);
 }
@@ -615,6 +616,15 @@ static void r600_texture_alloc_cmask_separate(struct r600_common_screen *rscreen
 	p_atomic_inc(&rscreen->compressed_colortex_counter);
 }
 
+void eg_resource_alloc_immed(struct r600_common_screen *rscreen,
+			     struct r600_resource *res,
+			     unsigned immed_size)
+{
+	res->immed_buffer = (struct r600_resource *)
+		pipe_buffer_create(&rscreen->b, PIPE_BIND_CUSTOM,
+				   PIPE_USAGE_DEFAULT, immed_size);
+}
+
 static unsigned r600_texture_get_htile_size(struct r600_common_screen *rscreen,
 					    struct r600_texture *rtex)
 {
-- 
2.5.0



More information about the mesa-dev mailing list