[Mesa-dev] [PATCH 4/8] radeonsi: prevent a negative buffer offset in si_upload_descriptors

Marek Olšák maraeo at gmail.com
Sun Feb 25 01:02:29 UTC 2018


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

Cc: 17.3 18.0 <mesa-stable at lists.freedesktop.org>
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 49b5a2c..6d5738b 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -160,25 +160,24 @@ static bool si_upload_descriptors(struct si_context *sctx,
 
 		/* The buffer is already in the buffer list. */
 		r600_resource_reference(&desc->buffer, NULL);
 		desc->gpu_list = NULL;
 		desc->gpu_address = si_desc_extract_buffer_address(descriptor);
 		si_mark_atom_dirty(sctx, &sctx->shader_pointers.atom);
 		return true;
 	}
 
 	uint32_t *ptr;
-	int buffer_offset;
-	u_upload_alloc(sctx->b.b.const_uploader, 0, upload_size,
+	unsigned buffer_offset;
+	u_upload_alloc(sctx->b.b.const_uploader, first_slot_offset, upload_size,
 		       si_optimal_tcc_alignment(sctx, upload_size),
-		       (unsigned*)&buffer_offset,
-		       (struct pipe_resource**)&desc->buffer,
+		       &buffer_offset, (struct pipe_resource**)&desc->buffer,
 		       (void**)&ptr);
 	if (!desc->buffer) {
 		desc->gpu_address = 0;
 		return false; /* skip the draw call */
 	}
 
 	util_memcpy_cpu_to_le32(ptr, (char*)desc->list + first_slot_offset,
 				upload_size);
 	desc->gpu_list = ptr - first_slot_offset / 4;
 
-- 
2.7.4



More information about the mesa-dev mailing list