On Tue, Nov 18, 2014 at 12:44 AM, Iago Toral Quiroga <ito...@igalia.com> wrote:
> From: Samuel Iglesias Gonsalvez <sigles...@igalia.com> > > We will use this later on to handle uint conversion scenarios in a master > convert function. > > Signed-off-by: Samuel Iglesias Gonsalvez <sigles...@igalia.com> > --- > src/mesa/main/format_pack.c.mako | 88 > ++++++++++++++++++++++++++++++++++++++++ > src/mesa/main/format_pack.h | 3 ++ > 2 files changed, 91 insertions(+) > > diff --git a/src/mesa/main/format_pack.c.mako > b/src/mesa/main/format_pack.c.mako > index 13a20c1..b9f4656 100644 > --- a/src/mesa/main/format_pack.c.mako > +++ b/src/mesa/main/format_pack.c.mako > @@ -150,6 +150,62 @@ pack_ubyte_r11g11b10_float(const GLubyte src[4], void > *dst) > *d = float3_to_r11g11b10f(rgb); > } > > +/* uint 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_uint_${f.short_name()}(const GLuint src[4], void *dst) > +{ > + %for (i, c) in enumerate(f.channels): > + <% i = f.swizzle.inverse()[i] %> > + %if c.type == 'x': > + <% continue %> > + %endif > + > + ${channel_datatype(c)} ${c.name} = > + %if not f.is_normalized(): > This if isn't needed. If you want the assertion, an "assert not f.is_normalized" would be ok, but I don't see the need given the continues above. > + %if c.type == parser.FLOAT and c.size == 32: > + UINT_TO_FLOAT(src[${i}]); > Why are we doing UINT_TO_FLOAT here? If these are for non-normalied functions, shouldn't we just be clampping the floating-point value to the maximum range for the integer? > + %elif c.type == parser.FLOAT and c.size == 16: > + _mesa_float_to_half(UINT_TO_FLOAT(src[${i}])); > + %else: > + (${channel_datatype(c)}) src[${i}]; > + %endif > + %else: > + <% assert False %> > + %endif > + %endfor > + > + %if f.layout == parser.ARRAY: > + ${format_datatype(f)} *d = (${format_datatype(f)} *)dst; > + %for (i, c) in enumerate(f.channels): > + %if c.type == 'x': > + <% continue %> > + %endif > + d[${i}] = ${c.name}; > + %endfor > + %elif f.layout == parser.PACKED: > + ${format_datatype(f)} d = 0; > + %for (i, c) in enumerate(f.channels): > + %if c.type == 'x': > + <% continue %> > + %endif > + d |= PACK(${c.name}, ${c.shift}, ${c.size}); > + %endfor > + (*(${format_datatype(f)} *)dst) = d; > + %else: > + <% assert False %> > + %endif > +} > +%endfor > > /* float packing functions */ > > @@ -298,6 +354,38 @@ _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint > n, > } > > /** > + * Pack a row of GLuint rgba[4] values to the destination. > + */ > +void > +_mesa_pack_uint_rgba_row(mesa_format format, GLuint n, > + const GLuint 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_uint_${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 > diff --git a/src/mesa/main/format_pack.h b/src/mesa/main/format_pack.h > index 2577def..1582ad1 100644 > --- a/src/mesa/main/format_pack.h > +++ b/src/mesa/main/format_pack.h > @@ -77,6 +77,9 @@ extern void > _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n, > const GLubyte src[][4], void *dst); > > +extern void > +_mesa_pack_uint_rgba_row(mesa_format format, GLuint n, > + const GLuint src[][4], void *dst); > > extern void > _mesa_pack_ubyte_rgba_rect(mesa_format format, GLuint width, GLuint > height, > -- > 1.9.1 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev >
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev