From 45e76d2665b38ba3787548310efc59e969124c01 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 8 Oct 2009 20:27:27 -0600 Subject: mesa: remove a bunch of gl_renderbuffer fields _ActualFormat is replaced by Format (MESA_FORMAT_x). ColorEncoding, ComponentType, RedBits, GreenBits, BlueBits, etc. are all replaced by MESA_FORMAT_x queries. --- src/mesa/swrast/s_depth.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/mesa/swrast/s_depth.c') diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 1a428fb1a2..8073a61197 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -25,6 +25,7 @@ #include "main/glheader.h" #include "main/context.h" +#include "main/formats.h" #include "main/macros.h" #include "main/imports.h" #include "main/fbobject.h" @@ -1298,11 +1299,15 @@ void _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, GLint n, GLint x, GLint y, GLuint depth[] ) { + GLuint depthBits; + if (!rb) { /* really only doing this to prevent FP exceptions later */ _mesa_bzero(depth, n * sizeof(GLfloat)); } + depthBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS); + ASSERT(rb->_BaseFormat == GL_DEPTH_COMPONENT); if (y < 0 || y >= (GLint) rb->Height || @@ -1334,8 +1339,8 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, if (rb->DataType == GL_UNSIGNED_INT) { rb->GetRow(ctx, rb, n, x, y, depth); - if (rb->DepthBits < 32) { - GLuint shift = 32 - rb->DepthBits; + if (depthBits < 32) { + GLuint shift = 32 - depthBits; GLint i; for (i = 0; i < n; i++) { GLuint z = depth[i]; @@ -1347,14 +1352,14 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, GLushort temp[MAX_WIDTH]; GLint i; rb->GetRow(ctx, rb, n, x, y, temp); - if (rb->DepthBits == 16) { + if (depthBits == 16) { for (i = 0; i < n; i++) { GLuint z = temp[i]; depth[i] = (z << 16) | z; } } else { - GLuint shift = 16 - rb->DepthBits; + GLuint shift = 16 - depthBits; for (i = 0; i < n; i++) { GLuint z = temp[i]; depth[i] = (z << (shift + 16)) | (z << shift); /* XXX lsb bits? */ -- cgit v1.2.3 From 32ec3f26731ac998b6fda7ce596ec568d6f76eeb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Oct 2009 16:35:16 -0700 Subject: mesa: Mostly fix swrast's ARB_depth_clamp support. I'd written a testcase for the hard part of the extension enablement, so naturally the easy stuff was completely broken. There are still issues, as I'm seeing FLOAT_TO_UINT(max_f) == 0x0 when max_f == 1.0, but it gets piglit depth-clamp-range closer to success. --- src/mesa/swrast/s_depth.c | 28 +++++++++++++++++++--------- src/mesa/swrast/s_span.c | 10 +++++++--- 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'src/mesa/swrast/s_depth.c') diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 393590c673..c37a54eb3e 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -506,22 +506,32 @@ _swrast_depth_clamp_span( GLcontext *ctx, SWspan *span ) struct gl_renderbuffer *rb = fb->_DepthBuffer; const GLuint count = span->end; GLuint *zValues = span->array->z; - GLuint near, far; + GLuint min, max; + GLfloat min_f, max_f; int i; + if (ctx->Viewport.Near < ctx->Viewport.Far) { + min_f = ctx->Viewport.Near; + max_f = ctx->Viewport.Far; + } else { + min_f = ctx->Viewport.Far; + max_f = ctx->Viewport.Near; + } + if (rb->DataType == GL_UNSIGNED_SHORT) { - near = FLOAT_TO_UINT(ctx->Viewport.Near); - far = FLOAT_TO_UINT(ctx->Viewport.Far); + CLAMPED_FLOAT_TO_USHORT(min, min_f); + CLAMPED_FLOAT_TO_USHORT(max, max_f); } else { assert(rb->DataType == GL_UNSIGNED_INT); - CLAMPED_FLOAT_TO_USHORT(near, ctx->Viewport.Near); - CLAMPED_FLOAT_TO_USHORT(far, ctx->Viewport.Far); + min = FLOAT_TO_UINT(min_f); + max = FLOAT_TO_UINT(max_f); } + for (i = 0; i < count; i++) { - if (zValues[i] < near) - zValues[i] = near; - if (zValues[i] > far) - zValues[i] = far; + if (zValues[i] < min) + zValues[i] = min; + if (zValues[i] > max) + zValues[i] = max; } } diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 704230d1d7..d36c8132f6 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -880,14 +880,14 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span) stipple_polygon_span(ctx, span); } - if (ctx->Transform.DepthClamp) - _swrast_depth_clamp_span(ctx, span); - /* Stencil and Z testing */ if (ctx->Stencil._Enabled || ctx->Depth.Test) { if (!(span->arrayMask & SPAN_Z)) _swrast_span_interpolate_z(ctx, span); + if (ctx->Transform.DepthClamp) + _swrast_depth_clamp_span(ctx, span); + if (ctx->Stencil._Enabled) { if (!_swrast_stencil_and_ztest_span(ctx, span)) { span->arrayMask = origArrayMask; @@ -1356,6 +1356,10 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) if (ctx->Stencil._Enabled || ctx->Depth.Test) { if (!(span->arrayMask & SPAN_Z)) _swrast_span_interpolate_z(ctx, span); + + if (ctx->Transform.DepthClamp) + _swrast_depth_clamp_span(ctx, span); + if (ctx->Stencil._Enabled) { /* Combined Z/stencil tests */ if (!_swrast_stencil_and_ztest_span(ctx, span)) { -- cgit v1.2.3