[Mesa-dev] [PATCH 10/45] spirv: Enable FPRoundingMode decorator to nir operations
Chema Casanova
jmcasanova at igalia.com
Wed Aug 23 12:25:37 UTC 2017
El 17/08/17 a las 21:16, Jason Ekstrand escribió:
> On Thu, Jul 13, 2017 at 7:35 AM, Alejandro Piñeiro
> <apinheiro at igalia.com <mailto:apinheiro at igalia.com>> wrote:
>
> From: Jose Maria Casanova Crespo <jmcasanova at igalia.com
> <mailto:jmcasanova at igalia.com>>
>
> SpvOpFConvert now manages the FPRoundingMode decorator for the
> returning values enabling the nir_rounding_mode in the conversion
> operation to fp16 values.
> ---
> src/compiler/spirv/vtn_alu.c | 33 ++++++++++++++++++++++++++++++++-
> 1 file changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/spirv/vtn_alu.c
> b/src/compiler/spirv/vtn_alu.c
> index 7ec30b8..5a6cc1b 100644
> --- a/src/compiler/spirv/vtn_alu.c
> +++ b/src/compiler/spirv/vtn_alu.c
> @@ -354,7 +354,6 @@ vtn_nir_alu_op_for_spirv_opcode(SpvOp opcode,
> bool *swap,
> case SpvOpConvertSToF:
> case SpvOpConvertUToF:
> case SpvOpSConvert:
> - case SpvOpFConvert:
>
>
> Getting rid of this will break specialization constants. Also, can
> you apply a rounding mode to an OpSpecConstantOp? I'm guessing the
> spec doesn't say...
Good catch. This line removal wasn't needed at all, and we can just use
the nir_rounding_mode_undef for SpvOpFConvert. As you said the
VK_KHR_16bit_storage extension doesn't have impact on specialization
constants because it doesn't apply to conversions of constants that
could be specialized. It just applies to data to be load or stored using
push constants, uniforms, ssbo and input/outputs.
Locally fixed.
>
>
> return nir_type_conversion_op(src, dst,
> nir_rounding_mode_undef);
>
> /* Derivatives: */
> @@ -381,6 +380,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)
> +{
> + 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 +587,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.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org <mailto:mesa-dev at lists.freedesktop.org>
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> <https://lists.freedesktop.org/mailman/listinfo/mesa-dev>
>
>
More information about the mesa-dev
mailing list