[Mesa-dev] [PATCH 05/22] nir/spirv: cast shift operand to u32

Jason Ekstrand jason at jlekstrand.net
Tue Nov 13 21:11:14 UTC 2018


Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Cc: mesa-stable at lists.freedesktop.org

On Tue, Nov 13, 2018 at 9:48 AM Karol Herbst <kherbst at redhat.com> wrote:

> v2: fix for specialization constants as well
>
> Signed-off-by: Karol Herbst <kherbst at redhat.com>
> ---
>  src/compiler/spirv/spirv_to_nir.c | 20 ++++++++++++++++++++
>  src/compiler/spirv/vtn_alu.c      | 11 +++++++++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/src/compiler/spirv/spirv_to_nir.c
> b/src/compiler/spirv/spirv_to_nir.c
> index d72f07dc1f9..2c214324774 100644
> --- a/src/compiler/spirv/spirv_to_nir.c
> +++ b/src/compiler/spirv/spirv_to_nir.c
> @@ -1813,6 +1813,26 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp
> opcode,
>              src[j] = src_val->constant->values[0];
>           }
>
> +         /* fix up fixed size sources */
> +         switch (op) {
> +         case nir_op_ishl:
> +         case nir_op_ishr:
> +         case nir_op_ushr: {
> +            if (bit_size == 32)
> +               break;
> +            for (unsigned i = 0; i < num_components; ++i) {
> +               switch (bit_size) {
> +               case 64: src[1].u32[i] = src[1].u64[i]; break;
> +               case 16: src[1].u32[i] = src[1].u16[i]; break;
> +               case  8: src[1].u32[i] = src[1].u8[i];  break;
> +               }
> +            }
> +            break;
> +         }
> +         default:
> +            break;
> +         }
> +
>           val->constant->values[0] =
>              nir_eval_const_opcode(op, num_components, bit_size, src);
>           break;
> diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
> index ea25d4bcbdc..32825da29cb 100644
> --- a/src/compiler/spirv/vtn_alu.c
> +++ b/src/compiler/spirv/vtn_alu.c
> @@ -743,6 +743,17 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
>           src[1] = tmp;
>        }
>
> +      switch (op) {
> +      case nir_op_ishl:
> +      case nir_op_ishr:
> +      case nir_op_ushr:
> +         if (src[1]->bit_size != 32)
> +            src[1] = nir_u2u32(&b->nb, src[1]);
> +         break;
> +      default:
> +         break;
> +      }
> +
>        val->ssa->def = nir_build_alu(&b->nb, op, src[0], src[1], src[2],
> src[3]);
>        break;
>     } /* default */
> --
> 2.19.1
>
> _______________________________________________
> 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/20181113/361ad588/attachment.html>


More information about the mesa-dev mailing list