<div dir="ltr"><div>I like this patch, but I doubt it actually builds at this point in the series. There are other callers of _mesa_swizzle_and_convert.<br></div>--Jason<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 9, 2014 at 4:07 AM, Iago Toral Quiroga <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In the future we would like to have a format conversion library that is<br>
independent of GL so we can share it with Gallium. This is a step in that<br>
direction.<br>
---<br>
src/mesa/main/format_utils.c | 262 ++++++++++++++++++++-----------------------<br>
src/mesa/main/format_utils.h | 8 +-<br>
2 files changed, 129 insertions(+), 141 deletions(-)<br>
<br>
diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c<br>
index fce5266..e174888 100644<br>
--- a/src/mesa/main/format_utils.c<br>
+++ b/src/mesa/main/format_utils.c<br>
@@ -253,32 +253,6 @@ _mesa_compute_component_mapping(GLenum inFormat, GLenum outFormat, GLubyte *map)<br>
#endif<br>
}<br>
<br>
-static GLenum<br>
-gl_type_for_array_format_datatype(enum mesa_array_format_datatype type)<br>
-{<br>
- switch (type) {<br>
- case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
- return GL_UNSIGNED_BYTE;<br>
- case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
- return GL_UNSIGNED_SHORT;<br>
- case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
- return GL_UNSIGNED_INT;<br>
- case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
- return GL_BYTE;<br>
- case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
- return GL_SHORT;<br>
- case MESA_ARRAY_FORMAT_TYPE_INT:<br>
- return GL_INT;<br>
- case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
- return GL_HALF_FLOAT;<br>
- case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
- return GL_FLOAT;<br>
- default:<br>
- assert(!"Invalid datatype");<br>
- return GL_NONE;<br>
- }<br>
-}<br>
-<br>
/* Takes a src to RGBA swizzle and applies a rebase swizzle to it. This<br>
* is used when we need to rebase a format to match a different<br>
* base internal format.<br>
@@ -441,7 +415,7 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
bool src_format_is_mesa_array_format, dst_format_is_mesa_array_format;<br>
uint8_t src2dst[4], src2rgba[4], rgba2dst[4], dst2rgba[4];<br>
uint8_t rebased_src2rgba[4];<br>
- GLenum src_gl_type, dst_gl_type, common_gl_type;<br>
+ enum mesa_array_format_datatype src_type = 0, dst_type = 0, common_type;<br>
bool normalized, dst_integer, src_integer, is_signed;<br>
int src_num_channels = 0, dst_num_channels = 0;<br>
uint8_t (*tmp_ubyte)[4];<br>
@@ -547,9 +521,7 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
/* Handle conversions between array formats */<br>
normalized = false;<br>
if (src_array_format) {<br>
- enum mesa_array_format_datatype datatype =<br>
- _mesa_array_format_get_datatype(src_array_format);<br>
- src_gl_type = gl_type_for_array_format_datatype(datatype);<br>
+ src_type = _mesa_array_format_get_datatype(src_array_format);<br>
<br>
src_num_channels = _mesa_array_format_get_num_channels(src_array_format);<br>
<br>
@@ -559,9 +531,7 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
}<br>
<br>
if (dst_array_format) {<br>
- enum mesa_array_format_datatype datatype =<br>
- _mesa_array_format_get_datatype(dst_array_format);<br>
- dst_gl_type = gl_type_for_array_format_datatype(datatype);<br>
+ dst_type = _mesa_array_format_get_datatype(dst_array_format);<br>
<br>
dst_num_channels = _mesa_array_format_get_num_channels(dst_array_format);<br>
<br>
@@ -579,8 +549,8 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
src2dst);<br>
<br>
for (row = 0; row < height; ++row) {<br>
- _mesa_swizzle_and_convert(dst, dst_gl_type, dst_num_channels,<br>
- src, src_gl_type, src_num_channels,<br>
+ _mesa_swizzle_and_convert(dst, dst_type, dst_num_channels,<br>
+ src, src_type, src_num_channels,<br>
src2dst, normalized, width);<br>
src += src_stride;<br>
dst += dst_stride;<br>
@@ -600,8 +570,8 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
src_integer = true;<br>
} else {<br>
switch (_mesa_get_format_datatype(src_format)) {<br>
- case GL_UNSIGNED_INT:<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
src_integer = true;<br>
break;<br>
}<br>
@@ -635,11 +605,11 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
case GL_FLOAT:<br>
is_signed = true;<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
is_signed = false;<br>
dst_integer = true;<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
is_signed = true;<br>
dst_integer = true;<br>
break;<br>
@@ -662,13 +632,14 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
* _mesa_swizzle_and_convert for signed formats, which is aware of the<br>
* truncation problem.<br>
*/<br>
- common_gl_type = is_signed ? GL_INT : GL_UNSIGNED_INT;<br>
+ common_type = is_signed ? MESA_ARRAY_FORMAT_TYPE_INT :<br>
+ MESA_ARRAY_FORMAT_TYPE_UINT;<br>
if (src_array_format) {<br>
compute_rebased_rgba_component_mapping(src2rgba, rebase_swizzle,<br>
rebased_src2rgba);<br>
for (row = 0; row < height; ++row) {<br>
- _mesa_swizzle_and_convert(tmp_uint + row * width, common_gl_type, 4,<br>
- src, src_gl_type, src_num_channels,<br>
+ _mesa_swizzle_and_convert(tmp_uint + row * width, common_type, 4,<br>
+ src, src_type, src_num_channels,<br>
rebased_src2rgba, normalized, width);<br>
src += src_stride;<br>
}<br>
@@ -677,8 +648,8 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
_mesa_unpack_uint_rgba_row(src_format, width,<br>
src, tmp_uint + row * width);<br>
if (rebase_swizzle)<br>
- _mesa_swizzle_and_convert(tmp_uint + row * width, common_gl_type, 4,<br>
- tmp_uint + row * width, common_gl_type, 4,<br>
+ _mesa_swizzle_and_convert(tmp_uint + row * width, common_type, 4,<br>
+ tmp_uint + row * width, common_type, 4,<br>
rebase_swizzle, false, width);<br>
src += src_stride;<br>
}<br>
@@ -690,8 +661,8 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
*/<br>
if (dst_format_is_mesa_array_format) {<br>
for (row = 0; row < height; ++row) {<br>
- _mesa_swizzle_and_convert(dst, dst_gl_type, dst_num_channels,<br>
- tmp_uint + row * width, common_gl_type, 4,<br>
+ _mesa_swizzle_and_convert(dst, dst_type, dst_num_channels,<br>
+ tmp_uint + row * width, common_type, 4,<br>
rgba2dst, normalized, width);<br>
dst += dst_stride;<br>
}<br>
@@ -711,8 +682,9 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
compute_rebased_rgba_component_mapping(src2rgba, rebase_swizzle,<br>
rebased_src2rgba);<br>
for (row = 0; row < height; ++row) {<br>
- _mesa_swizzle_and_convert(tmp_float + row * width, GL_FLOAT, 4,<br>
- src, src_gl_type, src_num_channels,<br>
+ _mesa_swizzle_and_convert(tmp_float + row * width,<br>
+ MESA_ARRAY_FORMAT_TYPE_FLOAT, 4,<br>
+ src, src_type, src_num_channels,<br>
rebased_src2rgba, normalized, width);<br>
src += src_stride;<br>
}<br>
@@ -721,8 +693,10 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
_mesa_unpack_rgba_row(src_format, width,<br>
src, tmp_float + row * width);<br>
if (rebase_swizzle)<br>
- _mesa_swizzle_and_convert(tmp_float + row * width, GL_FLOAT, 4,<br>
- tmp_float + row * width, GL_FLOAT, 4,<br>
+ _mesa_swizzle_and_convert(tmp_float + row * width,<br>
+ MESA_ARRAY_FORMAT_TYPE_FLOAT, 4,<br>
+ tmp_float + row * width,<br>
+ MESA_ARRAY_FORMAT_TYPE_FLOAT, 4,<br>
rebase_swizzle, false, width);<br>
src += src_stride;<br>
}<br>
@@ -730,8 +704,9 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
<br>
if (dst_format_is_mesa_array_format) {<br>
for (row = 0; row < height; ++row) {<br>
- _mesa_swizzle_and_convert(dst, dst_gl_type, dst_num_channels,<br>
- tmp_float + row * width, GL_FLOAT, 4,<br>
+ _mesa_swizzle_and_convert(dst, dst_type, dst_num_channels,<br>
+ tmp_float + row * width,<br>
+ MESA_ARRAY_FORMAT_TYPE_FLOAT, 4,<br>
rgba2dst, normalized, width);<br>
dst += dst_stride;<br>
}<br>
@@ -751,8 +726,9 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
compute_rebased_rgba_component_mapping(src2rgba, rebase_swizzle,<br>
rebased_src2rgba);<br>
for (row = 0; row < height; ++row) {<br>
- _mesa_swizzle_and_convert(tmp_ubyte + row * width, GL_UNSIGNED_BYTE, 4,<br>
- src, src_gl_type, src_num_channels,<br>
+ _mesa_swizzle_and_convert(tmp_ubyte + row * width,<br>
+ MESA_ARRAY_FORMAT_TYPE_UBYTE, 4,<br>
+ src, src_type, src_num_channels,<br>
rebased_src2rgba, normalized, width);<br>
src += src_stride;<br>
}<br>
@@ -761,8 +737,10 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
_mesa_unpack_ubyte_rgba_row(src_format, width,<br>
src, tmp_ubyte + row * width);<br>
if (rebase_swizzle)<br>
- _mesa_swizzle_and_convert(tmp_ubyte + row * width, GL_UNSIGNED_BYTE, 4,<br>
- tmp_ubyte + row * width, GL_UNSIGNED_BYTE, 4,<br>
+ _mesa_swizzle_and_convert(tmp_ubyte + row * width,<br>
+ MESA_ARRAY_FORMAT_TYPE_UBYTE, 4,<br>
+ tmp_ubyte + row * width,<br>
+ MESA_ARRAY_FORMAT_TYPE_UBYTE, 4,<br>
rebase_swizzle, false, width);<br>
src += src_stride;<br>
}<br>
@@ -770,8 +748,9 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,<br>
<br>
if (dst_format_is_mesa_array_format) {<br>
for (row = 0; row < height; ++row) {<br>
- _mesa_swizzle_and_convert(dst, dst_gl_type, dst_num_channels,<br>
- tmp_ubyte + row * width, GL_UNSIGNED_BYTE, 4,<br>
+ _mesa_swizzle_and_convert(dst, dst_type, dst_num_channels,<br>
+ tmp_ubyte + row * width,<br>
+ MESA_ARRAY_FORMAT_TYPE_UBYTE, 4,<br>
rgba2dst, normalized, width);<br>
dst += dst_stride;<br>
}<br>
@@ -830,8 +809,8 @@ _mesa_format_to_array(mesa_format format, GLenum *type, int *num_components,<br>
return true;<br>
case MESA_FORMAT_LAYOUT_PACKED:<br>
switch (*type) {<br>
- case GL_UNSIGNED_BYTE:<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
if (_mesa_get_format_max_bits(format) != 8)<br>
return false;<br>
*num_components = _mesa_get_format_bytes(format);<br>
@@ -850,8 +829,8 @@ _mesa_format_to_array(mesa_format format, GLenum *type, int *num_components,<br>
assert(!"Invalid number of components");<br>
}<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
case GL_HALF_FLOAT:<br>
if (_mesa_get_format_max_bits(format) != 16)<br>
return false;<br>
@@ -868,8 +847,8 @@ _mesa_format_to_array(mesa_format format, GLenum *type, int *num_components,<br>
assert(!"Invalid number of components");<br>
}<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
case GL_FLOAT:<br>
/* This isn't packed. At least not really. */<br>
assert(format_components == 1);<br>
@@ -916,8 +895,12 @@ half_to_uint(uint16_t x)<br>
* operation with memcpy, false otherwise<br>
*/<br>
static bool<br>
-swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels,<br>
- const void *src, GLenum src_type, int num_src_channels,<br>
+swizzle_convert_try_memcpy(void *dst,<br>
+ enum mesa_array_format_datatype dst_type,<br>
+ int num_dst_channels,<br>
+ const void *src,<br>
+ enum mesa_array_format_datatype src_type,<br>
+ int num_src_channels,<br>
const uint8_t swizzle[4], bool normalized, int count)<br>
{<br>
int i;<br>
@@ -931,7 +914,8 @@ swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels,<br>
if (swizzle[i] != i && swizzle[i] != MESA_FORMAT_SWIZZLE_NONE)<br>
return false;<br>
<br>
- memcpy(dst, src, count * num_src_channels * _mesa_sizeof_type(src_type));<br>
+ memcpy(dst, src, count * num_src_channels *<br>
+ _mesa_array_format_datatype_get_size(src_type));<br>
<br>
return true;<br>
}<br>
@@ -1087,48 +1071,48 @@ convert_float(void *void_dst, int num_dst_channels,<br>
const float one = 1.0f;<br>
<br>
switch (src_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
SWIZZLE_CONVERT(float, float, src);<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
SWIZZLE_CONVERT(float, uint16_t, _mesa_half_to_float(src));<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(float, uint8_t, _mesa_unorm_to_float(src, 8));<br>
} else {<br>
SWIZZLE_CONVERT(float, uint8_t, src);<br>
}<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(float, int8_t, _mesa_snorm_to_float(src, 8));<br>
} else {<br>
SWIZZLE_CONVERT(float, int8_t, src);<br>
}<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(float, uint16_t, _mesa_unorm_to_float(src, 16));<br>
} else {<br>
SWIZZLE_CONVERT(float, uint16_t, src);<br>
}<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(float, int16_t, _mesa_snorm_to_float(src, 16));<br>
} else {<br>
SWIZZLE_CONVERT(float, int16_t, src);<br>
}<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(float, uint32_t, _mesa_unorm_to_float(src, 32));<br>
} else {<br>
SWIZZLE_CONVERT(float, uint32_t, src);<br>
}<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(float, int32_t, _mesa_snorm_to_float(src, 32));<br>
} else {<br>
@@ -1149,48 +1133,48 @@ convert_half_float(void *void_dst, int num_dst_channels,<br>
const uint16_t one = _mesa_float_to_half(1.0f);<br>
<br>
switch (src_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
SWIZZLE_CONVERT(uint16_t, float, _mesa_float_to_half(src));<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
SWIZZLE_CONVERT(uint16_t, uint16_t, src);<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, uint8_t, _mesa_unorm_to_half(src, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, uint8_t, _mesa_float_to_half(src));<br>
}<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, int8_t, _mesa_snorm_to_half(src, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, int8_t, _mesa_float_to_half(src));<br>
}<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_unorm_to_half(src, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_float_to_half(src));<br>
}<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, int16_t, _mesa_snorm_to_half(src, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, int16_t, _mesa_float_to_half(src));<br>
}<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, uint32_t, _mesa_unorm_to_half(src, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, uint32_t, _mesa_float_to_half(src));<br>
}<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, int32_t, _mesa_snorm_to_half(src, 32));<br>
} else {<br>
@@ -1210,52 +1194,52 @@ convert_ubyte(void *void_dst, int num_dst_channels,<br>
const uint8_t one = normalized ? UINT8_MAX : 1;<br>
<br>
switch (src_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, float, _mesa_float_to_unorm(src, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint8_t, float, (src < 0) ? 0 : src);<br>
}<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_half_to_unorm(src, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_unsigned_to_unsigned(half_to_uint(src), 8));<br>
}<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
SWIZZLE_CONVERT(uint8_t, uint8_t, src);<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, int8_t, _mesa_snorm_to_unorm(src, 8, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint8_t, int8_t, _mesa_signed_to_unsigned(src, 8));<br>
}<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_unorm_to_unorm(src, 16, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_unsigned_to_unsigned(src, 8));<br>
}<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, int16_t, _mesa_snorm_to_unorm(src, 16, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint8_t, int16_t, _mesa_signed_to_unsigned(src, 8));<br>
}<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, uint32_t, _mesa_unorm_to_unorm(src, 32, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint8_t, uint32_t, _mesa_unsigned_to_unsigned(src, 8));<br>
}<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, int32_t, _mesa_snorm_to_unorm(src, 32, 8));<br>
} else {<br>
@@ -1276,52 +1260,52 @@ convert_byte(void *void_dst, int num_dst_channels,<br>
const int8_t one = normalized ? INT8_MAX : 1;<br>
<br>
switch (src_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, float, _mesa_float_to_snorm(src, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint8_t, float, src);<br>
}<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_half_to_snorm(src, 8));<br>
} else {<br>
SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_half_to_float(src));<br>
}<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int8_t, uint8_t, _mesa_unorm_to_snorm(src, 8, 8));<br>
} else {<br>
SWIZZLE_CONVERT(int8_t, uint8_t, _mesa_unsigned_to_signed(src, 8));<br>
}<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
SWIZZLE_CONVERT(int8_t, int8_t, src);<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int8_t, uint16_t, _mesa_unorm_to_snorm(src, 16, 8));<br>
} else {<br>
SWIZZLE_CONVERT(int8_t, uint16_t, _mesa_unsigned_to_signed(src, 8));<br>
}<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int8_t, int16_t, _mesa_snorm_to_snorm(src, 16, 8));<br>
} else {<br>
SWIZZLE_CONVERT(int8_t, int16_t, _mesa_signed_to_signed(src, 8));<br>
}<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int8_t, uint32_t, _mesa_unorm_to_snorm(src, 32, 8));<br>
} else {<br>
SWIZZLE_CONVERT(int8_t, uint32_t, _mesa_unsigned_to_signed(src, 8));<br>
}<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int8_t, int32_t, _mesa_snorm_to_snorm(src, 32, 8));<br>
} else {<br>
@@ -1342,52 +1326,52 @@ convert_ushort(void *void_dst, int num_dst_channels,<br>
const uint16_t one = normalized ? UINT16_MAX : 1;<br>
<br>
switch (src_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, float, _mesa_float_to_unorm(src, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, float, (src < 0) ? 0 : src);<br>
}<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_half_to_unorm(src, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_uint(src));<br>
}<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, uint8_t, _mesa_unorm_to_unorm(src, 8, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, uint8_t, src);<br>
}<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, int8_t, _mesa_snorm_to_unorm(src, 8, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, int8_t, _mesa_signed_to_unsigned(src, 16));<br>
}<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
SWIZZLE_CONVERT(uint16_t, uint16_t, src);<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, int16_t, _mesa_snorm_to_unorm(src, 16, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, int16_t, _mesa_signed_to_unsigned(src, 16));<br>
}<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, uint32_t, _mesa_unorm_to_unorm(src, 32, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, uint32_t, _mesa_unsigned_to_unsigned(src, 16));<br>
}<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, int32_t, _mesa_snorm_to_unorm(src, 32, 16));<br>
} else {<br>
@@ -1408,52 +1392,52 @@ convert_short(void *void_dst, int num_dst_channels,<br>
const int16_t one = normalized ? INT16_MAX : 1;<br>
<br>
switch (src_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, float, _mesa_float_to_snorm(src, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, float, src);<br>
}<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_half_to_snorm(src, 16));<br>
} else {<br>
SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_half_to_float(src));<br>
}<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int16_t, uint8_t, _mesa_unorm_to_snorm(src, 8, 16));<br>
} else {<br>
SWIZZLE_CONVERT(int16_t, uint8_t, src);<br>
}<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int16_t, int8_t, _mesa_snorm_to_snorm(src, 8, 16));<br>
} else {<br>
SWIZZLE_CONVERT(int16_t, int8_t, src);<br>
}<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int16_t, uint16_t, _mesa_unorm_to_snorm(src, 16, 16));<br>
} else {<br>
SWIZZLE_CONVERT(int16_t, uint16_t, _mesa_unsigned_to_signed(src, 16));<br>
}<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
SWIZZLE_CONVERT(int16_t, int16_t, src);<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int16_t, uint32_t, _mesa_unorm_to_snorm(src, 32, 16));<br>
} else {<br>
SWIZZLE_CONVERT(int16_t, uint32_t, _mesa_unsigned_to_signed(src, 16));<br>
}<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int16_t, int32_t, _mesa_snorm_to_snorm(src, 32, 16));<br>
} else {<br>
@@ -1473,52 +1457,52 @@ convert_uint(void *void_dst, int num_dst_channels,<br>
const uint32_t one = normalized ? UINT32_MAX : 1;<br>
<br>
switch (src_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, float, _mesa_float_to_unorm(src, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint32_t, float, (src < 0) ? 0 : src);<br>
}<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, uint16_t, _mesa_half_to_unorm(src, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_uint(src));<br>
}<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, uint8_t, _mesa_unorm_to_unorm(src, 8, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint32_t, uint8_t, src);<br>
}<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, int8_t, _mesa_snorm_to_unorm(src, 8, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint32_t, int8_t, _mesa_signed_to_unsigned(src, 32));<br>
}<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, uint16_t, _mesa_unorm_to_unorm(src, 16, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint32_t, uint16_t, src);<br>
}<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, int16_t, _mesa_snorm_to_unorm(src, 16, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint32_t, int16_t, _mesa_signed_to_unsigned(src, 32));<br>
}<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
SWIZZLE_CONVERT(uint32_t, uint32_t, src);<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, int32_t, _mesa_snorm_to_unorm(src, 32, 32));<br>
} else {<br>
@@ -1539,56 +1523,56 @@ convert_int(void *void_dst, int num_dst_channels,<br>
const int32_t one = normalized ? INT32_MAX : 1;<br>
<br>
switch (src_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, float, _mesa_float_to_snorm(src, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint32_t, float, src);<br>
}<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(uint32_t, uint16_t, _mesa_half_to_snorm(src, 32));<br>
} else {<br>
SWIZZLE_CONVERT(uint32_t, uint16_t, _mesa_half_to_float(src));<br>
}<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int32_t, uint8_t, _mesa_unorm_to_snorm(src, 8, 32));<br>
} else {<br>
SWIZZLE_CONVERT(int32_t, uint8_t, src);<br>
}<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int32_t, int8_t, _mesa_snorm_to_snorm(src, 8, 32));<br>
} else {<br>
SWIZZLE_CONVERT(int32_t, int8_t, src);<br>
}<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int32_t, uint16_t, _mesa_unorm_to_snorm(src, 16, 32));<br>
} else {<br>
SWIZZLE_CONVERT(int32_t, uint16_t, src);<br>
}<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int32_t, int16_t, _mesa_snorm_to_snorm(src, 16, 32));<br>
} else {<br>
SWIZZLE_CONVERT(int32_t, int16_t, src);<br>
}<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
if (normalized) {<br>
SWIZZLE_CONVERT(int32_t, uint32_t, _mesa_unorm_to_snorm(src, 32, 32));<br>
} else {<br>
SWIZZLE_CONVERT(int32_t, uint32_t, _mesa_unsigned_to_signed(src, 32));<br>
}<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
SWIZZLE_CONVERT(int32_t, int32_t, src);<br>
break;<br>
default:<br>
@@ -1656,35 +1640,35 @@ _mesa_swizzle_and_convert(void *void_dst, GLenum dst_type, int num_dst_channels,<br>
return;<br>
<br>
switch (dst_type) {<br>
- case GL_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_FLOAT:<br>
convert_float(void_dst, num_dst_channels, void_src, src_type,<br>
num_src_channels, swizzle, normalized, count);<br>
break;<br>
- case GL_HALF_FLOAT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_HALF:<br>
convert_half_float(void_dst, num_dst_channels, void_src, src_type,<br>
num_src_channels, swizzle, normalized, count);<br>
break;<br>
- case GL_UNSIGNED_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UBYTE:<br>
convert_ubyte(void_dst, num_dst_channels, void_src, src_type,<br>
num_src_channels, swizzle, normalized, count);<br>
break;<br>
- case GL_BYTE:<br>
+ case MESA_ARRAY_FORMAT_TYPE_BYTE:<br>
convert_byte(void_dst, num_dst_channels, void_src, src_type,<br>
num_src_channels, swizzle, normalized, count);<br>
break;<br>
- case GL_UNSIGNED_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_USHORT:<br>
convert_ushort(void_dst, num_dst_channels, void_src, src_type,<br>
num_src_channels, swizzle, normalized, count);<br>
break;<br>
- case GL_SHORT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_SHORT:<br>
convert_short(void_dst, num_dst_channels, void_src, src_type,<br>
num_src_channels, swizzle, normalized, count);<br>
break;<br>
- case GL_UNSIGNED_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_UINT:<br>
convert_uint(void_dst, num_dst_channels, void_src, src_type,<br>
num_src_channels, swizzle, normalized, count);<br>
break;<br>
- case GL_INT:<br>
+ case MESA_ARRAY_FORMAT_TYPE_INT:<br>
convert_int(void_dst, num_dst_channels, void_src, src_type,<br>
num_src_channels, swizzle, normalized, count);<br>
break;<br>
diff --git a/src/mesa/main/format_utils.h b/src/mesa/main/format_utils.h<br>
index ec08f27..d94cf92 100644<br>
--- a/src/mesa/main/format_utils.h<br>
+++ b/src/mesa/main/format_utils.h<br>
@@ -174,8 +174,12 @@ _mesa_format_to_array(mesa_format, GLenum *type, int *num_components,<br>
uint8_t swizzle[4], bool *normalized);<br>
<br>
void<br>
-_mesa_swizzle_and_convert(void *dst, GLenum dst_type, int num_dst_channels,<br>
- const void *src, GLenum src_type, int num_src_channels,<br>
+_mesa_swizzle_and_convert(void *dst,<br>
+ enum mesa_array_format_datatype dst_type,<br>
+ int num_dst_channels,<br>
+ const void *src,<br>
+ enum mesa_array_format_datatype src_type,<br>
+ int num_src_channels,<br>
const uint8_t swizzle[4], bool normalized, int count);<br>
<br>
void<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></div>