[Mesa-dev] [PATCH 2/3] radeonsi: Use util_memcpy_cpu_to_le32()

Tom Stellard thomas.stellard at amd.com
Fri Jul 18 12:10:52 PDT 2014


---
 src/gallium/drivers/radeonsi/si_descriptors.c | 4 +---
 src/gallium/drivers/radeonsi/si_shader.c      | 8 +-------
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 38ad077..41c1b67 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -451,9 +451,7 @@ void si_upload_const_buffer(struct si_context *sctx, struct r600_resource **rbuf
 			return;
 		}
 
-		for (i = 0; i < size / 4; ++i) {
-			tmpPtr[i] = util_cpu_to_le32(((uint32_t *)ptr)[i]);
-		}
+		util_memcpy_cpu_to_le32(tmpPtr, ptr, size);
 
 		u_upload_data(sctx->b.uploader, 0, size, tmpPtr, const_offset,
 				(struct pipe_resource**)rbuffer);
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index f0650f4..8593bca 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2559,13 +2559,7 @@ int si_compile_llvm(struct si_context *sctx, struct si_pipe_shader *shader,
 	}
 
 	ptr = (uint32_t*)sctx->b.ws->buffer_map(shader->bo->cs_buf, sctx->b.rings.gfx.cs, PIPE_TRANSFER_WRITE);
-	if (SI_BIG_ENDIAN) {
-		for (i = 0; i < binary.code_size / 4; ++i) {
-			ptr[i] = util_cpu_to_le32((*(uint32_t*)(binary.code + i*4)));
-		}
-	} else {
-		memcpy(ptr, binary.code, binary.code_size);
-	}
+	util_memcpy_cpu_to_le32(ptr, binary.code, binary.code_size);
 	sctx->b.ws->buffer_unmap(shader->bo->cs_buf);
 
 	free(binary.code);
-- 
1.8.1.5



More information about the mesa-dev mailing list