[Mesa-dev] [PATCH 23/31] mesa: don't flag _NEW_POLYGON for st/mesa

Marek Olšák maraeo at gmail.com
Mon Jun 12 16:55:48 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/mesa/main/enable.c              | 24 ++++++++++++++++++------
 src/mesa/main/mtypes.h              |  3 +++
 src/mesa/main/polygon.c             | 18 ++++++++++++------
 src/mesa/main/viewport.c            |  5 ++++-
 src/mesa/state_tracker/st_context.c |  4 ++--
 5 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 38bbe5f..99a4923 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -375,21 +375,23 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          FLUSH_CURRENT(ctx, 0);
          ctx->Light.ColorMaterialEnabled = state;
          if (state) {
             _mesa_update_color_material( ctx,
                                   ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
          }
          break;
       case GL_CULL_FACE:
          if (ctx->Polygon.CullFlag == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_POLYGON);
+         FLUSH_VERTICES(ctx,
+                        ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+         ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
          ctx->Polygon.CullFlag = state;
          break;
       case GL_DEPTH_TEST:
          if (ctx->Depth.Test == state)
             return;
          FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepth ? 0 : _NEW_DEPTH);
          ctx->NewDriverState |= ctx->DriverFlags.NewDepth;
          ctx->Depth.Test = state;
          break;
       case GL_DEBUG_OUTPUT:
@@ -643,51 +645,61 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          if (ctx->Point.SmoothFlag == state)
             return;
          FLUSH_VERTICES(ctx, _NEW_POINT);
          ctx->Point.SmoothFlag = state;
          break;
       case GL_POLYGON_SMOOTH:
          if (!_mesa_is_desktop_gl(ctx))
             goto invalid_enum_error;
          if (ctx->Polygon.SmoothFlag == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_POLYGON);
+         FLUSH_VERTICES(ctx,
+                        ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+         ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
          ctx->Polygon.SmoothFlag = state;
          break;
       case GL_POLYGON_STIPPLE:
          if (ctx->API != API_OPENGL_COMPAT)
             goto invalid_enum_error;
          if (ctx->Polygon.StippleFlag == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_POLYGON);
+         FLUSH_VERTICES(ctx,
+                        ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+         ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
          ctx->Polygon.StippleFlag = state;
          break;
       case GL_POLYGON_OFFSET_POINT:
          if (!_mesa_is_desktop_gl(ctx))
             goto invalid_enum_error;
          if (ctx->Polygon.OffsetPoint == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_POLYGON);
+         FLUSH_VERTICES(ctx,
+                        ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+         ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
          ctx->Polygon.OffsetPoint = state;
          break;
       case GL_POLYGON_OFFSET_LINE:
          if (!_mesa_is_desktop_gl(ctx))
             goto invalid_enum_error;
          if (ctx->Polygon.OffsetLine == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_POLYGON);
+         FLUSH_VERTICES(ctx,
+                        ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+         ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
          ctx->Polygon.OffsetLine = state;
          break;
       case GL_POLYGON_OFFSET_FILL:
          if (ctx->Polygon.OffsetFill == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_POLYGON);
+         FLUSH_VERTICES(ctx,
+                        ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+         ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
          ctx->Polygon.OffsetFill = state;
          break;
       case GL_RESCALE_NORMAL_EXT:
          if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
             goto invalid_enum_error;
          if (ctx->Transform.RescaleNormals == state)
             return;
          FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
          ctx->Transform.RescaleNormals = state;
          break;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 833932b..ff494cd 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4441,20 +4441,23 @@ struct gl_driver_flags
 
    /** gl_context::Transform::EyeUserPlane */
    uint64_t NewClipPlane;
 
    /** gl_context::Transform::ClipPlanesEnabled */
    uint64_t NewClipPlaneEnable;
 
    /** gl_context::Transform::DepthClamp */
    uint64_t NewDepthClamp;
 
+   /** gl_context::Polygon */
+   uint64_t NewPolygonState;
+
    /** gl_context::ViewportArray */
    uint64_t NewViewport;
 };
 
 struct gl_uniform_buffer_binding
 {
    struct gl_buffer_object *BufferObject;
    /** Start of uniform block data in the buffer */
    GLintptr Offset;
    /** Size of data allowed to be referenced from the buffer (in bytes) */
diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
index e509fe4..8153c5e 100644
--- a/src/mesa/main/polygon.c
+++ b/src/mesa/main/polygon.c
@@ -59,21 +59,22 @@ _mesa_CullFace( GLenum mode )
       _mesa_debug(ctx, "glCullFace %s\n", _mesa_enum_to_string(mode));
 
    if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) {
       _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" );
       return;
    }
 
    if (ctx->Polygon.CullFaceMode == mode)
       return;
 
-   FLUSH_VERTICES(ctx, _NEW_POLYGON);
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+   ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
    ctx->Polygon.CullFaceMode = mode;
 
    if (ctx->Driver.CullFace)
       ctx->Driver.CullFace( ctx, mode );
 }
 
 
 /**
  * Define front- and back-facing
  *
@@ -94,21 +95,22 @@ _mesa_FrontFace( GLenum mode )
       _mesa_debug(ctx, "glFrontFace %s\n", _mesa_enum_to_string(mode));
 
    if (ctx->Polygon.FrontFace == mode)
       return;
 
    if (mode!=GL_CW && mode!=GL_CCW) {
       _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" );
       return;
    }
 
-   FLUSH_VERTICES(ctx, _NEW_POLYGON);
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+   ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
    ctx->Polygon.FrontFace = mode;
 
    if (ctx->Driver.FrontFace)
       ctx->Driver.FrontFace( ctx, mode );
 }
 
 
 /**
  * Set the polygon rasterization mode.
  *
@@ -146,38 +148,41 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
    }
 
    switch (face) {
    case GL_FRONT:
       if (ctx->API == API_OPENGL_CORE) {
          _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
          return;
       }
       if (ctx->Polygon.FrontMode == mode)
          return;
-      FLUSH_VERTICES(ctx, _NEW_POLYGON);
+      FLUSH_VERTICES(ctx, ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+      ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
       ctx->Polygon.FrontMode = mode;
       break;
    case GL_FRONT_AND_BACK:
       if (ctx->Polygon.FrontMode == mode && ctx->Polygon.BackMode == mode)
          return;
-      FLUSH_VERTICES(ctx, _NEW_POLYGON);
+      FLUSH_VERTICES(ctx, ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+      ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
       ctx->Polygon.FrontMode = mode;
       ctx->Polygon.BackMode = mode;
       break;
    case GL_BACK:
       if (ctx->API == API_OPENGL_CORE) {
          _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
          return;
       }
       if (ctx->Polygon.BackMode == mode)
          return;
-      FLUSH_VERTICES(ctx, _NEW_POLYGON);
+      FLUSH_VERTICES(ctx, ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+      ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
       ctx->Polygon.BackMode = mode;
       break;
    default:
       _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
       return;
    }
 
    if (ctx->Driver.PolygonMode)
       ctx->Driver.PolygonMode(ctx, face, mode);
 }
@@ -245,21 +250,22 @@ _mesa_GetPolygonStipple( GLubyte *dest )
 
 void
 _mesa_polygon_offset_clamp(struct gl_context *ctx,
                            GLfloat factor, GLfloat units, GLfloat clamp)
 {
    if (ctx->Polygon.OffsetFactor == factor &&
        ctx->Polygon.OffsetUnits == units &&
        ctx->Polygon.OffsetClamp == clamp)
       return;
 
-   FLUSH_VERTICES(ctx, _NEW_POLYGON);
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
+   ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
    ctx->Polygon.OffsetFactor = factor;
    ctx->Polygon.OffsetUnits = units;
    ctx->Polygon.OffsetClamp = clamp;
 
    if (ctx->Driver.PolygonOffset)
       ctx->Driver.PolygonOffset( ctx, factor, units, clamp );
 }
 
 void GLAPIENTRY
 _mesa_PolygonOffset( GLfloat factor, GLfloat units )
diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index 51ae669..5529f55 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -453,21 +453,24 @@ _mesa_ClipControl(GLenum origin, GLenum depth)
 
    /* Affects transform state and the viewport transform */
    FLUSH_VERTICES(ctx, ctx->DriverFlags.NewClipControl ? 0 :
                                           _NEW_TRANSFORM | _NEW_VIEWPORT);
    ctx->NewDriverState |= ctx->DriverFlags.NewClipControl;
 
    if (ctx->Transform.ClipOrigin != origin) {
       ctx->Transform.ClipOrigin = origin;
 
       /* Affects the winding order of the front face. */
-      ctx->NewState |= _NEW_POLYGON;
+      if (ctx->DriverFlags.NewPolygonState)
+         ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
+      else
+         ctx->NewState |= _NEW_POLYGON;
 
       if (ctx->Driver.FrontFace)
          ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
    }
 
    if (ctx->Transform.ClipDepthMode != depth) {
       ctx->Transform.ClipDepthMode = depth;
 
       if (ctx->Driver.DepthRange)
          ctx->Driver.DepthRange(ctx);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 5355b8c..e2a4ffb 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -205,22 +205,21 @@ st_invalidate_state(struct gl_context * ctx)
       if (new_state & _NEW_FRAG_CLAMP) {
          if (st->clamp_frag_color_in_shader)
             st->dirty |= ST_NEW_FS_STATE;
          else
             st->dirty |= ST_NEW_RASTERIZER;
       }
    }
 
    if (new_state & (_NEW_LIGHT |
                     _NEW_LINE |
-                    _NEW_POINT |
-                    _NEW_POLYGON))
+                    _NEW_POINT))
       st->dirty |= ST_NEW_RASTERIZER;
 
    if (new_state & _NEW_PROJECTION &&
        st_user_clip_planes_enabled(ctx))
       st->dirty |= ST_NEW_CLIP_STATE;
 
    if (new_state & _NEW_PIXEL)
       st->dirty |= ST_NEW_PIXEL_TRANSFER;
 
    if (new_state & _NEW_CURRENT_ATTRIB)
@@ -515,20 +514,21 @@ static void st_init_driver_flags(struct st_context *st)
       f->NewMultisampleEnable |= ST_NEW_FS_STATE;
       f->NewSampleShading |= ST_NEW_FS_STATE;
    } else {
       f->NewSampleShading |= ST_NEW_RASTERIZER;
    }
 
    f->NewClipControl = ST_NEW_VIEWPORT | ST_NEW_RASTERIZER;
    f->NewClipPlane = ST_NEW_CLIP_STATE;
    f->NewClipPlaneEnable = ST_NEW_RASTERIZER;
    f->NewDepthClamp = ST_NEW_RASTERIZER;
+   f->NewPolygonState = ST_NEW_RASTERIZER;
    f->NewViewport = ST_NEW_VIEWPORT;
 }
 
 struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
                                      const struct gl_config *visual,
                                      struct st_context *share,
                                      const struct st_config_options *options)
 {
    struct gl_context *ctx;
    struct gl_context *shareCtx = share ? share->ctx : NULL;
-- 
2.7.4



More information about the mesa-dev mailing list