mesa: don't flag _NEW_TRANSFORM for st/mesa if possible
authorMarek Olšák <marek.olsak@amd.com>
Sat, 10 Jun 2017 10:09:43 +0000 (12:09 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/clip.c
src/mesa/main/enable.c
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_context.c

index f994728bc9595f3948d31586dcee2fd4606e8460..0950283ff3c6953cdba750d1561b5795a8a02921 100644 (file)
@@ -83,7 +83,9 @@ _mesa_ClipPlane( GLenum plane, const GLdouble *eq )
    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)) {
index f5bd48cd90f7d81c6667c3aad76af998c8b5e4be..2f348d8940fd2eca15123eca88a6a0de86dec329 100644 (file)
@@ -346,7 +346,16 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
                 == ((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);
@@ -973,7 +982,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          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;
 
index 59292f0c8a45866442af5d64bdf29e6962def05e..2d27e767a2a141af8f26ae43a2cd9cec3ca0d417 100644 (file)
@@ -4508,9 +4508,18 @@ struct gl_driver_flags
    /** 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;
 };
index c5f46aedb456253f6519f5e46c9f2b080caa8a35..23aad0a1f41ecf0aecc8031b707a1f95d397e1dd 100644 (file)
@@ -213,12 +213,10 @@ st_invalidate_state(struct gl_context * ctx)
    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;
 
@@ -523,6 +521,9 @@ static void st_init_driver_flags(struct st_context *st)
    }
 
    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;
 }