From c5c9241cca3c57684db955390410c8cda44b785e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 5 Jan 2009 17:52:14 -0700 Subject: mesa: add GLushort cases for render to texture (Z-buffers) --- src/mesa/main/texrender.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c index 163bda4501..4ae13a7b9b 100644 --- a/src/mesa/main/texrender.c +++ b/src/mesa/main/texrender.c @@ -49,6 +49,14 @@ texture_get_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, trb->TexImage->FetchTexelc(trb->TexImage, x + i, y, z, rgbaOut + 4 * i); } } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + GLushort *zValues = (GLushort *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); + zValues[i] = (GLushort) (flt * 0xffff); + } + } else if (rb->DataType == GL_UNSIGNED_INT) { GLuint *zValues = (GLuint *) values; /* @@ -96,6 +104,15 @@ texture_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, z, rgbaOut + 4 * i); } } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + GLushort *zValues = (GLushort *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, + z, &flt); + zValues[i] = (GLushort) (flt * 0xffff); + } + } else if (rb->DataType == GL_UNSIGNED_INT) { GLuint *zValues = (GLuint *) values; for (i = 0; i < count; i++) { @@ -147,6 +164,14 @@ texture_put_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, rgba += 4; } } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort *zValues = (const GLushort *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, zValues + i); + } + } + } else if (rb->DataType == GL_UNSIGNED_INT) { const GLuint *zValues = (const GLuint *) values; for (i = 0; i < count; i++) { @@ -189,6 +214,14 @@ texture_put_mono_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, } } } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort zValue = *((const GLushort *) value); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, &zValue); + } + } + } else if (rb->DataType == GL_UNSIGNED_INT) { const GLuint zValue = *((const GLuint *) value); for (i = 0; i < count; i++) { @@ -231,12 +264,19 @@ texture_put_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, rgba += 4; } } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort *zValues = (const GLushort *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i); + } + } + } else if (rb->DataType == GL_UNSIGNED_INT) { const GLuint *zValues = (const GLuint *) values; for (i = 0; i < count; i++) { if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, - zValues + i); + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i); } } } @@ -281,6 +321,14 @@ texture_put_mono_values(GLcontext *ctx, struct gl_renderbuffer *rb, } } } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort zValue = *((const GLushort *) value); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &zValue); + } + } + } else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { const GLuint zValue = *((const GLuint *) value); const GLfloat flt = (GLfloat) ((zValue >> 8) * (1.0 / 0xffffff)); -- cgit v1.2.3 From 241c0bfc985363bb15e6cc0eca859c6ec36d1b35 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 6 Jan 2009 15:30:34 +0800 Subject: mesa: Fix the number of components for GL_UNSIGNED_SHORT_1_5_5_5_REV. (bug #19390) --- src/mesa/main/texformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 4442ce39a4..1dd7bdd9ce 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -1641,7 +1641,7 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format, case MESA_FORMAT_ARGB1555: case MESA_FORMAT_ARGB1555_REV: *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; - *comps = 3; + *comps = 4; return; case MESA_FORMAT_AL88: -- cgit v1.2.3 From f1f022dbb103947b0edf5ae984fcff00f6a8e539 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 6 Jan 2009 15:37:45 +0800 Subject: mesa: Fix the size per pixel for packed pixel format data type. --- src/mesa/main/image.c | 2 +- src/mesa/main/image.h | 3 +++ src/mesa/main/mipmap.c | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index c205b4b766..4d86c54777 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -61,7 +61,7 @@ /** * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. */ -static GLboolean +GLboolean _mesa_type_is_packed(GLenum type) { switch (type) { diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 38e1374c20..0e0bbd96d8 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -36,6 +36,9 @@ _mesa_swap2( GLushort *p, GLuint n ); extern void _mesa_swap4( GLuint *p, GLuint n ); +extern GLboolean +_mesa_type_is_packed(GLenum type); + extern GLint _mesa_sizeof_type( GLenum type ); diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 9e051ace25..3dd4b3391b 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -41,7 +41,11 @@ bytes_per_pixel(GLenum datatype, GLuint comps) { GLint b = _mesa_sizeof_packed_type(datatype); assert(b >= 0); - return b * comps; + + if (_mesa_type_is_packed(datatype)) + return b; + else + return b * comps; } -- cgit v1.2.3