[Mesa-dev] [PATCH] nir/vtn: fix OpConvertXToY

Jason Ekstrand jason at jlekstrand.net
Wed Mar 14 15:30:56 UTC 2018


Samuel sent out a patch to fix this already which I've reviewed.  Feel free
to merge it.  I gave him comments on the second so maybe best to leave that
one be.

That said, I do sort-of like your macro...

On Wed, Mar 14, 2018 at 8:08 AM, Rob Clark <robdclark at gmail.com> wrote:

> These opcodes don't care about src/dst type, only src/dst size.
>
> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
>  src/compiler/spirv/vtn_alu.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
> index f0b69b38f83..1ca1f951200 100644
> --- a/src/compiler/spirv/vtn_alu.c
> +++ b/src/compiler/spirv/vtn_alu.c
> @@ -349,11 +349,17 @@ vtn_nir_alu_op_for_spirv_opcode(struct vtn_builder
> *b,
>
>     /* Conversions: */
>     case SpvOpQuantizeToF16:         return nir_op_fquantize2f16;
> +
> +#define nir_type_cast(type, basetype) (nir_alu_type_get_type_size(type)
> | nir_type_ ## basetype)
> +#define typed_conversion_op(src, srctype, dst, dsttype) \
> +      nir_type_conversion_op(nir_type_cast(src, srctype),
> nir_type_cast(dst, dsttype), nir_rounding_mode_undef)
> +
> +   case SpvOpConvertFToU:  return typed_conversion_op(src, float, dst,
> uint);
> +   case SpvOpConvertFToS:  return typed_conversion_op(src, float, dst,
>  int);
> +   case SpvOpConvertSToF:  return typed_conversion_op(src,   int, dst,
> float);
> +   case SpvOpConvertUToF:  return typed_conversion_op(src,  uint, dst,
> float);
> +
>     case SpvOpUConvert:
> -   case SpvOpConvertFToU:
> -   case SpvOpConvertFToS:
> -   case SpvOpConvertSToF:
> -   case SpvOpConvertUToF:
>     case SpvOpSConvert:
>     case SpvOpFConvert:
>        return nir_type_conversion_op(src, dst, nir_rounding_mode_undef);
> --
> 2.14.3
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180314/c75f3a00/attachment-0001.html>


More information about the mesa-dev mailing list