Mesa (master): mesa: Move RasterDiscard to toplevel of gl_context.

Paul Berry stereotype441 at kemper.freedesktop.org
Wed Dec 21 21:36:57 UTC 2011


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Tue Dec 20 16:18:39 2011 -0800

mesa: Move RasterDiscard to toplevel of gl_context.

Previously we were storing the RasterDiscard flag (for
GL_RASTERIZER_DISCARD) in gl_context::TransformFeedback.  This was
confusing, because we use the _NEW_TRANSFORM flag (not
_NEW_TRANSFORM_FEEDBACK) to track state updates to it, and because
rasterizer discard has effects even when transform feedback is not in
use.

This patch makes RasterDiscard a toplevel element in gl_context rather
than a subfield of gl_context::TransformFeedback.

Note: We can't put RasterDiscard inside gl_context::Transform, since
all items inside gl_context::Transform need to be pieces of state that
are saved and restored using PushAttrib and PopAttrib.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Marek Olšák <maraeo at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_gs.c          |    2 +-
 src/mesa/main/accum.c                       |    2 +-
 src/mesa/main/clear.c                       |   14 +++++++-------
 src/mesa/main/drawpix.c                     |    6 +++---
 src/mesa/main/enable.c                      |    6 +++---
 src/mesa/main/get.c                         |    2 +-
 src/mesa/main/mtypes.h                      |    4 ++--
 src/mesa/state_tracker/st_atom_rasterizer.c |    2 +-
 8 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index ee3f94c..2495ad5 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -210,7 +210,7 @@ static void populate_key( struct brw_context *brw,
       }
       /* On Gen6, GS is also used for rasterizer discard. */
       /* _NEW_TRANSFORM_FEEDBACK */
-      if (ctx->TransformFeedback.RasterDiscard) {
+      if (ctx->RasterDiscard) {
          key->need_gs_prog = true;
          key->rasterizer_discard = true;
       }
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index eb06bbb..a8c30c2 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -100,7 +100,7 @@ _mesa_Accum( GLenum op, GLfloat value )
       return;
    }
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
       return;
 
    if (ctx->RenderMode == GL_RENDER) {
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 2e27c95..bd5c012 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -200,7 +200,7 @@ _mesa_Clear( GLbitfield mask )
        ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax)
       return;
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
       return;
 
    if (ctx->RenderMode == GL_RENDER) {
@@ -338,7 +338,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
                      drawbuffer);
          return;
       }
-      else if (!ctx->TransformFeedback.RasterDiscard) {
+      else if (!ctx->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()
@@ -362,7 +362,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
                         drawbuffer);
             return;
          }
-         else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+         else if (mask && !ctx->RasterDiscard) {
             union gl_color_union clearSave;
 
             /* save color */
@@ -432,7 +432,7 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
                         drawbuffer);
             return;
          }
-         else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+         else if (mask && !ctx->RasterDiscard) {
             union gl_color_union clearSave;
 
             /* save color */
@@ -513,7 +513,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
                      drawbuffer);
          return;
       }
-      else if (!ctx->TransformFeedback.RasterDiscard) {
+      else if (!ctx->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()
@@ -538,7 +538,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
                         drawbuffer);
             return;
          }
-         else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+         else if (mask && !ctx->RasterDiscard) {
             union gl_color_union clearSave;
 
             /* save color */
@@ -615,7 +615,7 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
       return;
    }
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
       return;
 
    if (ctx->NewState) {
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index c9e714b..9f5b0b3 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -98,7 +98,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
       goto end;      /* the error code was recorded */
    }
 
-   if (ctx->TransformFeedback.RasterDiscard) {
+   if (ctx->RasterDiscard) {
       goto end;
    }
 
@@ -210,7 +210,7 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
       goto end;
    }
 
-   if (ctx->TransformFeedback.RasterDiscard) {
+   if (ctx->RasterDiscard) {
       goto end;
    }
 
@@ -268,7 +268,7 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
       return;
    }
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
       return;
 
    if (ctx->RenderMode == GL_RENDER) {
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 6461ac1..749ae98 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -889,9 +889,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
 #if FEATURE_EXT_transform_feedback
       case GL_RASTERIZER_DISCARD:
 	 CHECK_EXTENSION(EXT_transform_feedback, cap);
-         if (ctx->TransformFeedback.RasterDiscard != state) {
+         if (ctx->RasterDiscard != state) {
             FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
-            ctx->TransformFeedback.RasterDiscard = state;
+            ctx->RasterDiscard = state;
          }
          break;
 #endif
@@ -1403,7 +1403,7 @@ _mesa_IsEnabled( GLenum cap )
 #if FEATURE_EXT_transform_feedback
       case GL_RASTERIZER_DISCARD:
 	 CHECK_EXTENSION(EXT_transform_feedback);
-         return ctx->TransformFeedback.RasterDiscard;
+         return ctx->RasterDiscard;
 #endif
 
       /* GL_NV_primitive_restart */
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 4df6afe..0c9d6b3 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1204,7 +1204,7 @@ static const struct value_desc values[] = {
    /* GL_EXT_transform_feedback */
    { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0,
      extra_EXT_transform_feedback },
-   { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(TransformFeedback.RasterDiscard),
+   { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(RasterDiscard),
      extra_EXT_transform_feedback },
    { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,
      CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents),
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 93bf04e..ff97ea9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2386,8 +2386,6 @@ struct gl_transform_feedback
 {
    GLenum Mode;       /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
 
-   GLboolean RasterDiscard;  /**< GL_RASTERIZER_DISCARD */
-
    /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
    struct gl_buffer_object *CurrentBuffer;
 
@@ -3407,6 +3405,8 @@ struct gl_context
     */
    GLboolean mvp_with_dp4;
 
+   GLboolean RasterDiscard;  /**< GL_RASTERIZER_DISCARD */
+
    /**
     * \name Hooks for module contexts.  
     *
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index 4aa0b4e..7ebc872 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -259,7 +259,7 @@ static void update_raster_state( struct st_context *st )
    raster->gl_rasterization_rules = 1;
 
    /* _NEW_TRANSFORM */
-   raster->rasterizer_discard = ctx->TransformFeedback.RasterDiscard;
+   raster->rasterizer_discard = ctx->RasterDiscard;
 
    cso_set_rasterizer(st->cso_context, raster);
 }




More information about the mesa-commit mailing list