From 215c4c3a9c989b3d0e7090177ab2fc3eeab0ddaa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 27 Oct 2005 20:26:24 +0000 Subject: Bug #1028: Add hardware-accelerated stencil support to r128. Testing with stencilwrap reported many issues with various modes. Some of these were complicated by the fact that spans are broken (Bug #1615), but some appear to be real bugs. However, while spans remain broken, I found that visual results were better by avoiding fallbacks rather than avoiding just a broken stencil implementation. Note that this required changing the depth spans at 24+8bpp into read-modify-write cycles. It would be nicer as a single write with a mask, but the kernel span blits turn off masking. Reviewed by: ajax --- src/mesa/drivers/dri/r128/r128_ioctl.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/mesa/drivers/dri/r128/r128_ioctl.c') diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.c b/src/mesa/drivers/dri/r128/r128_ioctl.c index 8f14854887..3b34d9fbb2 100644 --- a/src/mesa/drivers/dri/r128/r128_ioctl.c +++ b/src/mesa/drivers/dri/r128/r128_ioctl.c @@ -408,6 +408,7 @@ static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all, GLuint flags = 0; GLint i; GLint ret; + GLuint depthmask = 0; if ( R128_DEBUG & DEBUG_VERBOSE_API ) { fprintf( stderr, "%s:\n", __FUNCTION__ ); @@ -438,15 +439,17 @@ static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all, if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) { flags |= R128_DEPTH; + /* if we're at 16 bits, extra plane mask won't hurt */ + depthmask |= 0x00ffffff; mask &= ~BUFFER_BIT_DEPTH; } -#if 0 - /* FIXME: Add stencil support */ - if ( mask & BUFFER_BIT_STENCIL ) { - flags |= DRM_R128_DEPTH_BUFFER; + + if ( mask & BUFFER_BIT_STENCIL && + (ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24) ) { + flags |= R128_DEPTH; + depthmask |= ctx->Stencil.WriteMask[0] << 24; mask &= ~BUFFER_BIT_STENCIL; } -#endif if ( flags ) { @@ -511,7 +514,7 @@ static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all, clear.clear_color = rmesa->ClearColor; clear.clear_depth = rmesa->ClearDepth; clear.color_mask = rmesa->setup.plane_3d_mask_c; - clear.depth_mask = ~0; + clear.depth_mask = depthmask; ret = drmCommandWrite( rmesa->driFd, DRM_R128_CLEAR, &clear, sizeof(clear) ); -- cgit v1.2.3