summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-06-23 22:47:46 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-06-23 22:47:46 +0000
commit0349b4b2abac65f67a638a9f8bb5d1a3d48ddf95 (patch)
treed484e3326c44576a3f560e54faa9adcf9d1bef19 /src/mesa
parentd7ea75061c1678bfca422e8776bd35f6546066f5 (diff)
Fixed occlusion_zless_triangle() to work with 16 or 32-bit Z buffers.
Removed some unneeded lines, other minor clean-ups.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/swrast/s_triangle.c52
1 files 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