Mesa (master): mesa: Respect GL_RASTERIZER_DISCARD for various meta-type operations.

Eric Anholt anholt at kemper.freedesktop.org
Sun Oct 2 06:31:47 UTC 2011


Module: Mesa
Branch: master
Commit: e7c2b711a3b01cbeb0bf93d5442599457e7f8f51
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7c2b711a3b01cbeb0bf93d5442599457e7f8f51

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Sep 29 23:13:44 2011 -0700

mesa: Respect GL_RASTERIZER_DISCARD for various meta-type operations.

>From the EXT_transform_feedback spec:

    Primitives can be optionally discarded before rasterization by calling
    Enable and Disable with RASTERIZER_DISCARD_EXT. When enabled, primitives
    are discared right before the rasterization stage, but after the optional
    transform feedback stage. When disabled, primitives are passed through to
    the rasterization stage to be processed normally. RASTERIZER_DISCARD_EXT
    applies to the DrawPixels, CopyPixels, Bitmap, Clear and Accum commands as
    well.

And the GL 3.2 spec says it applies to ClearBuffer* as well.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/accum.c   |    3 +++
 src/mesa/main/clear.c   |   16 +++++++++++-----
 src/mesa/main/drawpix.c |   11 +++++++++++
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index 6a83930..d7ed3a8 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -97,6 +97,9 @@ _mesa_Accum( GLenum op, GLfloat value )
       return;
    }
 
+   if (ctx->TransformFeedback.RasterDiscard)
+      return;
+
    if (ctx->RenderMode == GL_RENDER) {
       ctx->Driver.Accum(ctx, op, value);
    }
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 301fe69..c35675f 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -200,6 +200,9 @@ _mesa_Clear( GLbitfield mask )
        ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax)
       return;
 
+   if (ctx->TransformFeedback.RasterDiscard)
+      return;
+
    if (ctx->RenderMode == GL_RENDER) {
       GLbitfield bufferMask;
 
@@ -328,7 +331,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
                      drawbuffer);
          return;
       }
-      else {
+      else if (!ctx->TransformFeedback.RasterDiscard) {
          /* Save current stencil clear value, set to 'value', do the
           * stencil clear and restore the clear value.
           * XXX in the future we may have a new ctx->Driver.ClearBuffer()
@@ -352,7 +355,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
                         drawbuffer);
             return;
          }
-         else if (mask) {
+         else if (mask && !ctx->TransformFeedback.RasterDiscard) {
             union gl_color_union clearSave;
 
             /* save color */
@@ -403,7 +406,7 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
                         drawbuffer);
             return;
          }
-         else if (mask) {
+         else if (mask && !ctx->TransformFeedback.RasterDiscard) {
             union gl_color_union clearSave;
 
             /* save color */
@@ -452,7 +455,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
                      drawbuffer);
          return;
       }
-      else {
+      else if (!ctx->TransformFeedback.RasterDiscard) {
          /* Save current depth clear value, set to 'value', do the
           * depth clear and restore the clear value.
           * XXX in the future we may have a new ctx->Driver.ClearBuffer()
@@ -477,7 +480,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
                         drawbuffer);
             return;
          }
-         else if (mask) {
+         else if (mask && !ctx->TransformFeedback.RasterDiscard) {
             union gl_color_union clearSave;
 
             /* save color */
@@ -528,6 +531,9 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
       return;
    }
 
+   if (ctx->TransformFeedback.RasterDiscard)
+      return;
+
    if (ctx->NewState) {
       _mesa_update_state( ctx );
    }
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index b7e2c36..412cc15 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -80,6 +80,10 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
       goto end;      /* the error code was recorded */
    }
 
+   if (ctx->TransformFeedback.RasterDiscard) {
+      goto end;
+   }
+
    if (!ctx->Current.RasterPosValid) {
       goto end;  /* no-op, not an error */
    }
@@ -188,6 +192,10 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
       goto end;
    }
 
+   if (ctx->TransformFeedback.RasterDiscard) {
+      goto end;
+   }
+
    if (!ctx->Current.RasterPosValid || width == 0 || height == 0) {
       goto end; /* no-op, not an error */
    }
@@ -242,6 +250,9 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
       return;
    }
 
+   if (ctx->TransformFeedback.RasterDiscard)
+      return;
+
    if (ctx->RenderMode == GL_RENDER) {
       /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
       if (width > 0 && height > 0) {




More information about the mesa-commit mailing list