mesa: fix mipmap generation for MESA_FORMAT_AL44

This was missed when implementing AL44.
This commit is contained in:
Marek Olšák
2011-02-16 10:07:05 +01:00
parent 33d8ff9c31
commit 4d6994e40e
4 changed files with 61 additions and 1 deletions
+5 -1
View File
@@ -1372,7 +1372,11 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 4;
return;
case MESA_FORMAT_AL44: /* XXX this isn't plain GL_UNSIGNED_BYTE */
case MESA_FORMAT_AL44:
*datatype = MESA_UNSIGNED_BYTE_4_4;
*comps = 2;
return;
case MESA_FORMAT_AL88:
case MESA_FORMAT_AL88_REV:
case MESA_FORMAT_RG88:
+3
View File
@@ -35,6 +35,9 @@
#include <GL/gl.h>
/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type
* for GL_LUMINANCE4_ALPHA4. */
#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1)
/**
+3
View File
@@ -68,6 +68,7 @@ _mesa_type_is_packed(GLenum type)
switch (type) {
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case MESA_UNSIGNED_BYTE_4_4:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
case GL_UNSIGNED_SHORT_4_4_4_4:
@@ -194,6 +195,8 @@ _mesa_sizeof_packed_type( GLenum type )
return sizeof(GLubyte);
case GL_UNSIGNED_BYTE_2_3_3_REV:
return sizeof(GLubyte);
case MESA_UNSIGNED_BYTE_4_4:
return sizeof(GLubyte);
case GL_UNSIGNED_SHORT_5_6_5:
return sizeof(GLushort);
case GL_UNSIGNED_SHORT_5_6_5_REV:
+50
View File
@@ -612,6 +612,28 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth,
dst[i] = (blue << 5) | (green << 2) | red;
}
}
else if (datatype == MESA_UNSIGNED_BYTE_4_4 && comps == 2) {
GLuint i, j, k;
const GLubyte *rowA = (const GLubyte *) srcRowA;
const GLubyte *rowB = (const GLubyte *) srcRowB;
GLubyte *dst = (GLubyte *) dstRow;
for (i = j = 0, k = k0; i < (GLuint) dstWidth;
i++, j += colStride, k += colStride) {
const GLint rowAr0 = rowA[j] & 0xf;
const GLint rowAr1 = rowA[k] & 0xf;
const GLint rowBr0 = rowB[j] & 0xf;
const GLint rowBr1 = rowB[k] & 0xf;
const GLint rowAg0 = (rowA[j] >> 4) & 0xf;
const GLint rowAg1 = (rowA[k] >> 4) & 0xf;
const GLint rowBg0 = (rowB[j] >> 4) & 0xf;
const GLint rowBg1 = (rowB[k] >> 4) & 0xf;
const GLint r = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
const GLint g = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
dst[i] = (g << 4) | r;
}
}
else {
_mesa_problem(NULL, "bad format in do_row()");
}
@@ -1115,6 +1137,34 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth,
dst[i] = (b << 5) | (g << 2) | r;
}
}
else if (datatype == MESA_UNSIGNED_BYTE_4_4 && comps == 2) {
DECLARE_ROW_POINTERS0(GLushort);
for (i = j = 0, k = k0; i < (GLuint) dstWidth;
i++, j += colStride, k += colStride) {
const GLint rowAr0 = rowA[j] & 0xf;
const GLint rowAr1 = rowA[k] & 0xf;
const GLint rowBr0 = rowB[j] & 0xf;
const GLint rowBr1 = rowB[k] & 0xf;
const GLint rowCr0 = rowC[j] & 0xf;
const GLint rowCr1 = rowC[k] & 0xf;
const GLint rowDr0 = rowD[j] & 0xf;
const GLint rowDr1 = rowD[k] & 0xf;
const GLint rowAg0 = (rowA[j] >> 4) & 0xf;
const GLint rowAg1 = (rowA[k] >> 4) & 0xf;
const GLint rowBg0 = (rowB[j] >> 4) & 0xf;
const GLint rowBg1 = (rowB[k] >> 4) & 0xf;
const GLint rowCg0 = (rowC[j] >> 4) & 0xf;
const GLint rowCg1 = (rowC[k] >> 4) & 0xf;
const GLint rowDg0 = (rowD[j] >> 4) & 0xf;
const GLint rowDg1 = (rowD[k] >> 4) & 0xf;
const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1,
rowCr0, rowCr1, rowDr0, rowDr1);
const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1,
rowCg0, rowCg1, rowDg0, rowDg1);
dst[i] = (g << 4) | r;
}
}
else {
_mesa_problem(NULL, "bad format in do_row()");
}