[Mesa-dev] [PATCH 11/16] radeonsi: unify code for extracting a buffer address from a descriptor

Marek Olšák maraeo at gmail.com
Fri Oct 13 12:04:07 UTC 2017


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

---
 src/gallium/drivers/radeonsi/si_descriptors.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index cac203b..3c33e85 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -90,20 +90,25 @@ static uint32_t null_texture_descriptor[8] = {
 
 static uint32_t null_image_descriptor[8] = {
 	0,
 	0,
 	0,
 	S_008F1C_TYPE(V_008F1C_SQ_RSRC_IMG_1D)
 	/* the rest must contain zeros, which is also used by the buffer
 	 * descriptor */
 };
 
+static uint64_t si_desc_extract_buffer_address(uint32_t *desc)
+{
+	return desc[0] | ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc[1]) << 32);
+}
+
 static void si_init_descriptor_list(uint32_t *desc_list,
 				    unsigned element_dw_size,
 				    unsigned num_elements,
 				    const uint32_t *null_descriptor)
 {
 	int i;
 
 	/* Initialize the array to NULL descriptors if the element size is 8. */
 	if (null_descriptor) {
 		assert(element_dw_size % 8 == 0);
@@ -1358,22 +1363,21 @@ 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,
 					struct pipe_resource *new_buf)
 {
 	/* Retrieve the buffer offset from the descriptor. */
-	uint64_t old_desc_va =
-		desc[0] | ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc[1]) << 32);
+	uint64_t old_desc_va = si_desc_extract_buffer_address(desc);
 
 	assert(old_buf_va <= old_desc_va);
 	uint64_t offset_within_buffer = old_desc_va - old_buf_va;
 
 	/* Update the descriptor. */
 	si_set_buf_desc_address(r600_resource(new_buf), offset_within_buffer,
 				desc);
 }
 
 /* INTERNAL CONST BUFFERS */
@@ -2171,22 +2175,21 @@ static void si_update_bindless_buffer_descriptor(struct si_context *sctx,
 {
 	struct si_descriptors *desc = &sctx->bindless_descriptors;
 	struct r600_resource *buf = r600_resource(resource);
 	unsigned desc_slot_offset = desc_slot * 16;
 	uint32_t *desc_list = desc->list + desc_slot_offset + 4;
 	uint64_t old_desc_va;
 
 	assert(resource->target == PIPE_BUFFER);
 
 	/* Retrieve the old buffer addr from the descriptor. */
-	old_desc_va  = desc_list[0];
-	old_desc_va |= ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc_list[1]) << 32);
+	old_desc_va = si_desc_extract_buffer_address(desc_list);
 
 	if (old_desc_va != buf->gpu_address + offset) {
 		/* The buffer has been invalidated when the handle wasn't
 		 * resident, update the descriptor and the dirty flag.
 		 */
 		si_set_buf_desc_address(buf, offset, &desc_list[0]);
 
 		*desc_dirty = true;
 	}
 }
-- 
2.7.4



More information about the mesa-dev mailing list