[Mesa-dev] [PATCH 2/2] ac/nir: add glsl_is_array_image() helper

Bas Nieuwenhuizen basni at chromium.org
Tue Feb 20 12:24:27 UTC 2018


Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

for the series.

On Tue, Feb 20, 2018 at 11:11 AM, Samuel Pitoiset <samuel.pitoiset at gmail.com
> wrote:

> For consistency.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/amd/common/ac_nir_to_llvm.c | 41 ++++++++++++++++++------------
> -----------
>  1 file changed, 18 insertions(+), 23 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_
> llvm.c
> index 9244f8bc7b..8840bc8cc3 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -3419,6 +3419,19 @@ static int image_type_to_components_count(enum
> glsl_sampler_dim dim, bool array)
>         return 0;
>  }
>
> +static bool
> +glsl_is_array_image(const struct glsl_type *type)
> +{
> +       const enum glsl_sampler_dim dim = glsl_get_sampler_dim(type);
> +
> +       if (glsl_sampler_type_is_array(type))
> +               return true;
> +
> +       return dim == GLSL_SAMPLER_DIM_CUBE ||
> +              dim == GLSL_SAMPLER_DIM_3D ||
> +              dim == GLSL_SAMPLER_DIM_SUBPASS ||
> +              dim == GLSL_SAMPLER_DIM_SUBPASS_MS;
> +}
>
>
>  /* Adjust the sample index according to FMASK.
> @@ -3623,12 +3636,7 @@ static LLVMValueRef visit_image_load(struct
> ac_nir_context *ctx,
>                 res = trim_vector(&ctx->ac, res, instr->dest.ssa.num_
> components);
>                 res = ac_to_integer(&ctx->ac, res);
>         } else {
> -               bool is_da = glsl_sampler_type_is_array(type) ||
> -                            dim == GLSL_SAMPLER_DIM_CUBE ||
> -                            dim == GLSL_SAMPLER_DIM_3D ||
> -                            dim == GLSL_SAMPLER_DIM_SUBPASS ||
> -                            dim == GLSL_SAMPLER_DIM_SUBPASS_MS;
> -               LLVMValueRef da = is_da ? ctx->ac.i1true : ctx->ac.i1false;
> +               LLVMValueRef da = glsl_is_array_image(type) ?
> ctx->ac.i1true : ctx->ac.i1false;
>                 LLVMValueRef glc = ctx->ac.i1false;
>                 LLVMValueRef slc = ctx->ac.i1false;
>
> @@ -3676,10 +3684,7 @@ static void visit_image_store(struct ac_nir_context
> *ctx,
>                 ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.buffer.store.format.v4f32",
> ctx->ac.voidt,
>                                    params, 6, 0);
>         } else {
> -               bool is_da = glsl_sampler_type_is_array(type) ||
> -                            dim == GLSL_SAMPLER_DIM_CUBE ||
> -                            dim == GLSL_SAMPLER_DIM_3D;
> -               LLVMValueRef da = is_da ? ctx->ac.i1true : ctx->ac.i1false;
> +               LLVMValueRef da = glsl_is_array_image(type) ?
> ctx->ac.i1true : ctx->ac.i1false;
>                 LLVMValueRef slc = ctx->ac.i1false;
>
>                 params[0] = ac_to_float(&ctx->ac, get_src(ctx,
> instr->src[2]));
> @@ -3763,15 +3768,11 @@ static LLVMValueRef visit_image_atomic(struct
> ac_nir_context *ctx,
>         } else {
>                 char coords_type[8];
>
> -               bool da = glsl_sampler_type_is_array(type) ||
> -                         glsl_get_sampler_dim(type) ==
> GLSL_SAMPLER_DIM_CUBE ||
> -                         glsl_get_sampler_dim(type) ==
> GLSL_SAMPLER_DIM_3D;
> -
>                 LLVMValueRef coords = params[param_count++] =
> get_image_coords(ctx, instr);
>                 params[param_count++] = get_sampler_desc(ctx,
> instr->variables[0], AC_DESC_IMAGE,
>                                                          NULL, true, true);
>                 params[param_count++] = ctx->ac.i1false; /* r128 */
> -               params[param_count++] = da ? ctx->ac.i1true :
> ctx->ac.i1false;      /* da */
> +               params[param_count++] = glsl_is_array_image(type) ?
> ctx->ac.i1true : ctx->ac.i1false;      /* da */
>                 params[param_count++] = ctx->ac.i1false;  /* slc */
>
>                 build_int_type_name(LLVMTypeOf(coords),
> @@ -3790,12 +3791,9 @@ static LLVMValueRef visit_image_samples(struct
> ac_nir_context *ctx,
>  {
>         const nir_variable *var = instr->variables[0]->var;
>         const struct glsl_type *type = glsl_without_array(var->type);
> -       bool da = glsl_sampler_type_is_array(type) ||
> -                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE ||
> -                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_3D;
>
>         struct ac_image_args args = { 0 };
> -       args.da = da;
> +       args.da = glsl_is_array_image(type);
>         args.dmask = 0xf;
>         args.resource = get_sampler_desc(ctx, instr->variables[0],
>                                          AC_DESC_IMAGE, NULL, true, false);
> @@ -3811,9 +3809,6 @@ static LLVMValueRef visit_image_size(struct
> ac_nir_context *ctx,
>         LLVMValueRef res;
>         const nir_variable *var = instr->variables[0]->var;
>         const struct glsl_type *type = glsl_without_array(var->type);
> -       bool da = glsl_sampler_type_is_array(type) ||
> -                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE ||
> -                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_3D;
>
>         if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_BUF)
>                 return get_buffer_size(ctx,
> @@ -3822,7 +3817,7 @@ static LLVMValueRef visit_image_size(struct
> ac_nir_context *ctx,
>
>         struct ac_image_args args = { 0 };
>
> -       args.da = da;
> +       args.da = glsl_is_array_image(type);
>         args.dmask = 0xf;
>         args.resource = get_sampler_desc(ctx, instr->variables[0],
> AC_DESC_IMAGE, NULL, true, false);
>         args.opcode = ac_image_get_resinfo;
> --
> 2.16.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180220/71b39911/attachment.html>


More information about the mesa-dev mailing list