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

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


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

---
 src/mesa/state_tracker/st_atom.c        |  4 ++--
 src/mesa/state_tracker/st_atom.h        | 23 ++++++++++++-----------
 src/mesa/state_tracker/st_cb_feedback.c |  2 +-
 src/mesa/state_tracker/st_cb_program.c  |  2 +-
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index b73ae32..7548a29 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -58,21 +58,21 @@ void st_destroy_atoms( struct st_context *st )
 }
 
 
 /* Too complex to figure out, just check every time:
  */
 static void check_program_state( struct st_context *st )
 {
    struct gl_context *ctx = st->ctx;
 
    if (ctx->VertexProgram._Current != &st->vp->Base)
-      st->dirty |= ST_NEW_VERTEX_PROGRAM;
+      st->dirty |= ST_NEW_VERTEX_PROGRAM(st);
 
    if (ctx->FragmentProgram._Current != &st->fp->Base)
       st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
 
    if (ctx->GeometryProgram._Current != &st->gp->Base)
       st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
 
    if (ctx->TessCtrlProgram._Current != &st->tcp->Base)
       st->dirty |= ST_NEW_TESSCTRL_PROGRAM;
 
@@ -90,21 +90,21 @@ static void check_attrib_edgeflag(struct st_context *st)
    if (!arrays)
       return;
 
    edgeflags_enabled = st->ctx->Polygon.FrontMode != GL_FILL ||
                        st->ctx->Polygon.BackMode != GL_FILL;
 
    vertdata_edgeflags = edgeflags_enabled &&
                         arrays[VERT_ATTRIB_EDGEFLAG]->StrideB != 0;
    if (vertdata_edgeflags != st->vertdata_edgeflags) {
       st->vertdata_edgeflags = vertdata_edgeflags;
-      st->dirty |= ST_NEW_VERTEX_PROGRAM;
+      st->dirty |= ST_NEW_VERTEX_PROGRAM(st);
    }
 
    edgeflag_culls_prims = edgeflags_enabled && !vertdata_edgeflags &&
                           !st->ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0];
    if (edgeflag_culls_prims != st->edgeflag_culls_prims) {
       st->edgeflag_culls_prims = edgeflag_culls_prims;
       st->dirty |= ST_NEW_RASTERIZER;
    }
 }
 
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index febd7ce..7c8cd3a 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -81,31 +81,32 @@ enum {
 #undef ST_STATE
 
 /* Combined state flags. */
 #define ST_NEW_SAMPLERS         (ST_NEW_RENDER_SAMPLERS | \
                                  ST_NEW_CS_SAMPLERS)
 
 #define ST_NEW_FRAMEBUFFER      (ST_NEW_FB_STATE | \
                                  ST_NEW_SAMPLE_MASK | \
                                  ST_NEW_SAMPLE_SHADING)
 
-#define ST_NEW_VERTEX_PROGRAM   (ST_NEW_VS_STATE | \
-                                 ST_NEW_VS_SAMPLER_VIEWS | \
-                                 ST_NEW_VS_IMAGES | \
-                                 ST_NEW_VS_CONSTANTS | \
-                                 ST_NEW_VS_UBOS | \
-                                 ST_NEW_VS_ATOMICS | \
-                                 ST_NEW_VS_SSBOS | \
-                                 ST_NEW_VERTEX_ARRAYS | \
-                                 ST_NEW_CLIP_STATE | \
-                                 ST_NEW_RASTERIZER | \
-                                 ST_NEW_RENDER_SAMPLERS)
+#define ST_NEW_VERTEX_PROGRAM(st) (ST_NEW_VS_STATE | \
+                                   ST_NEW_VS_SAMPLER_VIEWS | \
+                                   ST_NEW_VS_IMAGES | \
+                                   ST_NEW_VS_CONSTANTS | \
+                                   ST_NEW_VS_UBOS | \
+                                   ST_NEW_VS_ATOMICS | \
+                                   ST_NEW_VS_SSBOS | \
+                                   ST_NEW_VERTEX_ARRAYS | \
+                                   (st_user_clip_planes_enabled(st->ctx) ? \
+                                    ST_NEW_CLIP_STATE : 0) | \
+                                   ST_NEW_RASTERIZER | \
+                                   ST_NEW_RENDER_SAMPLERS)
 
 #define ST_NEW_TCS_RESOURCES    (ST_NEW_TCS_SAMPLER_VIEWS | \
                                  ST_NEW_TCS_IMAGES | \
                                  ST_NEW_TCS_CONSTANTS | \
                                  ST_NEW_TCS_UBOS | \
                                  ST_NEW_TCS_ATOMICS | \
                                  ST_NEW_TCS_SSBOS)
 
 #define ST_NEW_TESSCTRL_PROGRAM (ST_NEW_TCS_STATE | \
                                  ST_NEW_TCS_RESOURCES | \
diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c
index a18f4f7..db682cc 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -290,20 +290,20 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
       /* Plug in new vbo draw function */
       vbo_set_draw_func(ctx, st_feedback_draw_vbo);
    }
    else {
       if (!st->feedback_stage)
          st->feedback_stage = draw_glfeedback_stage(ctx, draw);
       draw_set_rasterize_stage(draw, st->feedback_stage);
       /* Plug in new vbo draw function */
       vbo_set_draw_func(ctx, st_feedback_draw_vbo);
       /* need to generate/use a vertex program that emits pos/color/tex */
-      st->dirty |= ST_NEW_VERTEX_PROGRAM;
+      st->dirty |= ST_NEW_VERTEX_PROGRAM(st);
    }
 }
 
 
 
 void st_init_feedback_functions(struct dd_function_table *functions)
 {
    functions->RenderMode = st_RenderMode;
 }
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 8291edb..1783a1c 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -208,21 +208,21 @@ st_program_string_notify( struct gl_context *ctx,
 	 st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
    }
    else if (target == GL_VERTEX_PROGRAM_ARB) {
       struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
 
       st_release_vp_variants(st, stvp);
       if (!st_translate_vertex_program(st, stvp))
          return false;
 
       if (st->vp == stvp)
-	 st->dirty |= ST_NEW_VERTEX_PROGRAM;
+	 st->dirty |= ST_NEW_VERTEX_PROGRAM(st);
    }
    else if (target == GL_TESS_CONTROL_PROGRAM_NV) {
       struct st_tessctrl_program *sttcp =
          (struct st_tessctrl_program *) prog;
 
       st_release_basic_variants(st, sttcp->Base.Base.Target,
                                 &sttcp->variants, &sttcp->tgsi);
       if (!st_translate_tessctrl_program(st, sttcp))
          return false;
 
-- 
2.7.4



More information about the mesa-dev mailing list