summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@vmware.com>2009-01-22 09:43:42 +0000
committerAlan Hourihane <alanh@vmware.com>2009-01-22 09:43:42 +0000
commit4df482086ebf0663c708b089d8d8d22de0ef972c (patch)
treee802cc36b266bfdeb80ab9e55643c50f5a5e6d9c /src/mesa/main
parent01cbd764962ff49bf104e5997914ced53360ef81 (diff)
parentb8bd0b0ddc357f9b430bb6ddeb60c5a2179d3791 (diff)
Merge commit 'origin/master' into gallium-0.2
Conflicts: windows/VC8/mesa/osmesa/osmesa.vcproj windows/VC8/progs/demos/gears.vcproj windows/VC8/progs/progs.sln
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/colormac.h4
-rw-r--r--src/mesa/main/enable.c4
-rw-r--r--src/mesa/main/texformat.c48
-rw-r--r--src/mesa/main/texformat.h4
-rw-r--r--src/mesa/main/texformat_tmp.h51
-rw-r--r--src/mesa/main/texobj.c14
-rw-r--r--src/mesa/main/texstate.c8
-rw-r--r--src/mesa/main/texstore.c107
-rw-r--r--src/mesa/main/texstore.h2
-rw-r--r--src/mesa/main/version.h2
10 files changed, 237 insertions, 7 deletions
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index a34bd2ed38..74692e9a98 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -195,6 +195,10 @@ do { \
#define PACK_COLOR_565_REV( X, Y, Z ) \
(((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5))
+#define PACK_COLOR_5551( R, G, B, A ) \
+ ((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \
+ ((A) ? 1 : 0))
+
#define PACK_COLOR_1555( A, B, G, R ) \
((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \
((A) ? 0x8000 : 0))
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 72ed50808c..2ef4b1b207 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -341,10 +341,6 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
ctx->Transform.CullVertexFlag = state;
break;
case GL_DEPTH_TEST:
- if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
- _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
- return;
- }
if (ctx->Depth.Test == state)
return;
FLUSH_VERTICES(ctx, _NEW_DEPTH);
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 50e8d7a3b8..f49c916b33 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -896,6 +896,30 @@ const struct gl_texture_format _mesa_texformat_rgb565_rev = {
store_texel_rgb565_rev /* StoreTexel */
};
+const struct gl_texture_format _mesa_texformat_rgba4444 = {
+ MESA_FORMAT_RGBA4444, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /* RedBits */
+ 4, /* GreenBits */
+ 4, /* BlueBits */
+ 4, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* StencilBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_rgba4444, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba4444, /* FetchTexel1D */
+ fetch_texel_2d_rgba4444, /* FetchTexel2D */
+ fetch_texel_3d_rgba4444, /* FetchTexel3D */
+ NULL, /* FetchTexel1Df */
+ NULL, /* FetchTexel2Df */
+ NULL, /* FetchTexel3Df */
+ store_texel_rgba4444 /* StoreTexel */
+};
+
const struct gl_texture_format _mesa_texformat_argb4444 = {
MESA_FORMAT_ARGB4444, /* MesaFormat */
GL_RGBA, /* BaseFormat */
@@ -944,6 +968,30 @@ const struct gl_texture_format _mesa_texformat_argb4444_rev = {
store_texel_argb4444_rev /* StoreTexel */
};
+const struct gl_texture_format _mesa_texformat_rgba5551 = {
+ MESA_FORMAT_RGBA5551, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 5, /* RedBits */
+ 5, /* GreenBits */
+ 5, /* BlueBits */
+ 1, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* StencilBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_rgba5551, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba5551, /* FetchTexel1D */
+ fetch_texel_2d_rgba5551, /* FetchTexel2D */
+ fetch_texel_3d_rgba5551, /* FetchTexel3D */
+ NULL, /* FetchTexel1Df */
+ NULL, /* FetchTexel2Df */
+ NULL, /* FetchTexel3Df */
+ store_texel_rgba5551 /* StoreTexel */
+};
+
const struct gl_texture_format _mesa_texformat_argb1555 = {
MESA_FORMAT_ARGB1555, /* MesaFormat */
GL_RGBA, /* BaseFormat */
diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h
index c7a754b0b7..31364c36b1 100644
--- a/src/mesa/main/texformat.h
+++ b/src/mesa/main/texformat.h
@@ -71,8 +71,10 @@ enum _format {
MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */
+ MESA_FORMAT_RGBA4444, /* RRRR GGGG BBBB AAAA */
MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */
+ MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */
MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */
MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
@@ -217,10 +219,12 @@ extern const struct gl_texture_format _mesa_texformat_rgb888;
extern const struct gl_texture_format _mesa_texformat_bgr888;
extern const struct gl_texture_format _mesa_texformat_rgb565;
extern const struct gl_texture_format _mesa_texformat_rgb565_rev;
+extern const struct gl_texture_format _mesa_texformat_rgba4444;
extern const struct gl_texture_format _mesa_texformat_argb4444;
extern const struct gl_texture_format _mesa_texformat_argb4444_rev;
extern const struct gl_texture_format _mesa_texformat_argb1555;
extern const struct gl_texture_format _mesa_texformat_argb1555_rev;
+extern const struct gl_texture_format _mesa_texformat_rgba5551;
extern const struct gl_texture_format _mesa_texformat_al88;
extern const struct gl_texture_format _mesa_texformat_al88_rev;
extern const struct gl_texture_format _mesa_texformat_rgb332;
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index b1031b0cfe..08b6d8f12f 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -695,7 +695,7 @@ static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
{
const GLubyte *rgba = (const GLubyte *) texel;
GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+ *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]);
}
#endif
@@ -804,6 +804,30 @@ static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
}
#endif
+/* MESA_FORMAT_RGBA4444 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
+static void FETCH(rgba4444)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLushort s = *src;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) | ((s >> 4) & 0xf0) );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) | ((s ) & 0xf0) );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) | ((s << 4) & 0xf0) );
+}
+
+#if DIM == 3
+static void store_texel_rgba4444(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
/* MESA_FORMAT_ARGB4444 ******************************************************/
@@ -825,7 +849,7 @@ static void store_texel_argb4444(struct gl_texture_image *texImage,
{
const GLubyte *rgba = (const GLubyte *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+ *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
}
#endif
@@ -853,6 +877,29 @@ static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
}
#endif
+/* MESA_FORMAT_RGBA5551 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
+static void FETCH(rgba5551)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLushort s = *src;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xf8) | ((s >> 8) & 0x7) );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 2) & 0xf8) | ((s >> 3) & 0x7) );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s) & 0x01) ? 255 : 0);
+}
+
+#if DIM == 3
+static void store_texel_rgba5551(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
/* MESA_FORMAT_ARGB1555 ******************************************************/
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index d8e8b559f5..7848f0be35 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -762,24 +762,31 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj)
struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
if (texObj == unit->Current1D) {
_mesa_reference_texobj(&unit->Current1D, ctx->Shared->Default1D);
+ ASSERT(unit->Current1D);
}
else if (texObj == unit->Current2D) {
_mesa_reference_texobj(&unit->Current2D, ctx->Shared->Default2D);
+ ASSERT(unit->Current2D);
}
else if (texObj == unit->Current3D) {
_mesa_reference_texobj(&unit->Current3D, ctx->Shared->Default3D);
+ ASSERT(unit->Current3D);
}
else if (texObj == unit->CurrentCubeMap) {
_mesa_reference_texobj(&unit->CurrentCubeMap, ctx->Shared->DefaultCubeMap);
+ ASSERT(unit->CurrentCubeMap);
}
else if (texObj == unit->CurrentRect) {
_mesa_reference_texobj(&unit->CurrentRect, ctx->Shared->DefaultRect);
+ ASSERT(unit->CurrentRect);
}
else if (texObj == unit->Current1DArray) {
_mesa_reference_texobj(&unit->Current1DArray, ctx->Shared->Default1DArray);
+ ASSERT(unit->Current1DArray);
}
else if (texObj == unit->Current2DArray) {
_mesa_reference_texobj(&unit->Current2DArray, ctx->Shared->Default2DArray);
+ ASSERT(unit->Current2DArray);
}
}
}
@@ -953,24 +960,31 @@ _mesa_BindTexture( GLenum target, GLuint texName )
switch (target) {
case GL_TEXTURE_1D:
_mesa_reference_texobj(&texUnit->Current1D, newTexObj);
+ ASSERT(texUnit->Current1D);
break;
case GL_TEXTURE_2D:
_mesa_reference_texobj(&texUnit->Current2D, newTexObj);
+ ASSERT(texUnit->Current2D);
break;
case GL_TEXTURE_3D:
_mesa_reference_texobj(&texUnit->Current3D, newTexObj);
+ ASSERT(texUnit->Current3D);
break;
case GL_TEXTURE_CUBE_MAP_ARB:
_mesa_reference_texobj(&texUnit->CurrentCubeMap, newTexObj);
+ ASSERT(texUnit->CurrentCubeMap);
break;
case GL_TEXTURE_RECTANGLE_NV:
_mesa_reference_texobj(&texUnit->CurrentRect, newTexObj);
+ ASSERT(texUnit->CurrentRect);
break;
case GL_TEXTURE_1D_ARRAY_EXT:
texUnit->Current1DArray = newTexObj;
+ ASSERT(texUnit->Current1DArray);
break;
case GL_TEXTURE_2D_ARRAY_EXT:
texUnit->Current2DArray = newTexObj;
+ ASSERT(texUnit->Current2DArray);
break;
default:
/* Bad target should be caught above */
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 29955d76cb..9bfb7e0ec2 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -517,6 +517,14 @@ update_texture_state( GLcontext *ctx )
enableBits = texUnit->Enabled;
}
+ ASSERT(texUnit->Current1D);
+ ASSERT(texUnit->Current2D);
+ ASSERT(texUnit->Current3D);
+ ASSERT(texUnit->CurrentCubeMap);
+ ASSERT(texUnit->CurrentRect);
+ ASSERT(texUnit->Current1DArray);
+ ASSERT(texUnit->Current2DArray);
+
/* Look for the highest-priority texture target that's enabled and
* complete. That's the one we'll use for texturing. If we're using
* a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 8afb947fa1..2b06796aba 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1899,6 +1899,60 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
return GL_TRUE;
}
+GLboolean
+_mesa_texstore_rgba4444(TEXSTORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_rgba4444);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_rgba4444 &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_RGBA &&
+ srcType == GL_UNSIGNED_SHORT_4_4_4_4){
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[ACOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
GLboolean
_mesa_texstore_argb4444(TEXSTORE_PARAMS)
@@ -1967,7 +2021,60 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
return GL_TRUE;
}
+GLboolean
+_mesa_texstore_rgba5551(TEXSTORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_rgba5551);
+ ASSERT(dstFormat->TexelBytes == 2);
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_rgba5551 &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_RGBA &&
+ srcType == GL_UNSIGNED_SHORT_5_5_5_1) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src =tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[ACOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
GLboolean
_mesa_texstore_argb1555(TEXSTORE_PARAMS)
diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h
index 8dc1c963cd..b03386b2ac 100644
--- a/src/mesa/main/texstore.h
+++ b/src/mesa/main/texstore.h
@@ -47,8 +47,10 @@ extern GLboolean _mesa_texstore_rgb888(TEXSTORE_PARAMS);
extern GLboolean _mesa_texstore_bgr888(TEXSTORE_PARAMS);
extern GLboolean _mesa_texstore_rgb565(TEXSTORE_PARAMS);
extern GLboolean _mesa_texstore_rgb565_rev(TEXSTORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba4444(TEXSTORE_PARAMS);
extern GLboolean _mesa_texstore_argb4444(TEXSTORE_PARAMS);
extern GLboolean _mesa_texstore_argb4444_rev(TEXSTORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba5551(TEXSTORE_PARAMS);
extern GLboolean _mesa_texstore_argb1555(TEXSTORE_PARAMS);
extern GLboolean _mesa_texstore_argb1555_rev(TEXSTORE_PARAMS);
extern GLboolean _mesa_texstore_al88(TEXSTORE_PARAMS);
diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h
index 24495d608a..3d874c8ba8 100644
--- a/src/mesa/main/version.h
+++ b/src/mesa/main/version.h
@@ -31,7 +31,7 @@
#define MESA_MAJOR 7
#define MESA_MINOR 3
#define MESA_PATCH 0
-#define MESA_VERSION_STRING "7.3-rc2"
+#define MESA_VERSION_STRING "7.3-rc3"
/* To make version comparison easy */
#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))