patches for clearing hw depth buffers from software fallback (Nicolai Haehnle)
This commit is contained in:
@@ -64,6 +64,42 @@ static void TAG(WriteDepthSpan)( GLcontext *ctx,
|
|||||||
HW_WRITE_UNLOCK();
|
HW_WRITE_UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void TAG(WriteMonoDepthSpan)( GLcontext *ctx,
|
||||||
|
GLuint n, GLint x, GLint y,
|
||||||
|
const GLdepth depth,
|
||||||
|
const GLubyte mask[] )
|
||||||
|
{
|
||||||
|
HW_WRITE_LOCK()
|
||||||
|
{
|
||||||
|
GLint x1;
|
||||||
|
GLint n1;
|
||||||
|
LOCAL_DEPTH_VARS;
|
||||||
|
|
||||||
|
y = Y_FLIP( y );
|
||||||
|
|
||||||
|
HW_CLIPLOOP()
|
||||||
|
{
|
||||||
|
GLint i = 0;
|
||||||
|
CLIPSPAN( x, y, n, x1, n1, i );
|
||||||
|
|
||||||
|
if ( DBG ) fprintf( stderr, "%s %d..%d (x1 %d) = %u\n",
|
||||||
|
__FUNCTION__, (int)i, (int)n1, (int)x1, (uint)depth );
|
||||||
|
|
||||||
|
if ( mask ) {
|
||||||
|
for ( ; i < n1 ; i++, x1++ ) {
|
||||||
|
if ( mask[i] ) WRITE_DEPTH( x1, y, depth );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for ( ; i < n1 ; i++, x1++ ) {
|
||||||
|
WRITE_DEPTH( x1, y, depth );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HW_ENDCLIPLOOP();
|
||||||
|
}
|
||||||
|
HW_WRITE_UNLOCK();
|
||||||
|
}
|
||||||
|
|
||||||
static void TAG(WriteDepthPixels)( GLcontext *ctx,
|
static void TAG(WriteDepthPixels)( GLcontext *ctx,
|
||||||
GLuint n,
|
GLuint n,
|
||||||
const GLint x[],
|
const GLint x[],
|
||||||
|
@@ -123,15 +123,29 @@ static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
|
|||||||
|
|
||||||
HW_WRITE_CLIPLOOP()
|
HW_WRITE_CLIPLOOP()
|
||||||
{
|
{
|
||||||
for (i=0;i<n;i++)
|
if (mask)
|
||||||
{
|
{
|
||||||
if (mask[i]) {
|
for (i=0;i<n;i++)
|
||||||
|
{
|
||||||
|
if (mask[i]) {
|
||||||
|
const int fy = Y_FLIP(y[i]);
|
||||||
|
if (CLIPPIXEL(x[i],fy))
|
||||||
|
WRITE_RGBA( x[i], fy,
|
||||||
|
rgba[i][0], rgba[i][1],
|
||||||
|
rgba[i][2], rgba[i][3] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i=0;i<n;i++)
|
||||||
|
{
|
||||||
const int fy = Y_FLIP(y[i]);
|
const int fy = Y_FLIP(y[i]);
|
||||||
if (CLIPPIXEL(x[i],fy))
|
if (CLIPPIXEL(x[i],fy))
|
||||||
WRITE_RGBA( x[i], fy,
|
WRITE_RGBA( x[i], fy,
|
||||||
rgba[i][0], rgba[i][1],
|
rgba[i][0], rgba[i][1],
|
||||||
rgba[i][2], rgba[i][3] );
|
rgba[i][2], rgba[i][3] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HW_ENDCLIPLOOP();
|
HW_ENDCLIPLOOP();
|
||||||
@@ -160,9 +174,17 @@ static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
|
|||||||
{
|
{
|
||||||
GLint i = 0;
|
GLint i = 0;
|
||||||
CLIPSPAN(x,y,n,x1,n1,i);
|
CLIPSPAN(x,y,n,x1,n1,i);
|
||||||
for (;n1>0;i++,x1++,n1--)
|
if (mask)
|
||||||
if (mask[i])
|
{
|
||||||
|
for (;n1>0;i++,x1++,n1--)
|
||||||
|
if (mask[i])
|
||||||
|
WRITE_PIXEL( x1, y, p );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (;n1>0;i++,x1++,n1--)
|
||||||
WRITE_PIXEL( x1, y, p );
|
WRITE_PIXEL( x1, y, p );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
HW_ENDCLIPLOOP();
|
HW_ENDCLIPLOOP();
|
||||||
}
|
}
|
||||||
@@ -186,12 +208,23 @@ static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
|
|||||||
|
|
||||||
HW_WRITE_CLIPLOOP()
|
HW_WRITE_CLIPLOOP()
|
||||||
{
|
{
|
||||||
for (i=0;i<n;i++)
|
if (mask)
|
||||||
if (mask[i]) {
|
{
|
||||||
|
for (i=0;i<n;i++)
|
||||||
|
if (mask[i]) {
|
||||||
|
int fy = Y_FLIP(y[i]);
|
||||||
|
if (CLIPPIXEL( x[i], fy ))
|
||||||
|
WRITE_PIXEL( x[i], fy, p );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i=0;i<n;i++) {
|
||||||
int fy = Y_FLIP(y[i]);
|
int fy = Y_FLIP(y[i]);
|
||||||
if (CLIPPIXEL( x[i], fy ))
|
if (CLIPPIXEL( x[i], fy ))
|
||||||
WRITE_PIXEL( x[i], fy, p );
|
WRITE_PIXEL( x[i], fy, p );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
HW_ENDCLIPLOOP();
|
HW_ENDCLIPLOOP();
|
||||||
}
|
}
|
||||||
@@ -238,12 +271,23 @@ static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
|
|||||||
|
|
||||||
HW_READ_CLIPLOOP()
|
HW_READ_CLIPLOOP()
|
||||||
{
|
{
|
||||||
for (i=0;i<n;i++)
|
if (mask)
|
||||||
if (mask[i]) {
|
{
|
||||||
|
for (i=0;i<n;i++)
|
||||||
|
if (mask[i]) {
|
||||||
|
int fy = Y_FLIP( y[i] );
|
||||||
|
if (CLIPPIXEL( x[i], fy ))
|
||||||
|
READ_RGBA( rgba[i], x[i], fy );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i=0;i<n;i++) {
|
||||||
int fy = Y_FLIP( y[i] );
|
int fy = Y_FLIP( y[i] );
|
||||||
if (CLIPPIXEL( x[i], fy ))
|
if (CLIPPIXEL( x[i], fy ))
|
||||||
READ_RGBA( rgba[i], x[i], fy );
|
READ_RGBA( rgba[i], x[i], fy );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
HW_ENDCLIPLOOP();
|
HW_ENDCLIPLOOP();
|
||||||
}
|
}
|
||||||
|
@@ -1665,13 +1665,33 @@ _swrast_alloc_depth_buffer( GLframebuffer *buffer )
|
|||||||
void
|
void
|
||||||
_swrast_clear_depth_buffer( GLcontext *ctx )
|
_swrast_clear_depth_buffer( GLcontext *ctx )
|
||||||
{
|
{
|
||||||
|
SWcontext *swrast = SWRAST_CONTEXT(ctx);
|
||||||
|
|
||||||
if (ctx->Visual.depthBits == 0
|
if (ctx->Visual.depthBits == 0
|
||||||
|| !ctx->DrawBuffer->DepthBuffer
|
|
||||||
|| !ctx->Depth.Mask) {
|
|| !ctx->Depth.Mask) {
|
||||||
/* no depth buffer, or writing to it is disabled */
|
/* no depth buffer, or writing to it is disabled */
|
||||||
return;
|
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
|
/* The loops in this function have been written so the IRIX 5.3
|
||||||
* C compiler can unroll them. Hopefully other compilers can too!
|
* C compiler can unroll them. Hopefully other compilers can too!
|
||||||
*/
|
*/
|
||||||
|
@@ -403,6 +403,13 @@ struct swrast_device_driver {
|
|||||||
* depth[i] value if mask[i] is nonzero.
|
* 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,
|
void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
|
||||||
GLdepth depth[] );
|
GLdepth depth[] );
|
||||||
/* Read a horizontal span of values from the depth buffer.
|
/* Read a horizontal span of values from the depth buffer.
|
||||||
|
Reference in New Issue
Block a user