From b9c84e8e3433d8804b99ec82065ec1e920469d87 Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 13 Dec 2011 15:54:46 +0100 Subject: git update pixman mesa 13 dec 2011 --- mesalib/src/mesa/SConscript | 2 +- mesalib/src/mesa/main/depthstencil.c | 959 ------------------- mesalib/src/mesa/main/depthstencil.h | 46 - mesalib/src/mesa/main/fbobject.c | 14 +- mesalib/src/mesa/main/framebuffer.c | 95 -- mesalib/src/mesa/main/mtypes.h | 5 +- mesalib/src/mesa/sources.mak | 2 +- mesalib/src/mesa/state_tracker/st_cb_drawpixels.c | 16 +- mesalib/src/mesa/state_tracker/st_cb_texture.c | 5 +- mesalib/src/mesa/swrast/s_blit.c | 3 + mesalib/src/mesa/swrast/s_clear.c | 3 + mesalib/src/mesa/swrast/s_context.c | 23 + mesalib/src/mesa/swrast/s_depthstencil.c | 1037 +++++++++++++++++++++ mesalib/src/mesa/swrast/s_depthstencil.h | 39 + mesalib/src/mesa/swrast/s_renderbuffer.c | 54 +- 15 files changed, 1171 insertions(+), 1132 deletions(-) delete mode 100644 mesalib/src/mesa/main/depthstencil.c delete mode 100644 mesalib/src/mesa/main/depthstencil.h create mode 100644 mesalib/src/mesa/swrast/s_depthstencil.c create mode 100644 mesalib/src/mesa/swrast/s_depthstencil.h (limited to 'mesalib/src/mesa') diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index da4d9b185..bd9e94b82 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -58,7 +58,6 @@ main_sources = [ 'main/cpuinfo.c', 'main/debug.c', 'main/depth.c', - 'main/depthstencil.c', 'main/dlist.c', 'main/dlopen.c', 'main/drawpix.c', @@ -162,6 +161,7 @@ swrast_sources = [ 'swrast/s_copypix.c', 'swrast/s_context.c', 'swrast/s_depth.c', + 'swrast/s_depthstencil.c', 'swrast/s_drawpix.c', 'swrast/s_feedback.c', 'swrast/s_fog.c', diff --git a/mesalib/src/mesa/main/depthstencil.c b/mesalib/src/mesa/main/depthstencil.c deleted file mode 100644 index af5c12f67..000000000 --- a/mesalib/src/mesa/main/depthstencil.c +++ /dev/null @@ -1,959 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "formats.h" -#include "mtypes.h" -#include "depthstencil.h" -#include "renderbuffer.h" - - -/** - * Adaptor/wrappers for GL_DEPTH_STENCIL renderbuffers. - * - * The problem with a GL_DEPTH_STENCIL renderbuffer is that sometimes we - * want to treat it as a stencil buffer, other times we want to treat it - * as a depth/z buffer and still other times when we want to treat it as - * a combined Z+stencil buffer! That implies we need three different sets - * of Get/Put functions. - * - * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and - * stencil adaptors, each with the right kind of depth/stencil Get/Put functions. - */ - - -static void * -nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) -{ - (void) ctx; - (void) rb; - (void) x; - (void) y; - return NULL; -} - - -/** - * Delete a depth or stencil wrapper renderbuffer. - */ -static void -delete_wrapper(struct gl_renderbuffer *rb) -{ - ASSERT(rb->Format == MESA_FORMAT_S8 || - rb->Format == MESA_FORMAT_X8_Z24 || - rb->Format == MESA_FORMAT_Z32_FLOAT); - _mesa_reference_renderbuffer(&rb->Wrapped, NULL); - free(rb); -} - - -/** - * Realloc storage for wrapper. - */ -static GLboolean -alloc_wrapper_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, GLuint width, GLuint height) -{ - /* just pass this on to the wrapped renderbuffer */ - struct gl_renderbuffer *dsrb = rb->Wrapped; - GLboolean retVal; - - (void) internalFormat; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_Z24_X8 || - dsrb->Format == MESA_FORMAT_S8_Z24 || - dsrb->Format == MESA_FORMAT_X8_Z24); - - retVal = dsrb->AllocStorage(ctx, dsrb, dsrb->InternalFormat, width, height); - if (retVal) { - rb->Width = width; - rb->Height = height; - rb->RowStride = dsrb->RowStride; - } - return retVal; -} - - - - -/*====================================================================== - * Depth wrapper around depth/stencil renderbuffer - */ - -static void -get_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, void *values) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - GLuint *dst = (GLuint *) values; - const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (!src) { - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - src = temp; - } - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = src[i] >> 8; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = src[i] & 0xffffff; - } - } -} - -static void -get_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - GLuint *dst = (GLuint *) values; - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - ASSERT(count <= MAX_WIDTH); - /* don't bother trying direct access */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = temp[i] >> 8; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = temp[i] & 0xffffff; - } - } -} - -static void -put_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (src[i] << 8) | (dst[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (src[i] & 0xffffff) | (dst[i] & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] << 8) | (temp[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = shiftedVal | (dst[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = shiftedVal | (dst[i] & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff000000); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - const GLuint *src = (const GLuint *) values; - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (src[i] << 8) | (*dst & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (src[i] & 0xffffff) | (*dst & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] << 8) | (temp[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - /* get, modify, put */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff000000); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); -} - - -/** - * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like - * a depth renderbuffer. - * \return new depth renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx, - struct gl_renderbuffer *dsrb) -{ - struct gl_renderbuffer *z24rb; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_Z24_X8 || - dsrb->Format == MESA_FORMAT_S8_Z24 || - dsrb->Format == MESA_FORMAT_X8_Z24); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - - z24rb = ctx->Driver.NewRenderbuffer(ctx, 0); - if (!z24rb) - return NULL; - - /* NOTE: need to do manual refcounting here */ - z24rb->Wrapped = dsrb; - dsrb->RefCount++; - - z24rb->Name = dsrb->Name; - z24rb->RefCount = 0; - z24rb->Width = dsrb->Width; - z24rb->Height = dsrb->Height; - z24rb->RowStride = dsrb->RowStride; - z24rb->InternalFormat = GL_DEPTH_COMPONENT24; - z24rb->Format = MESA_FORMAT_X8_Z24; - z24rb->_BaseFormat = GL_DEPTH_COMPONENT; - z24rb->DataType = GL_UNSIGNED_INT; - z24rb->Data = NULL; - z24rb->Delete = delete_wrapper; - z24rb->AllocStorage = alloc_wrapper_storage; - z24rb->GetPointer = nop_get_pointer; - z24rb->GetRow = get_row_z24; - z24rb->GetValues = get_values_z24; - z24rb->PutRow = put_row_z24; - z24rb->PutRowRGB = NULL; - z24rb->PutMonoRow = put_mono_row_z24; - z24rb->PutValues = put_values_z24; - z24rb->PutMonoValues = put_mono_values_z24; - - return z24rb; -} - - -static void -get_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - GLint x, GLint y, void *values) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - GLfloat temp[MAX_WIDTH*2]; - GLfloat *dst = (GLfloat *) values; - const GLfloat *src = (const GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); - GLuint i; - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - if (!src) { - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - src = temp; - } - for (i = 0; i < count; i++) { - dst[i] = src[i*2]; - } -} - -static void -get_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - GLfloat temp[MAX_WIDTH*2]; - GLfloat *dst = (GLfloat *) values; - GLuint i; - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - ASSERT(count <= MAX_WIDTH); - /* don't bother trying direct access */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - dst[i] = temp[i*2]; - } -} - -static void -put_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - const GLfloat *src = (const GLfloat *) values; - GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - if (dst) { - /* direct access */ - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i*2] = src[i]; - } - } - } - else { - /* get, modify, put */ - GLfloat temp[MAX_WIDTH*2]; - GLuint i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2] = src[i]; - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - if (dst) { - /* direct access */ - GLuint i; - const GLfloat val = *(GLfloat*)value; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i*2] = val; - } - } - } - else { - /* get, modify, put */ - GLfloat temp[MAX_WIDTH*2]; - GLuint i; - const GLfloat val = *(GLfloat *)value; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2] = val; - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - const GLfloat *src = (const GLfloat *) values; - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { - /* direct access */ - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = src[i]; - } - } - } - else { - /* get, modify, put */ - GLfloat temp[MAX_WIDTH*2]; - GLuint i; - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2] = src[i]; - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - GLfloat temp[MAX_WIDTH*2]; - GLuint i; - const GLfloat val = *(GLfloat *)value; - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - /* get, modify, put */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2] = val; - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); -} - - -/** - * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like - * a depth renderbuffer. - * \return new depth renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx, - struct gl_renderbuffer *dsrb) -{ - struct gl_renderbuffer *z32frb; - - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - - z32frb = ctx->Driver.NewRenderbuffer(ctx, 0); - if (!z32frb) - return NULL; - - /* NOTE: need to do manual refcounting here */ - z32frb->Wrapped = dsrb; - dsrb->RefCount++; - - z32frb->Name = dsrb->Name; - z32frb->RefCount = 0; - z32frb->Width = dsrb->Width; - z32frb->Height = dsrb->Height; - z32frb->RowStride = dsrb->RowStride; - z32frb->InternalFormat = GL_DEPTH_COMPONENT32F; - z32frb->Format = MESA_FORMAT_Z32_FLOAT; - z32frb->_BaseFormat = GL_DEPTH_COMPONENT; - z32frb->DataType = GL_FLOAT; - z32frb->Data = NULL; - z32frb->Delete = delete_wrapper; - z32frb->AllocStorage = alloc_wrapper_storage; - z32frb->GetPointer = nop_get_pointer; - z32frb->GetRow = get_row_z32f; - z32frb->GetValues = get_values_z32f; - z32frb->PutRow = put_row_z32f; - z32frb->PutRowRGB = NULL; - z32frb->PutMonoRow = put_mono_row_z32f; - z32frb->PutValues = put_values_z32f; - z32frb->PutMonoValues = put_mono_values_z32f; - - return z32frb; -} - - -/*====================================================================== - * Stencil wrapper around depth/stencil renderbuffer - */ - -static void -get_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, void *values) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH*2], i; - GLubyte *dst = (GLubyte *) values; - const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - if (!src) { - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - src = temp; - } - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - dst[i] = src[i*2+1] & 0xff; - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = src[i] & 0xff; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = src[i] >> 24; - } - } -} - -static void -get_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH*2], i; - GLubyte *dst = (GLubyte *) values; - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(count <= MAX_WIDTH); - /* don't bother trying direct access */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - dst[i] = temp[i*2+1] & 0xff; - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = temp[i] & 0xff; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = temp[i] >> 24; - } - } -} - -static void -put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte *src = (const GLubyte *) values; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i*2+1] = src[i]; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff) | (src[i] << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH*2], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2+1] = src[i]; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte val = *((GLubyte *) value); - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i*2+1] = val; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff) | (val << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH*2], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2+1] = val; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (val << 24); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte *src = (const GLubyte *) values; - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - dst[1] = src[i]; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (*dst & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (*dst & 0xffffff) | (src[i] << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH*2], i; - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2+1] = src[i]; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH*2], i; - const GLubyte val = *((GLubyte *) value); - /* get, modify, put */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2+1] = val; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (val << 24); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); -} - - -/** - * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like - * a stencil renderbuffer. - * \return new stencil renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer *dsrb) -{ - struct gl_renderbuffer *s8rb; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_S8_Z24 || - dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - - s8rb = ctx->Driver.NewRenderbuffer(ctx, 0); - if (!s8rb) - return NULL; - - /* NOTE: need to do manual refcounting here */ - s8rb->Wrapped = dsrb; - dsrb->RefCount++; - - s8rb->Name = dsrb->Name; - s8rb->RefCount = 0; - s8rb->Width = dsrb->Width; - s8rb->Height = dsrb->Height; - s8rb->RowStride = dsrb->RowStride; - s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT; - s8rb->Format = MESA_FORMAT_S8; - s8rb->_BaseFormat = GL_STENCIL_INDEX; - s8rb->DataType = GL_UNSIGNED_BYTE; - s8rb->Data = NULL; - s8rb->Delete = delete_wrapper; - s8rb->AllocStorage = alloc_wrapper_storage; - s8rb->GetPointer = nop_get_pointer; - s8rb->GetRow = get_row_s8; - s8rb->GetValues = get_values_s8; - s8rb->PutRow = put_row_s8; - s8rb->PutRowRGB = NULL; - s8rb->PutMonoRow = put_mono_row_s8; - s8rb->PutValues = put_values_s8; - s8rb->PutMonoValues = put_mono_values_s8; - - return s8rb; -} diff --git a/mesalib/src/mesa/main/depthstencil.h b/mesalib/src/mesa/main/depthstencil.h deleted file mode 100644 index c3871d805..000000000 --- a/mesalib/src/mesa/main/depthstencil.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef DEPTHSTENCIL_H -#define DEPTHSTENCIL_H - -struct gl_context; - -extern struct gl_renderbuffer * -_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx, - struct gl_renderbuffer *dsrb); - - -extern struct gl_renderbuffer * -_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx, - struct gl_renderbuffer *dsrb); - - -extern struct gl_renderbuffer * -_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, - struct gl_renderbuffer *dsrb); - - -#endif /* DEPTHSTENCIL_H */ diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index 9111caa1b..611a6d0b0 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -2669,8 +2669,10 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, } if (mask & GL_STENCIL_BUFFER_BIT) { - struct gl_renderbuffer *readRb = readFb->_StencilBuffer; - struct gl_renderbuffer *drawRb = drawFb->_StencilBuffer; + struct gl_renderbuffer *readRb = + readFb->Attachment[BUFFER_STENCIL].Renderbuffer; + struct gl_renderbuffer *drawRb = + drawFb->Attachment[BUFFER_STENCIL].Renderbuffer; /* From the EXT_framebuffer_object spec: * @@ -2679,7 +2681,6 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, * ignored." */ if ((readRb == NULL) || (drawRb == NULL)) { - readRb = drawRb = NULL; mask &= ~GL_STENCIL_BUFFER_BIT; } else if (_mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != @@ -2691,8 +2692,10 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, } if (mask & GL_DEPTH_BUFFER_BIT) { - struct gl_renderbuffer *readRb = readFb->_DepthBuffer; - struct gl_renderbuffer *drawRb = drawFb->_DepthBuffer; + struct gl_renderbuffer *readRb = + readFb->Attachment[BUFFER_DEPTH].Renderbuffer; + struct gl_renderbuffer *drawRb = + drawFb->Attachment[BUFFER_DEPTH].Renderbuffer; /* From the EXT_framebuffer_object spec: * @@ -2701,7 +2704,6 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, * ignored." */ if ((readRb == NULL) || (drawRb == NULL)) { - readRb = drawRb = NULL; mask &= ~GL_DEPTH_BUFFER_BIT; } else if (_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c index e30f31a39..6d5e4524a 100644 --- a/mesalib/src/mesa/main/framebuffer.c +++ b/mesalib/src/mesa/main/framebuffer.c @@ -34,7 +34,6 @@ #include "imports.h" #include "buffers.h" #include "context.h" -#include "depthstencil.h" #include "enums.h" #include "formats.h" #include "macros.h" @@ -307,24 +306,6 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, } } - if (fb->_DepthBuffer) { - struct gl_renderbuffer *rb = fb->_DepthBuffer; - if (rb->Width != width || rb->Height != height) { - if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - } - } - } - - if (fb->_StencilBuffer) { - struct gl_renderbuffer *rb = fb->_StencilBuffer; - if (rb->Width != width || rb->Height != height) { - if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - } - } - } - fb->Width = width; fb->Height = height; @@ -600,80 +581,6 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx, } -/** - * Update the framebuffer's _DepthBuffer field using the renderbuffer - * found at the given attachment index. - * - * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, - * create and install a depth wrapper/adaptor. - * - * \param fb the framebuffer whose _DepthBuffer field to update - */ -static void -update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - struct gl_renderbuffer *depthRb = - fb->Attachment[BUFFER_DEPTH].Renderbuffer; - - if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) { - /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */ - if (!fb->_DepthBuffer - || fb->_DepthBuffer->Wrapped != depthRb - || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) { - /* need to update wrapper */ - struct gl_renderbuffer *wrapper; - - if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - wrapper = _mesa_new_z32f_renderbuffer_wrapper(ctx, depthRb); - } - else { - wrapper = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb); - } - _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper); - ASSERT(fb->_DepthBuffer->Wrapped == depthRb); - } - } - else { - /* depthRb may be null */ - _mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb); - } -} - - -/** - * Update the framebuffer's _StencilBuffer field using the renderbuffer - * found at the given attachment index. - * - * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, - * create and install a stencil wrapper/adaptor. - * - * \param fb the framebuffer whose _StencilBuffer field to update - */ -static void -update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - struct gl_renderbuffer *stencilRb = - fb->Attachment[BUFFER_STENCIL].Renderbuffer; - - if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) { - /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */ - if (!fb->_StencilBuffer - || fb->_StencilBuffer->Wrapped != stencilRb - || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) { - /* need to update wrapper */ - struct gl_renderbuffer *wrapper - = _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb); - _mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper); - ASSERT(fb->_StencilBuffer->Wrapped == stencilRb); - } - } - else { - /* stencilRb may be null */ - _mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb); - } -} - - /* * Example DrawBuffers scenarios: * @@ -812,8 +719,6 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) */ update_color_draw_buffers(ctx, fb); update_color_read_buffer(ctx, fb); - update_depth_buffer(ctx, fb); - update_stencil_buffer(ctx, fb); compute_depth_max(fb); } diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index fc494f748..1e06cd55c 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2650,8 +2650,9 @@ struct gl_framebuffer struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; struct gl_renderbuffer *_ColorReadBuffer; - /** The Actual depth/stencil buffers to use. May be wrappers around the - * depth/stencil buffers attached above. */ + /** Wrappers to make combined depth/stencil buffers look like separate + * buffers. Only used by swrast. Will be removed in the future. + */ struct gl_renderbuffer *_DepthBuffer; struct gl_renderbuffer *_StencilBuffer; diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak index a3ce85535..09cdd261b 100644 --- a/mesalib/src/mesa/sources.mak +++ b/mesalib/src/mesa/sources.mak @@ -27,7 +27,6 @@ MAIN_SOURCES = \ main/cpuinfo.c \ main/debug.c \ main/depth.c \ - main/depthstencil.c \ main/dlist.c \ main/dlopen.c \ main/drawpix.c \ @@ -134,6 +133,7 @@ SWRAST_SOURCES = \ swrast/s_copypix.c \ swrast/s_context.c \ swrast/s_depth.c \ + swrast/s_depthstencil.c \ swrast/s_drawpix.c \ swrast/s_feedback.c \ swrast/s_fog.c \ diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 912241b35..65b444552 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1182,12 +1182,9 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, return; } - /* Get the dest renderbuffer. If there's a wrapper, use the - * underlying renderbuffer. - */ - rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer); - if (rbDraw->Base.Wrapped) - rbDraw = st_renderbuffer(rbDraw->Base.Wrapped); + /* Get the dest renderbuffer */ + rbDraw = st_renderbuffer(ctx->DrawBuffer-> + Attachment[BUFFER_STENCIL].Renderbuffer); /* this will do stencil pixel transfer ops */ _mesa_readpixels(ctx, srcx, srcy, width, height, @@ -1484,7 +1481,8 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, } else { assert(type == GL_DEPTH); - rbRead = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer); + rbRead = st_renderbuffer(ctx->ReadBuffer-> + Attachment[BUFFER_DEPTH].Renderbuffer); color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; fpv = get_depth_stencil_fp_variant(st, GL_TRUE, GL_FALSE); @@ -1496,10 +1494,6 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, /* update fragment program constants */ st_upload_constants(st, fpv->parameters, PIPE_SHADER_FRAGMENT); - - if (rbRead->Base.Wrapped) - rbRead = st_renderbuffer(rbRead->Base.Wrapped); - sample_count = rbRead->texture->nr_samples; /* I believe this would be legal, presumably would need to do a resolve for color, and for depth/stencil spec says to just use one of the diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 52f654d7d..289ad5114 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -1385,10 +1385,7 @@ st_copy_texsubimage(struct gl_context *ctx, /* determine if copying depth or color data */ if (texBaseFormat == GL_DEPTH_COMPONENT || texBaseFormat == GL_DEPTH_STENCIL) { - strb = st_renderbuffer(fb->_DepthBuffer); - if (strb->Base.Wrapped) { - strb = st_renderbuffer(strb->Base.Wrapped); - } + strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer); } else { /* texBaseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */ diff --git a/mesalib/src/mesa/swrast/s_blit.c b/mesalib/src/mesa/swrast/s_blit.c index f094be898..2817ec12f 100644 --- a/mesalib/src/mesa/swrast/s_blit.c +++ b/mesalib/src/mesa/swrast/s_blit.c @@ -573,6 +573,9 @@ _swrast_BlitFramebuffer(struct gl_context *ctx, return; } + if (SWRAST_CONTEXT(ctx)->NewState) + _swrast_validate_derived(ctx); + swrast_render_start(ctx); if (srcX1 - srcX0 == dstX1 - dstX0 && diff --git a/mesalib/src/mesa/swrast/s_clear.c b/mesalib/src/mesa/swrast/s_clear.c index 615747d69..851f6d165 100644 --- a/mesalib/src/mesa/swrast/s_clear.c +++ b/mesalib/src/mesa/swrast/s_clear.c @@ -213,6 +213,9 @@ _swrast_Clear(struct gl_context *ctx, GLbitfield buffers) if (!_mesa_check_conditional_render(ctx)) return; /* don't clear */ + if (SWRAST_CONTEXT(ctx)->NewState) + _swrast_validate_derived(ctx); + swrast_render_start(ctx); /* do software clearing here */ diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c index 924612578..6850a09f3 100644 --- a/mesalib/src/mesa/swrast/s_context.c +++ b/mesalib/src/mesa/swrast/s_context.c @@ -36,6 +36,7 @@ #include "swrast.h" #include "s_blend.h" #include "s_context.h" +#include "s_depthstencil.h" #include "s_lines.h" #include "s_points.h" #include "s_span.h" @@ -545,6 +546,25 @@ _swrast_update_active_attribs(struct gl_context *ctx) } +/** + * Update the depth/stencil renderbuffers, if needed. + */ +static void +_swrast_update_depth_stencil(struct gl_context *ctx) +{ + struct gl_framebuffer *drawFb = ctx->DrawBuffer; + struct gl_framebuffer *readFb = ctx->ReadBuffer; + + _swrast_update_depth_buffer(ctx, drawFb); + _swrast_update_stencil_buffer(ctx, drawFb); + + if (readFb != drawFb) { + _swrast_update_depth_buffer(ctx, readFb); + _swrast_update_stencil_buffer(ctx, readFb); + } +} + + void _swrast_validate_derived( struct gl_context *ctx ) { @@ -589,6 +609,9 @@ _swrast_validate_derived( struct gl_context *ctx ) _NEW_TEXTURE)) _swrast_update_specular_vertex_add(ctx); + if (swrast->NewState & _NEW_BUFFERS) + _swrast_update_depth_stencil(ctx); + swrast->NewState = 0; swrast->StateChanges = 0; swrast->InvalidateState = _swrast_invalidate_state; diff --git a/mesalib/src/mesa/swrast/s_depthstencil.c b/mesalib/src/mesa/swrast/s_depthstencil.c new file mode 100644 index 000000000..dc768e216 --- /dev/null +++ b/mesalib/src/mesa/swrast/s_depthstencil.c @@ -0,0 +1,1037 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "main/glheader.h" +#include "main/imports.h" +#include "main/context.h" +#include "main/formats.h" +#include "main/mtypes.h" +#include "main/renderbuffer.h" +#include "swrast/s_depthstencil.h" + + +/** + * Adaptor/wrappers for GL_DEPTH_STENCIL renderbuffers. + * + * The problem with a GL_DEPTH_STENCIL renderbuffer is that sometimes we + * want to treat it as a stencil buffer, other times we want to treat it + * as a depth/z buffer and still other times when we want to treat it as + * a combined Z+stencil buffer! That implies we need three different sets + * of Get/Put functions. + * + * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and + * stencil adaptors, each with the right kind of depth/stencil Get/Put functions. + */ + + +static void * +nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) +{ + (void) ctx; + (void) rb; + (void) x; + (void) y; + return NULL; +} + + +/** + * Delete a depth or stencil wrapper renderbuffer. + */ +static void +delete_wrapper(struct gl_renderbuffer *rb) +{ + ASSERT(rb->Format == MESA_FORMAT_S8 || + rb->Format == MESA_FORMAT_X8_Z24 || + rb->Format == MESA_FORMAT_Z32_FLOAT); + _mesa_reference_renderbuffer(&rb->Wrapped, NULL); + free(rb); +} + + +/** + * Realloc storage for wrapper. + */ +static GLboolean +alloc_wrapper_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, GLuint width, GLuint height) +{ + /* just pass this on to the wrapped renderbuffer */ + struct gl_renderbuffer *dsrb = rb->Wrapped; + GLboolean retVal; + + (void) internalFormat; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_Z24_X8 || + dsrb->Format == MESA_FORMAT_S8_Z24 || + dsrb->Format == MESA_FORMAT_X8_Z24); + + retVal = dsrb->AllocStorage(ctx, dsrb, dsrb->InternalFormat, width, height); + if (retVal) { + rb->Width = width; + rb->Height = height; + rb->RowStride = dsrb->RowStride; + } + return retVal; +} + + + + +/*====================================================================== + * Depth wrapper around depth/stencil renderbuffer + */ + +static void +get_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, void *values) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + GLuint *dst = (GLuint *) values; + const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (!src) { + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + src = temp; + } + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = src[i] >> 8; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = src[i] & 0xffffff; + } + } +} + +static void +get_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + GLuint *dst = (GLuint *) values; + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(count <= MAX_WIDTH); + /* don't bother trying direct access */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = temp[i] >> 8; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = temp[i] & 0xffffff; + } + } +} + +static void +put_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (src[i] << 8) | (dst[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (src[i] & 0xffffff) | (dst[i] & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] << 8) | (temp[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = shiftedVal | (dst[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = shiftedVal | (dst[i] & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff000000); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + const GLuint *src = (const GLuint *) values; + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (src[i] << 8) | (*dst & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (src[i] & 0xffffff) | (*dst & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] << 8) | (temp[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + /* get, modify, put */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff000000); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); +} + + +/** + * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like + * a depth renderbuffer. + * \return new depth renderbuffer + */ +static struct gl_renderbuffer * +new_z24_renderbuffer_wrapper(struct gl_context *ctx, + struct gl_renderbuffer *dsrb) +{ + struct gl_renderbuffer *z24rb; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_Z24_X8 || + dsrb->Format == MESA_FORMAT_S8_Z24 || + dsrb->Format == MESA_FORMAT_X8_Z24); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + + z24rb = ctx->Driver.NewRenderbuffer(ctx, 0); + if (!z24rb) + return NULL; + + /* NOTE: need to do manual refcounting here */ + z24rb->Wrapped = dsrb; + dsrb->RefCount++; + + z24rb->Name = dsrb->Name; + z24rb->RefCount = 0; + z24rb->Width = dsrb->Width; + z24rb->Height = dsrb->Height; + z24rb->RowStride = dsrb->RowStride; + z24rb->InternalFormat = GL_DEPTH_COMPONENT24; + z24rb->Format = MESA_FORMAT_X8_Z24; + z24rb->_BaseFormat = GL_DEPTH_COMPONENT; + z24rb->DataType = GL_UNSIGNED_INT; + z24rb->Data = NULL; + z24rb->Delete = delete_wrapper; + z24rb->AllocStorage = alloc_wrapper_storage; + z24rb->GetPointer = nop_get_pointer; + z24rb->GetRow = get_row_z24; + z24rb->GetValues = get_values_z24; + z24rb->PutRow = put_row_z24; + z24rb->PutRowRGB = NULL; + z24rb->PutMonoRow = put_mono_row_z24; + z24rb->PutValues = put_values_z24; + z24rb->PutMonoValues = put_mono_values_z24; + + return z24rb; +} + + +static void +get_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + GLint x, GLint y, void *values) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + GLfloat temp[MAX_WIDTH*2]; + GLfloat *dst = (GLfloat *) values; + const GLfloat *src = (const GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); + GLuint i; + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + if (!src) { + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + src = temp; + } + for (i = 0; i < count; i++) { + dst[i] = src[i*2]; + } +} + +static void +get_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + GLfloat temp[MAX_WIDTH*2]; + GLfloat *dst = (GLfloat *) values; + GLuint i; + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + ASSERT(count <= MAX_WIDTH); + /* don't bother trying direct access */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + dst[i] = temp[i*2]; + } +} + +static void +put_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + const GLfloat *src = (const GLfloat *) values; + GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + if (dst) { + /* direct access */ + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i*2] = src[i]; + } + } + } + else { + /* get, modify, put */ + GLfloat temp[MAX_WIDTH*2]; + GLuint i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2] = src[i]; + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + if (dst) { + /* direct access */ + GLuint i; + const GLfloat val = *(GLfloat*)value; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i*2] = val; + } + } + } + else { + /* get, modify, put */ + GLfloat temp[MAX_WIDTH*2]; + GLuint i; + const GLfloat val = *(GLfloat *)value; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2] = val; + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + const GLfloat *src = (const GLfloat *) values; + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { + /* direct access */ + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = src[i]; + } + } + } + else { + /* get, modify, put */ + GLfloat temp[MAX_WIDTH*2]; + GLuint i; + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2] = src[i]; + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + GLfloat temp[MAX_WIDTH*2]; + GLuint i; + const GLfloat val = *(GLfloat *)value; + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + /* get, modify, put */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2] = val; + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); +} + + +/** + * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like + * a depth renderbuffer. + * \return new depth renderbuffer + */ +static struct gl_renderbuffer * +new_z32f_renderbuffer_wrapper(struct gl_context *ctx, + struct gl_renderbuffer *dsrb) +{ + struct gl_renderbuffer *z32frb; + + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + + z32frb = ctx->Driver.NewRenderbuffer(ctx, 0); + if (!z32frb) + return NULL; + + /* NOTE: need to do manual refcounting here */ + z32frb->Wrapped = dsrb; + dsrb->RefCount++; + + z32frb->Name = dsrb->Name; + z32frb->RefCount = 0; + z32frb->Width = dsrb->Width; + z32frb->Height = dsrb->Height; + z32frb->RowStride = dsrb->RowStride; + z32frb->InternalFormat = GL_DEPTH_COMPONENT32F; + z32frb->Format = MESA_FORMAT_Z32_FLOAT; + z32frb->_BaseFormat = GL_DEPTH_COMPONENT; + z32frb->DataType = GL_FLOAT; + z32frb->Data = NULL; + z32frb->Delete = delete_wrapper; + z32frb->AllocStorage = alloc_wrapper_storage; + z32frb->GetPointer = nop_get_pointer; + z32frb->GetRow = get_row_z32f; + z32frb->GetValues = get_values_z32f; + z32frb->PutRow = put_row_z32f; + z32frb->PutRowRGB = NULL; + z32frb->PutMonoRow = put_mono_row_z32f; + z32frb->PutValues = put_values_z32f; + z32frb->PutMonoValues = put_mono_values_z32f; + + return z32frb; +} + + +/*====================================================================== + * Stencil wrapper around depth/stencil renderbuffer + */ + +static void +get_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, void *values) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH*2], i; + GLubyte *dst = (GLubyte *) values; + const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (!src) { + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + src = temp; + } + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + dst[i] = src[i*2+1] & 0xff; + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = src[i] & 0xff; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = src[i] >> 24; + } + } +} + +static void +get_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH*2], i; + GLubyte *dst = (GLubyte *) values; + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(count <= MAX_WIDTH); + /* don't bother trying direct access */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + dst[i] = temp[i*2+1] & 0xff; + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = temp[i] & 0xff; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = temp[i] >> 24; + } + } +} + +static void +put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte *src = (const GLubyte *) values; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i*2+1] = src[i]; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff) | (src[i] << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH*2], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2+1] = src[i]; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte val = *((GLubyte *) value); + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i*2+1] = val; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff) | (val << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH*2], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2+1] = val; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (val << 24); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte *src = (const GLubyte *) values; + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + dst[1] = src[i]; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (*dst & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (*dst & 0xffffff) | (src[i] << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH*2], i; + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2+1] = src[i]; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH*2], i; + const GLubyte val = *((GLubyte *) value); + /* get, modify, put */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2+1] = val; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (val << 24); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); +} + + +/** + * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like + * a stencil renderbuffer. + * \return new stencil renderbuffer + */ +static struct gl_renderbuffer * +new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer *dsrb) +{ + struct gl_renderbuffer *s8rb; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_S8_Z24 || + dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + + s8rb = ctx->Driver.NewRenderbuffer(ctx, 0); + if (!s8rb) + return NULL; + + /* NOTE: need to do manual refcounting here */ + s8rb->Wrapped = dsrb; + dsrb->RefCount++; + + s8rb->Name = dsrb->Name; + s8rb->RefCount = 0; + s8rb->Width = dsrb->Width; + s8rb->Height = dsrb->Height; + s8rb->RowStride = dsrb->RowStride; + s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT; + s8rb->Format = MESA_FORMAT_S8; + s8rb->_BaseFormat = GL_STENCIL_INDEX; + s8rb->DataType = GL_UNSIGNED_BYTE; + s8rb->Data = NULL; + s8rb->Delete = delete_wrapper; + s8rb->AllocStorage = alloc_wrapper_storage; + s8rb->GetPointer = nop_get_pointer; + s8rb->GetRow = get_row_s8; + s8rb->GetValues = get_values_s8; + s8rb->PutRow = put_row_s8; + s8rb->PutRowRGB = NULL; + s8rb->PutMonoRow = put_mono_row_s8; + s8rb->PutValues = put_values_s8; + s8rb->PutMonoValues = put_mono_values_s8; + + return s8rb; +} + + +/** + * Update the framebuffer's _DepthBuffer field using the renderbuffer + * found at the given attachment index. + * + * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, + * create and install a depth wrapper/adaptor. + * + * \param fb the framebuffer whose _DepthBuffer field to update + */ +void +_swrast_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + struct gl_renderbuffer *depthRb = + fb->Attachment[BUFFER_DEPTH].Renderbuffer; + + if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) { + /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */ + if (!fb->_DepthBuffer + || fb->_DepthBuffer->Wrapped != depthRb + || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) { + /* need to update wrapper */ + struct gl_renderbuffer *wrapper; + + if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + wrapper = new_z32f_renderbuffer_wrapper(ctx, depthRb); + } + else { + wrapper = new_z24_renderbuffer_wrapper(ctx, depthRb); + } + _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper); + } + ASSERT(fb->_DepthBuffer->Wrapped == depthRb); + fb->_DepthBuffer->Width = depthRb->Width; + fb->_DepthBuffer->Height = depthRb->Height; + } + else { + /* depthRb may be null */ + _mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb); + } +} + + +/** + * Update the framebuffer's _StencilBuffer field using the renderbuffer + * found at the given attachment index. + * + * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, + * create and install a stencil wrapper/adaptor. + * + * \param fb the framebuffer whose _StencilBuffer field to update + */ +void +_swrast_update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + struct gl_renderbuffer *stencilRb = + fb->Attachment[BUFFER_STENCIL].Renderbuffer; + + if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) { + /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */ + if (!fb->_StencilBuffer + || fb->_StencilBuffer->Wrapped != stencilRb + || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) { + /* need to update wrapper */ + struct gl_renderbuffer *wrapper + = new_s8_renderbuffer_wrapper(ctx, stencilRb); + _mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper); + } + ASSERT(fb->_StencilBuffer->Wrapped == stencilRb); + fb->_StencilBuffer->Width = stencilRb->Width; + fb->_StencilBuffer->Height = stencilRb->Height; + } + else { + /* stencilRb may be null */ + _mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb); + } +} diff --git a/mesalib/src/mesa/swrast/s_depthstencil.h b/mesalib/src/mesa/swrast/s_depthstencil.h new file mode 100644 index 000000000..0bf624a7b --- /dev/null +++ b/mesalib/src/mesa/swrast/s_depthstencil.h @@ -0,0 +1,39 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef S_DEPTHSTENCIL_H +#define S_DEPTHSTENCIL_H + +struct gl_context; +struct gl_framebuffer; + +void +_swrast_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb); + +void +_swrast_update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb); + + +#endif /* S_DEPTHSTENCIL_H */ diff --git a/mesalib/src/mesa/swrast/s_renderbuffer.c b/mesalib/src/mesa/swrast/s_renderbuffer.c index 7622e38fd..bb7cdebfe 100644 --- a/mesalib/src/mesa/swrast/s_renderbuffer.c +++ b/mesalib/src/mesa/swrast/s_renderbuffer.c @@ -1888,6 +1888,31 @@ add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, } +static GLboolean +add_depth_stencil_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb) +{ + struct gl_renderbuffer *rb; + + assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); + assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth+stencil buffer"); + return GL_FALSE; + } + + rb->InternalFormat = GL_DEPTH_STENCIL; + + rb->AllocStorage = soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb); + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb); + + return GL_TRUE; +} + + /** * Add a software-based accumulation renderbuffer to the given framebuffer. * This is a helper routine for device drivers when creating a @@ -1999,14 +2024,29 @@ _swrast_add_soft_renderbuffers(struct gl_framebuffer *fb, frontRight, backRight); } - if (depth) { - assert(fb->Visual.depthBits > 0); - add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); - } +#if 0 + /* This is pretty much for debugging purposes only since there's a perf + * hit for using combined depth/stencil in swrast. + */ + if (depth && fb->Visual.depthBits == 24 && + stencil && fb->Visual.stencilBits == 8) { + /* use combined depth/stencil buffer */ + add_depth_stencil_renderbuffer(NULL, fb); + } + else +#else + (void) add_depth_stencil_renderbuffer; +#endif + { + if (depth) { + assert(fb->Visual.depthBits > 0); + add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); + } - if (stencil) { - assert(fb->Visual.stencilBits > 0); - add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); + if (stencil) { + assert(fb->Visual.stencilBits > 0); + add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); + } } if (accum) { -- cgit v1.2.3