[Mesa-dev] [PATCH 22/31] mesa: don't flag _NEW_TRANSFORM for st/mesa if possible

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


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

---
 src/mesa/main/clip.c                |  2 ++
 src/mesa/main/enable.c              | 15 +++++++++++++--
 src/mesa/main/mtypes.h              | 11 ++++++++++-
 src/mesa/state_tracker/st_context.c |  9 +++++----
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c
index f994728..0950283 100644
--- a/src/mesa/main/clip.c
+++ b/src/mesa/main/clip.c
@@ -76,21 +76,23 @@ _mesa_ClipPlane( GLenum plane, const GLdouble *eq )
     */
    if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top))
       _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
 
    _mesa_transform_vector( equation, equation,
                            ctx->ModelviewMatrixStack.Top->inv );
 
    if (TEST_EQ_4V(ctx->Transform.EyeUserPlane[p], equation))
       return;
 
+   /* EyeUserPlane is used by program state constants. */
    FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+   ctx->NewDriverState |= ctx->DriverFlags.NewClipPlane;
    COPY_4FV(ctx->Transform.EyeUserPlane[p], equation);
 
    if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
       _mesa_update_clip_plane(ctx, p);
    }
 
    if (ctx->Driver.ClipPlane)
       ctx->Driver.ClipPlane( ctx, plane, equation );
 }
 
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 7955007..38bbe5f 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -339,21 +339,30 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          {
             const GLuint p = cap - GL_CLIP_DISTANCE0;
 
             if (p >= ctx->Const.MaxClipPlanes)
                goto invalid_enum_error;
 
             if ((ctx->Transform.ClipPlanesEnabled & (1 << p))
                 == ((GLuint) state << p))
                return;
 
-            FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+            /* The compatibility profile needs _NEW_TRANSFORM to transform
+             * clip planes according to the projection matrix.
+             */
+            if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES ||
+                !ctx->DriverFlags.NewClipPlaneEnable) {
+               FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+            } else {
+               FLUSH_VERTICES(ctx, 0);
+            }
+            ctx->NewDriverState |= ctx->DriverFlags.NewClipPlaneEnable;
 
             if (state) {
                ctx->Transform.ClipPlanesEnabled |= (1 << p);
                _mesa_update_clip_plane(ctx, p);
             }
             else {
                ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
             }               
          }
          break;
@@ -966,21 +975,23 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          ctx->NewDriverState |= ctx->DriverFlags.NewDepth;
          ctx->Depth.BoundsTest = state;
          break;
 
       case GL_DEPTH_CLAMP:
          if (!_mesa_is_desktop_gl(ctx))
             goto invalid_enum_error;
 	 CHECK_EXTENSION(ARB_depth_clamp, cap);
          if (ctx->Transform.DepthClamp == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+         FLUSH_VERTICES(ctx, ctx->DriverFlags.NewDepthClamp ? 0 :
+                                                           _NEW_TRANSFORM);
+         ctx->NewDriverState |= ctx->DriverFlags.NewDepthClamp;
 	 ctx->Transform.DepthClamp = state;
 	 break;
 
       case GL_FRAGMENT_SHADER_ATI:
          if (ctx->API != API_OPENGL_COMPAT)
             goto invalid_enum_error;
         CHECK_EXTENSION(ATI_fragment_shader, cap);
 	if (ctx->ATIFragmentShader.Enabled == state)
 	  return;
 	FLUSH_VERTICES(ctx, _NEW_PROGRAM);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 55682e2..833932b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4429,23 +4429,32 @@ struct gl_driver_flags
 
    /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
    uint64_t NewSampleMask;
 
    /** gl_context::Multisample::(Min)SampleShading */
    uint64_t NewSampleShading;
 
    /** gl_context::Stencil */
    uint64_t NewStencil;
 
-   /** gl_context::Transform::Clip* */
+   /** gl_context::Transform::ClipOrigin/ClipDepthMode */
    uint64_t NewClipControl;
 
+   /** gl_context::Transform::EyeUserPlane */
+   uint64_t NewClipPlane;
+
+   /** gl_context::Transform::ClipPlanesEnabled */
+   uint64_t NewClipPlaneEnable;
+
+   /** gl_context::Transform::DepthClamp */
+   uint64_t NewDepthClamp;
+
    /** 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/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 357b838..5355b8c 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -206,26 +206,24 @@ st_invalidate_state(struct gl_context * ctx)
          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_TRANSFORM))
+                    _NEW_POLYGON))
       st->dirty |= ST_NEW_RASTERIZER;
 
-   if (new_state & (_NEW_PROJECTION |
-                    _NEW_TRANSFORM) &&
+   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)
       st->dirty |= ST_NEW_VERTEX_ARRAYS;
 
    /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
@@ -514,20 +512,23 @@ static void st_init_driver_flags(struct st_context *st)
 
    /* This depends on what the gallium driver wants. */
    if (st->force_persample_in_shader) {
       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->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