[Mesa-dev] [PATCH 1/2] nir: Add a fquantize2f16 opcode

Roland Scheidegger sroland at vmware.com
Tue Jan 12 17:36:54 PST 2016


Am 13.01.2016 um 02:23 schrieb Jason Ekstrand:
> On Tue, Jan 12, 2016 at 4:50 PM, Ian Romanick <idr at freedesktop.org
> <mailto:idr at freedesktop.org>> wrote:
> 
>     With the SPIR-V link added and the wording change suggested by Erik RE:
>     precision vs. number of bits in the type, this series is
> 
> 
> How about:
> 
> This opcode takes a 32-bit floating-point value and reduces its
> precision to that of a 16-bit half-float value.  Values inside the range
> of an fp16 get rounded, while values outside the range are clamped to
> the appropriate infinity.

I think you could just say this uses round-to-nearest(-even or
whatever). From that the rounding to infinty should follow. Truncation
would imply clamp to max representable value. (Albeit  the docs don't
actually seem to explicitly say that it's round-to-nearest?)
Though it's probably better to explicitly mention what happens with too
large values, it's not quite obvious this is really a result of the
rounding mode...

Roland


>  
> 
> 
>     Reviewed-by: Ian Romanick <ian.d.romanick at intel.com
>     <mailto:ian.d.romanick at intel.com>>
> 
> 
> Thanks!
>  
> 
> 
>     At some point we should add a debug mode that inserts these operations
>     in GLSL ES shaders around mediump and lowp types and operations.  Maybe
>     leave that as a GSoC or EVoC project...
> 
> 
> Yeah, that would be a pretty good decent project for someone who wants
> to get their feet wet in the compiler.
>  
> 
> 
>     On 01/12/2016 03:35 PM, Jason Ekstrand wrote:
>     > This opcode simply takes a 32-bit floating-point value and reduces its
>     > effective precision to 16 bits.
>     > ---
>     >  src/glsl/nir/nir_opcodes.py | 1 +
>     >  1 file changed, 1 insertion(+)
>     >
>     > diff --git a/src/glsl/nir/nir_opcodes.py b/src/glsl/nir/nir_opcodes.py
>     > index d31507f..9dbb341 100644
>     > --- a/src/glsl/nir/nir_opcodes.py
>     > +++ b/src/glsl/nir/nir_opcodes.py
>     > @@ -176,6 +176,7 @@ unop("ffloor", tfloat, "floorf(src0)")
>     >  unop("ffract", tfloat, "src0 - floorf(src0)")
>     >  unop("fround_even", tfloat, "_mesa_roundevenf(src0)")
>     >
>     > +unop("fquantize2f16", tfloat,
>     "_mesa_half_to_float(_mesa_float_to_half(src0))")
>     >
>     >  # Trigonometric operations.
>     >
>     >
> 
> 
> 
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



More information about the mesa-dev mailing list