<p dir="ltr"><br>
On Jan 9, 2015 2:43 AM, "Samuel Iglesias Gonsalvez" <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>> wrote:<br>
><br>
> This will be used to unify code in pack.c.<br>
><br>
> v2:<br>
> - Modify pack_int_*() function generator to use c.datatype() and<br>
>   f.datatype()<br>
><br>
> v3:<br>
> - Only autogenerate pack_int_*() functions for non-normalized integer<br>
>   formats.<br>
><br>
> Signed-off-by: Samuel Iglesias Gonsalvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
> ---<br>
>  src/mesa/main/format_pack.h  |  3 ++<br>
>  src/mesa/main/format_pack.py | 85 ++++++++++++++++++++++++++++++++++++++++++++<br>
>  2 files changed, 88 insertions(+)<br>
><br>
> diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h<br>
> index 1582ad1..6087fc3 100644<br>
> --- a/src/mesa/main/format_pack.h<br>
> +++ b/src/mesa/main/format_pack.h<br>
> @@ -68,6 +68,9 @@ extern gl_pack_ubyte_stencil_func<br>
>  _mesa_get_pack_ubyte_stencil_func(mesa_format format);<br>
><br>
><br>
> +extern void<br>
> +_mesa_pack_int_rgba_row(mesa_format format, GLuint n,<br>
> +                          const GLint src[][4], void *dst);<br>
><br>
>  extern void<br>
>  _mesa_pack_float_rgba_row(mesa_format format, GLuint n,<br>
> diff --git a/src/mesa/main/format_pack.py b/src/mesa/main/format_pack.py<br>
> index f141da8..f714923 100644<br>
> --- a/src/mesa/main/format_pack.py<br>
> +++ b/src/mesa/main/format_pack.py<br>
> @@ -214,6 +214,59 @@ pack_uint_${f.short_name()}(const GLuint src[4], void *dst)<br>
>  }<br>
>  %endfor<br>
><br>
> +/* int 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_int_${f.short_name()}(const GLint 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>
> +      %elif c.type == parser.UNSIGNED:<br>
> +         _mesa_signed_to_unsigned(src[${i}], ${c.size});</p>
<p dir="ltr">As I just commented on another patch, this needs to be unsigned_to_unsigned</p>
<p dir="ltr">With that, assuming no piglit regressions, you can have my r-b here too.</p>
<p dir="ltr">--Jason</p>
<p dir="ltr">> +      %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>
>  %for f in rgb_formats:<br>
> @@ -397,6 +450,38 @@ _mesa_pack_uint_rgba_row(mesa_format format, GLuint n,<br>
>  }<br>
><br>
>  /**<br>
> + * Pack a row of GLint rgba[4] values to the destination.<br>
> + */<br>
> +void<br>
> +_mesa_pack_int_rgba_row(mesa_format format, GLuint n,<br>
> +                          const GLint 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_int_${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>
> 2.1.0<br>
><br>
</p>