[Mesa-dev] [PATCH] radeonsi: Allow Sinking pass to move preloaded const/res/sampl

Marek Olšák maraeo at gmail.com
Sun Oct 6 09:02:07 PDT 2013


I don't like the hardcoded numbers and they are mostly wrong anyway.

The number of constant buffers is NUM_CONST_BUFFERS (which is 2).
The number of sampler views is NUM_SAMPLER_VIEWS (which is 32 at the moment).
The number of sampler states is NUM_TEX_UNITS (which is 16 at the
moment), feel free to define NUM_SAMPLER_STATES=NUM_TEX_UNITS next to
the definition of NUM_SAMPLER_VIEWS.

I don't like the magic "3" number in the expression "if (i < 3)".
Could you use a proper definition SI_PARAM_xxx?

Marek

On Sun, Oct 6, 2013 at 4:05 PM, Vincent Lejeune <vljn at ovi.com> wrote:
> This fixes a crash in Unigine Heaven 3.0, and probably in some
> others apps.
> ---
>  src/gallium/drivers/radeonsi/radeonsi_shader.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c
> index 97ed4e3..89c12c3 100644
> --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
> +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
> @@ -114,8 +114,12 @@ static LLVMValueRef build_indexed_load(
>  {
>         struct lp_build_context * base = &si_shader_ctx->radeon_bld.soa.bld_base.base;
>
> +       LLVMValueRef indices[2] = {
> +               LLVMConstInt(LLVMInt64TypeInContext(base->gallivm->context), 0, false),
> +               offset
> +       };
>         LLVMValueRef computed_ptr = LLVMBuildGEP(
> -               base->gallivm->builder, base_ptr, &offset, 1, "");
> +               base->gallivm->builder, base_ptr, indices, 2, "");
>
>         LLVMValueRef result = LLVMBuildLoad(base->gallivm->builder, computed_ptr, "");
>         LLVMSetMetadata(result, 1, si_shader_ctx->const_md);
> @@ -1578,9 +1582,13 @@ static void create_function(struct si_shader_context *si_shader_ctx)
>         v2i32 = LLVMVectorType(i32, 2);
>         v3i32 = LLVMVectorType(i32, 3);
>
> -       params[SI_PARAM_CONST] = LLVMPointerType(LLVMVectorType(i8, 16), CONST_ADDR_SPACE);
> -       params[SI_PARAM_SAMPLER] = params[SI_PARAM_CONST];
> -       params[SI_PARAM_RESOURCE] = LLVMPointerType(LLVMVectorType(i8, 32), CONST_ADDR_SPACE);
> +       params[SI_PARAM_CONST] = LLVMPointerType(LLVMArrayType(LLVMVectorType(i8, 16), 64), CONST_ADDR_SPACE);
> +       /* We assume at most 16 textures per program at the moment.
> +        * This need probably need to be changed to support bindless textures */
> +       params[SI_PARAM_SAMPLER] = LLVMPointerType(
> +               LLVMArrayType(LLVMVectorType(i8, 16), 16), CONST_ADDR_SPACE);
> +       params[SI_PARAM_RESOURCE] = LLVMPointerType(
> +               LLVMArrayType(LLVMVectorType(i8, 32), 16), CONST_ADDR_SPACE);
>
>         switch (si_shader_ctx->type) {
>         case TGSI_PROCESSOR_VERTEX:
> @@ -1647,6 +1655,10 @@ static void create_function(struct si_shader_context *si_shader_ctx)
>         for (i = 0; i <= last_sgpr; ++i) {
>                 LLVMValueRef P = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, i);
>                 LLVMAddAttribute(P, LLVMInRegAttribute);
> +               /* We tell llvm that array inputs are passed by value to allow Sinking pass
> +                * to move load. Inputs are constant so this is fine. */
> +               if (i < 3)
> +                       LLVMAddAttribute(P, LLVMByValAttribute);
>         }
>
>  #if HAVE_LLVM >= 0x0304
> --
> 1.8.3.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list