summaryrefslogtreecommitdiff
path: root/src/mesa/main/image.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/image.c')
-rw-r--r--src/mesa/main/image.c370
1 files changed, 259 insertions, 111 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 4d86c54777..fa3149d56d 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -293,6 +293,9 @@ _mesa_components_in_format( GLenum format )
return 2;
case GL_DEPTH_STENCIL_EXT:
return 2;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ return 2;
default:
return -1;
}
@@ -503,6 +506,20 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type )
return GL_TRUE;
else
return GL_FALSE;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
default:
; /* fall-through */
}
@@ -1674,8 +1691,19 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
GLfloat luminance[MAX_WIDTH];
const GLint comps = _mesa_components_in_format(dstFormat);
GLuint i;
-
- if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) {
+ /* clamping only applies to colors, not the dudv values, but still need
+ it if converting to unsigned values (which doesn't make much sense) */
+ if (dstFormat == GL_DUDV_ATI || dstFormat == GL_DU8DV8_ATI) {
+ switch (dstType) {
+ case GL_UNSIGNED_BYTE:
+ case GL_UNSIGNED_SHORT:
+ case GL_UNSIGNED_INT:
+ transferOps |= IMAGE_CLAMP_BIT;
+ break;
+ /* actually might want clamp to [-1,1] otherwise but shouldn't matter? */
+ }
+ }
+ else if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) {
/* need to clamp to [0, 1] */
transferOps |= IMAGE_CLAMP_BIT;
}
@@ -1774,6 +1802,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
}
break;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[i*2+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ }
+ break;
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
@@ -1847,6 +1882,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
}
break;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ }
+ break;
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
@@ -1920,6 +1962,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], rgba[i][RCOMP]);
}
break;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ dst[i*2+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ }
+ break;
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
@@ -1993,6 +2042,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
}
break;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ }
+ break;
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
@@ -2066,6 +2122,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
dst[i*4+3] = FLOAT_TO_UINT(rgba[i][RCOMP]);
}
break;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ dst[i*2+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ }
+ break;
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
@@ -2139,6 +2202,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
dst[i*4+3] = FLOAT_TO_INT(rgba[i][RCOMP]);
}
break;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ dst[i*2+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ }
+ break;
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
@@ -2212,6 +2282,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
dst[i*4+3] = rgba[i][RCOMP];
}
break;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = rgba[i][RCOMP];
+ dst[i*2+1] = rgba[i][GCOMP];
+ }
+ break;
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
@@ -2285,6 +2362,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
dst[i*4+3] = _mesa_float_to_half(rgba[i][RCOMP]);
}
break;
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = _mesa_float_to_half(rgba[i][RCOMP]);
+ dst[i*2+1] = _mesa_float_to_half(rgba[i][GCOMP]);
+ }
+ break;
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
@@ -2294,9 +2378,9 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGB) {
GLubyte *dst = (GLubyte *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) << 5)
- | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 2)
- | (((GLint) (rgba[i][BCOMP] * 3.0F)) );
+ dst[i] = (IROUND(rgba[i][RCOMP] * 7.0F) << 5)
+ | (IROUND(rgba[i][GCOMP] * 7.0F) << 2)
+ | (IROUND(rgba[i][BCOMP] * 3.0F) );
}
}
break;
@@ -2304,9 +2388,9 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGB) {
GLubyte *dst = (GLubyte *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3)
- | (((GLint) (rgba[i][BCOMP] * 3.0F)) << 6);
+ dst[i] = (IROUND(rgba[i][RCOMP] * 7.0F) )
+ | (IROUND(rgba[i][GCOMP] * 7.0F) << 3)
+ | (IROUND(rgba[i][BCOMP] * 3.0F) << 6);
}
}
break;
@@ -2314,9 +2398,9 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGB) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
- | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) );
+ dst[i] = (IROUND(rgba[i][RCOMP] * 31.0F) << 11)
+ | (IROUND(rgba[i][GCOMP] * 63.0F) << 5)
+ | (IROUND(rgba[i][BCOMP] * 31.0F) );
}
}
break;
@@ -2324,9 +2408,9 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGB) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11);
+ dst[i] = (IROUND(rgba[i][RCOMP] * 31.0F) )
+ | (IROUND(rgba[i][GCOMP] * 63.0F) << 5)
+ | (IROUND(rgba[i][BCOMP] * 31.0F) << 11);
}
}
break;
@@ -2334,28 +2418,28 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGBA) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12)
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][ACOMP] * 15.0F)) );
+ dst[i] = (IROUND(rgba[i][RCOMP] * 15.0F) << 12)
+ | (IROUND(rgba[i][GCOMP] * 15.0F) << 8)
+ | (IROUND(rgba[i][BCOMP] * 15.0F) << 4)
+ | (IROUND(rgba[i][ACOMP] * 15.0F) );
}
}
else if (dstFormat == GL_BGRA) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][BCOMP] * 15.0F)) << 12)
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][ACOMP] * 15.0F)) );
+ dst[i] = (IROUND(rgba[i][BCOMP] * 15.0F) << 12)
+ | (IROUND(rgba[i][GCOMP] * 15.0F) << 8)
+ | (IROUND(rgba[i][RCOMP] * 15.0F) << 4)
+ | (IROUND(rgba[i][ACOMP] * 15.0F) );
}
}
else if (dstFormat == GL_ABGR_EXT) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12)
- | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][RCOMP] * 15.0F)) );
+ dst[i] = (IROUND(rgba[i][ACOMP] * 15.0F) << 12)
+ | (IROUND(rgba[i][BCOMP] * 15.0F) << 8)
+ | (IROUND(rgba[i][GCOMP] * 15.0F) << 4)
+ | (IROUND(rgba[i][RCOMP] * 15.0F) );
}
}
break;
@@ -2363,28 +2447,28 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGBA) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12);
+ dst[i] = (IROUND(rgba[i][RCOMP] * 15.0F) )
+ | (IROUND(rgba[i][GCOMP] * 15.0F) << 4)
+ | (IROUND(rgba[i][BCOMP] * 15.0F) << 8)
+ | (IROUND(rgba[i][ACOMP] * 15.0F) << 12);
}
}
else if (dstFormat == GL_BGRA) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][BCOMP] * 15.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12);
+ dst[i] = (IROUND(rgba[i][BCOMP] * 15.0F) )
+ | (IROUND(rgba[i][GCOMP] * 15.0F) << 4)
+ | (IROUND(rgba[i][RCOMP] * 15.0F) << 8)
+ | (IROUND(rgba[i][ACOMP] * 15.0F) << 12);
}
}
else if (dstFormat == GL_ABGR_EXT) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) )
- | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12);
+ dst[i] = (IROUND(rgba[i][ACOMP] * 15.0F) )
+ | (IROUND(rgba[i][BCOMP] * 15.0F) << 4)
+ | (IROUND(rgba[i][GCOMP] * 15.0F) << 8)
+ | (IROUND(rgba[i][RCOMP] * 15.0F) << 12);
}
}
break;
@@ -2392,28 +2476,28 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGBA) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 1)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
+ dst[i] = (IROUND(rgba[i][RCOMP] * 31.0F) << 11)
+ | (IROUND(rgba[i][GCOMP] * 31.0F) << 6)
+ | (IROUND(rgba[i][BCOMP] * 31.0F) << 1)
+ | (IROUND(rgba[i][ACOMP] * 1.0F) );
}
}
else if (dstFormat == GL_BGRA) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11)
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
- | (((GLint) (rgba[i][RCOMP] * 31.0F)) << 1)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
+ dst[i] = (IROUND(rgba[i][BCOMP] * 31.0F) << 11)
+ | (IROUND(rgba[i][GCOMP] * 31.0F) << 6)
+ | (IROUND(rgba[i][RCOMP] * 31.0F) << 1)
+ | (IROUND(rgba[i][ACOMP] * 1.0F) );
}
}
else if (dstFormat == GL_ABGR_EXT) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][ACOMP] * 31.0F)) << 11)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 6)
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 1)
- | (((GLint) (rgba[i][RCOMP] * 1.0F)) );
+ dst[i] = (IROUND(rgba[i][ACOMP] * 31.0F) << 11)
+ | (IROUND(rgba[i][BCOMP] * 31.0F) << 6)
+ | (IROUND(rgba[i][GCOMP] * 31.0F) << 1)
+ | (IROUND(rgba[i][RCOMP] * 1.0F) );
}
}
break;
@@ -2421,28 +2505,28 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGBA) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 10)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
+ dst[i] = (IROUND(rgba[i][RCOMP] * 31.0F) )
+ | (IROUND(rgba[i][GCOMP] * 31.0F) << 5)
+ | (IROUND(rgba[i][BCOMP] * 31.0F) << 10)
+ | (IROUND(rgba[i][ACOMP] * 1.0F) << 15);
}
}
else if (dstFormat == GL_BGRA) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][BCOMP] * 31.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
- | (((GLint) (rgba[i][RCOMP] * 31.0F)) << 10)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
+ dst[i] = (IROUND(rgba[i][BCOMP] * 31.0F) )
+ | (IROUND(rgba[i][GCOMP] * 31.0F) << 5)
+ | (IROUND(rgba[i][RCOMP] * 31.0F) << 10)
+ | (IROUND(rgba[i][ACOMP] * 1.0F) << 15);
}
}
else if (dstFormat == GL_ABGR_EXT) {
GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][ACOMP] * 31.0F)) )
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 5)
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 10)
- | (((GLint) (rgba[i][RCOMP] * 1.0F)) << 15);
+ dst[i] = (IROUND(rgba[i][ACOMP] * 31.0F) )
+ | (IROUND(rgba[i][BCOMP] * 31.0F) << 5)
+ | (IROUND(rgba[i][GCOMP] * 31.0F) << 10)
+ | (IROUND(rgba[i][RCOMP] * 1.0F) << 15);
}
}
break;
@@ -2450,28 +2534,28 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGBA) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24)
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
+ dst[i] = (IROUND(rgba[i][RCOMP] * 255.F) << 24)
+ | (IROUND(rgba[i][GCOMP] * 255.F) << 16)
+ | (IROUND(rgba[i][BCOMP] * 255.F) << 8)
+ | (IROUND(rgba[i][ACOMP] * 255.F) );
}
}
else if (dstFormat == GL_BGRA) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 24)
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
+ dst[i] = (IROUND(rgba[i][BCOMP] * 255.F) << 24)
+ | (IROUND(rgba[i][GCOMP] * 255.F) << 16)
+ | (IROUND(rgba[i][RCOMP] * 255.F) << 8)
+ | (IROUND(rgba[i][ACOMP] * 255.F) );
}
}
else if (dstFormat == GL_ABGR_EXT) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24)
- | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][RCOMP] * 255.0F)) );
+ dst[i] = (IROUND(rgba[i][ACOMP] * 255.F) << 24)
+ | (IROUND(rgba[i][BCOMP] * 255.F) << 16)
+ | (IROUND(rgba[i][GCOMP] * 255.F) << 8)
+ | (IROUND(rgba[i][RCOMP] * 255.F) );
}
}
break;
@@ -2479,28 +2563,28 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGBA) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) )
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
+ dst[i] = (IROUND(rgba[i][RCOMP] * 255.0F) )
+ | (IROUND(rgba[i][GCOMP] * 255.0F) << 8)
+ | (IROUND(rgba[i][BCOMP] * 255.0F) << 16)
+ | (IROUND(rgba[i][ACOMP] * 255.0F) << 24);
}
}
else if (dstFormat == GL_BGRA) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) )
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
+ dst[i] = (IROUND(rgba[i][BCOMP] * 255.0F) )
+ | (IROUND(rgba[i][GCOMP] * 255.0F) << 8)
+ | (IROUND(rgba[i][RCOMP] * 255.0F) << 16)
+ | (IROUND(rgba[i][ACOMP] * 255.0F) << 24);
}
}
else if (dstFormat == GL_ABGR_EXT) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) )
- | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24);
+ dst[i] = (IROUND(rgba[i][ACOMP] * 255.0F) )
+ | (IROUND(rgba[i][BCOMP] * 255.0F) << 8)
+ | (IROUND(rgba[i][GCOMP] * 255.0F) << 16)
+ | (IROUND(rgba[i][RCOMP] * 255.0F) << 24);
}
}
break;
@@ -2508,28 +2592,28 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGBA) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 22)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 2)
- | (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
+ dst[i] = (IROUND(rgba[i][RCOMP] * 1023.0F) << 22)
+ | (IROUND(rgba[i][GCOMP] * 1023.0F) << 12)
+ | (IROUND(rgba[i][BCOMP] * 1023.0F) << 2)
+ | (IROUND(rgba[i][ACOMP] * 3.0F) );
}
}
else if (dstFormat == GL_BGRA) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 22)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
- | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 2)
- | (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
+ dst[i] = (IROUND(rgba[i][BCOMP] * 1023.0F) << 22)
+ | (IROUND(rgba[i][GCOMP] * 1023.0F) << 12)
+ | (IROUND(rgba[i][RCOMP] * 1023.0F) << 2)
+ | (IROUND(rgba[i][ACOMP] * 3.0F) );
}
}
else if (dstFormat == GL_ABGR_EXT) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) << 22)
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 12)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 2)
- | (((GLuint) (rgba[i][RCOMP] * 3.0F)) );
+ dst[i] = (IROUND(rgba[i][ACOMP] * 1023.0F) << 22)
+ | (IROUND(rgba[i][BCOMP] * 1023.0F) << 12)
+ | (IROUND(rgba[i][GCOMP] * 1023.0F) << 2)
+ | (IROUND(rgba[i][RCOMP] * 3.0F) );
}
}
break;
@@ -2537,28 +2621,28 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
if (dstFormat == GL_RGBA) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) )
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 20)
- | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
+ dst[i] = (IROUND(rgba[i][RCOMP] * 1023.0F) )
+ | (IROUND(rgba[i][GCOMP] * 1023.0F) << 10)
+ | (IROUND(rgba[i][BCOMP] * 1023.0F) << 20)
+ | (IROUND(rgba[i][ACOMP] * 3.0F) << 30);
}
}
else if (dstFormat == GL_BGRA) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) )
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
- | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 20)
- | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
+ dst[i] = (IROUND(rgba[i][BCOMP] * 1023.0F) )
+ | (IROUND(rgba[i][GCOMP] * 1023.0F) << 10)
+ | (IROUND(rgba[i][RCOMP] * 1023.0F) << 20)
+ | (IROUND(rgba[i][ACOMP] * 3.0F) << 30);
}
}
else if (dstFormat == GL_ABGR_EXT) {
GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) )
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 10)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 20)
- | (((GLuint) (rgba[i][RCOMP] * 3.0F)) << 30);
+ dst[i] = (IROUND(rgba[i][ACOMP] * 1023.0F) )
+ | (IROUND(rgba[i][BCOMP] * 1023.0F) << 10)
+ | (IROUND(rgba[i][GCOMP] * 1023.0F) << 20)
+ | (IROUND(rgba[i][RCOMP] * 3.0F) << 30);
}
}
break;
@@ -2834,7 +2918,8 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
srcFormat == GL_BGR ||
srcFormat == GL_RGBA ||
srcFormat == GL_BGRA ||
- srcFormat == GL_ABGR_EXT);
+ srcFormat == GL_ABGR_EXT ||
+ srcFormat == GL_DUDV_ATI);
ASSERT(srcType == GL_UNSIGNED_BYTE ||
srcType == GL_BYTE ||
@@ -2949,6 +3034,13 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
aComp = 0;
stride = 4;
break;
+ case GL_DUDV_ATI:
+ redIndex = 0;
+ greenIndex = 1;
+ blueIndex = -1;
+ alphaIndex = -1;
+ stride = 2;
+ break;
default:
_mesa_problem(NULL, "bad srcFormat in extract float data");
return;
@@ -3877,6 +3969,62 @@ _mesa_unpack_color_span_float( GLcontext *ctx,
}
}
+/**
+ * Similar to _mesa_unpack_color_span_float(), but for dudv data instead of rgba,
+ * directly return GLbyte data, no transfer ops apply.
+ */
+void
+_mesa_unpack_dudv_span_byte( GLcontext *ctx,
+ GLuint n, GLenum dstFormat, GLbyte dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLbitfield transferOps )
+{
+ ASSERT(dstFormat == GL_DUDV_ATI);
+ ASSERT(srcFormat == GL_DUDV_ATI);
+
+ ASSERT(srcType == GL_UNSIGNED_BYTE ||
+ srcType == GL_BYTE ||
+ srcType == GL_UNSIGNED_SHORT ||
+ srcType == GL_SHORT ||
+ srcType == GL_UNSIGNED_INT ||
+ srcType == GL_INT ||
+ srcType == GL_HALF_FLOAT_ARB ||
+ srcType == GL_FLOAT);
+
+ /* general solution */
+ {
+ GLint dstComponents;
+ GLfloat rgba[MAX_WIDTH][4];
+ GLbyte *dst = dest;
+ GLuint i;
+
+ dstComponents = _mesa_components_in_format( dstFormat );
+ /* source & dest image formats should have been error checked by now */
+ assert(dstComponents > 0);
+
+ /*
+ * Extract image data and convert to RGBA floats
+ */
+ assert(n <= MAX_WIDTH);
+ extract_float_rgba(n, rgba, srcFormat, srcType, source,
+ srcPacking->SwapBytes);
+
+
+ /* Now determine which color channels we need to produce.
+ * And determine the dest index (offset) within each color tuple.
+ */
+
+ /* Now pack results in the requested dstFormat */
+ for (i = 0; i < n; i++) {
+ /* not sure - need clamp[-1,1] here? */
+ dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ dst[1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst += dstComponents;
+ }
+ }
+}
/*
* Unpack a row of color index data from a client buffer according to