<p dir="ltr"><br>
On Jan 9, 2015 2:40 AM, "Samuel Iglesias Gonsálvez" <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>> wrote:<br>
><br>
> On Thursday, January 08, 2015 08:20:55 AM Iago Toral Quiroga wrote:<br>
> > From: Samuel Iglesias Gonsalvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
> ><br>
> > We will use this later on to handle uint conversion scenarios in a master<br>
> > convert function.<br>
> ><br>
> > v2:<br>
> > - Modify pack_uint_*() function generation to use c.datatype() and<br>
> >   f.datatype().<br>
> > - Remove UINT_TO_FLOAT() macro usage from pack_uint*()<br>
> > - Remove "if not f.is_normalized()" conditional as pack_uint*()<br>
> >   functions are only autogenerated for non normalized formats.<br>
> ><br>
> > v3:<br>
> > - Add clamping for non-normalized integer formats in pack_uint*()<br>
> ><br>
> > Signed-off-by: Samuel Iglesias Gonsalvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
> > Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
> > ---<br>
> >  src/mesa/main/format_pack.h  |  3 ++<br>
> >  src/mesa/main/format_pack.py | 84<br>
> > ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87<br>
> > insertions(+)<br>
> ><br>
> > diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h<br>
> > index 2577def..1582ad1 100644<br>
> > --- a/src/mesa/main/format_pack.h<br>
> > +++ b/src/mesa/main/format_pack.h<br>
> > @@ -77,6 +77,9 @@ extern void<br>
> >  _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n,<br>
> >                            const GLubyte src[][4], void *dst);<br>
> ><br>
> > +extern void<br>
> > +_mesa_pack_uint_rgba_row(mesa_format format, GLuint n,<br>
> > +                         const GLuint src[][4], void *dst);<br>
> ><br>
> >  extern void<br>
> >  _mesa_pack_ubyte_rgba_rect(mesa_format format, GLuint width, GLuint height,<br>
> > diff --git a/src/mesa/main/format_pack.py b/src/mesa/main/format_pack.py<br>
> > index cb347ab..3240d24 100644<br>
> > --- a/src/mesa/main/format_pack.py<br>
> > +++ b/src/mesa/main/format_pack.py<br>
> > @@ -160,6 +160,58 @@ pack_ubyte_r11g11b10_float(const GLubyte src[4], void<br>
> > *dst) *d = float3_to_r11g11b10f(rgb);<br>
> >  }<br>
> ><br>
> > +/* uint packing functions */<br>
> > +<br>
> > +%for f in rgb_formats:<br>
> > +   %if not f.is_int():<br>
> > +      <% continue %><br>
> > +   %elif f.is_normalized():<br>
> > +      <% continue %><br>
> > +   %elif f.is_compressed():<br>
> > +      <% continue %><br>
> > +   %endif<br>
> > +<br>
> > +static inline void<br>
> > +pack_uint_${f.short_name()}(const GLuint src[4], void *dst)<br>
> > +{<br>
> > +   %for (i, c) in enumerate(f.channels):<br>
> > +      <% i = f.swizzle.inverse()[i] %><br>
> > +      %if c.type == 'x':<br>
> > +         <% continue %><br>
> > +      %endif<br>
> > +<br>
> > +      ${c.datatype()} ${<a href="http://c.name">c.name</a>} =<br>
> > +      %if c.type == parser.SIGNED:<br>
> > +         _mesa_signed_to_signed(src[${i}], ${c.size});<br>
><br>
> When fixing "mesa/format_pack: Add _mesa_pack_int_rgba_row()" patch I found an<br>
> error here, it should be:<br>
><br>
>          _mesa_unsigned_to_signed(src[${i}], ${c.size});<br>
><br>
> I tested it with piglit and it gives no regressions.<br>
><br>
> Jason, if you agree with it, we will integrate this change before pushing the<br>
> patch to master.</p>
<p dir="ltr">No, I think this of the correct one.  In order to be able to pack both signed and unsigned formats, we need to sign-extend.  In other words, we test the 32-bit integer as signed for signed formats and treat it as unsigned for unsigned formats.</p>
<p dir="ltr">In the end it doesn't matter because we only end up using this for packed integer formats which are all unsigned anyway.  However we should keep with the same semantics we has before and do signed_to_signed.</p>
<p dir="ltr">><br>
> Sam<br>
><br>
> > +      %elif c.type == parser.UNSIGNED:<br>
> > +         _mesa_unsigned_to_unsigned(src[${i}], ${c.size});<br>
> > +      %else:<br>
> > +         assert(!"Invalid type: only integer types are allowed");<br>
> > +      %endif<br>
> > +   %endfor<br>
> > +<br>
> > +   %if f.layout == parser.ARRAY:<br>
> > +      ${f.datatype()} *d = (${f.datatype()} *)dst;<br>
> > +      %for (i, c) in enumerate(f.channels):<br>
> > +         %if c.type == 'x':<br>
> > +            <% continue %><br>
> > +         %endif<br>
> > +         d[${i}] = ${<a href="http://c.name">c.name</a>};<br>
> > +      %endfor<br>
> > +   %elif f.layout == parser.PACKED:<br>
> > +      ${f.datatype()} d = 0;<br>
> > +      %for (i, c) in enumerate(f.channels):<br>
> > +         %if c.type == 'x':<br>
> > +            <% continue %><br>
> > +         %endif<br>
> > +         d |= PACK(${<a href="http://c.name">c.name</a>}, ${c.shift}, ${c.size});<br>
> > +      %endfor<br>
> > +      (*(${f.datatype()} *)dst) = d;<br>
> > +   %else:<br>
> > +      <% assert False %><br>
> > +   %endif<br>
> > +}<br>
> > +%endfor<br>
> ><br>
> >  /* float packing functions */<br>
> ><br>
> > @@ -312,6 +364,38 @@ _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n,<br>
> > }<br>
> ><br>
> >  /**<br>
> > + * Pack a row of GLuint rgba[4] values to the destination.<br>
> > + */<br>
> > +void<br>
> > +_mesa_pack_uint_rgba_row(mesa_format format, GLuint n,<br>
> > +                          const GLuint src[][4], void *dst)<br>
> > +{<br>
> > +   GLuint i;<br>
> > +   GLubyte *d = dst;<br>
> > +<br>
> > +   switch (format) {<br>
> > +%for f in rgb_formats:<br>
> > +   %if not f.is_int():<br>
> > +      <% continue %><br>
> > +   %elif f.is_normalized():<br>
> > +      <% continue %><br>
> > +   %elif f.is_compressed():<br>
> > +      <% continue %><br>
> > +   %endif<br>
> > +<br>
> > +   case ${<a href="http://f.name">f.name</a>}:<br>
> > +      for (i = 0; i < n; ++i) {<br>
> > +         pack_uint_${f.short_name()}(src[i], d);<br>
> > +         d += ${f.block_size() / 8};<br>
> > +      }<br>
> > +      break;<br>
> > +%endfor<br>
> > +   default:<br>
> > +      assert(!"Invalid format");<br>
> > +   }<br>
> > +}<br>
> > +<br>
> > +/**<br>
> >   * Pack a row of GLfloat rgba[4] values to the destination.<br>
> >   */<br>
> >  void<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>
><br>
</p>