ilo: add 3DSTATE_SO_BUFFER variants
authorChia-I Wu <olvaffe@gmail.com>
Tue, 11 Nov 2014 03:21:01 +0000 (11:21 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 11 Nov 2014 05:52:25 +0000 (13:52 +0800)
Add gen7_disable_3DSTATE_SO_BUFFER() to disable SO buffers.

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 8f2a25a6a499a96660a928c24dabda5f3733931f..5f758a1ccbdecdda7852e34926351fe8a7e8231d 100644 (file)
@@ -956,52 +956,55 @@ gen7_3DSTATE_SO_DECL_LIST(struct ilo_builder *builder,
 }
 
 static inline void
-gen7_3DSTATE_SO_BUFFER(struct ilo_builder *builder,
-                       int index, int base, int stride,
+gen7_3DSTATE_SO_BUFFER(struct ilo_builder *builder, int index, int stride,
                        const struct pipe_stream_output_target *so_target)
 {
    const uint8_t cmd_len = 4;
-   const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_SO_BUFFER) |
-                        (cmd_len - 2);
    struct ilo_buffer *buf;
-   int end;
+   int start, end;
    uint32_t *dw;
    unsigned pos;
 
    ILO_DEV_ASSERT(builder->dev, 7, 7.5);
 
-   if (!so_target || !so_target->buffer) {
-      ilo_builder_batch_pointer(builder, cmd_len, &dw);
-      dw[0] = dw0;
-      dw[1] = index << GEN7_SO_BUF_DW1_INDEX__SHIFT;
-      dw[2] = 0;
-      dw[3] = 0;
-
-      return;
-   }
-
    buf = ilo_buffer(so_target->buffer);
 
    /* DWord-aligned */
-   assert(stride % 4 == 0 && base % 4 == 0);
+   assert(stride % 4 == 0);
    assert(so_target->buffer_offset % 4 == 0);
 
    stride &= ~3;
-   base = (base + so_target->buffer_offset) & ~3;
-   end = (base + so_target->buffer_size) & ~3;
+   start = so_target->buffer_offset & ~3;
+   end = (start + so_target->buffer_size) & ~3;
 
    pos = ilo_builder_batch_pointer(builder, cmd_len, &dw);
 
-   dw[0] = dw0;
+   dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SO_BUFFER) | (cmd_len - 2);
    dw[1] = index << GEN7_SO_BUF_DW1_INDEX__SHIFT |
            stride;
 
    ilo_builder_batch_reloc(builder, pos + 2,
-         buf->bo, base, INTEL_RELOC_WRITE);
+         buf->bo, start, INTEL_RELOC_WRITE);
    ilo_builder_batch_reloc(builder, pos + 3,
          buf->bo, end, INTEL_RELOC_WRITE);
 }
 
+static inline void
+gen7_disable_3DSTATE_SO_BUFFER(struct ilo_builder *builder, int index)
+{
+   const uint8_t cmd_len = 4;
+   uint32_t *dw;
+
+   ILO_DEV_ASSERT(builder->dev, 7, 7.5);
+
+   ilo_builder_batch_pointer(builder, cmd_len, &dw);
+
+   dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SO_BUFFER) | (cmd_len - 2);
+   dw[1] = index << GEN7_SO_BUF_DW1_INDEX__SHIFT;
+   dw[2] = 0;
+   dw[3] = 0;
+}
+
 static inline void
 gen6_3DSTATE_BINDING_TABLE_POINTERS(struct ilo_builder *builder,
                                     uint32_t vs_binding_table,
index 8830db4e852a25340addb49fd8cd668137974e67..2051f1254bb90218220cdc93af2e320c3e63aed2 100644 (file)
@@ -458,14 +458,12 @@ gen7_draw_sol(struct ilo_render *r,
 
       for (i = 0; i < vec->so.count; i++) {
          const int stride = so_info->stride[i] * 4; /* in bytes */
-         int base = 0;
 
-         gen7_3DSTATE_SO_BUFFER(r->builder, i, base, stride,
-               vec->so.states[i]);
+         gen7_3DSTATE_SO_BUFFER(r->builder, i, stride, vec->so.states[i]);
       }
 
       for (; i < 4; i++)
-         gen7_3DSTATE_SO_BUFFER(r->builder, i, 0, 0, NULL);
+         gen7_disable_3DSTATE_SO_BUFFER(r->builder, i);
    }
 
    /* 3DSTATE_SO_DECL_LIST */