On Jan 9, 2015 2:43 AM, "Samuel Iglesias Gonsalvez" <sigles...@igalia.com> wrote: > > This will be used to unify code in pack.c. > > v2: > - Modify pack_int_*() function generator to use c.datatype() and > f.datatype() > > v3: > - Only autogenerate pack_int_*() functions for non-normalized integer > formats. > > Signed-off-by: Samuel Iglesias Gonsalvez <sigles...@igalia.com> > --- > src/mesa/main/format_pack.h | 3 ++ > src/mesa/main/format_pack.py | 85 ++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 88 insertions(+) > > diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h > index 1582ad1..6087fc3 100644 > --- a/src/mesa/main/format_pack.h > +++ b/src/mesa/main/format_pack.h > @@ -68,6 +68,9 @@ extern gl_pack_ubyte_stencil_func > _mesa_get_pack_ubyte_stencil_func(mesa_format format); > > > +extern void > +_mesa_pack_int_rgba_row(mesa_format format, GLuint n, > + const GLint src[][4], void *dst); > > extern void > _mesa_pack_float_rgba_row(mesa_format format, GLuint n, > diff --git a/src/mesa/main/format_pack.py b/src/mesa/main/format_pack.py > index f141da8..f714923 100644 > --- a/src/mesa/main/format_pack.py > +++ b/src/mesa/main/format_pack.py > @@ -214,6 +214,59 @@ pack_uint_${f.short_name()}(const GLuint src[4], void *dst) > } > %endfor > > +/* int packing functions */ > + > +%for f in rgb_formats: > + %if not f.is_int(): > + <% continue %> > + %elif f.is_normalized(): > + <% continue %> > + %elif f.is_compressed(): > + <% continue %> > + %endif > + > +static inline void > +pack_int_${f.short_name()}(const GLint src[4], void *dst) > +{ > + %for (i, c) in enumerate(f.channels): > + <% i = f.swizzle.inverse()[i] %> > + %if c.type == 'x': > + <% continue %> > + %endif > + > + ${c.datatype()} ${c.name} = > + %if c.type == parser.SIGNED: > + _mesa_signed_to_signed(src[${i}], ${c.size}); > + %elif c.type == parser.UNSIGNED: > + _mesa_signed_to_unsigned(src[${i}], ${c.size});
As I just commented on another patch, this needs to be unsigned_to_unsigned With that, assuming no piglit regressions, you can have my r-b here too. --Jason > + %else: > + assert(!"Invalid type: only integer types are allowed"); > + %endif > + %endfor > + > + %if f.layout == parser.ARRAY: > + ${f.datatype()} *d = (${f.datatype()} *)dst; > + %for (i, c) in enumerate(f.channels): > + %if c.type == 'x': > + <% continue %> > + %endif > + d[${i}] = ${c.name}; > + %endfor > + %elif f.layout == parser.PACKED: > + ${f.datatype()} d = 0; > + %for (i, c) in enumerate(f.channels): > + %if c.type == 'x': > + <% continue %> > + %endif > + d |= PACK(${c.name}, ${c.shift}, ${c.size}); > + %endfor > + (*(${f.datatype()} *)dst) = d; > + %else: > + <% assert False %> > + %endif > +} > +%endfor > + > /* float packing functions */ > > %for f in rgb_formats: > @@ -397,6 +450,38 @@ _mesa_pack_uint_rgba_row(mesa_format format, GLuint n, > } > > /** > + * Pack a row of GLint rgba[4] values to the destination. > + */ > +void > +_mesa_pack_int_rgba_row(mesa_format format, GLuint n, > + const GLint src[][4], void *dst) > +{ > + GLuint i; > + GLubyte *d = dst; > + > + switch (format) { > +%for f in rgb_formats: > + %if not f.is_int(): > + <% continue %> > + %elif f.is_normalized(): > + <% continue %> > + %elif f.is_compressed(): > + <% continue %> > + %endif > + > + case ${f.name}: > + for (i = 0; i < n; ++i) { > + pack_int_${f.short_name()}(src[i], d); > + d += ${f.block_size() / 8}; > + } > + break; > +%endfor > + default: > + assert(!"Invalid format"); > + } > +} > + > +/** > * Pack a row of GLfloat rgba[4] values to the destination. > */ > void > -- > 2.1.0 >
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev