diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_tex.c | 2 | ||||
-rw-r--r-- | src/mesa/main/texcompress_fxt1.c | 2 | ||||
-rw-r--r-- | src/mesa/main/texcompress_s3tc.c | 4 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 108 | ||||
-rw-r--r-- | src/mesa/main/texformat.h | 22 | ||||
-rw-r--r-- | src/mesa/main/texformat_tmp.h | 44 | ||||
-rw-r--r-- | src/mesa/main/texrender.c | 77 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 34 | ||||
-rw-r--r-- | src/mesa/main/texstore.h | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_depth.c | 83 | ||||
-rw-r--r-- | src/mesa/swrast/s_depth.h | 9 | ||||
-rw-r--r-- | src/mesa/swrast/s_texstore.c | 35 |
12 files changed, 299 insertions, 129 deletions
diff --git a/src/mesa/drivers/dri/i915/intel_tex.c b/src/mesa/drivers/dri/i915/intel_tex.c index 4bd7f92db0..d2bf9d06c1 100644 --- a/src/mesa/drivers/dri/i915/intel_tex.c +++ b/src/mesa/drivers/dri/i915/intel_tex.c @@ -572,7 +572,7 @@ intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT32: - return &_mesa_texformat_depth_component16; + return &_mesa_texformat_z16; default: fprintf(stderr, "unexpected texture format %s in %s\n", diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 44b450fd56..a3d5db93fc 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -243,6 +243,7 @@ const struct gl_texture_format _mesa_texformat_rgb_fxt1 = { NULL, /*impossible*/ /* FetchTexel1Df */ fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */ NULL, /*impossible*/ /* FetchTexel3Df */ + NULL /* StoreTexel */ }; const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { @@ -266,6 +267,7 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { NULL, /*impossible*/ /* FetchTexel1Df */ fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */ NULL, /*impossible*/ /* FetchTexel3Df */ + NULL /* StoreTexel */ }; diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 881da83b0f..5a6685e0f3 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -491,6 +491,7 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = { NULL, /*impossible*/ /* FetchTexel1Df */ fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */ NULL, /*impossible*/ /* FetchTexel3Df */ + NULL /* StoreTexel */ }; const struct gl_texture_format _mesa_texformat_rgba_dxt1 = { @@ -514,6 +515,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt1 = { NULL, /*impossible*/ /* FetchTexel1Df */ fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */ NULL, /*impossible*/ /* FetchTexel3Df */ + NULL /* StoreTexel */ }; const struct gl_texture_format _mesa_texformat_rgba_dxt3 = { @@ -537,6 +539,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt3 = { NULL, /*impossible*/ /* FetchTexel1Df */ fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */ NULL, /*impossible*/ /* FetchTexel3Df */ + NULL /* StoreTexel */ }; const struct gl_texture_format _mesa_texformat_rgba_dxt5 = { @@ -560,4 +563,5 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt5 = { NULL, /*impossible*/ /* FetchTexel1Df */ fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */ NULL, /*impossible*/ /* FetchTexel3Df */ + NULL /* StoreTexel */ }; diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 5ef9e46df2..792bfbc1e4 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -79,6 +79,11 @@ static void fetch_null_texelf( const struct gl_texture_image *texImage, static void store_null_texel(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel) { + (void) texImage; + (void) i; + (void) j; + (void) k; + (void) texel; /* no-op */ } @@ -245,53 +250,6 @@ const struct gl_texture_format _mesa_texformat_intensity = { store_texel_intensity /* StoreTexel */ }; -const struct gl_texture_format _mesa_texformat_depth_component_float32 = { - MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, /* MesaFormat */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 0, /* RedBits */ - 0, /* GreenBits */ - 0, /* BlueBits */ - 0, /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - sizeof(GLfloat) * 8, /* DepthBits */ - sizeof(GLfloat) * 8, /* StencilBits */ - sizeof(GLfloat), /* TexelBytes */ - _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */ - NULL, /* FetchTexel1D */ - NULL, /* FetchTexel1D */ - NULL, /* FetchTexel1D */ - fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */ - fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */ - fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */ - store_texel_depth_component_f32 /* StoreTexel */ -}; - -const struct gl_texture_format _mesa_texformat_depth_component16 = { - MESA_FORMAT_DEPTH_COMPONENT16, /* MesaFormat */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 0, /* RedBits */ - 0, /* GreenBits */ - 0, /* BlueBits */ - 0, /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - sizeof(GLushort) * 8, /* DepthBits */ - sizeof(GLushort) * 8, /* StencilBits */ - sizeof(GLushort), /* TexelBytes */ - _mesa_texstore_depth_component16, /* StoreTexImageFunc */ - NULL, /* FetchTexel1D */ - NULL, /* FetchTexel1D */ - NULL, /* FetchTexel1D */ - fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */ - fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */ - fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */ - store_texel_depth_component16 /* StoreTexel */ -}; const struct gl_texture_format _mesa_texformat_rgba_float32 = { MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */ @@ -1117,6 +1075,54 @@ const struct gl_texture_format _mesa_texformat_z24_s8 = { store_texel_z24_s8 /* StoreTexel */ }; +const struct gl_texture_format _mesa_texformat_z16 = { + MESA_FORMAT_Z16, /* MesaFormat */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 0, /* RedBits */ + 0, /* GreenBits */ + 0, /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + sizeof(GLushort) * 8, /* DepthBits */ + 0, /* StencilBits */ + sizeof(GLushort), /* TexelBytes */ + _mesa_texstore_z16, /* StoreTexImageFunc */ + NULL, /* FetchTexel1D */ + NULL, /* FetchTexel1D */ + NULL, /* FetchTexel1D */ + fetch_texel_1d_f_z16, /* FetchTexel1Df */ + fetch_texel_2d_f_z16, /* FetchTexel2Df */ + fetch_texel_3d_f_z16, /* FetchTexel3Df */ + store_texel_z16 /* StoreTexel */ +}; + +const struct gl_texture_format _mesa_texformat_z32 = { + MESA_FORMAT_Z32, /* MesaFormat */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 0, /* RedBits */ + 0, /* GreenBits */ + 0, /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + sizeof(GLuint) * 8, /* DepthBits */ + 0, /* StencilBits */ + sizeof(GLuint), /* TexelBytes */ + _mesa_texstore_z32, /* StoreTexImageFunc */ + NULL, /* FetchTexel1D */ + NULL, /* FetchTexel1D */ + NULL, /* FetchTexel1D */ + fetch_texel_1d_f_z32, /* FetchTexel1Df */ + fetch_texel_2d_f_z32, /* FetchTexel2Df */ + fetch_texel_3d_f_z32, /* FetchTexel3Df */ + store_texel_z32 /* StoreTexel */ +}; + /*@}*/ @@ -1264,9 +1270,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT24_SGIX: case GL_DEPTH_COMPONENT32_SGIX: - return &_mesa_texformat_depth_component_float32; + return &_mesa_texformat_z32; case GL_DEPTH_COMPONENT16_SGIX: - return &_mesa_texformat_depth_component16; + return &_mesa_texformat_z16; default: ; /* fallthrough */ } diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h index 63f524bbe1..b7e5fc27dc 100644 --- a/src/mesa/main/texformat.h +++ b/src/mesa/main/texformat.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 6.5.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -84,6 +84,8 @@ enum _format { MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ + MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z32, /*ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ /*@}*/ /** @@ -118,14 +120,6 @@ enum _format { /*@}*/ /** - * Depth textures - */ - /*@{*/ - MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, - MESA_FORMAT_DEPTH_COMPONENT16, - /*@}*/ - - /** * \name Floating point texture formats. */ /*@{*/ @@ -155,12 +149,6 @@ extern const struct gl_texture_format _mesa_texformat_luminance_alpha; extern const struct gl_texture_format _mesa_texformat_intensity; /*@}*/ -/** Depth textures */ -/*@{*/ -extern const struct gl_texture_format _mesa_texformat_depth_component_float32; -extern const struct gl_texture_format _mesa_texformat_depth_component16; -/*@}*/ - /** Floating point texture formats */ /*@{*/ extern const struct gl_texture_format _mesa_texformat_rgba_float32; @@ -199,6 +187,8 @@ extern const struct gl_texture_format _mesa_texformat_l8; extern const struct gl_texture_format _mesa_texformat_i8; extern const struct gl_texture_format _mesa_texformat_ci8; extern const struct gl_texture_format _mesa_texformat_z24_s8; +extern const struct gl_texture_format _mesa_texformat_z16; +extern const struct gl_texture_format _mesa_texformat_z32; /*@}*/ /** \name YCbCr formats */ diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index cc6ed1cc93..1c41278059 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * @@ -234,46 +234,46 @@ static void store_texel_intensity(struct gl_texture_image *texImage, #endif -/* MESA_FORMAT_DEPTH_COMPONENT_F32 *******************************************/ +/* MESA_FORMAT_Z32 ***********************************************************/ -/* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture, +/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture, * returning 1 GLfloat. * Note: no GLchan version of this function. */ -static void FETCH(f_depth_component_f32)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void FETCH(f_z32)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - texel[0] = src[0]; + const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[0] = src[0] * (1.0F / 0xffffffff); } #if DIM == 3 -static void store_texel_depth_component_f32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) +static void store_texel_z32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) { - const GLfloat *depth = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); + const GLuint *depth = (const GLuint *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); dst[0] = *depth; } #endif -/* MESA_FORMAT_DEPTH_COMPONENT16 *********************************************/ +/* MESA_FORMAT_Z16 ***********************************************************/ -/* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture, +/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture, * returning 1 GLfloat. * Note: no GLchan version of this function. */ -static void FETCH(f_depth_component16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void FETCH(f_z16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[0] = src[0] * (1.0F / 65535.0F); } #if DIM == 3 -static void store_texel_depth_component16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) +static void store_texel_z16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) { const GLushort *depth = (const GLushort *) texel; GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); @@ -1211,6 +1211,11 @@ static void FETCH(ycbcr)( const struct gl_texture_image *texImage, static void store_texel_ycbcr(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel) { + (void) texImage; + (void) i; + (void) j; + (void) k; + (void) texel; /* XXX to do */ } #endif @@ -1253,6 +1258,11 @@ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, static void store_texel_ycbcr_rev(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel) { + (void) texImage; + (void) i; + (void) j; + (void) k; + (void) texel; /* XXX to do */ } #endif diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c index db720cef6e..32e7b575f0 100644 --- a/src/mesa/main/texrender.c +++ b/src/mesa/main/texrender.c @@ -1,6 +1,7 @@ #include "context.h" #include "fbobject.h" +#include "texformat.h" #include "texrender.h" #include "renderbuffer.h" @@ -43,6 +44,23 @@ 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_INT) { + GLuint *zValues = (GLuint *) values; + /* + const GLdouble scale = (GLdouble) 0xffffffff; + */ + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); +#if 0 + /* this should work, but doesn't (overflow due to low precision) */ + zValues[i] = (GLuint) (flt * scale); +#else + /* temporary hack */ + zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; +#endif + } + } else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { GLuint *zValues = (GLuint *) values; for (i = 0; i < count; i++) { @@ -73,6 +91,18 @@ texture_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, rgbaOut + 4 * i); } } + else if (rb->DataType == GL_UNSIGNED_INT) { + GLuint *zValues = (GLuint *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i], z, &flt); +#if 0 + zValues[i] = (GLuint) (flt * 0xffffffff); +#else + zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; +#endif + } + } else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { GLuint *zValues = (GLuint *) values; for (i = 0; i < count; i++) { @@ -108,6 +138,14 @@ texture_put_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, rgba += 4; } } + 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, z, zValues + i); + } + } + } else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { const GLuint *zValues = (const GLuint *) values; for (i = 0; i < count; i++) { @@ -140,6 +178,14 @@ texture_put_mono_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, } } } + else if (rb->DataType == GL_UNSIGNED_INT) { + const GLuint zValue = *((const GLuint *) 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_24_8_EXT) { const GLuint zValue = *((const GLuint *) value); const GLfloat flt = (zValue >> 8) * (1.0 / 0xffffff); @@ -174,6 +220,14 @@ texture_put_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, rgba += 4; } } + 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], z, zValues + i); + } + } + } else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { const GLuint *zValues = (const GLuint *) values; for (i = 0; i < count; i++) { @@ -207,6 +261,14 @@ texture_put_mono_values(GLcontext *ctx, struct gl_renderbuffer *rb, } } } + else if (rb->DataType == GL_UNSIGNED_INT) { + const GLuint zValue = *((const GLuint *) value); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i], z, &zValue); + } + } + } else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { const GLuint zValue = *((const GLuint *) value); const GLfloat flt = (zValue >> 8) * (1.0 / 0xffffff); @@ -279,6 +341,7 @@ update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att) struct texture_renderbuffer *trb = (struct texture_renderbuffer *) att->Renderbuffer; + (void) ctx; ASSERT(trb); trb->TexImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; @@ -293,13 +356,17 @@ update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att) trb->Base.Height = trb->TexImage->Height; trb->Base.InternalFormat = trb->TexImage->InternalFormat; /* XXX may need more special cases here */ - if (trb->TexImage->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT) { + if (trb->TexImage->TexFormat->MesaFormat == MESA_FORMAT_Z24_S8) { trb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT; trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; } - else if (trb->TexImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) { + else if (trb->TexImage->TexFormat->MesaFormat == MESA_FORMAT_Z16) { trb->Base._ActualFormat = GL_DEPTH_COMPONENT; - trb->Base.DataType = GL_FLOAT; + trb->Base.DataType = GL_UNSIGNED_SHORT; + } + else if (trb->TexImage->TexFormat->MesaFormat == MESA_FORMAT_Z32) { + trb->Base._ActualFormat = GL_DEPTH_COMPONENT; + trb->Base.DataType = GL_UNSIGNED_INT; } else { trb->Base._ActualFormat = trb->TexImage->InternalFormat; @@ -345,6 +412,8 @@ _mesa_render_texture(GLcontext *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att) { + (void) fb; + if (!att->Renderbuffer) { wrap_texture(ctx, att); } @@ -360,4 +429,6 @@ _mesa_finish_render_texture(GLcontext *ctx, /* The renderbuffer texture wrapper will get deleted by the * normal mechanism for deleting renderbuffers. */ + (void) ctx; + (void) att; } diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 717551d716..fab0fad3b4 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * @@ -848,20 +848,21 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims, /** - * Store a floating point depth component texture image. + * Store a 32-bit integer depth component texture image. */ GLboolean -_mesa_texstore_depth_component_float32(STORE_PARAMS) +_mesa_texstore_z32(STORE_PARAMS) { + const GLfloat depthScale = (GLfloat) 0xffffffff; (void) dims; - ASSERT(dstFormat == &_mesa_texformat_depth_component_float32); - ASSERT(dstFormat->TexelBytes == sizeof(GLfloat)); + ASSERT(dstFormat == &_mesa_texformat_z32); + ASSERT(dstFormat->TexelBytes == sizeof(GLuint)); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && baseInternalFormat == GL_DEPTH_COMPONENT && srcFormat == GL_DEPTH_COMPONENT && - srcType == GL_FLOAT) { + srcType == GL_UNSIGNED_INT) { /* simple memcpy path */ memcpy_texture(ctx, dims, dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, @@ -882,8 +883,8 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS) const GLvoid *src = _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); _mesa_unpack_depth_span(ctx, srcWidth, - GL_FLOAT, (GLfloat *) dstRow, 1.0F, - srcType, src, srcPacking); + GL_UNSIGNED_INT, (GLuint *) dstRow, + depthScale, srcType, src, srcPacking); dstRow += dstRowStride; } dstImage += dstImageStride; @@ -897,10 +898,11 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS) * Store a 16-bit integer depth component texture image. */ GLboolean -_mesa_texstore_depth_component16(STORE_PARAMS) +_mesa_texstore_z16(STORE_PARAMS) { + const GLfloat depthScale = 65535.0f; (void) dims; - ASSERT(dstFormat == &_mesa_texformat_depth_component16); + ASSERT(dstFormat == &_mesa_texformat_z16); ASSERT(dstFormat->TexelBytes == sizeof(GLushort)); if (!ctx->_ImageTransferState && @@ -929,7 +931,7 @@ _mesa_texstore_depth_component16(STORE_PARAMS) srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); GLushort *dst16 = (GLushort *) dstRow; _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_SHORT, dst16, 65535.0F, + GL_UNSIGNED_SHORT, dst16, depthScale, srcType, src, srcPacking); dstRow += dstRowStride; } @@ -3068,19 +3070,19 @@ do_row(const struct gl_texture_format *format, GLint srcWidth, } } return; - case MESA_FORMAT_DEPTH_COMPONENT_FLOAT32: + case MESA_FORMAT_Z32: { GLuint i, j, k; - const GLfloat *rowA = (const GLfloat *) srcRowA; - const GLfloat *rowB = (const GLfloat *) srcRowB; + const GLuint *rowA = (const GLuint *) srcRowA; + const GLuint *rowB = (const GLuint *) srcRowB; GLfloat *dst = (GLfloat *) dstRow; for (i = j = 0, k = k0; i < (GLuint) dstWidth; i++, j += colStride, k += colStride) { - dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) * 0.25F; + dst[i] = rowA[j] / 4 + rowA[k] / 4 + rowB[j] / 4 + rowB[k] / 4; } } return; - case MESA_FORMAT_DEPTH_COMPONENT16: + case MESA_FORMAT_Z16: { GLuint i, j, k; const GLushort *rowA = (const GLushort *) srcRowA; diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h index b71bae24eb..7fef20d7b8 100644 --- a/src/mesa/main/texstore.h +++ b/src/mesa/main/texstore.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -53,8 +53,6 @@ extern GLboolean _mesa_texstore_rgba(STORE_PARAMS); extern GLboolean _mesa_texstore_color_index(STORE_PARAMS); -extern GLboolean _mesa_texstore_depth_component16(STORE_PARAMS); -extern GLboolean _mesa_texstore_depth_component_float32(STORE_PARAMS); extern GLboolean _mesa_texstore_rgba8888(STORE_PARAMS); extern GLboolean _mesa_texstore_argb8888(STORE_PARAMS); extern GLboolean _mesa_texstore_rgb888(STORE_PARAMS); @@ -72,6 +70,8 @@ extern GLboolean _mesa_texstore_a8(STORE_PARAMS); extern GLboolean _mesa_texstore_ci8(STORE_PARAMS); extern GLboolean _mesa_texstore_ycbcr(STORE_PARAMS); extern GLboolean _mesa_texstore_z24_s8(STORE_PARAMS); +extern GLboolean _mesa_texstore_z16(STORE_PARAMS); +extern GLboolean _mesa_texstore_z32(STORE_PARAMS); extern GLboolean _mesa_texstore_rgba_float32(STORE_PARAMS); extern GLboolean _mesa_texstore_rgba_float16(STORE_PARAMS); extern GLboolean _mesa_texstore_rgb_fxt1(STORE_PARAMS); diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 061eb9c595..ab5dbce64c 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1265,6 +1265,85 @@ _swrast_read_depth_span_float( GLcontext *ctx, struct gl_renderbuffer *rb, /** + * As above, but return 32-bit GLuint values. + */ +void +_swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, + GLint n, GLint x, GLint y, GLuint depth[] ) +{ + const GLfloat scale = 1.0F / ctx->DrawBuffer->_DepthMaxF; + + if (!rb) { + /* really only doing this to prevent FP exceptions later */ + _mesa_bzero(depth, n * sizeof(GLfloat)); + } + + ASSERT(rb->_BaseFormat == GL_DEPTH_COMPONENT); + + if (y < 0 || y >= (GLint) rb->Height || + x + n <= 0 || x >= (GLint) rb->Width) { + /* span is completely outside framebuffer */ + _mesa_bzero(depth, n * sizeof(GLfloat)); + return; + } + + if (x < 0) { + GLint dx = -x; + GLint i; + for (i = 0; i < dx; i++) + depth[i] = 0.0; + x = 0; + n -= dx; + depth += dx; + } + if (x + n > (GLint) rb->Width) { + GLint dx = x + n - (GLint) rb->Width; + GLint i; + for (i = 0; i < dx; i++) + depth[n - i - 1] = 0.0; + n -= dx; + } + if (n <= 0) { + return; + } + + if (rb->DataType == GL_UNSIGNED_INT) { + rb->GetRow(ctx, rb, n, x, y, depth); + if (rb->DepthBits < 32) { + GLuint shift = 32 - rb->DepthBits; + GLint i; + for (i = 0; i < n; i++) { + GLuint z = depth[i]; + depth[i] = z << shift; /* XXX lsb bits? */ + } + } + } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + GLushort temp[MAX_WIDTH]; + GLint i; + rb->GetRow(ctx, rb, n, x, y, temp); + if (rb->DepthBits == 16) { + for (i = 0; i < n; i++) { + GLuint z = temp[i]; + depth[i] = (z << 16) | z; + } + } + else { + GLuint shift = 16 - rb->DepthBits; + for (i = 0; i < n; i++) { + GLuint z = temp[i]; + depth[i] = (z << (shift + 16)) | (z << shift); /* XXX lsb bits? */ + } + } + } + else { + _mesa_problem(ctx, "Invalid depth renderbuffer data type"); + } +} + + + +/** * Clear the given z/depth renderbuffer. */ void diff --git a/src/mesa/swrast/s_depth.h b/src/mesa/swrast/s_depth.h index a5856151f0..f93d95fa3d 100644 --- a/src/mesa/swrast/s_depth.h +++ b/src/mesa/swrast/s_depth.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -45,6 +45,11 @@ _swrast_read_depth_span_float( GLcontext *ctx, struct gl_renderbuffer *rb, extern void +_swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, + GLint n, GLint x, GLint y, GLuint depth[] ); + + +extern void _swrast_clear_depth_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ); diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c index d6b98acf9d..a9da77ed65 100644 --- a/src/mesa/swrast/s_texstore.c +++ b/src/mesa/swrast/s_texstore.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -88,18 +88,19 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, /** - * As above, but read data from depth buffer. + * As above, but read data from depth buffer. Returned as GLuints. + * \sa read_color_image */ -static GLfloat * +static GLuint * read_depth_image( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ) { struct gl_renderbuffer *rb = ctx->ReadBuffer->_DepthBuffer; SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLfloat *image, *dst; + GLuint *image, *dst; GLint i; - image = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat)); + image = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); if (!image) return NULL; @@ -107,7 +108,7 @@ read_depth_image( GLcontext *ctx, GLint x, GLint y, dst = image; for (i = 0; i < height; i++) { - _swrast_read_depth_span_float(ctx, rb, width, x, y + i, dst); + _swrast_read_depth_span_uint(ctx, rb, width, x, y + i, dst); dst += width; } @@ -255,7 +256,7 @@ _swrast_copy_teximage1d( GLcontext *ctx, GLenum target, GLint level, if (is_depth_format(internalFormat)) { /* read depth image from framebuffer */ - GLfloat *image = read_depth_image(ctx, x, y, width, 1); + GLuint *image = read_depth_image(ctx, x, y, width, 1); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D"); return; @@ -263,7 +264,7 @@ _swrast_copy_teximage1d( GLcontext *ctx, GLenum target, GLint level, /* call glTexImage1D to redefine the texture */ ctx->Driver.TexImage1D(ctx, target, level, internalFormat, width, border, - GL_DEPTH_COMPONENT, GL_FLOAT, image, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, &ctx->DefaultPacking, texObj, texImage); _mesa_free(image); } @@ -326,7 +327,7 @@ _swrast_copy_teximage2d( GLcontext *ctx, GLenum target, GLint level, if (is_depth_format(internalFormat)) { /* read depth image from framebuffer */ - GLfloat *image = read_depth_image(ctx, x, y, width, height); + GLuint *image = read_depth_image(ctx, x, y, width, height); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D"); return; @@ -334,7 +335,7 @@ _swrast_copy_teximage2d( GLcontext *ctx, GLenum target, GLint level, /* call glTexImage2D to redefine the texture */ ctx->Driver.TexImage2D(ctx, target, level, internalFormat, width, height, border, - GL_DEPTH_COMPONENT, GL_FLOAT, image, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, &ctx->DefaultPacking, texObj, texImage); _mesa_free(image); } @@ -394,7 +395,7 @@ _swrast_copy_texsubimage1d( GLcontext *ctx, GLenum target, GLint level, if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) { /* read depth image from framebuffer */ - GLfloat *image = read_depth_image(ctx, x, y, width, 1); + GLuint *image = read_depth_image(ctx, x, y, width, 1); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D"); return; @@ -402,7 +403,7 @@ _swrast_copy_texsubimage1d( GLcontext *ctx, GLenum target, GLint level, /* call glTexSubImage1D to redefine the texture */ ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width, - GL_DEPTH_COMPONENT, GL_FLOAT, image, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, &ctx->DefaultPacking, texObj, texImage); _mesa_free(image); } @@ -463,7 +464,7 @@ _swrast_copy_texsubimage2d( GLcontext *ctx, if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) { /* read depth image from framebuffer */ - GLfloat *image = read_depth_image(ctx, x, y, width, height); + GLuint *image = read_depth_image(ctx, x, y, width, height); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D"); return; @@ -471,7 +472,7 @@ _swrast_copy_texsubimage2d( GLcontext *ctx, /* call glTexImage2D to redefine the texture */ ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset, width, height, - GL_DEPTH_COMPONENT, GL_FLOAT, image, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, &ctx->DefaultPacking, texObj, texImage); _mesa_free(image); } @@ -534,7 +535,7 @@ _swrast_copy_texsubimage3d( GLcontext *ctx, if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) { /* read depth image from framebuffer */ - GLfloat *image = read_depth_image(ctx, x, y, width, height); + GLuint *image = read_depth_image(ctx, x, y, width, height); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D"); return; @@ -542,7 +543,7 @@ _swrast_copy_texsubimage3d( GLcontext *ctx, /* call glTexImage3D to redefine the texture */ ctx->Driver.TexSubImage3D(ctx, target, level, xoffset, yoffset, zoffset, width, height, 1, - GL_DEPTH_COMPONENT, GL_FLOAT, image, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, &ctx->DefaultPacking, texObj, texImage); _mesa_free(image); } |