This allows render to depth texture (we don't support floating pt. Z buffers).
Rename MESA_FORMAT_DEPTH_COMPONENT16/32 as MESA_FORMAT_Z16/32.
Software fallback for glCopyTexImage now uses integer temporary image instead
of float, eliminates a lot of float/int conversions.
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",
NULL, /*impossible*/ /* FetchTexel1Df */
fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */
NULL, /*impossible*/ /* FetchTexel3Df */
+ NULL /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
NULL, /*impossible*/ /* FetchTexel1Df */
fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */
NULL, /*impossible*/ /* FetchTexel3Df */
+ NULL /* StoreTexel */
};
NULL, /*impossible*/ /* FetchTexel1Df */
fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */
NULL, /*impossible*/ /* FetchTexel3Df */
+ NULL /* StoreTexel */
};
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 = {
NULL, /*impossible*/ /* FetchTexel1Df */
fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */
NULL, /*impossible*/ /* FetchTexel3Df */
+ NULL /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
NULL, /*impossible*/ /* FetchTexel1Df */
fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */
NULL, /*impossible*/ /* FetchTexel3Df */
+ NULL /* StoreTexel */
};
/*
* 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"),
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 */
}
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 */
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 */
+};
+
/*@}*/
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 */
}
/*
* 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"),
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 */
/*@}*/
/**
MESA_FORMAT_INTENSITY,
/*@}*/
- /**
- * Depth textures
- */
- /*@{*/
- MESA_FORMAT_DEPTH_COMPONENT_FLOAT32,
- MESA_FORMAT_DEPTH_COMPONENT16,
- /*@}*/
-
/**
* \name Floating point texture formats.
*/
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;
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 */
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.1
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
#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);
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
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
#include "context.h"
#include "fbobject.h"
+#include "texformat.h"
#include "texrender.h"
#include "renderbuffer.h"
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++) {
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++) {
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++) {
}
}
}
+ 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);
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++) {
}
}
}
+ 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);
struct texture_renderbuffer *trb
= (struct texture_renderbuffer *) att->Renderbuffer;
+ (void) ctx;
ASSERT(trb);
trb->TexImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
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;
struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
+ (void) fb;
+
if (!att->Renderbuffer) {
wrap_texture(ctx, att);
}
/* The renderbuffer texture wrapper will get deleted by the
* normal mechanism for deleting renderbuffers.
*/
+ (void) ctx;
+ (void) att;
}
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.1
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
/**
- * 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,
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;
* 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 &&
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;
}
}
}
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;
/*
* 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"),
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);
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);
/*
* 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"),
}
+/**
+ * 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.
*/
/*
* 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"),
GLint n, GLint x, GLint y, GLfloat depth[] );
+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 );
/*
* 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"),
/**
- * 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;
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;
}
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;
/* 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);
}
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;
/* 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);
}
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;
/* 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);
}
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;
/* 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);
}
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;
/* 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);
}