On 8 November 2011 14:32, Kenneth Graunke <span dir="ltr">&lt;<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
These were only split for historical reasons: brw_wm_constants used to<br>
be the &quot;prepare&quot; step, while brw_wm_constant_surface was &quot;emit&quot;.  Now<br>
that both happen at emit time, it makes sense to combine them.<br>
<br>
Call the newly combined state atom &quot;brw_wm_pull_constants&quot; to indicate<br>
help distinguish it from the Gen6+ atoms that handle push constants.<br>
<br>
Finally, remove the BRW_NEW_WM_CONSTBUF dirty bit entirely now that it&#39;s<br>
never flagged nor used.<br>
<br>
Signed-off-by: Kenneth Graunke &lt;<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>&gt;<br>
---<br>
 src/mesa/drivers/dri/i965/brw_context.h          |    2 -<br>
 src/mesa/drivers/dri/i965/brw_state.h            |    3 +-<br>
 src/mesa/drivers/dri/i965/brw_state_upload.c     |   10 +---<br>
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   58 ++++-----------------<br>
 4 files changed, 15 insertions(+), 58 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 f8e6f81..c889e54 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -142,7 +142,6 @@ enum brw_state_id {<br>
    BRW_STATE_NR_VS_SURFACES,<br>
    BRW_STATE_INDEX_BUFFER,<br>
    BRW_STATE_VS_CONSTBUF,<br>
-   BRW_STATE_WM_CONSTBUF,<br>
    BRW_STATE_PROGRAM_CACHE,<br>
    BRW_STATE_STATE_BASE_ADDRESS,<br>
 };<br>
