<div dir="ltr"><div>For the v2 series:<br><br></div>Reviewed-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz">chrisf@ijw.co.nz</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 12, 2015 at 6:58 PM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The old code was disasterously complex - spread across multiple atoms<br>
which may not even run, inspecting the dirty bits to try and decide<br>
whether it was necessary to do checks...storing VS information in<br>
brw_context...extra flagging...<br>
<br>
This code tripped me and Carl up very badly when working on the<br>
shader cache code.  It's very fragile and hard to maintain.<br>
<br>
Now that geometry shaders only depend on their inputs and don't have<br>
to worry about the VS VUE map, we can dramatically simplify this:<br>
just compute the VUE map coming out of the geometry shader stage<br>
in brw_upload_programs.  If it changes, flag it.  Done.<br>
<br>
v2: Also check vue_map.separable.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
Reviewed-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz">chrisf@ijw.co.nz</a>> [v1]<br>
---<br>
 src/mesa/drivers/dri/i965/brw_context.h      | 12 +-----------<br>
 src/mesa/drivers/dri/i965/brw_gs.c           | 16 +---------------<br>
 src/mesa/drivers/dri/i965/brw_state_upload.c | 16 +++++++++++++++-<br>
 src/mesa/drivers/dri/i965/brw_vs.c           | 15 ---------------<br>
 4 files changed, 17 insertions(+), 42 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h<br>
index 772a9fd..4cac30c 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -194,7 +194,6 @@ enum brw_state_id {<br>
    BRW_STATE_GS_CONSTBUF,<br>
    BRW_STATE_PROGRAM_CACHE,<br>
    BRW_STATE_STATE_BASE_ADDRESS,<br>
-   BRW_STATE_VUE_MAP_VS,<br>
    BRW_STATE_VUE_MAP_GEOM_OUT,<br>
    BRW_STATE_TRANSFORM_FEEDBACK,<br>
    BRW_STATE_RASTERIZER_DISCARD,<br>
@@ -276,7 +275,6 @@ enum brw_state_id {<br>
 #define BRW_NEW_GS_CONSTBUF             (1ull << BRW_STATE_GS_CONSTBUF)<br>
 #define BRW_NEW_PROGRAM_CACHE           (1ull << BRW_STATE_PROGRAM_CACHE)<br>
 #define BRW_NEW_STATE_BASE_ADDRESS      (1ull << BRW_STATE_STATE_BASE_ADDRESS)<br>
-#define BRW_NEW_VUE_MAP_VS              (1ull << BRW_STATE_VUE_MAP_VS)<br>
 #define BRW_NEW_VUE_MAP_GEOM_OUT        (1ull << BRW_STATE_VUE_MAP_GEOM_OUT)<br>
 #define BRW_NEW_TRANSFORM_FEEDBACK      (1ull << BRW_STATE_TRANSFORM_FEEDBACK)<br>
 #define BRW_NEW_RASTERIZER_DISCARD      (1ull << BRW_STATE_RASTERIZER_DISCARD)<br>
@@ -1375,16 +1373,8 @@ struct brw_context<br>
    } curbe;<br>
<br>
    /**<br>
-    * Layout of vertex data exiting the vertex shader.<br>
-    *<br>
-    * BRW_NEW_VUE_MAP_VS is flagged when this VUE map changes.<br>
-    */<br>
-   struct brw_vue_map vue_map_vs;<br>
-<br>
-   /**<br>
     * Layout of vertex data exiting the geometry portion of the pipleine.<br>
-    * This comes from the geometry shader if one exists, otherwise from the<br>
-    * vertex shader.<br>
+    * This comes from the last enabled shader stage (GS, DS, or VS).<br>
     *<br>
     * BRW_NEW_VUE_MAP_GEOM_OUT is flagged when the VUE map changes.<br>
     */<br>
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c<br>
index 77be9d9..1f219c0 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_gs.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_gs.c<br>
@@ -297,8 +297,7 @@ brw_gs_state_dirty(struct brw_context *brw)<br>
    return brw_state_dirty(brw,<br>
                           _NEW_TEXTURE,<br>
                           BRW_NEW_GEOMETRY_PROGRAM |<br>
-                          BRW_NEW_TRANSFORM_FEEDBACK |<br>
-                          BRW_NEW_VUE_MAP_VS);<br>
+                          BRW_NEW_TRANSFORM_FEEDBACK);<br>
 }<br>
<br>
 static void<br>
