ilo: clean up gen7_3DSTATE_STREAMOUT()
authorChia-I Wu <olvaffe@gmail.com>
Tue, 11 Nov 2014 05:28:32 +0000 (13:28 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 11 Nov 2014 05:52:26 +0000 (13:52 +0800)
Render stream and render enable are independent from so enable.  Having a
single return point makes it easier to see that.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/gallium/drivers/ilo/ilo_builder_3d_top.h
src/gallium/drivers/ilo/ilo_render_gen7.c

index ce2debec6f0fa1a381987df7c1383c2df711a42c..4a6d0443b7ae1275909e917a97b00c297bf777aa 100644 (file)
@@ -804,61 +804,50 @@ gen7_disable_3DSTATE_GS(struct ilo_builder *builder)
 
 static inline void
 gen7_3DSTATE_STREAMOUT(struct ilo_builder *builder,
+                       int render_stream,
+                       bool render_disable,
                        unsigned buffer_mask,
-                       int vertex_attrib_count,
-                       bool rasterizer_discard)
+                       int vertex_attrib_count)
 {
    const uint8_t cmd_len = 3;
-   const bool enable = (buffer_mask != 0);
-   const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_STREAMOUT) |
-                        (cmd_len - 2);
    uint32_t dw1, dw2, *dw;
-   int read_len;
 
    ILO_DEV_ASSERT(builder->dev, 7, 7.5);
 
-   if (!enable) {
-      dw1 = 0 << GEN7_SO_DW1_RENDER_STREAM_SELECT__SHIFT;
-      if (rasterizer_discard)
-         dw1 |= GEN7_SO_DW1_RENDER_DISABLE;
-
-      dw2 = 0;
-
-      ilo_builder_batch_pointer(builder, cmd_len, &dw);
-      dw[0] = dw0;
-      dw[1] = dw1;
-      dw[2] = dw2;
-      return;
-   }
-
-   read_len = (vertex_attrib_count + 1) / 2;
-   if (!read_len)
-      read_len = 1;
-
-   dw1 = GEN7_SO_DW1_SO_ENABLE |
-         0 << GEN7_SO_DW1_RENDER_STREAM_SELECT__SHIFT |
-         GEN7_SO_DW1_STATISTICS |
-         buffer_mask << 8;
-
-   if (rasterizer_discard)
+   dw1 = render_stream << GEN7_SO_DW1_RENDER_STREAM_SELECT__SHIFT;
+   if (render_disable)
       dw1 |= GEN7_SO_DW1_RENDER_DISABLE;
 
-   /* API_OPENGL */
-   if (true)
-      dw1 |= GEN7_SO_DW1_REORDER_TRAILING;
+   dw2 = 0;
 
-   dw2 = 0 << GEN7_SO_DW2_STREAM3_READ_OFFSET__SHIFT |
-         0 << GEN7_SO_DW2_STREAM3_READ_LEN__SHIFT |
-         0 << GEN7_SO_DW2_STREAM2_READ_OFFSET__SHIFT |
-         0 << GEN7_SO_DW2_STREAM2_READ_LEN__SHIFT |
-         0 << GEN7_SO_DW2_STREAM1_READ_OFFSET__SHIFT |
-         0 << GEN7_SO_DW2_STREAM1_READ_LEN__SHIFT |
-         0 << GEN7_SO_DW2_STREAM0_READ_OFFSET__SHIFT |
-         (read_len - 1) << GEN7_SO_DW2_STREAM0_READ_LEN__SHIFT;
+   if (buffer_mask) {
+      int read_len;
+
+      read_len = (vertex_attrib_count + 1) / 2;
+      if (!read_len)
+         read_len = 1;
+
+      dw1 |= GEN7_SO_DW1_SO_ENABLE |
+             GEN7_SO_DW1_STATISTICS |
+             buffer_mask << GEN7_SO_DW1_BUFFER_ENABLES__SHIFT;
+
+      /* API_OPENGL */
+      if (true)
+         dw1 |= GEN7_SO_DW1_REORDER_TRAILING;
+
+      dw2 = 0 << GEN7_SO_DW2_STREAM3_READ_OFFSET__SHIFT |
+            (read_len - 1) << GEN7_SO_DW2_STREAM3_READ_LEN__SHIFT |
+            0 << GEN7_SO_DW2_STREAM2_READ_OFFSET__SHIFT |
+            (read_len - 1) << GEN7_SO_DW2_STREAM2_READ_LEN__SHIFT |
+            0 << GEN7_SO_DW2_STREAM1_READ_OFFSET__SHIFT |
+            (read_len - 1) << GEN7_SO_DW2_STREAM1_READ_LEN__SHIFT |
+            0 << GEN7_SO_DW2_STREAM0_READ_OFFSET__SHIFT |
+            (read_len - 1) << GEN7_SO_DW2_STREAM0_READ_LEN__SHIFT;
+   }
 
    ilo_builder_batch_pointer(builder, cmd_len, &dw);
 
-   dw[0] = dw0;
+   dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_STREAMOUT) | (cmd_len - 2);
    dw[1] = dw1;
    dw[2] = dw2;
 }
index 2051f1254bb90218220cdc93af2e320c3e63aed2..08190e8cc4a6c63d5dfca5f24b7f7211debb2301 100644 (file)
@@ -476,8 +476,9 @@ gen7_draw_sol(struct ilo_render *r,
       const int output_count = ilo_shader_get_kernel_param(shader,
             ILO_KERNEL_OUTPUT_COUNT);
 
-      gen7_3DSTATE_STREAMOUT(r->builder, buffer_mask, output_count,
-            vec->rasterizer->state.rasterizer_discard);
+      gen7_3DSTATE_STREAMOUT(r->builder, 0,
+            vec->rasterizer->state.rasterizer_discard,
+            buffer_mask, output_count);
    }
 }
 
@@ -732,7 +733,7 @@ gen7_rectlist_vs_to_sf(struct ilo_render *r,
    gen7_3DSTATE_CONSTANT_GS(r->builder, NULL, NULL, 0);
    gen7_disable_3DSTATE_GS(r->builder);
 
-   gen7_3DSTATE_STREAMOUT(r->builder, 0x0, 0, false);
+   gen7_3DSTATE_STREAMOUT(r->builder, 0, false, 0x0, 0);
 
    gen6_disable_3DSTATE_CLIP(r->builder);