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

Jason Ekstrand jason at jlekstrand.net
Tue Jan 12 17:23:48 PST 2016


On Tue, Jan 12, 2016 at 4:50 PM, Ian Romanick <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.


>
> Reviewed-by: Ian Romanick <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.
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20160112/e7c5c712/attachment.html>


More information about the mesa-dev mailing list