[Mesa-dev] [PATCH] radeonsi: simplify constant buffer upload for big endian
Michel Dänzer
michel at daenzer.net
Sat Aug 9 20:10:46 PDT 2014
On 10.08.2014 06:54, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> Point util_memcpy_cpu_to_le32 to a buffer storage directly.
> ---
> src/gallium/drivers/radeonsi/si_descriptors.c | 15 +++------------
> 1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
> index 81ad14b..bfd2b76 100644
> --- a/src/gallium/drivers/radeonsi/si_descriptors.c
> +++ b/src/gallium/drivers/radeonsi/si_descriptors.c
> @@ -649,20 +649,11 @@ void si_upload_const_buffer(struct si_context *sctx, struct r600_resource **rbuf
> const uint8_t *ptr, unsigned size, uint32_t *const_offset)
> {
> if (SI_BIG_ENDIAN) {
> - uint32_t *tmpPtr;
> - unsigned i;
> -
> - if (!(tmpPtr = malloc(size))) {
> - R600_ERR("Failed to allocate BE swap buffer.\n");
> - return;
> - }
> + void *tmpPtr;
>
> + u_upload_alloc(sctx->b.uploader, 0, size, const_offset,
> + (struct pipe_resource**)rbuffer, &tmpPtr);
> util_memcpy_cpu_to_le32(tmpPtr, ptr, size);
> -
> - u_upload_data(sctx->b.uploader, 0, size, tmpPtr, const_offset,
> - (struct pipe_resource**)rbuffer);
> -
> - free(tmpPtr);
> } else {
> u_upload_data(sctx->b.uploader, 0, size, ptr, const_offset,
> (struct pipe_resource**)rbuffer);
>
Since util_memcpy_cpu_to_le32() is memcpy() on little endian, is there
any point keeping the separate (non-)SI_BIG_ENDIAN paths here? Either way,
Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
More information about the mesa-dev
mailing list