[Mesa-dev] [PATCH v3 08/43] spirv: Enable FPRoundingMode decorator to nir operations
Jason Ekstrand
jason at jlekstrand.net
Mon Oct 30 22:03:38 UTC 2017
On Thu, Oct 12, 2017 at 11:37 AM, Jose Maria Casanova Crespo <
jmcasanova at igalia.com> wrote:
> SpvOpFConvert now manages the FPRoundingMode decorator for the
> returning values enabling the nir_rounding_mode in the conversion
> operation to fp16 values.
>
> v2: Fixed breaking of specialization constants. (Jason Ekstrand)
> ---
> src/compiler/spirv/vtn_alu.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
> index 7ec30b8a63..b7e1b72889 100644
> --- a/src/compiler/spirv/vtn_alu.c
> +++ b/src/compiler/spirv/vtn_alu.c
> @@ -381,6 +381,26 @@ handle_no_contraction(struct vtn_builder *b, struct
> vtn_value *val, int member,
> b->nb.exact = true;
> }
>
> +static void
> +handle_rounding_mode(struct vtn_builder *b, struct vtn_value *val, int
> member,
> + const struct vtn_decoration *dec, void
> *_out_rounding_mode)
> +{
>
How about we put
nir_rounding_mode *out_rounding_mode = _out_rounding_mode;
here and avoid the cast below.
> + assert(dec->scope == VTN_DEC_DECORATION);
> + if (dec->decoration != SpvDecorationFPRoundingMode)
> + return;
> + switch (dec->literals[0]) {
> + case SpvFPRoundingModeRTE:
> + *((nir_rounding_mode *) _out_rounding_mode) =
> nir_rounding_mode_rtne;
> + break;
> + case SpvFPRoundingModeRTZ:
> + *((nir_rounding_mode *) _out_rounding_mode) =
> nir_rounding_mode_rtz;
> + break;
> + default:
> + unreachable("Not supported rounding mode");
> + break;
> + }
> +}
> +
> void
> vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
> const uint32_t *w, unsigned count)
> @@ -568,6 +588,18 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
> vtn_handle_bitcast(b, val->ssa, src[0]);
> break;
>
> + case SpvOpFConvert: {
> + nir_alu_type src_alu_type = nir_get_nir_type_for_glsl_
> type(vtn_src[0]->type);
> + nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(type);
> + nir_rounding_mode rounding_mode = nir_rounding_mode_undef;
> +
> + vtn_foreach_decoration(b, val, handle_rounding_mode,
> &rounding_mode);
> + nir_op op = nir_type_conversion_op(src_alu_type, dst_alu_type,
> rounding_mode);
> +
> + val->ssa->def = nir_build_alu(&b->nb, op, src[0], src[1], NULL,
> NULL);
> + break;
> + }
> +
> default: {
> bool swap;
> nir_alu_type src_alu_type = nir_get_nir_type_for_glsl_
> type(vtn_src[0]->type);
> --
> 2.13.6
>
> _______________________________________________
> 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/20171030/79e8bfbe/attachment.html>
More information about the mesa-dev
mailing list