[Mesa-dev] [PATCH 09/25] radeonsi: add code for combining and uploading shaders from 3 shader parts
Nicolai Hähnle
nhaehnle at gmail.com
Tue Feb 16 15:53:13 UTC 2016
On 15.02.2016 18:59, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/gallium/drivers/radeonsi/si_shader.c | 35 ++++++++++++++++++++++++--------
> src/gallium/drivers/radeonsi/si_shader.h | 9 ++++++++
> 2 files changed, 36 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
> index dbb9217..a6a0984 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -4036,26 +4036,45 @@ void si_shader_apply_scratch_relocs(struct si_context *sctx,
>
> int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
> {
> - const struct radeon_shader_binary *binary = &shader->binary;
> - unsigned code_size = binary->code_size + binary->rodata_size;
> + const struct radeon_shader_binary *prolog =
> + shader->prolog ? &shader->prolog->binary : NULL;
> + const struct radeon_shader_binary *epilog =
> + shader->epilog ? &shader->epilog->binary : NULL;
> + const struct radeon_shader_binary *mainb = &shader->binary;
> + unsigned bo_size =
> + (prolog ? prolog->code_size : 0) +
> + mainb->code_size +
> + (epilog ? epilog->code_size : mainb->rodata_size);
> unsigned char *ptr;
>
> + assert(!prolog || !prolog->rodata_size);
> + assert((!prolog && !epilog) || !mainb->rodata_size);
> + assert(!epilog || !epilog->rodata_size);
Strictly speaking it should be possible for main to have rodata if there
is a prolog but no epilog, right? In any case, patches 1-9 are
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
> +
> r600_resource_reference(&shader->bo, NULL);
> shader->bo = si_resource_create_custom(&sscreen->b.b,
> PIPE_USAGE_IMMUTABLE,
> - code_size);
> + bo_size);
> if (!shader->bo)
> return -ENOMEM;
>
> + /* Upload. */
> ptr = sscreen->b.ws->buffer_map(shader->bo->buf, NULL,
> PIPE_TRANSFER_READ_WRITE);
> - util_memcpy_cpu_to_le32(ptr, binary->code, binary->code_size);
> - if (binary->rodata_size > 0) {
> - ptr += binary->code_size;
> - util_memcpy_cpu_to_le32(ptr, binary->rodata,
> - binary->rodata_size);
> +
> + if (prolog) {
> + util_memcpy_cpu_to_le32(ptr, prolog->code, prolog->code_size);
> + ptr += prolog->code_size;
> }
>
> + util_memcpy_cpu_to_le32(ptr, mainb->code, mainb->code_size);
> + ptr += mainb->code_size;
> +
> + if (epilog)
> + util_memcpy_cpu_to_le32(ptr, epilog->code, epilog->code_size);
> + else if (mainb->rodata_size > 0)
> + util_memcpy_cpu_to_le32(ptr, mainb->rodata, mainb->rodata_size);
> +
> sscreen->b.ws->buffer_unmap(shader->bo->buf);
> return 0;
> }
> diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
> index 9331156..4c3c14a 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.h
> +++ b/src/gallium/drivers/radeonsi/si_shader.h
> @@ -304,6 +304,9 @@ struct si_shader {
> struct si_shader_selector *selector;
> struct si_shader *next_variant;
>
> + struct si_shader_part *prolog;
> + struct si_shader_part *epilog;
> +
> struct si_shader *gs_copy_shader;
> struct si_pm4_state *pm4;
> struct r600_resource *bo;
> @@ -322,6 +325,12 @@ struct si_shader {
> unsigned nr_param_exports;
> };
>
> +struct si_shader_part {
> + struct si_shader_part *next;
> + struct radeon_shader_binary binary;
> + struct si_shader_config config;
> +};
> +
> static inline struct tgsi_shader_info *si_get_vs_info(struct si_context *sctx)
> {
> if (sctx->gs_shader.cso)
>
More information about the mesa-dev
mailing list