@@ -336,11 +335,6 @@ brw_upload_gs_prog(struct brw_context *brw)<br>
<br>
    if (gp == NULL) {<br>
       /* No geometry shader.  Vertex data just passes straight through. */<br>
-      if (brw->ctx.NewDriverState & BRW_NEW_VUE_MAP_VS) {<br>
-         brw->vue_map_geom_out = brw->vue_map_vs;<br>
-         brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT;<br>
-      }<br>
-<br>
       if (brw->gen == 6 &&<br>
           (brw->ctx.NewDriverState & BRW_NEW_TRANSFORM_FEEDBACK)) {<br>
          gen6_brw_upload_ff_gs_prog(brw);<br>
@@ -367,14 +361,6 @@ brw_upload_gs_prog(struct brw_context *brw)<br>
       (void)success;<br>
    }<br>
    brw->gs.base.prog_data = &brw->gs.prog_data->base.base;<br>
-<br>
-   if (brw->gs.prog_data->base.vue_map.slots_valid !=<br>
-       brw->vue_map_geom_out.slots_valid ||<br>
-       brw->gs.prog_data->base.vue_map.separate !=<br>
-       brw->vue_map_geom_out.separate) {<br>
-      brw->vue_map_geom_out = brw->gs.prog_data->base.vue_map;<br>
-      brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT;<br>
-   }<br>
 }<br>
<br>
 bool<br>
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
index 14627d5..89fde52 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
@@ -593,7 +593,6 @@ static struct dirty_bit_map brw_bits[] = {<br>
    DEFINE_BIT(BRW_NEW_GS_CONSTBUF),<br>
    DEFINE_BIT(BRW_NEW_PROGRAM_CACHE),<br>
    DEFINE_BIT(BRW_NEW_STATE_BASE_ADDRESS),<br>
-   DEFINE_BIT(BRW_NEW_VUE_MAP_VS),<br>
    DEFINE_BIT(BRW_NEW_VUE_MAP_GEOM_OUT),<br>
    DEFINE_BIT(BRW_NEW_TRANSFORM_FEEDBACK),<br>
    DEFINE_BIT(BRW_NEW_RASTERIZER_DISCARD),<br>
@@ -648,6 +647,21 @@ brw_upload_programs(struct brw_context *brw,<br>
       else<br>
          brw_upload_gs_prog(brw);<br>
<br>
+      /* Update the VUE map for data exiting the GS stage of the pipeline.<br>
+       * This comes from the last enabled shader stage.<br>
+       */<br>
+      GLbitfield64 old_slots = brw->vue_map_geom_out.slots_valid;<br>
+      bool old_separate = brw->vue_map_geom_out.separate;<br>
+      if (brw->geometry_program)<br>
+         brw->vue_map_geom_out = brw->gs.prog_data->base.vue_map;<br>
+      else<br>
+         brw->vue_map_geom_out = brw->vs.prog_data->base.vue_map;<br>
+<br>
+      /* If the layout has changed, signal BRW_NEW_VUE_MAP_GEOM_OUT. */<br>
+      if (old_slots != brw->vue_map_geom_out.slots_valid ||<br>
+          old_separate != brw->vue_map_geom_out.separate)<br>
+         brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT;<br>
+<br>
       brw_upload_wm_prog(brw);<br>
    } else if (pipeline == BRW_COMPUTE_PIPELINE) {<br>
       brw_upload_cs_prog(brw);<br>
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c<br>
index adc1810..6f4c110 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_vs.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_vs.c<br>
@@ -368,21 +368,6 @@ brw_upload_vs_prog(struct brw_context *brw)<br>
       assert(success);<br>
    }<br>
    brw->vs.base.prog_data = &brw->vs.prog_data->base.base;<br>
-<br>
-   if (brw->vs.prog_data->base.vue_map.slots_valid !=<br>
-       brw->vue_map_geom_out.slots_valid ||<br>
-       brw->vs.prog_data->base.vue_map.separate !=<br>
-       brw->vue_map_geom_out.separate) {<br>
-      brw->vue_map_vs = brw->vs.prog_data->base.vue_map;<br>
-      brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_VS;<br>
-      if (brw->gen < 6) {<br>
-         /* No geometry shader support, so the VS VUE map is the VUE map for<br>
-          * the output of the "geometry" portion of the pipeline.<br>
-          */<br>
-         brw->vue_map_geom_out = brw->vue_map_vs;<br>
-         brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT;<br>
-      }<br>
-   }<br>
 }<br>
<br>
 bool<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>