diff options
author | Brian Paul <[email protected]> | 2003-06-13 02:37:27 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2003-06-13 02:37:27 +0000 |
commit | b17a722ca3989e8563ee04cb2939f4835f8a171e (patch) | |
tree | 817c548199ee8e4a1ba2a0266f491b2b80b942d3 /src/mesa/swrast | |
parent | 0c0e583c01116c9e26ac99735e581ea2b842a88d (diff) |
Implemented GL_ARB_occlusion_query (not 100% finalized).
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_context.c | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 24 | ||||
-rw-r--r-- | src/mesa/swrast/s_triangle.c | 14 |
3 files changed, 34 insertions, 6 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 5160e810cdb..6a25be68f5d 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -79,7 +79,7 @@ _swrast_update_rasterflags( GLcontext *ctx ) RasterMask |= CLIP_BIT; } - if (ctx->Depth.OcclusionTest) + if (ctx->Depth.OcclusionTest || ctx->Occlusion.Active) RasterMask |= OCCLUSION_BIT; diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index cce69b8c439..59e89252a05 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -841,6 +841,14 @@ _swrast_write_index_span( GLcontext *ctx, struct sw_span *span) /* if we get here, something passed the depth test */ ctx->OcclusionResult = GL_TRUE; +#if FEATURE_ARB_occlusion_query + if (ctx->Occlusion.Active) { + GLuint i; + for (i = 0; i < span->end; i++) + ctx->Occlusion.PassedCounter += span->array->mask[i]; + } +#endif + /* we have to wait until after occlusion to do this test */ if (ctx->Color.DrawBuffer == GL_NONE || ctx->Color.IndexMask == 0) { /* write no pixels */ @@ -1046,6 +1054,14 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span) /* if we get here, something passed the depth test */ ctx->OcclusionResult = GL_TRUE; +#if FEATURE_ARB_occlusion_query + if (ctx->Occlusion.Active) { + GLuint i; + for (i = 0; i < span->end; i++) + ctx->Occlusion.PassedCounter += span->array->mask[i]; + } +#endif + /* can't abort span-writing until after occlusion testing */ if (colorMask == 0x0) { span->interpMask = origInterpMask; @@ -1288,6 +1304,14 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span) /* if we get here, some fragments passed the depth test */ ctx->OcclusionResult = GL_TRUE; +#if FEATURE_ARB_occlusion_query + if (ctx->Occlusion.Active) { + GLuint i; + for (i = 0; i < span->end; i++) + ctx->Occlusion.PassedCounter += span->array->mask[i]; + } +#endif + /* We had to wait until now to check for glColorMask(F,F,F,F) because of * the occlusion test. */ diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 43c131a6e75..0ce3459d544 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -899,13 +899,16 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span, +/* + * Special tri function for occlusion testing + */ #define NAME occlusion_zless_triangle #define DO_OCCLUSION_TEST #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE -#define SETUP_CODE \ - if (ctx->OcclusionResult) { \ - return; \ +#define SETUP_CODE \ + if (ctx->OcclusionResult && !ctx->Occlusion.Active) { \ + return; \ } #define RENDER_SPAN( span ) \ GLuint i; \ @@ -913,7 +916,7 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span, GLdepth z = FixedToDepth(span.z); \ if (z < zRow[i]) { \ ctx->OcclusionResult = GL_TRUE; \ - return; \ + ctx->Occlusion.PassedCounter++; \ } \ span.z += span.zStep; \ } @@ -1034,7 +1037,8 @@ _swrast_choose_triangle( GLcontext *ctx ) return; } - if (ctx->Depth.OcclusionTest && + /* special case for occlusion testing */ + if ((ctx->Depth.OcclusionTest || ctx->Occlusion.Active) && ctx->Depth.Test && ctx->Depth.Mask == GL_FALSE && ctx->Depth.Func == GL_LESS && |