@@ -171,7 +170,6 @@ enum brw_state_id {<br>
 /** \see brw.state.depth_region */<br>
 #define BRW_NEW_INDEX_BUFFER           (1 &lt;&lt; BRW_STATE_INDEX_BUFFER)<br>
 #define BRW_NEW_VS_CONSTBUF            (1 &lt;&lt; BRW_STATE_VS_CONSTBUF)<br>
-#define BRW_NEW_WM_CONSTBUF            (1 &lt;&lt; BRW_STATE_WM_CONSTBUF)<br>
 #define BRW_NEW_PROGRAM_CACHE          (1 &lt;&lt; BRW_STATE_PROGRAM_CACHE)<br>
 #define BRW_NEW_STATE_BASE_ADDRESS     (1 &lt;&lt; BRW_STATE_STATE_BASE_ADDRESS)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h<br>
index 6357188..3979206 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_state.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_state.h<br>
@@ -42,7 +42,7 @@ extern const struct brw_tracked_state brw_check_fallback;<br>
 extern const struct brw_tracked_state brw_clip_prog;<br>
 extern const struct brw_tracked_state brw_clip_unit;<br>
 extern const struct brw_tracked_state brw_vs_constants;<br>
-extern const struct brw_tracked_state brw_wm_constants;<br>
+extern const struct brw_tracked_state brw_wm_pull_constants;<br>
 extern const struct brw_tracked_state brw_constant_buffer;<br>
 extern const struct brw_tracked_state brw_curbe_offsets;<br>
 extern const struct brw_tracked_state brw_invarient_state;<br>
@@ -69,7 +69,6 @@ extern const struct brw_tracked_state brw_vs_unit;<br>
 extern const struct brw_tracked_state brw_wm_input_sizes;<br>
 extern const struct brw_tracked_state brw_wm_prog;<br>
 extern const struct brw_tracked_state brw_wm_samplers;<br>
-extern const struct brw_tracked_state brw_wm_constant_surface;<br>
 extern const struct brw_tracked_state brw_wm_surfaces;<br>
 extern const struct brw_tracked_state brw_wm_binding_table;<br>
 extern const struct brw_tracked_state brw_wm_unit;<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 40563ec..d3bc5e0 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
@@ -64,10 +64,9 @@ static const struct brw_tracked_state *gen4_atoms[] =<br>
    &amp;brw_cc_unit,<br>
<br>
    &amp;brw_vs_constants, /* Before vs_surfaces and constant_buffer */<br>
-   &amp;brw_wm_constants, /* Before wm_surfaces and constant_buffer */<br>
+   &amp;brw_wm_pull_constants, /* Before brw_wm_binding_table */<br>
<br>
    &amp;brw_vs_surfaces,           /* must do before unit */<br>
-   &amp;brw_wm_constant_surface,   /* must do before wm surfaces/bind bo */<br>
    &amp;brw_wm_surfaces,           /* must do before samplers and unit */<br>
    &amp;brw_wm_binding_table,<br>
    &amp;brw_wm_samplers,<br>
@@ -134,12 +133,11 @@ static const struct brw_tracked_state *gen6_atoms[] =<br>
    &amp;gen6_cc_state_pointers,<br>
<br>
    &amp;brw_vs_constants, /* Before vs_surfaces and constant_buffer */<br>
-   &amp;brw_wm_constants, /* Before wm_surfaces and constant_buffer */<br>
+   &amp;brw_wm_pull_constants,  /* Before brw_wm_binding_table */<br>
    &amp;gen6_vs_push_constants, /* Before vs_state */<br>
    &amp;gen6_wm_push_constants, /* Before wm_state */<br>
<br>
    &amp;brw_vs_surfaces,           /* must do before unit */<br>
-   &amp;brw_wm_constant_surface,   /* must do before wm surfaces/bind bo */<br>
    &amp;brw_wm_surfaces,           /* must do before samplers and unit */<br>
    &amp;brw_wm_binding_table,<br>
<br>
@@ -199,12 +197,11 @@ const struct brw_tracked_state *gen7_atoms[] =<br>
    &amp;gen7_depth_stencil_state_pointer,<br>
<br>
    &amp;brw_vs_constants, /* Before vs_surfaces and constant_buffer */<br>
-   &amp;brw_wm_constants, /* Before wm_surfaces and constant_buffer */<br>
+   &amp;brw_wm_pull_constants,  /* Before brw_wm_binding_table */<br>
    &amp;gen6_vs_push_constants, /* Before vs_state */<br>
    &amp;gen6_wm_push_constants, /* Before wm_surfaces and constant_buffer */<br>
<br>
    &amp;brw_vs_surfaces,           /* must do before unit */<br>
-   &amp;brw_wm_constant_surface,   /* must do before wm surfaces/bind bo */<br>
    &amp;brw_wm_surfaces,           /* must do before samplers and unit */<br>
    &amp;brw_wm_binding_table,<br>
<br>
@@ -358,7 +355,6 @@ static struct dirty_bit_map brw_bits[] = {<br>
    DEFINE_BIT(BRW_NEW_VERTICES),<br>
    DEFINE_BIT(BRW_NEW_BATCH),<br>
    DEFINE_BIT(BRW_NEW_VS_CONSTBUF),<br>
-   DEFINE_BIT(BRW_NEW_WM_CONSTBUF),<br>
    DEFINE_BIT(BRW_NEW_VS_BINDING_TABLE),<br>
    DEFINE_BIT(BRW_NEW_GS_BINDING_TABLE),<br>
    DEFINE_BIT(BRW_NEW_PS_BINDING_TABLE),<br>
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
index c5e5efb..2cc9392 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
@@ -328,18 +328,21 @@ brw_upload_wm_pull_constants(struct brw_context *brw)<br>
    /* BRW_NEW_FRAGMENT_PROGRAM */<br>
    struct brw_fragment_program *fp =<br>
       (struct brw_fragment_program *) brw-&gt;fragment_program;<br>
+   struct gl_program_parameter_list *params = fp-&gt;program.Base.Parameters;<br>
    const int size = brw-&gt;wm.prog_data-&gt;nr_pull_params * sizeof(float);<br>
+   const int surf_index = SURF_INDEX_FRAG_CONST_BUFFER;<br>
    float *constants;<br>
    unsigned int i;<br>
<br>
-   _mesa_load_state_parameters(ctx, fp-&gt;program.Base.Parameters);<br>
+   _mesa_load_state_parameters(ctx, params);<br>
<br>
    /* CACHE_NEW_WM_PROG */<br>
    if (brw-&gt;wm.prog_data-&gt;nr_pull_params == 0) {<br>
       if (brw-&gt;wm.const_bo) {<br>
         drm_intel_bo_unreference(brw-&gt;wm.const_bo);<br>
         brw-&gt;wm.const_bo = NULL;<br>
-        brw-&gt;state.dirty.brw |= BRW_NEW_WM_CONSTBUF;<br>
+        brw-&gt;wm.surf_offset[surf_index] = 0;<br>
+        brw-&gt;state.dirty.brw |= BRW_NEW_WM_SURFACES;<br>
       }<br>
       return;<br>
    }<br>
@@ -357,10 +360,14 @@ brw_upload_wm_pull_constants(struct brw_context *brw)<br>
    }<br>
    drm_intel_gem_bo_unmap_gtt(brw-&gt;wm.const_bo);<br>
<br>
-   brw-&gt;state.dirty.brw |= BRW_NEW_WM_CONSTBUF;<br>
+   intel-&gt;vtbl.create_constant_surface(brw, brw-&gt;wm.const_bo,<br>
+                                      params-&gt;NumParameters,<br>
+                                      &amp;brw-&gt;wm.surf_offset[surf_index]);<br>
+<br>
+   brw-&gt;state.dirty.brw |= BRW_NEW_WM_SURFACES;<br>
 }<br>
