summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/drawpix.c36
-rw-r--r--src/mesa/main/extensions.c2
-rw-r--r--src/mesa/main/fbobject.c51
-rw-r--r--src/mesa/main/image.c148
-rw-r--r--src/mesa/main/image.h16
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/main/texcompress_fxt1.c2
-rw-r--r--src/mesa/main/texcompress_s3tc.c8
-rw-r--r--src/mesa/main/texformat.c76
-rw-r--r--src/mesa/main/texformat.h3
-rw-r--r--src/mesa/main/texformat_tmp.h24
-rw-r--r--src/mesa/main/teximage.c40
-rw-r--r--src/mesa/main/texstate.c10
-rw-r--r--src/mesa/main/texstore.c16
-rw-r--r--src/mesa/main/texstore.h3
15 files changed, 373 insertions, 66 deletions
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 3ced207247..de62909e7a 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -91,12 +91,34 @@ error_check_format_type(GLcontext *ctx, GLenum format, GLenum type,
return GL_TRUE;
}
break;
+ case GL_DEPTH_STENCIL_EXT:
+ if (!ctx->Extensions.EXT_packed_depth_stencil ||
+ type != GL_UNSIGNED_INT_24_8_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+ return GL_TRUE;
+ }
+ if (ctx->DrawBuffer->Visual.depthBits == 0 ||
+ ctx->ReadBuffer->Visual.depthBits == 0 ||
+ ctx->DrawBuffer->Visual.stencilBits == 0 ||
+ ctx->ReadBuffer->Visual.stencilBits == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "gl%sPixels(no depth or stencil buffer)", readDraw);
+ return GL_TRUE;
+ }
+ break;
default:
/* this should have been caught in _mesa_is_legal_format_type() */
_mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw);
return GL_TRUE;
}
+ /* XXX might have to move this to the top of the function */
+ if (type == GL_UNSIGNED_INT_24_8_EXT && format != GL_DEPTH_STENCIL_EXT) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
+ return GL_TRUE;
+ }
+
/* no errors */
return GL_FALSE;
}
@@ -201,6 +223,20 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
return;
}
break;
+ case GL_DEPTH_STENCIL_EXT:
+ if (!ctx->Extensions.EXT_packed_depth_stencil) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCopyPixels");
+ return;
+ }
+ if (ctx->DrawBuffer->Visual.depthBits == 0 ||
+ ctx->ReadBuffer->Visual.depthBits == 0 ||
+ ctx->DrawBuffer->Visual.stencilBits == 0 ||
+ ctx->ReadBuffer->Visual.stencilBits == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyPixels(no depth or stencil buffer)");
+ return;
+ }
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glCopyPixels");
return;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 006f55ccca..cd97b0ccb2 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -95,6 +95,7 @@ static const struct {
{ OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) },
{ OFF, "GL_EXT_histogram", F(EXT_histogram) },
{ OFF, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) },
+ { ON, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) },
{ ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) },
{ OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) },
{ OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) },
@@ -232,6 +233,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
#endif
ctx->Extensions.EXT_histogram = GL_TRUE;
ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
+ ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
ctx->Extensions.EXT_paletted_texture = GL_TRUE;
#if FEATURE_EXT_pixel_buffer_object
ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f41f464e3d..4c9967e7d2 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
@@ -289,7 +289,14 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
}
}
else if (format == GL_DEPTH) {
- if (texImage->TexFormat->BaseFormat != GL_DEPTH_COMPONENT) {
+ if (texImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
+ /* OK */
+ }
+ else if (ctx->Extensions.EXT_packed_depth_stencil &&
+ att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
+ /* OK */
+ }
+ else {
att->Complete = GL_FALSE;
return;
}
@@ -313,14 +320,28 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
}
}
else if (format == GL_DEPTH) {
- if (att->Renderbuffer->_BaseFormat != GL_DEPTH_COMPONENT) {
+ if (att->Renderbuffer->_BaseFormat == GL_DEPTH_COMPONENT) {
+ /* OK */
+ }
+ else if (ctx->Extensions.EXT_packed_depth_stencil &&
+ att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
+ /* OK */
+ }
+ else {
att->Complete = GL_FALSE;
return;
}
}
else {
assert(format == GL_STENCIL);
- if (att->Renderbuffer->_BaseFormat != GL_STENCIL_INDEX) {
+ if (att->Renderbuffer->_BaseFormat == GL_STENCIL_INDEX) {
+ /* OK */
+ }
+ else if (ctx->Extensions.EXT_packed_depth_stencil &&
+ att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
+ /* OK */
+ }
+ else {
att->Complete = GL_FALSE;
return;
}
@@ -390,6 +411,7 @@ _mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb)
f = att->Texture->Image[att->CubeMapFace][att->TextureLevel]->Format;
numImages++;
if (f != GL_RGB && f != GL_RGBA && f != GL_DEPTH_COMPONENT) {
+ /* XXX need GL_DEPTH_STENCIL_EXT test? */
fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT;
return;
}
@@ -449,14 +471,17 @@ _mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb)
}
}
- /* Check if any renderbuffer is attached more than once */
+ /* Check if any renderbuffer is attached more than once.
+ * Note that there's one exception: a GL_DEPTH_STENCIL renderbuffer can be
+ * bound to both the stencil and depth attachment points at the same time.
+ */
for (i = 0; i < BUFFER_COUNT - 1; i++) {
struct gl_renderbuffer *rb_i = fb->Attachment[i].Renderbuffer;
if (rb_i) {
GLint j;
for (j = i + 1; j < BUFFER_COUNT; j++) {
struct gl_renderbuffer *rb_j = fb->Attachment[j].Renderbuffer;
- if (rb_i == rb_j) {
+ if (rb_i == rb_j && rb_i->_BaseFormat != GL_DEPTH_STENCIL_EXT) {
fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT;
return;
}
@@ -607,7 +632,7 @@ _mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers)
* Given an internal format token for a render buffer, return the
* corresponding base format.
* \return one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT
- * or zero if error.
+ * GL_DEPTH_STENCIL_EXT or zero if error.
*/
static GLenum
base_internal_format(GLcontext *ctx, GLenum internalFormat)
@@ -642,6 +667,12 @@ base_internal_format(GLcontext *ctx, GLenum internalFormat)
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
return GL_DEPTH_COMPONENT;
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ if (ctx->Extensions.EXT_packed_depth_stencil)
+ return GL_DEPTH_STENCIL_EXT;
+ else
+ return 0;
/* XXX add floating point formats eventually */
default:
return 0;
@@ -781,7 +812,8 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
}
break;
case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
- if (ctx->CurrentRenderbuffer->_BaseFormat == GL_DEPTH_COMPONENT) {
+ if (ctx->CurrentRenderbuffer->_BaseFormat == GL_DEPTH_COMPONENT ||
+ ctx->CurrentRenderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
*params = ctx->CurrentRenderbuffer->DepthBits;
}
else {
@@ -789,7 +821,8 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
}
break;
case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
- if (ctx->CurrentRenderbuffer->_BaseFormat == GL_STENCIL_INDEX) {
+ if (ctx->CurrentRenderbuffer->_BaseFormat == GL_STENCIL_INDEX ||
+ ctx->CurrentRenderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
*params = ctx->CurrentRenderbuffer->StencilBits;
}
else {
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 93521a79bd..b6841d7a13 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -30,7 +30,6 @@
#include "glheader.h"
-#include "bufferobj.h"
#include "colormac.h"
#include "context.h"
#include "image.h"
@@ -38,7 +37,6 @@
#include "histogram.h"
#include "macros.h"
#include "pixel.h"
-#include "mtypes.h"
/** Compute ceiling of integer quotient of A divided by B. */
@@ -201,7 +199,9 @@ GLint _mesa_sizeof_packed_type( GLenum type )
return sizeof(GLuint);
case GL_UNSIGNED_SHORT_8_8_MESA:
case GL_UNSIGNED_SHORT_8_8_REV_MESA:
- return sizeof(GLushort);
+ return sizeof(GLushort);
+ case GL_UNSIGNED_INT_24_8_EXT:
+ return sizeof(GLuint);
default:
return -1;
}
@@ -248,6 +248,8 @@ GLint _mesa_components_in_format( GLenum format )
return 4;
case GL_YCBCR_MESA:
return 2;
+ case GL_DEPTH_STENCIL_EXT:
+ return 2;
default:
return -1;
}
@@ -318,6 +320,11 @@ GLint _mesa_bytes_per_pixel( GLenum format, GLenum type )
return sizeof(GLushort);
else
return -1;
+ case GL_UNSIGNED_INT_24_8_EXT:
+ if (format == GL_DEPTH_STENCIL_EXT)
+ return sizeof(GLuint);
+ else
+ return -1;
default:
return -1;
}
@@ -443,6 +450,12 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type )
return GL_TRUE;
else
return GL_FALSE;
+ case GL_DEPTH_STENCIL_EXT:
+ if (ctx->Extensions.EXT_packed_depth_stencil
+ && type == GL_UNSIGNED_INT_24_8_EXT)
+ return GL_TRUE;
+ else
+ return GL_FALSE;
default:
; /* fall-through */
}
@@ -2066,6 +2079,7 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
srcType == GL_SHORT ||
srcType == GL_UNSIGNED_INT ||
srcType == GL_INT ||
+ srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_HALF_FLOAT_ARB ||
srcType == GL_FLOAT);
@@ -2221,6 +2235,24 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
}
}
break;
+ case GL_UNSIGNED_INT_24_8_EXT:
+ {
+ GLuint i;
+ const GLuint *s = (const GLuint *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLuint value = s[i];
+ SWAP4BYTE(value);
+ indexes[i] = value & 0xff; /* lower 8 bits */
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i] & 0xfff; /* lower 8 bits */
+ }
+ }
+ break;
+
default:
_mesa_problem(NULL, "bad srcType in extract_uint_indexes");
return;
@@ -3563,6 +3595,7 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
srcType == GL_SHORT ||
srcType == GL_UNSIGNED_INT ||
srcType == GL_INT ||
+ srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_HALF_FLOAT_ARB ||
srcType == GL_FLOAT);
@@ -3801,10 +3834,20 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
void
-_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
+_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, GLfloat depthScale,
GLenum srcType, const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking )
{
+ GLfloat depthTemp[MAX_WIDTH], *depthValues;
+
+ if (dstType == GL_FLOAT) {
+ depthValues = (GLfloat *) dest;
+ }
+ else {
+ depthValues = depthTemp;
+ }
+
(void) srcPacking;
switch (srcType) {
@@ -3813,7 +3856,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
GLuint i;
const GLubyte *src = (const GLubyte *) source;
for (i = 0; i < n; i++) {
- dest[i] = BYTE_TO_FLOAT(src[i]);
+ depthValues[i] = BYTE_TO_FLOAT(src[i]);
}
}
break;
@@ -3822,7 +3865,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
GLuint i;
const GLubyte *src = (const GLubyte *) source;
for (i = 0; i < n; i++) {
- dest[i] = UBYTE_TO_FLOAT(src[i]);
+ depthValues[i] = UBYTE_TO_FLOAT(src[i]);
}
}
break;
@@ -3831,7 +3874,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
GLuint i;
const GLshort *src = (const GLshort *) source;
for (i = 0; i < n; i++) {
- dest[i] = SHORT_TO_FLOAT(src[i]);
+ depthValues[i] = SHORT_TO_FLOAT(src[i]);
}
}
break;
@@ -3840,7 +3883,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
GLuint i;
const GLushort *src = (const GLushort *) source;
for (i = 0; i < n; i++) {
- dest[i] = USHORT_TO_FLOAT(src[i]);
+ depthValues[i] = USHORT_TO_FLOAT(src[i]);
}
}
break;
@@ -3849,7 +3892,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
GLuint i;
const GLint *src = (const GLint *) source;
for (i = 0; i < n; i++) {
- dest[i] = INT_TO_FLOAT(src[i]);
+ depthValues[i] = INT_TO_FLOAT(src[i]);
}
}
break;
@@ -3858,19 +3901,39 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
GLuint i;
const GLuint *src = (const GLuint *) source;
for (i = 0; i < n; i++) {
- dest[i] = UINT_TO_FLOAT(src[i]);
+ depthValues[i] = UINT_TO_FLOAT(src[i]);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */
+ if (dstType == GL_UNSIGNED_INT && ctx->Pixel.DepthScale == 1.0 &&
+ ctx->Pixel.DepthBias == 0.0 && depthScale == (GLfloat) 0xffffff) {
+ const GLuint *src = (const GLuint *) source;
+ GLuint *zValues = (GLuint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ zValues[i] = src[i] & 0xffffff00;
+ }
+ return;
+ }
+ else {
+ const GLuint *src = (const GLuint *) source;
+ const GLfloat scale = 1.0f / 0xffffff;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ depthValues[i] = (src[i] >> 8) * scale;
}
}
break;
case GL_FLOAT:
- MEMCPY(dest, source, n * sizeof(GLfloat));
+ MEMCPY(depthValues, source, n * sizeof(GLfloat));
break;
case GL_HALF_FLOAT_ARB:
{
GLuint i;
const GLhalfARB *src = (const GLhalfARB *) source;
for (i = 0; i < n; i++) {
- dest[i] = _mesa_half_to_float(src[i]);
+ depthValues[i] = _mesa_half_to_float(src[i]);
}
}
break;
@@ -3882,12 +3945,27 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
/* apply depth scale and bias and clamp to [0,1] */
if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) {
+ _mesa_scale_and_bias_depth(ctx, n, depthValues);
+ }
+
+ if (dstType == GL_UNSIGNED_INT) {
+ GLuint *zValues = (GLuint *) dest;
GLuint i;
for (i = 0; i < n; i++) {
- GLfloat d = dest[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
- dest[i] = CLAMP(d, 0.0F, 1.0F);
+ zValues[i] = (GLuint) (depthValues[i] * depthScale);
}
}
+ else if (dstType == GL_UNSIGNED_SHORT) {
+ GLushort *zValues = (GLushort *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ zValues[i] = (GLushort) (depthValues[i] * depthScale);
+ }
+ }
+ else {
+ ASSERT(dstType == GL_FLOAT);
+ ASSERT(depthScale == 1.0F);
+ }
}
@@ -3900,18 +3978,12 @@ _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
const struct gl_pixelstore_attrib *dstPacking )
{
GLfloat depthCopy[MAX_WIDTH];
- const GLboolean bias_or_scale = ctx->Pixel.DepthBias != 0.0 ||
- ctx->Pixel.DepthScale != 1.0;
ASSERT(n <= MAX_WIDTH);
- if (bias_or_scale) {
- GLuint i;
- for (i = 0; i < n; i++) {
- GLfloat d;
- d = depthSpan[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
- depthCopy[i] = CLAMP(d, 0.0F, 1.0F);
- }
+ if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) {
+ _mesa_memcpy(depthCopy, depthSpan, n * sizeof(GLfloat));
+ _mesa_scale_and_bias_depth(ctx, n, depthCopy);
depthSpan = depthCopy;
}
@@ -4089,7 +4161,7 @@ _mesa_unpack_image( GLuint dimensions,
/**
* Perform clipping for glDrawPixels. The image's window position
- * and size, and the unpack skipPixels and skipRows are adjusted so
+ * and size, and the unpack SkipPixels and SkipRows are adjusted so
* that the image region is entirely within the window and scissor bounds.
* NOTE: this will only work when glPixelZoom is (1, 1).
*
@@ -4100,15 +4172,19 @@ GLboolean
_mesa_clip_drawpixels(const GLcontext *ctx,
GLint *destX, GLint *destY,
GLsizei *width, GLsizei *height,
- GLint *skipPixels, GLint *skipRows)
+ struct gl_pixelstore_attrib *unpack)
{
const GLframebuffer *buffer = ctx->DrawBuffer;
+ if (unpack->RowLength == 0) {
+ unpack->RowLength = *width;
+ }
+
ASSERT(ctx->Pixel.ZoomX == 1.0F && ctx->Pixel.ZoomY == 1.0F);
/* left clipping */
if (*destX < buffer->_Xmin) {
- *skipPixels += (buffer->_Xmin - *destX);
+ unpack->SkipPixels += (buffer->_Xmin - *destX);
*width -= (buffer->_Xmin - *destX);
*destX = buffer->_Xmin;
}
@@ -4121,7 +4197,7 @@ _mesa_clip_drawpixels(const GLcontext *ctx,
/* bottom clipping */
if (*destY < buffer->_Ymin) {
- *skipRows += (buffer->_Ymin - *destY);
+ unpack->SkipRows += (buffer->_Ymin - *destY);
*height -= (buffer->_Ymin - *destY);
*destY = buffer->_Ymin;
}
@@ -4138,11 +4214,11 @@ _mesa_clip_drawpixels(const GLcontext *ctx,
/**
* Perform clipping for glReadPixels. The image's window position
- * and size, and the pack skipPixels and skipRows are adjusted so
- * that the image region is entirely within the window bounds.
+ * and size, and the pack skipPixels, skipRows and rowLength are adjusted
+ * so that the image region is entirely within the window bounds.
* Note: this is different from _mesa_clip_drawpixels() in that the
- * scissor box is ignored, and we use the bounds of the current "read"
- * surface;
+ * scissor box is ignored, and we use the bounds of the current readbuffer
+ * surface.
*
* \return GL_TRUE if image is ready for drawing or
* GL_FALSE if image was completely clipped away (draw nothing)
@@ -4151,13 +4227,17 @@ GLboolean
_mesa_clip_readpixels(const GLcontext *ctx,
GLint *srcX, GLint *srcY,
GLsizei *width, GLsizei *height,
- GLint *skipPixels, GLint *skipRows)
+ struct gl_pixelstore_attrib *pack)
{
const GLframebuffer *buffer = ctx->ReadBuffer;
+ if (pack->RowLength == 0) {
+ pack->RowLength = *width;
+ }
+
/* left clipping */
if (*srcX < 0) {
- *skipPixels += (0 - *srcX);
+ pack->SkipPixels += (0 - *srcX);
*width -= (0 - *srcX);
*srcX = 0;
}
@@ -4170,7 +4250,7 @@ _mesa_clip_readpixels(const GLcontext *ctx,
/* bottom clipping */
if (*srcY < 0) {
- *skipRows += (0 - *srcY);
+ pack->SkipRows += (0 - *srcY);
*height -= (0 - *srcY);
*srcY = 0;
}
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index 6b76fd8af0..74be4aebaa 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -1,13 +1,8 @@
-/**
- * \file image.h
- * Image handling.
- */
-
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 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"),
@@ -183,7 +178,8 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
extern void
-_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
+_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, GLfloat depthScale,
GLenum srcType, const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking );
@@ -204,14 +200,14 @@ extern GLboolean
_mesa_clip_drawpixels(const GLcontext *ctx,
GLint *destX, GLint *destY,
GLsizei *width, GLsizei *height,
- GLint *skipPixels, GLint *skipRows);
+ struct gl_pixelstore_attrib *unpack);
extern GLboolean
_mesa_clip_readpixels(const GLcontext *ctx,
GLint *destX, GLint *destY,
GLsizei *width, GLsizei *height,
- GLint *skipPixels, GLint *skipRows);
+ struct gl_pixelstore_attrib *pack);
#endif
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index beb371fb01..164394522b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1178,6 +1178,7 @@ struct gl_texture_format
GLubyte IntensityBits;
GLubyte IndexBits;
GLubyte DepthBits;
+ GLubyte StencilBits; /**< GL_EXT_packed_depth_stencil */
GLuint TexelBytes; /**< Bytes per texel, 0 if compressed format */
@@ -2200,7 +2201,7 @@ struct gl_framebuffer
GLbitfield _ColorDrawBufferMask[MAX_DRAW_BUFFERS]; /* Mask of BUFFER_BIT_* flags */
GLint _ColorReadBufferIndex; /* -1 = None */
- /* These are computed from _Draw/ReadBufferMask, above. */
+ /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
GLuint _NumColorDrawBuffers[MAX_DRAW_BUFFERS];
struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS][4];
struct gl_renderbuffer *_ColorReadBuffer;
@@ -2334,6 +2335,7 @@ struct gl_extensions
GLboolean EXT_histogram;
GLboolean EXT_multi_draw_arrays;
GLboolean EXT_paletted_texture;
+ GLboolean EXT_packed_depth_stencil;
GLboolean EXT_packed_pixels;
GLboolean EXT_pixel_buffer_object;
GLboolean EXT_point_parameters;
diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c
index aa56d9c91a..58d4298dd6 100644
--- a/src/mesa/main/texcompress_fxt1.c
+++ b/src/mesa/main/texcompress_fxt1.c
@@ -234,6 +234,7 @@ const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
0, /* TexelBytes */
texstore_rgb_fxt1, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
@@ -256,6 +257,7 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
0, /* TexelBytes */
texstore_rgba_fxt1, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
index f4d77f373f..881da83b0f 100644
--- a/src/mesa/main/texcompress_s3tc.c
+++ b/src/mesa/main/texcompress_s3tc.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.5
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 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"),
@@ -482,6 +482,7 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
0, /* TexelBytes */
texstore_rgb_dxt1, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
@@ -504,6 +505,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
0, /* TexelBytes */
texstore_rgba_dxt1, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
@@ -526,6 +528,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
0, /* TexelBytes */
texstore_rgba_dxt3, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
@@ -548,6 +551,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
0, /* TexelBytes */
texstore_rgba_dxt5, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 794dea313a..2cea5151f9 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -113,6 +113,7 @@ const struct gl_texture_format _mesa_texformat_rgba = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
4 * sizeof(GLchan), /* TexelBytes */
_mesa_texstore_rgba, /* StoreTexImageFunc */
fetch_texel_1d_rgba, /* FetchTexel1D */
@@ -136,6 +137,7 @@ const struct gl_texture_format _mesa_texformat_rgb = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
3 * sizeof(GLchan), /* TexelBytes */
_mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_rgb, /* FetchTexel1D */
@@ -159,6 +161,7 @@ const struct gl_texture_format _mesa_texformat_alpha = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
sizeof(GLchan), /* TexelBytes */
_mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_alpha, /* FetchTexel1D */
@@ -182,6 +185,7 @@ const struct gl_texture_format _mesa_texformat_luminance = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
sizeof(GLchan), /* TexelBytes */
_mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_luminance, /* FetchTexel1D */
@@ -205,6 +209,7 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2 * sizeof(GLchan), /* TexelBytes */
_mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
@@ -228,6 +233,7 @@ const struct gl_texture_format _mesa_texformat_intensity = {
CHAN_BITS, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
sizeof(GLchan), /* TexelBytes */
_mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_intensity, /* FetchTexel1D */
@@ -251,6 +257,7 @@ const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
0, /* IntensityBits */
0, /* IndexBits */
sizeof(GLfloat) * 8, /* DepthBits */
+ sizeof(GLfloat) * 8, /* StencilBits */
sizeof(GLfloat), /* TexelBytes */
_mesa_texstore_depth_component_float32,/* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -274,6 +281,7 @@ const struct gl_texture_format _mesa_texformat_depth_component16 = {
0, /* IntensityBits */
0, /* IndexBits */
sizeof(GLushort) * 8, /* DepthBits */
+ sizeof(GLushort) * 8, /* StencilBits */
sizeof(GLushort), /* TexelBytes */
_mesa_texstore_depth_component16, /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -297,6 +305,7 @@ const struct gl_texture_format _mesa_texformat_rgba_float32 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
4 * sizeof(GLfloat), /* TexelBytes */
_mesa_texstore_rgba_float32, /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -320,6 +329,7 @@ const struct gl_texture_format _mesa_texformat_rgba_float16 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
4 * sizeof(GLhalfARB), /* TexelBytes */
_mesa_texstore_rgba_float16, /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -343,6 +353,7 @@ const struct gl_texture_format _mesa_texformat_rgb_float32 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
3 * sizeof(GLfloat), /* TexelBytes */
_mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -366,6 +377,7 @@ const struct gl_texture_format _mesa_texformat_rgb_float16 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
3 * sizeof(GLhalfARB), /* TexelBytes */
_mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -389,6 +401,7 @@ const struct gl_texture_format _mesa_texformat_alpha_float32 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1 * sizeof(GLfloat), /* TexelBytes */
_mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -412,6 +425,7 @@ const struct gl_texture_format _mesa_texformat_alpha_float16 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1 * sizeof(GLhalfARB), /* TexelBytes */
_mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -435,6 +449,7 @@ const struct gl_texture_format _mesa_texformat_luminance_float32 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1 * sizeof(GLfloat), /* TexelBytes */
_mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -458,6 +473,7 @@ const struct gl_texture_format _mesa_texformat_luminance_float16 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1 * sizeof(GLhalfARB), /* TexelBytes */
_mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -481,6 +497,7 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2 * sizeof(GLfloat), /* TexelBytes */
_mesa_texstore_rgba_float32, /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -504,6 +521,7 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2 * sizeof(GLhalfARB), /* TexelBytes */
_mesa_texstore_rgba_float16, /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -527,6 +545,7 @@ const struct gl_texture_format _mesa_texformat_intensity_float32 = {
8 * sizeof(GLfloat), /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1 * sizeof(GLfloat), /* TexelBytes */
_mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -550,6 +569,7 @@ const struct gl_texture_format _mesa_texformat_intensity_float16 = {
8 * sizeof(GLhalfARB), /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1 * sizeof(GLhalfARB), /* TexelBytes */
_mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
@@ -581,6 +601,7 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
4, /* TexelBytes */
_mesa_texstore_rgba8888, /* StoreTexImageFunc */
fetch_texel_1d_rgba8888, /* FetchTexel1D */
@@ -604,6 +625,7 @@ const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
4, /* TexelBytes */
_mesa_texstore_rgba8888, /* StoreTexImageFunc */
fetch_texel_1d_rgba8888_rev, /* FetchTexel1D */
@@ -627,6 +649,7 @@ const struct gl_texture_format _mesa_texformat_argb8888 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
4, /* TexelBytes */
_mesa_texstore_argb8888, /* StoreTexImageFunc */
fetch_texel_1d_argb8888, /* FetchTexel1D */
@@ -650,6 +673,7 @@ const struct gl_texture_format _mesa_texformat_argb8888_rev = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
4, /* TexelBytes */
_mesa_texstore_argb8888, /* StoreTexImageFunc */
fetch_texel_1d_argb8888_rev, /* FetchTexel1D */
@@ -673,6 +697,7 @@ const struct gl_texture_format _mesa_texformat_rgb888 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
3, /* TexelBytes */
_mesa_texstore_rgb888, /* StoreTexImageFunc */
fetch_texel_1d_rgb888, /* FetchTexel1D */
@@ -696,6 +721,7 @@ const struct gl_texture_format _mesa_texformat_bgr888 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
3, /* TexelBytes */
_mesa_texstore_bgr888, /* StoreTexImageFunc */
fetch_texel_1d_bgr888, /* FetchTexel1D */
@@ -719,6 +745,7 @@ const struct gl_texture_format _mesa_texformat_rgb565 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_rgb565, /* StoreTexImageFunc */
fetch_texel_1d_rgb565, /* FetchTexel1D */
@@ -742,6 +769,7 @@ const struct gl_texture_format _mesa_texformat_rgb565_rev = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_rgb565, /* StoreTexImageFunc */
fetch_texel_1d_rgb565_rev, /* FetchTexel1D */
@@ -765,6 +793,7 @@ const struct gl_texture_format _mesa_texformat_argb4444 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_argb4444, /* StoreTexImageFunc */
fetch_texel_1d_argb4444, /* FetchTexel1D */
@@ -788,6 +817,7 @@ const struct gl_texture_format _mesa_texformat_argb4444_rev = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_argb4444, /* StoreTexImageFunc */
fetch_texel_1d_argb4444_rev, /* FetchTexel1D */
@@ -811,6 +841,7 @@ const struct gl_texture_format _mesa_texformat_argb1555 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_argb1555, /* StoreTexImageFunc */
fetch_texel_1d_argb1555, /* FetchTexel1D */
@@ -834,6 +865,7 @@ const struct gl_texture_format _mesa_texformat_argb1555_rev = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_argb1555, /* StoreTexImageFunc */
fetch_texel_1d_argb1555_rev, /* FetchTexel1D */
@@ -857,6 +889,7 @@ const struct gl_texture_format _mesa_texformat_al88 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_al88, /* StoreTexImageFunc */
fetch_texel_1d_al88, /* FetchTexel1D */
@@ -880,6 +913,7 @@ const struct gl_texture_format _mesa_texformat_al88_rev = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_al88, /* StoreTexImageFunc */
fetch_texel_1d_al88_rev, /* FetchTexel1D */
@@ -903,6 +937,7 @@ const struct gl_texture_format _mesa_texformat_rgb332 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1, /* TexelBytes */
_mesa_texstore_rgb332, /* StoreTexImageFunc */
fetch_texel_1d_rgb332, /* FetchTexel1D */
@@ -926,6 +961,7 @@ const struct gl_texture_format _mesa_texformat_a8 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1, /* TexelBytes */
_mesa_texstore_a8, /* StoreTexImageFunc */
fetch_texel_1d_a8, /* FetchTexel1D */
@@ -949,6 +985,7 @@ const struct gl_texture_format _mesa_texformat_l8 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1, /* TexelBytes */
_mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_l8, /* FetchTexel1D */
@@ -972,6 +1009,7 @@ const struct gl_texture_format _mesa_texformat_i8 = {
8, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1, /* TexelBytes */
_mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_i8, /* FetchTexel1D */
@@ -995,6 +1033,7 @@ const struct gl_texture_format _mesa_texformat_ci8 = {
0, /* IntensityBits */
8, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
1, /* TexelBytes */
_mesa_texstore_ci8, /* StoreTexImageFunc */
fetch_texel_1d_ci8, /* FetchTexel1D */
@@ -1018,6 +1057,7 @@ const struct gl_texture_format _mesa_texformat_ycbcr = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_ycbcr, /* StoreTexImageFunc */
fetch_texel_1d_ycbcr, /* FetchTexel1D */
@@ -1041,6 +1081,7 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
2, /* TexelBytes */
_mesa_texstore_ycbcr, /* StoreTexImageFunc */
fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
@@ -1052,6 +1093,30 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
store_texel_ycbcr_rev /* StoreTexel */
};
+const struct gl_texture_format _mesa_texformat_z24_s8 = {
+ MESA_FORMAT_Z24_S8, /* MesaFormat */
+ GL_DEPTH_STENCIL_EXT, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 24, /* DepthBits */
+ 8, /* StencilBits */
+ 4, /* TexelBytes */
+ NULL/*_mesa_texstore_z24_s8*/, /* StoreTexImageFunc */
+ NULL, /* FetchTexel1D */
+ NULL, /* FetchTexel2D */
+ NULL, /* FetchTexel3D */
+ fetch_texel_1d_f_z24_s8, /* FetchTexel1Df */
+ fetch_texel_2d_f_z24_s8, /* FetchTexel2Df */
+ fetch_texel_3d_f_z24_s8, /* FetchTexel3Df */
+ store_texel_z24_s8 /* StoreTexel */
+};
+
/*@}*/
@@ -1071,6 +1136,7 @@ const struct gl_texture_format _mesa_null_texformat = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
+ 0, /* StencilBits */
0, /* TexelBytes */
NULL, /* StoreTexImageFunc */
fetch_null_texel, /* FetchTexel1D */
@@ -1316,6 +1382,16 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
}
}
+ if (ctx->Extensions.EXT_packed_depth_stencil) {
+ switch (internalFormat) {
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ return &_mesa_texformat_z24_s8;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
return NULL;
}
diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h
index 35522d6218..63f524bbe1 100644
--- a/src/mesa/main/texformat.h
+++ b/src/mesa/main/texformat.h
@@ -83,6 +83,7 @@ enum _format {
MESA_FORMAT_CI8, /* CCCC CCCC */
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 */
/*@}*/
/**
@@ -197,7 +198,7 @@ extern const struct gl_texture_format _mesa_texformat_a8;
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;
/*@}*/
/** \name YCbCr formats */
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index f060179eee..92df277564 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -1215,6 +1215,30 @@ static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
#endif
+/* MESA_TEXFORMAT_Z24_S8 ***************************************************/
+
+static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* only return Z, not stencil data */
+ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ const GLfloat scale = 0xffffff;
+ texel[0] = *src * scale;
+}
+
+#if DIM == 3
+static void store_texel_z24_s8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* only store Z, not stencil */
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ GLfloat z = *((GLfloat *) texel);
+ GLuint zi = ((GLuint) (z * 0xffffff)) << 8;
+ *dst = zi | (*dst & 0xff);
+}
+#endif
+
+
#undef TEXEL_ADDR
#undef DIM
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index c19e5b0a5a..db78a6d24e 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -341,6 +341,16 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
}
}
+ if (ctx->Extensions.EXT_packed_depth_stencil) {
+ switch (internalFormat) {
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ return GL_DEPTH_STENCIL_EXT;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
return -1; /* error */
}
@@ -496,6 +506,23 @@ is_ycbcr_format(GLenum format)
/**
+ * Test if the given image format is a Depth/Stencil format.
+ */
+static GLboolean
+is_depthstencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH24_STENCIL8_EXT:
+ case GL_DEPTH_STENCIL_EXT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+
+/**
* Test if it is a supported compressed format.
*
* \param internalFormat the internal format token provided by the user.
@@ -1369,7 +1396,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
if ((is_color_format(internalFormat) && !colorFormat && !indexFormat) ||
(is_index_format(internalFormat) && !indexFormat) ||
(is_depth_format(internalFormat) != is_depth_format(format)) ||
- (is_ycbcr_format(internalFormat) != is_ycbcr_format(format))) {
+ (is_ycbcr_format(internalFormat) != is_ycbcr_format(format)) ||
+ (is_depthstencil_format(internalFormat) != is_depthstencil_format(format))) {
if (!isProxy)
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage(internalFormat/format)");
@@ -1992,6 +2020,11 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
}
+ if (!ctx->Extensions.EXT_packed_depth_stencil
+ && is_depthstencil_format(format)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
+ }
+
if (!pixels)
return;
@@ -2026,6 +2059,11 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
return;
}
+ else if (is_depthstencil_format(format)
+ && !is_depthstencil_format(texImage->TexFormat->BaseFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
+ return;
+ }
/* typically, this will call _mesa_get_teximage() */
ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels,
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index d427a5e1dd..2cc7eb5211 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1778,6 +1778,15 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetTexLevelParameter[if]v(pname)");
return;
+ case GL_TEXTURE_STENCIL_SIZE_EXT:
+ if (ctx->Extensions.EXT_packed_depth_stencil) {
+ *params = img->TexFormat->StencilBits;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
/* GL_ARB_texture_compression */
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
@@ -1867,6 +1876,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
"glGetTexLevelParameter[if]v(pname)");
}
return;
+
default:
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetTexLevelParameter[if]v(pname)");
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 53be319ad7..ccdb81c615 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -881,7 +881,8 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS)
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
+ _mesa_unpack_depth_span(ctx, srcWidth,
+ GL_FLOAT, (GLfloat *) dstRow, 1.0F,
srcType, src, srcPacking);
dstRow += dstRowStride;
}
@@ -920,19 +921,16 @@ _mesa_texstore_depth_component16(STORE_PARAMS)
+ dstZoffset * dstImageStride
+ dstYoffset * dstRowStride
+ dstXoffset * dstFormat->TexelBytes;
- GLint img, row, col;
+ GLint img, row;
for (img = 0; img < srcDepth; img++) {
GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
- GLfloat depthTemp[MAX_WIDTH];
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
GLushort *dst16 = (GLushort *) dstRow;
- _mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
+ _mesa_unpack_depth_span(ctx, srcWidth,
+ GL_UNSIGNED_SHORT, dst16, 65535.0F,
srcType, src, srcPacking);
- for (col = 0; col < srcWidth; col++) {
- dst16[col] = (GLushort) (depthTemp[col] * 65535.0F);
- }
dstRow += dstRowStride;
}
dstImage += dstImageStride;
@@ -4071,6 +4069,10 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
_mesa_swap2((GLushort *) dest, width);
}
}
+ else if (format == GL_DEPTH_STENCIL_EXT) {
+ /* XXX special case */
+
+ }
else {
/* general case: convert row to RGBA format */
GLfloat rgba[MAX_WIDTH][4];
diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h
index 0b91f20e3a..381f610b5e 100644
--- a/src/mesa/main/texstore.h
+++ b/src/mesa/main/texstore.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
@@ -71,6 +71,7 @@ extern GLboolean _mesa_texstore_rgb332(STORE_PARAMS);
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_rgba_float32(STORE_PARAMS);
extern GLboolean _mesa_texstore_rgba_float16(STORE_PARAMS);
extern GLboolean _mesa_texstore_rgb_fxt1(STORE_PARAMS);