From 0349b4b2abac65f67a638a9f8bb5d1a3d48ddf95 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 23 Jun 2004 22:47:46 +0000 Subject: [PATCH] Fixed occlusion_zless_triangle() to work with 16 or 32-bit Z buffers. Removed some unneeded lines, other minor clean-ups. --- src/mesa/swrast/s_triangle.c | 52 ++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index ff4ebb3704d..8c2ba368c04 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -102,7 +102,6 @@ _swrast_culltriangle( GLcontext *ctx, #define NAME flat_rgba_triangle #define INTERP_Z 1 #define INTERP_FOG 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define SETUP_CODE \ ASSERT(ctx->Texture._EnabledCoordUnits == 0);\ ASSERT(ctx->Light.ShadeModel==GL_FLAT); \ @@ -126,7 +125,6 @@ _swrast_culltriangle( GLcontext *ctx, #define NAME smooth_rgba_triangle #define INTERP_Z 1 #define INTERP_FOG 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define INTERP_ALPHA 1 #define SETUP_CODE \ @@ -528,7 +526,6 @@ affine_span(GLcontext *ctx, struct sw_span *span, #define NAME affine_textured_triangle #define INTERP_Z 1 #define INTERP_FOG 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define INTERP_ALPHA 1 #define INTERP_INT_TEX 1 @@ -801,7 +798,6 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span, #define INTERP_Z 1 #define INTERP_W 1 #define INTERP_FOG 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define INTERP_ALPHA 1 #define INTERP_TEX 1 @@ -873,7 +869,6 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span, #define INTERP_Z 1 #define INTERP_W 1 #define INTERP_FOG 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define INTERP_SPEC 1 #define INTERP_ALPHA 1 @@ -892,7 +887,6 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span, #define INTERP_Z 1 #define INTERP_W 1 #define INTERP_FOG 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define INTERP_ALPHA 1 #define INTERP_SPEC 1 @@ -908,20 +902,38 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span, #define NAME occlusion_zless_triangle #define DO_OCCLUSION_TEST #define INTERP_Z 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define SETUP_CODE \ + ASSERT(ctx->Depth.Test); \ + ASSERT(!ctx->Depth.Mask); \ + ASSERT(ctx->Depth.Func == GL_LESS); \ if (ctx->OcclusionResult && !ctx->Occlusion.Active) { \ return; \ } -#define RENDER_SPAN( span ) \ - GLuint i; \ - for (i = 0; i < span.end; i++) { \ - GLdepth z = FixedToDepth(span.z); \ - if (z < zRow[i]) { \ - ctx->OcclusionResult = GL_TRUE; \ - ctx->Occlusion.PassedCounter++; \ - } \ - span.z += span.zStep; \ +#define RENDER_SPAN( span ) \ + if (ctx->Visual.depthBits <= 16) { \ + GLuint i; \ + const GLushort *zRow = (const GLushort *) \ + _swrast_zbuffer_address(ctx, span.x, span.y); \ + for (i = 0; i < span.end; i++) { \ + GLdepth z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + ctx->OcclusionResult = GL_TRUE; \ + ctx->Occlusion.PassedCounter++; \ + } \ + span.z += span.zStep; \ + } \ + } \ + else { \ + GLuint i; \ + const GLuint *zRow = (const GLuint *) \ + _swrast_zbuffer_address(ctx, span.x, span.y); \ + for (i = 0; i < span.end; i++) { \ + if (span.z < zRow[i]) { \ + ctx->OcclusionResult = GL_TRUE; \ + ctx->Occlusion.PassedCounter++; \ + } \ + span.z += span.zStep; \ + } \ } #include "s_tritemp.h" @@ -1072,13 +1084,13 @@ _swrast_choose_triangle( GLcontext *ctx ) envMode = ctx->Texture.Unit[0].EnvMode; /* First see if we can use an optimized 2-D texture function */ - if (ctx->Texture._EnabledCoordUnits == 1 + if (ctx->Texture._EnabledCoordUnits == 0x1 && !ctx->FragmentProgram._Enabled && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT - && texObj2D->WrapS==GL_REPEAT - && texObj2D->WrapT==GL_REPEAT + && texObj2D->WrapS == GL_REPEAT + && texObj2D->WrapT == GL_REPEAT && texObj2D->_IsPowerOfTwo - && texImg->Border==0 + && texImg->Border == 0 && texImg->Width == texImg->RowStride && (format == MESA_FORMAT_RGB || format == MESA_FORMAT_RGBA) && minFilter == magFilter -- 2.30.2