|
|
Read combined depth/stencil values. We'll have already done error checking to be sure the expected depth and stencil buffers really exist.
Definition at line 458 of file s_readpix.c.
Referenced by _swrast_ReadPixels().
{
const GLboolean scaleOrBias
= ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
const GLboolean stencilTransfer = ctx->Pixel.IndexShift
|| ctx->Pixel.IndexOffset || ctx->Pixel.MapStencilFlag;
struct gl_renderbuffer *depthRb, *stencilRb;
depthRb = ctx->ReadBuffer->_DepthBuffer;
stencilRb = ctx->ReadBuffer->_StencilBuffer;
if (!depthRb || !stencilRb)
return;
depthRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
stencilRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
if (depthRb->_BaseFormat == GL_DEPTH_STENCIL_EXT &&
stencilRb->_BaseFormat == GL_DEPTH_STENCIL_EXT &&
depthRb == stencilRb &&
!scaleOrBias &&
!stencilTransfer) {
GLint i;
GLint dstStride = _mesa_image_row_stride(packing, width,
GL_DEPTH_STENCIL_EXT, type);
GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
width, height,
GL_DEPTH_STENCIL_EXT,
type, 0, 0);
for (i = 0; i < height; i++) {
depthRb->GetRow(ctx, depthRb, width, x, y + i, dst);
dst += dstStride;
}
}
else {
GLint i;
depthRb = ctx->ReadBuffer->_DepthBuffer;
stencilRb = ctx->ReadBuffer->_StencilBuffer;
for (i = 0; i < height; i++) {
GLstencil stencilVals[MAX_WIDTH];
GLuint *depthStencilDst = (GLuint *)
_mesa_image_address2d(packing, pixels, width, height,
GL_DEPTH_STENCIL_EXT, type, i, 0);
_swrast_read_stencil_span(ctx, stencilRb, width,
x, y + i, stencilVals);
if (!scaleOrBias && !stencilTransfer
&& ctx->ReadBuffer->Visual.depthBits == 24) {
GLuint zVals[MAX_WIDTH];
GLint j;
ASSERT(depthRb->DataType == GL_UNSIGNED_INT);
depthRb->GetRow(ctx, depthRb, width, x, y + i, zVals);
for (j = 0; j < width; j++) {
depthStencilDst[j] = (zVals[j] << 8) | (stencilVals[j] & 0xff);
}
}
else {
GLfloat depthVals[MAX_WIDTH];
_swrast_read_depth_span_float(ctx, depthRb, width, x, y + i,
depthVals);
_mesa_pack_depth_stencil_span(ctx, width, depthStencilDst,
depthVals, stencilVals, packing);
}
}
}
}
|