[Mesa-stable] [Mesa-dev] [PATCH 1/2] spirv: Fix image writes with less than 4 components.

Jason Ekstrand jason at jlekstrand.net
Sun Jul 15 02:00:06 UTC 2018


I thought I'd just fixed this...

Just sent a patch which fixes this and a few other image bugs.  I've
had it sitting in a FutureTech branch for about a week and forgot to
send it. :(

On July 14, 2018 16:26:17 Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl> wrote:

> nir_validate complains in case less than 4 components are
> provided.
>
> CC: 18.1 <mesa-stable at lists.freedesktop.org>
> ---
> src/compiler/spirv/spirv_to_nir.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/src/compiler/spirv/spirv_to_nir.c
> b/src/compiler/spirv/spirv_to_nir.c
> index 48154303ff2..b082af57b10 100644
> --- a/src/compiler/spirv/spirv_to_nir.c
> +++ b/src/compiler/spirv/spirv_to_nir.c
> @@ -2450,10 +2450,20 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
>    case SpvOpAtomicStore:
>       intrin->src[3] = nir_src_for_ssa(vtn_ssa_value(b, w[4])->def);
>       break;
> -   case SpvOpImageWrite:
> -      intrin->src[3] = nir_src_for_ssa(vtn_ssa_value(b, w[3])->def);
> -      break;
> +   case SpvOpImageWrite: {
> +      nir_ssa_def *value = vtn_ssa_value(b, w[3])->def;
>
> +      if (value->num_components < 4) {
> +         unsigned swiz[4];
> +         for (unsigned i = 0; i < 4; i++)
> +            swiz[i] = i < value->num_components ? i : 0;
> +
> +         value = nir_swizzle(&b->nb, value, swiz, 4, false);
> +      }
> +
> +      intrin->src[3] = nir_src_for_ssa(value);
> +      break;
> +   }
>    case SpvOpAtomicCompareExchange:
>    case SpvOpAtomicIIncrement:
>    case SpvOpAtomicIDecrement:
> --
> 2.18.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-stable mailing list