<p dir="ltr"><br>
On Jan 29, 2016 8:44 AM, "Iago Toral" <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br>
><br>
> On Thu, 2016-01-28 at 09:21 -0800, Matt Turner wrote:<br>
> > On Thu, Jan 28, 2016 at 12:32 AM, Iago Toral <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br>
> > > On Mon, 2016-01-25 at 15:18 -0800, Matt Turner wrote:<br>
> (...)<br>
> > >> diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py<br>
> > >> index b761b54..56b0f5e 100644<br>
> > >> --- a/src/glsl/nir/nir_opt_algebraic.py<br>
> > >> +++ b/src/glsl/nir/nir_opt_algebraic.py<br>
> > >> @@ -258,6 +258,26 @@ optimizations = [<br>
> > >> (('extract_uword', a, b),<br>
> > >> ('iand', ('ushr', a, ('imul', b, 16)), 0xffff),<br>
> > >> 'options->lower_extract_word'),<br>
> > >> +<br>
> > >> + (('pack_unorm_2x16', 'v'),<br>
> > >> + ('pack_uvec2_to_uint',<br>
> > >> + ('f2u', ('fround_even', ('fmul', ('fsat', 'v'), 65535.0)))),<br>
> > >> + 'options->lower_pack_unorm_2x16'),<br>
> > >> +<br>
> > >> + (('pack_unorm_4x8', 'v'),<br>
> > >> + ('pack_uvec4_to_uint',<br>
> > >> + ('f2u', ('fround_even', ('fmul', ('fsat', 'v'), 255.0)))),<br>
> > >> + 'options->lower_pack_unorm_4x8'),<br>
> > >> +<br>
> > >> + (('pack_snorm_2x16', 'v'),<br>
> > >> + ('pack_uvec2_to_uint',<br>
> > >> + ('f2i', ('fround_even', ('fmul', ('fmin', 1.0, ('fmax', -1.0, 'v')), 32767.0)))),<br>
> > >> + 'options->lower_pack_snorm_2x16'),<br>
> > >> +<br>
> > >> + (('pack_snorm_4x8', 'v'),<br>
> > >> + ('pack_uvec4_to_uint',<br>
> > >> + ('f2i', ('fround_even', ('fmul', ('fmin', 1.0, ('fmax', -1.0, 'v')), 127.0)))),<br>
> > >> + 'options->lower_pack_snorm_4x8'),<br>
> > ><br>
> > > I think the pack_snorm_* opcodes need a i2u conversion at the end.<br>
> > > That's what the GLSL IR lowering is doing and also what the spec [1]<br>
> > > seems to indicate:<br>
> ><br>
> > Right, but since NIR operands are typeless, there's nothing to do (NIR<br>
> > doesn't even have i2u/u2i).<br>
><br>
> I suppose that since these pack the incoming vector components into an<br>
> uint it does not really matter in the end, since that won't affect the<br>
> bits involved. Anyway, why not use f2u instead of f2i, seems like that<br>
> would represent the semantics expected more accurately.</p>
<p dir="ltr">Actually, since this is for snorm, I think signed integers are, in fact, what you want. The fact that we're packing things into a single uint later doesn't matter. I don't know off-hand what happens if you run a negative number through f2u.</p>
<p dir="ltr">> Iago<br>
><br>
><br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>