<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 22, 2016 at 4:26 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">They're basically the same.  Let's avoid the code duplication.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_state.h        |  2 +-<br>
 src/mesa/drivers/dri/i965/brw_state_upload.c |  2 +-<br>
 src/mesa/drivers/dri/i965/gen7_sol_state.c   | 32 ++++++++--<br>
 src/mesa/drivers/dri/i965/gen8_sol_state.c   | 90 +---------------------------<br>
 4 files changed, 31 insertions(+), 95 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h<br>
index b29412e..a16e876 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_state.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_state.h<br>
@@ -166,7 +166,6 @@ extern const struct brw_tracked_state gen8_wm_state;<br>
 extern const struct brw_tracked_state gen8_raster_state;<br>
 extern const struct brw_tracked_state gen8_sbe_state;<br>
 extern const struct brw_tracked_state gen8_sf_state;<br>
-extern const struct brw_tracked_state gen8_sol_state;<br>
 extern const struct brw_tracked_state gen8_sf_clip_viewport;<br>
 extern const struct brw_tracked_state gen8_vertices;<br>
 extern const struct brw_tracked_state gen8_vf_topology;<br>
@@ -303,6 +302,7 @@ void gen8_upload_ps_extra(struct brw_context *brw,<br>
 /* gen7_sol_state.c */<br>
 void gen7_upload_3dstate_so_decl_list(struct brw_context *brw,<br>
                                       const struct brw_vue_map *vue_map);<br>
+void gen8_upload_3dstate_so_buffers(struct brw_context *brw);<br>
<br>
 /* gen8_surface_state.c */<br>
<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 0b47ebe..4a20821 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
@@ -337,7 +337,7 @@ static const struct brw_tracked_state *gen8_render_atoms[] =<br>
    &gen7_te_state,<br>
    &gen8_ds_state,<br>
    &gen8_gs_state,<br>
-   &gen8_sol_state,<br>
+   &gen7_sol_state,<br>
    &gen6_clip_state,<br>
    &gen8_raster_state,<br>
    &gen8_sbe_state,<br>
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c<br>
index 4749cc8..8fcc591 100644<br>
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c<br>
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c<br>
@@ -222,7 +222,9 @@ upload_3dstate_streamout(struct brw_context *brw, bool active,<br>
    /* BRW_NEW_TRANSFORM_FEEDBACK */<br>
    struct gl_transform_feedback_object *xfb_obj =<br>
       ctx->TransformFeedback.CurrentObject;<br>
-   uint32_t dw1 = 0, dw2 = 0;<br>
+   const struct gl_transform_feedback_info *linked_xfb_info =<br>
+      &xfb_obj->shader_program->LinkedTransformFeedback;<br>
+   uint32_t dw1 = 0, dw2 = 0, dw3 = 0, dw4 = 0;<br>
    int i;<br>
<br>
    if (active) {<br></blockquote><div><br></div><div>In here (not visible) gen7 sets a bunch of enable bits that don't exist on gen8.  That should be inside of an "if (brw->gen <= 7)" guard.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
@@ -258,12 +260,30 @@ upload_3dstate_streamout(struct brw_context *brw, bool active,<br>
<br>
       dw2 |= SET_FIELD(urb_entry_read_offset, SO_STREAM_3_VERTEX_READ_OFFSET);<br>
       dw2 |= SET_FIELD(urb_entry_read_length - 1, SO_STREAM_3_VERTEX_READ_LENGTH);<br>
+<br>
+      if (brw->gen >= 8) {<br>
+        /* Set buffer pitches; 0 means unbound. */<br>
+        if (xfb_obj->Buffers[0])<br>
+           dw3 |= linked_xfb_info->Buffers[0].Stride * 4;<br>
+        if (xfb_obj->Buffers[1])<br>
+           dw3 |= (linked_xfb_info->Buffers[1].Stride * 4) << 16;<br>
+        if (xfb_obj->Buffers[2])<br>
+           dw4 |= linked_xfb_info->Buffers[2].Stride * 4;<br>
+        if (xfb_obj->Buffers[3])<br>
+           dw4 |= (linked_xfb_info->Buffers[3].Stride * 4) << 16;<br>
+      }<br>
    }<br>
<br>
-   BEGIN_BATCH(3);<br>
-   OUT_BATCH(_3DSTATE_STREAMOUT << 16 | (3 - 2));<br>
+   const int dwords = brw->gen >= 8 ? 5 : 3;<br>
+<br>
+   BEGIN_BATCH(dwords);<br>
+   OUT_BATCH(_3DSTATE_STREAMOUT << 16 | (dwords - 2));<br>
    OUT_BATCH(dw1);<br>
    OUT_BATCH(dw2);<br>
+   if (dwords > 3) {<br>
+      OUT_BATCH(dw3);<br>
+      OUT_BATCH(dw4);<br>
+   }<br>
    ADVANCE_BATCH();<br>
 }<br>
<br>
@@ -275,7 +295,11 @@ upload_sol_state(struct brw_context *brw)<br>
    bool active = _mesa_is_xfb_active_and_unpaused(ctx);<br>
<br>
    if (active) {<br>
-      upload_3dstate_so_buffers(brw);<br>
+      if (brw->gen >= 8)<br>
+         gen8_upload_3dstate_so_buffers(brw);<br>
+      else<br>
+         upload_3dstate_so_buffers(brw);<br>
+<br>
       /* BRW_NEW_VUE_MAP_GEOM_OUT */<br>
       gen7_upload_3dstate_so_decl_list(brw, &brw->vue_map_geom_out);<br>
    }<br>
diff --git a/src/mesa/drivers/dri/i965/gen8_sol_state.c b/src/mesa/drivers/dri/i965/gen8_sol_state.c<br>
index a72f5e1..21cc129 100644<br>
--- a/src/mesa/drivers/dri/i965/gen8_sol_state.c<br>
+++ b/src/mesa/drivers/dri/i965/gen8_sol_state.c<br>
@@ -35,7 +35,7 @@<br>
 #include "intel_buffer_objects.h"<br>
 #include "main/transformfeedback.h"<br>
<br>
-static void<br>
+void<br>
 gen8_upload_3dstate_so_buffers(struct brw_context *brw)<br>
 {<br>
    struct gl_context *ctx = &brw->ctx;<br>
@@ -93,91 +93,3 @@ gen8_upload_3dstate_so_buffers(struct brw_context *brw)<br>
    }<br>
    brw_obj->zero_offsets = false;<br>
 }<br>
-<br>
-static void<br>
-gen8_upload_3dstate_streamout(struct brw_context *brw, bool active,<br>
-                              struct brw_vue_map *vue_map)<br>
-{<br>
-   struct gl_context *ctx = &brw->ctx;<br>
-<br>
-   /* BRW_NEW_TRANSFORM_FEEDBACK */<br>
-   struct gl_transform_feedback_object *xfb_obj =<br>
-      ctx->TransformFeedback.CurrentObject;<br>
-   const struct gl_transform_feedback_info *linked_xfb_info =<br>
-      &xfb_obj->shader_program->LinkedTransformFeedback;<br>
-   uint32_t dw1 = 0, dw2 = 0, dw3 = 0, dw4 = 0;<br>
-<br>
-   if (active) {<br>
-      int urb_entry_read_offset = 0;<br>
-      int urb_entry_read_length = (vue_map->num_slots + 1) / 2 -<br>
-         urb_entry_read_offset;<br>
-<br>
-      dw1 |= SO_FUNCTION_ENABLE;<br>
-      dw1 |= SO_STATISTICS_ENABLE;<br>
-<br>
-      /* _NEW_LIGHT */<br>
-      if (ctx->Light.ProvokingVertex != GL_FIRST_VERTEX_CONVENTION)<br>
-         dw1 |= SO_REORDER_TRAILING;<br>
-<br>
-      /* We always read the whole vertex.  This could be reduced at some<br>
-       * point by reading less and offsetting the register index in the<br>
-       * SO_DECLs.<br>
-       */<br>
-      dw2 |= SET_FIELD(urb_entry_read_offset, SO_STREAM_0_VERTEX_READ_OFFSET);<br>
-      dw2 |= SET_FIELD(urb_entry_read_length - 1, SO_STREAM_0_VERTEX_READ_LENGTH);<br>
-<br>
-      dw2 |= SET_FIELD(urb_entry_read_offset, SO_STREAM_1_VERTEX_READ_OFFSET);<br>
-      dw2 |= SET_FIELD(urb_entry_read_length - 1, SO_STREAM_1_VERTEX_READ_LENGTH);<br>
-<br>
-      dw2 |= SET_FIELD(urb_entry_read_offset, SO_STREAM_2_VERTEX_READ_OFFSET);<br>
-      dw2 |= SET_FIELD(urb_entry_read_length - 1, SO_STREAM_2_VERTEX_READ_LENGTH);<br>
-<br>
-      dw2 |= SET_FIELD(urb_entry_read_offset, SO_STREAM_3_VERTEX_READ_OFFSET);<br>
-      dw2 |= SET_FIELD(urb_entry_read_length - 1, SO_STREAM_3_VERTEX_READ_LENGTH);<br>
-<br>
-      /* Set buffer pitches; 0 means unbound. */<br>
-      if (xfb_obj->Buffers[0])<br>
-         dw3 |= linked_xfb_info->Buffers[0].Stride * 4;<br>
-      if (xfb_obj->Buffers[1])<br>
-         dw3 |= (linked_xfb_info->Buffers[1].Stride * 4) << 16;<br>
-      if (xfb_obj->Buffers[2])<br>
-         dw4 |= linked_xfb_info->Buffers[2].Stride * 4;<br>
-      if (xfb_obj->Buffers[3])<br>
-         dw4 |= (linked_xfb_info->Buffers[3].Stride * 4) << 16;<br>
-   }<br>
-<br>
-   BEGIN_BATCH(5);<br>
-   OUT_BATCH(_3DSTATE_STREAMOUT << 16 | (5 - 2));<br>
-   OUT_BATCH(dw1);<br>
-   OUT_BATCH(dw2);<br>
-   OUT_BATCH(dw3);<br>
-   OUT_BATCH(dw4);<br>
-   ADVANCE_BATCH();<br>
-}<br>
-<br>
-static void<br>
-upload_sol_state(struct brw_context *brw)<br>
-{<br>
-   struct gl_context *ctx = &brw->ctx;<br>
-   /* BRW_NEW_TRANSFORM_FEEDBACK */<br>
-   bool active = _mesa_is_xfb_active_and_unpaused(ctx);<br>
-<br>
-   if (active) {<br>
-      gen8_upload_3dstate_so_buffers(brw);<br>
-      /* BRW_NEW_VUE_MAP_GEOM_OUT */<br>
-      gen7_upload_3dstate_so_decl_list(brw, &brw->vue_map_geom_out);<br>
-   }<br>
-<br>
-   gen8_upload_3dstate_streamout(brw, active, &brw->vue_map_geom_out);<br>
-}<br>
-<br>
-const struct brw_tracked_state gen8_sol_state = {<br>
-   .dirty = {<br>
-      .mesa  = _NEW_LIGHT,<br>
-      .brw   = BRW_NEW_BATCH |<br>
-               BRW_NEW_BLORP |<br>
-               BRW_NEW_TRANSFORM_FEEDBACK |<br>
-               BRW_NEW_VUE_MAP_GEOM_OUT,<br>
-   },<br>
-   .emit = upload_sol_state,<br>
-};<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.0<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="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>