diff options
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_depth.c | 22 | ||||
-rw-r--r-- | src/mesa/swrast/swrast.h | 7 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index fc242be2aa..34897ba931 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -1665,13 +1665,33 @@ _swrast_alloc_depth_buffer( GLframebuffer *buffer ) void _swrast_clear_depth_buffer( GLcontext *ctx ) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); + if (ctx->Visual.depthBits == 0 - || !ctx->DrawBuffer->DepthBuffer || !ctx->Depth.Mask) { /* no depth buffer, or writing to it is disabled */ return; } + if (swrast->Driver.WriteMonoDepthSpan) { + const GLdepth clearValue = (GLdepth)(ctx->Depth.Clear * ctx->DepthMax); + const GLint x = ctx->DrawBuffer->_Xmin; + const GLint y = ctx->DrawBuffer->_Ymin; + const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; + const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; + GLint i; + + for (i = 0; i < height; i++) { + (*swrast->Driver.WriteMonoDepthSpan)( ctx, width, x, y + i, + clearValue, NULL ); + } + + return; + } + + if (!ctx->DrawBuffer->DepthBuffer) + return; + /* The loops in this function have been written so the IRIX 5.3 * C compiler can unroll them. Hopefully other compilers can too! */ diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index 9447e99880..7fb0d2a389 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -403,6 +403,13 @@ struct swrast_device_driver { * depth[i] value if mask[i] is nonzero. */ + void (*WriteMonoDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth depth, const GLubyte mask[] ); + /* Write a horizontal run of depth values. + * If mask is NULL, draw all pixels. + * If mask is not null, only draw pixel [i] when mask [i] is true. + */ + void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth depth[] ); /* Read a horizontal span of values from the depth buffer. |