<br>
-const struct brw_tracked_state brw_wm_constants = {<br>
+const struct brw_tracked_state brw_wm_pull_constants = {<br>
    .dirty = {<br>
       .mesa = (_NEW_PROGRAM_CONSTANTS),<br>
       .brw = (BRW_NEW_FRAGMENT_PROGRAM),<br></blockquote><div><br>It seems like we should add a dependency on BRW_NEW_BATCH here (since that dependency previously existed on brw_wm_constant_surface).<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

@@ -369,49 +376,6 @@ const struct brw_tracked_state brw_wm_constants = {<br>
    .emit = brw_upload_wm_pull_constants,<br>
 };<br>
<br>
-/**<br>
- * Updates surface / buffer for fragment shader constant buffer, if<br>
- * one is required.<br>
- *<br>
- * This consumes the state updates for the constant buffer, and produces<br>
- * BRW_NEW_WM_SURFACES to get picked up by brw_prepare_wm_surfaces for<br>
- * inclusion in the binding table.<br>
- */<br>
-static void upload_wm_constant_surface(struct brw_context *brw )<br>
-{<br>
-   GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;<br>
-   struct brw_fragment_program *fp =<br>
-      (struct brw_fragment_program *) brw-&gt;fragment_program;<br>
-   const struct gl_program_parameter_list *params =<br>
-      fp-&gt;program.Base.Parameters;<br>
-<br>
-   /* If there&#39;s no constant buffer, then no surface BO is needed to point at<br>
-    * it.<br>
-    */<br>
-   if (brw-&gt;wm.const_bo == 0) {<br>
-      if (brw-&gt;wm.surf_offset[surf]) {<br>
-        brw-&gt;state.dirty.brw |= BRW_NEW_WM_SURFACES;<br>
-        brw-&gt;wm.surf_offset[surf] = 0;<br>
-      }<br>
-      return;<br>
-   }<br>
-<br>
-   brw-&gt;intel.vtbl.create_constant_surface(brw, brw-&gt;wm.const_bo,<br>
-                                          params-&gt;NumParameters,<br>
-                                          &amp;brw-&gt;wm.surf_offset[surf]);<br>
-   brw-&gt;state.dirty.brw |= BRW_NEW_WM_SURFACES;<br>
-}<br>
-<br>
-const struct brw_tracked_state brw_wm_constant_surface = {<br>
-   .dirty = {<br>
-      .mesa = 0,<br>
-      .brw = (BRW_NEW_WM_CONSTBUF |<br>
-             BRW_NEW_BATCH),<br></blockquote><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
-      .cache = 0<br>
-   },<br>
-   .emit = upload_wm_constant_surface,<br>
-};<br>
-<br>
 static void<br>
 brw_update_null_renderbuffer_surface(struct brw_context *brw, unsigned int unit)<br>
 {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.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" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>