[Mesa-dev] [PATCH 1/8] st/mesa: don't update clip state if it has no effect

Marek Olšák maraeo at gmail.com
Sun Aug 7 01:12:17 UTC 2016


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

---
 src/mesa/state_tracker/st_atom.c    | 3 ---
 src/mesa/state_tracker/st_context.c | 3 ++-
 src/mesa/state_tracker/st_context.h | 7 +++++++
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index 06c523e..b73ae32 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -134,23 +134,20 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
 
       pipeline_mask = ST_PIPELINE_RENDER_STATE_MASK;
 
       /* Don't update states that have no effect. */
       if (!ctx->TessCtrlProgram._Current)
          pipeline_mask &= ~ST_NEW_TCS_RESOURCES;
       if (!ctx->TessEvalProgram._Current)
          pipeline_mask &= ~ST_NEW_TES_RESOURCES;
       if (!ctx->GeometryProgram._Current)
          pipeline_mask &= ~ST_NEW_GS_RESOURCES;
-      if (!ctx->Transform.ClipPlanesEnabled)
-         pipeline_mask &= ~ST_NEW_CLIP_STATE;
-
       break;
    case ST_PIPELINE_COMPUTE:
       if (ctx->ComputeProgram._Current != &st->cp->Base)
          st->dirty |= ST_NEW_COMPUTE_PROGRAM;
 
       st->compute_shader_may_be_dirty = false;
       pipeline_mask = ST_PIPELINE_COMPUTE_STATE_MASK;
       break;
    default:
       unreachable("Invalid pipeline specified");
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index e4dd6fa..1ff0355 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -186,21 +186,22 @@ void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state)
        */
       if (new_state & (_NEW_LIGHT |
                        _NEW_LINE |
                        _NEW_POINT |
                        _NEW_POLYGON |
                        _NEW_TRANSFORM))
          st->dirty |= ST_NEW_RASTERIZER;
    }
 
    if (new_state & (_NEW_PROJECTION |
-                    _NEW_TRANSFORM))
+                    _NEW_TRANSFORM) &&
+       st_user_clip_planes_enabled(ctx))
       st->dirty |= ST_NEW_CLIP_STATE;
 
    if (new_state & _NEW_COLOR)
       st->dirty |= ST_NEW_BLEND |
                    ST_NEW_DSA;
 
    if (new_state & _NEW_PIXEL)
       st->dirty |= ST_NEW_PIXEL_TRANSFER;
 
    if (new_state & _NEW_TEXTURE)
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index e0f29e3..556b9c9 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -329,20 +329,27 @@ st_shader_stage_to_ptarget(gl_shader_stage stage)
    case MESA_SHADER_TESS_EVAL:
       return PIPE_SHADER_TESS_EVAL;
    case MESA_SHADER_COMPUTE:
       return PIPE_SHADER_COMPUTE;
    }
 
    assert(!"should not be reached");
    return PIPE_SHADER_VERTEX;
 }
 
+static inline bool
+st_user_clip_planes_enabled(struct gl_context *ctx)
+{
+   return (ctx->API == API_OPENGL_COMPAT ||
+           ctx->API == API_OPENGLES) && /* only ES 1.x */
+          ctx->Transform.ClipPlanesEnabled;
+}
 
 /** clear-alloc a struct-sized object, with casting */
 #define ST_CALLOC_STRUCT(T)   (struct T *) calloc(1, sizeof(struct T))
 
 
 extern 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);
-- 
2.7.4



More information about the mesa-dev mailing list