[Mesa-dev] [PATCH 07/14] radeonsi: don't use util_memcpy_cpu_to_le32 for shader uploads

Nicolai Hähnle nhaehnle at gmail.com
Thu May 4 11:08:42 UTC 2017


On 28.04.2017 23:42, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> at least I think this is correct.

Yes, LLVM does the endian conversion.

Patches 1-7:

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>


> ---
>  src/gallium/drivers/radeonsi/si_shader.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
> index 06ad370..8bdde1a 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -6545,41 +6545,42 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
>  					PIPE_USAGE_IMMUTABLE,
>  					align(bo_size, SI_CPDMA_ALIGNMENT));
>  	if (!shader->bo)
>  		return -ENOMEM;
>
>  	/* Upload. */
>  	ptr = sscreen->b.ws->buffer_map(shader->bo->buf, NULL,
>  					PIPE_TRANSFER_READ_WRITE |
>  					PIPE_TRANSFER_UNSYNCHRONIZED);
>
> +	/* Don't use util_memcpy_cpu_to_le32. LLVM binaries are
> +	 * endian-independent. */
>  	if (prolog) {
> -		util_memcpy_cpu_to_le32(ptr, prolog->code, prolog->code_size);
> +		memcpy(ptr, prolog->code, prolog->code_size);
>  		ptr += prolog->code_size;
>  	}
>  	if (previous_stage) {
> -		util_memcpy_cpu_to_le32(ptr, previous_stage->code,
> -					previous_stage->code_size);
> +		memcpy(ptr, previous_stage->code, previous_stage->code_size);
>  		ptr += previous_stage->code_size;
>  	}
>  	if (prolog2) {
> -		util_memcpy_cpu_to_le32(ptr, prolog2->code, prolog2->code_size);
> +		memcpy(ptr, prolog2->code, prolog2->code_size);
>  		ptr += prolog2->code_size;
>  	}
>
> -	util_memcpy_cpu_to_le32(ptr, mainb->code, mainb->code_size);
> +	memcpy(ptr, mainb->code, mainb->code_size);
>  	ptr += mainb->code_size;
>
>  	if (epilog)
> -		util_memcpy_cpu_to_le32(ptr, epilog->code, epilog->code_size);
> +		memcpy(ptr, epilog->code, epilog->code_size);
>  	else if (mainb->rodata_size > 0)
> -		util_memcpy_cpu_to_le32(ptr, mainb->rodata, mainb->rodata_size);
> +		memcpy(ptr, mainb->rodata, mainb->rodata_size);
>
>  	sscreen->b.ws->buffer_unmap(shader->bo->buf);
>  	return 0;
>  }
>
>  static void si_shader_dump_disassembly(const struct ac_shader_binary *binary,
>  				       struct pipe_debug_callback *debug,
>  				       const char *name, FILE *file)
>  {
>  	char *line, *p;
>


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list