<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 4, 2014 at 7:55 AM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 08/02/2014 02:11 PM, Jason Ekstrand wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Most format conversion operations required by GL can be performed by<br>
converting one channel at a time, shuffling the channels around, and<br>
optionally filling missing channels with zeros and ones.  This adds a<br>
function to do just that in a general, yet efficient, way.<br>
<br>
v2:<br>
  * Add better comments including full docs for functions<br>
  * Don't use __typeof__<br>
  * Use inline helpers instead of writing out conversions by hand,<br>
  * Force full loop unrolling for better performance<br>
<br>
Signed-off-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com" target="_blank">jason.ekstrand@intel.com</a>><br>
---<br>
  src/mesa/main/format_utils.c | 844 ++++++++++++++++++++++++++++++<u></u>+++++++++++++<br>
  src/mesa/main/format_utils.h |   5 +<br>
  2 files changed, 849 insertions(+)<br>
<br>
diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c<br>
index 241c158..d60aeb3 100644<br>
--- a/src/mesa/main/format_utils.c<br>
+++ b/src/mesa/main/format_utils.c<br>
@@ -54,3 +54,847 @@ _mesa_srgb_ubyte_to_linear_<u></u>float(uint8_t cl)<br>
<br>
     return lut[cl];<br>
  }<br>
+<br>
+/* A bunch of format conversion macros and helper functions used below */<br>
+<br>
+/* Only guaranteed to work for BITS <= 32 */<br>
+#define MAX_UINT(BITS) ((BITS) == 32 ? UINT32_MAX : ((1u << (BITS)) - 1))<br>
+#define MAX_INT(BITS) (int)MAX_UINT((BITS) - 1)<br>
</blockquote>
<br></div></div>
I'd probably put one more set of parens around the whole macro body, just to be safe.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Yup, fixed.<br></div><div>--Jason<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
<br>
-Brian<br>
<br>
</font></span></blockquote></div><br></div></div>