<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 18, 2014 at 12:44 AM, Iago Toral Quiroga <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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>
Signed-off-by: Samuel Iglesias Gonsalvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
---<br>
src/mesa/main/format_pack.c.mako | 88 ++++++++++++++++++++++++++++++++++++++++<br>
src/mesa/main/format_pack.h | 3 ++<br>
2 files changed, 91 insertions(+)<br>
<br>
diff --git a/src/mesa/main/format_pack.c.mako b/src/mesa/main/format_pack.c.mako<br>
index 13a20c1..b9f4656 100644<br>
--- a/src/mesa/main/format_pack.c.mako<br>
+++ b/src/mesa/main/format_pack.c.mako<br>
@@ -150,6 +150,62 @@ pack_ubyte_r11g11b10_float(const GLubyte src[4], void *dst)<br>
*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>
+ ${channel_datatype(c)} ${<a href="http://c.name" target="_blank">c.name</a>} =<br>
+ %if not f.is_normalized():<br></blockquote><div><br></div><div>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.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ %if c.type == parser.FLOAT and c.size == 32:<br>
+ UINT_TO_FLOAT(src[${i}]);<br></blockquote><div><br></div><div>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?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ %elif c.type == parser.FLOAT and c.size == 16:<br>
+ _mesa_float_to_half(UINT_TO_FLOAT(src[${i}]));<br>
+ %else:<br>
+ (${channel_datatype(c)}) src[${i}];<br>
+ %endif<br>
+ %else:<br>
+ <% assert False %><br>
+ %endif<br>
+ %endfor<br>
+<br>
+ %if f.layout == parser.ARRAY:<br>
+ ${format_datatype(f)} *d = (${format_datatype(f)} *)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" target="_blank">c.name</a>};<br>
+ %endfor<br>
+ %elif f.layout == parser.PACKED:<br>
+ ${format_datatype(f)} 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" target="_blank">c.name</a>}, ${c.shift}, ${c.size});<br>
+ %endfor<br>
+ (*(${format_datatype(f)} *)dst) = d;<br>
+ %else:<br>
+ <% assert False %><br>
+ %endif<br>
+}<br>
+%endfor<br>
<br>
/* float packing functions */<br>
<br>
@@ -298,6 +354,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" target="_blank">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>
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>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<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" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>