aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/pack.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-08-16 14:48:54 +0200
committermarha <marha@users.sourceforge.net>2012-08-16 14:48:54 +0200
commit4aac32998c2b173b84aec0b020aa086fef4b1423 (patch)
tree3ffcb971bcc2f01929f60f8f704996544b69b2e1 /mesalib/src/mesa/main/pack.c
parent9ddf44af81782451cee798e06749ce3067a14a41 (diff)
downloadvcxsrv-4aac32998c2b173b84aec0b020aa086fef4b1423.tar.gz
vcxsrv-4aac32998c2b173b84aec0b020aa086fef4b1423.tar.bz2
vcxsrv-4aac32998c2b173b84aec0b020aa086fef4b1423.zip
libxcb xserver mesa git update 16 Aug 2012
Diffstat (limited to 'mesalib/src/mesa/main/pack.c')
-rw-r--r--mesalib/src/mesa/main/pack.c725
1 files changed, 713 insertions, 12 deletions
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index 83192c157..7aebd45ea 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -462,8 +462,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
}
}
-/* Customization of integer packing. We always treat src as uint, and can pack dst
- * as any integer type/format combo.
+/* Customization of unsigned integer packing.
*/
#define SRC_TYPE GLuint
@@ -475,6 +474,14 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef SRC_CONVERT
#undef FN_NAME
+#define DST_TYPE GLint
+#define SRC_CONVERT(x) MIN2(x, 0x7fffffff)
+#define FN_NAME pack_int_from_uint_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FN_NAME
+
#define DST_TYPE GLushort
#define SRC_CONVERT(x) MIN2(x, 0xffff)
#define FN_NAME pack_ushort_from_uint_rgba
@@ -507,18 +514,32 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef SRC_CONVERT
#undef FN_NAME
+#undef SRC_TYPE
+
+static void
+_pack_rgba_span_from_uints_problem(struct gl_context *ctx,
+ GLenum dstFormat, GLenum dstType)
+{
+ _mesa_problem(ctx,
+ "Unsupported type (%s) / format (%s) "
+ "in _mesa_pack_rgba_span_from_uints",
+ _mesa_lookup_enum_by_nr(dstType),
+ _mesa_lookup_enum_by_nr(dstFormat));
+}
+
void
-_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
- GLenum dstFormat, GLenum dstType,
- GLvoid *dstAddr)
+_mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr)
{
+ GLuint i;
+
switch(dstType) {
case GL_UNSIGNED_INT:
pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
case GL_INT:
- /* No conversion necessary. */
- pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
+ pack_int_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
case GL_UNSIGNED_SHORT:
pack_ushort_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
@@ -532,11 +553,691 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
case GL_BYTE:
pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
+ GLubyte *dst = (GLubyte *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) << 5)
+ | (CLAMP(rgba[i][GCOMP], 0, 7) << 2)
+ | (CLAMP(rgba[i][BCOMP], 0, 3) );
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
+ GLubyte *dst = (GLubyte *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) )
+ | (CLAMP(rgba[i][GCOMP], 0, 7) << 3)
+ | (CLAMP(rgba[i][BCOMP], 0, 3) << 6);
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11)
+ | (CLAMP(rgba[i][GCOMP], 0, 63) << 5)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) );
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) )
+ | (CLAMP(rgba[i][GCOMP], 0, 63) << 5)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 11);
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) << 12)
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][BCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][ACOMP], 0, 15) );
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) << 12)
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][RCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][ACOMP], 0, 15) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) << 12)
+ | (CLAMP(rgba[i][BCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][RCOMP], 0, 15) );
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) )
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][BCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][ACOMP], 0, 15) << 12);
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) )
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][RCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][ACOMP], 0, 15) << 12);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) )
+ | (CLAMP(rgba[i][BCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][RCOMP], 0, 15) << 12);
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11)
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 6)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 1)
+ | (CLAMP(rgba[i][ACOMP], 0, 1) );
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) << 11)
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 6)
+ | (CLAMP(rgba[i][RCOMP], 0, 31) << 1)
+ | (CLAMP(rgba[i][ACOMP], 0, 1) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) << 11)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 6)
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 1)
+ | (CLAMP(rgba[i][RCOMP], 0, 1) );
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) )
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 5)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 10)
+ | (CLAMP(rgba[i][ACOMP], 0, 1) << 15);
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) )
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 5)
+ | (CLAMP(rgba[i][RCOMP], 0, 31) << 10)
+ | (CLAMP(rgba[i][ACOMP], 0, 1) << 15);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) )
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 5)
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 10)
+ | (CLAMP(rgba[i][RCOMP], 0, 1) << 15);
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) << 24)
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][BCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][ACOMP], 0, 255) );
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) << 24)
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][RCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][ACOMP], 0, 255) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) << 24)
+ | (CLAMP(rgba[i][BCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][RCOMP], 0, 255) );
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) )
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][BCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][ACOMP], 0, 255) << 24);
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) )
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][RCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][ACOMP], 0, 255) << 24);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) )
+ | (CLAMP(rgba[i][BCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][RCOMP], 0, 255) << 24);
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_INT_10_10_10_2:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) << 22)
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12)
+ | (CLAMP(rgba[i][BCOMP], 0, 1023) << 2)
+ | (CLAMP(rgba[i][ACOMP], 0, 3) );
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) << 22)
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12)
+ | (CLAMP(rgba[i][RCOMP], 0, 1023) << 2)
+ | (CLAMP(rgba[i][ACOMP], 0, 3) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) << 22)
+ | (CLAMP(rgba[i][BCOMP], 0, 1023) << 12)
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 2)
+ | (CLAMP(rgba[i][RCOMP], 0, 3) );
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) )
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10)
+ | (CLAMP(rgba[i][BCOMP], 0, 1023) << 20)
+ | (CLAMP(rgba[i][ACOMP], 0, 3) << 30);
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) )
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10)
+ | (CLAMP(rgba[i][RCOMP], 0, 1023) << 20)
+ | (CLAMP(rgba[i][ACOMP], 0, 3) << 30);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) )
+ | (CLAMP(rgba[i][BCOMP], 0, 1023) << 10)
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 20)
+ | (CLAMP(rgba[i][RCOMP], 0, 3) << 30);
+ }
+ } else {
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ default:
+ _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType);
+ return;
+ }
+}
+
+
+/* Customization of signed integer packing.
+ */
+#define SRC_TYPE GLint
+
+#define DST_TYPE GLuint
+#define SRC_CONVERT(x) MAX2(x, 0)
+#define FN_NAME pack_uint_from_int_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLushort
+#define SRC_CONVERT(x) MAX2(x, 0)
+#define FN_NAME pack_ushort_from_int_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLshort
+#define SRC_CONVERT(x) CLAMP(x, -0x8000, 0x7fff)
+#define FN_NAME pack_short_from_int_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLubyte
+#define SRC_CONVERT(x) MAX2(x, 0)
+#define FN_NAME pack_ubyte_from_int_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FN_NAME
+
+#define DST_TYPE GLbyte
+#define SRC_CONVERT(x) CLAMP(x, -0x80, 0x7f)
+#define FN_NAME pack_byte_from_int_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FN_NAME
+
+#undef SRC_TYPE
+
+static void
+_pack_rgba_span_from_ints_problem(struct gl_context *ctx,
+ GLenum dstFormat, GLenum dstType)
+{
+ _mesa_problem(ctx,
+ "Unsupported type (%s) / format (%s) "
+ "in _mesa_pack_rgba_span_from_ints",
+ _mesa_lookup_enum_by_nr(dstType),
+ _mesa_lookup_enum_by_nr(dstFormat));
+}
+
+void
+_mesa_pack_rgba_span_from_ints(struct gl_context *ctx, GLuint n, GLint rgba[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr)
+{
+ GLuint i;
+
+ switch(dstType) {
+ case GL_UNSIGNED_INT:
+ pack_uint_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+ break;
+ case GL_INT:
+ /* No conversion necessary. */
+ pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
+ break;
+ case GL_UNSIGNED_SHORT:
+ pack_ushort_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+ break;
+ case GL_SHORT:
+ pack_short_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+ break;
+ case GL_UNSIGNED_BYTE:
+ pack_ubyte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+ break;
+ case GL_BYTE:
+ pack_byte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n);
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
+ GLubyte *dst = (GLubyte *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) << 5)
+ | (CLAMP(rgba[i][GCOMP], 0, 7) << 2)
+ | (CLAMP(rgba[i][BCOMP], 0, 3) );
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
+ GLubyte *dst = (GLubyte *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) )
+ | (CLAMP(rgba[i][GCOMP], 0, 7) << 3)
+ | (CLAMP(rgba[i][BCOMP], 0, 3) << 6);
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11)
+ | (CLAMP(rgba[i][GCOMP], 0, 63) << 5)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) );
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) )
+ | (CLAMP(rgba[i][GCOMP], 0, 63) << 5)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 11);
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) << 12)
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][BCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][ACOMP], 0, 15) );
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) << 12)
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][RCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][ACOMP], 0, 15) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) << 12)
+ | (CLAMP(rgba[i][BCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][RCOMP], 0, 15) );
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) )
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][BCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][ACOMP], 0, 15) << 12);
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) )
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][RCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][ACOMP], 0, 15) << 12);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) )
+ | (CLAMP(rgba[i][BCOMP], 0, 15) << 4)
+ | (CLAMP(rgba[i][GCOMP], 0, 15) << 8)
+ | (CLAMP(rgba[i][RCOMP], 0, 15) << 12);
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11)
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 6)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 1)
+ | (CLAMP(rgba[i][ACOMP], 0, 1) );
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) << 11)
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 6)
+ | (CLAMP(rgba[i][RCOMP], 0, 31) << 1)
+ | (CLAMP(rgba[i][ACOMP], 0, 1) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) << 11)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 6)
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 1)
+ | (CLAMP(rgba[i][RCOMP], 0, 1) );
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) )
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 5)
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 10)
+ | (CLAMP(rgba[i][ACOMP], 0, 1) << 15);
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) )
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 5)
+ | (CLAMP(rgba[i][RCOMP], 0, 31) << 10)
+ | (CLAMP(rgba[i][ACOMP], 0, 1) << 15);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) )
+ | (CLAMP(rgba[i][BCOMP], 0, 31) << 5)
+ | (CLAMP(rgba[i][GCOMP], 0, 31) << 10)
+ | (CLAMP(rgba[i][RCOMP], 0, 1) << 15);
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) << 24)
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][BCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][ACOMP], 0, 255) );
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) << 24)
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][RCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][ACOMP], 0, 255) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) << 24)
+ | (CLAMP(rgba[i][BCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][RCOMP], 0, 255) );
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) )
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][BCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][ACOMP], 0, 255) << 24);
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) )
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][RCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][ACOMP], 0, 255) << 24);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) )
+ | (CLAMP(rgba[i][BCOMP], 0, 255) << 8)
+ | (CLAMP(rgba[i][GCOMP], 0, 255) << 16)
+ | (CLAMP(rgba[i][RCOMP], 0, 255) << 24);
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_INT_10_10_10_2:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) << 22)
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12)
+ | (CLAMP(rgba[i][BCOMP], 0, 1023) << 2)
+ | (CLAMP(rgba[i][ACOMP], 0, 3) );
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) << 22)
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12)
+ | (CLAMP(rgba[i][RCOMP], 0, 1023) << 2)
+ | (CLAMP(rgba[i][ACOMP], 0, 3) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) << 22)
+ | (CLAMP(rgba[i][BCOMP], 0, 1023) << 12)
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 2)
+ | (CLAMP(rgba[i][RCOMP], 0, 3) );
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) )
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10)
+ | (CLAMP(rgba[i][BCOMP], 0, 1023) << 20)
+ | (CLAMP(rgba[i][ACOMP], 0, 3) << 30);
+ }
+ }
+ else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) )
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10)
+ | (CLAMP(rgba[i][RCOMP], 0, 1023) << 20)
+ | (CLAMP(rgba[i][ACOMP], 0, 3) << 30);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) )
+ | (CLAMP(rgba[i][BCOMP], 0, 1023) << 10)
+ | (CLAMP(rgba[i][GCOMP], 0, 1023) << 20)
+ | (CLAMP(rgba[i][RCOMP], 0, 3) << 30);
+ }
+ } else {
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
+ }
+ break;
default:
- _mesa_problem(ctx,
- "Unsupported type (%s) for format (%s)",
- _mesa_lookup_enum_by_nr(dstType),
- _mesa_lookup_enum_by_nr(dstFormat));
+ _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType);
return;
}
}
@@ -4913,7 +5614,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
else {
/* need to use double precision to prevent overflow problems */
for (i = 0; i < n; i++) {
- GLdouble z = depthValues[i] * (GLfloat) depthMax;
+ GLdouble z = depthValues[i] * (GLdouble) depthMax;
if (z >= (GLdouble) 0xffffffff)
zValues[i] = 0xffffffff;
else