summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-10-21 22:43:15 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-10-21 22:43:15 +0000
commitbb19e64d12eaf27e2adc3faac7e09555bb66d724 (patch)
tree5efc1a713c0c9c9d1d5ae05f9139e2ae3c669322
parent828d15a6e0907fe4bb7c564d453a2b1a05f109bc (diff)
For deferredTexture, need to check if the fragment program/shader writes
the fragment Z.
-rw-r--r--src/mesa/swrast/s_span.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 8a2e5d118e..4fcd4d2251 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1402,9 +1402,12 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
|| ctx->ShaderObjects._FragmentShaderPresent
|| ctx->ATIFragmentShader._Enabled;
const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledUnits;
- const GLboolean deferredTexture
- = shaderOrTexture && !ctx->Color.AlphaEnabled;
+ GLboolean deferredTexture;
+ /*
+ printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__,
+ span->interpMask, span->arrayMask);
+ */
ASSERT(span->primitive == GL_POINT ||
span->primitive == GL_LINE ||
@@ -1414,11 +1417,33 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
ASSERT((span->interpMask & span->arrayMask) == 0);
ASSERT((span->interpMask & SPAN_RGBA) ^ (span->arrayMask & SPAN_RGBA));
- /*
- printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__,
- span->interpMask, span->arrayMask);
- */
+ /* check for conditions that prevent deferred shading */
+ if (ctx->Color.AlphaEnabled) {
+ /* alpha test depends on post-texture/shader colors */
+ deferredTexture = GL_FALSE;
+ }
+ else if (shaderOrTexture) {
+ if (ctx->FragmentProgram._Enabled &&
+ (ctx->FragmentProgram.Current->Base.OutputsWritten
+ & (1 << FRAG_RESULT_DEPR))) {
+ /* Z comes from fragment program */
+ deferredTexture = GL_FALSE;
+ }
+ else if (ctx->ShaderObjects._FragmentShaderPresent) {
+ /* XXX how do we test if Z is written by shader? */
+ deferredTexture = GL_FALSE; /* never defer to be safe */
+ }
+ else {
+ /* ATI frag shader or conventional texturing */
+ deferredTexture = GL_TRUE;
+ }
+ }
+ else {
+ /* no texturing or shadering */
+ deferredTexture = GL_FALSE;
+ }
+ /* Fragment write masks */
if (span->arrayMask & SPAN_MASK) {
/* mask was initialized by caller, probably glBitmap */
span->writeAll = GL_FALSE;