radeonsi: implement glDrawTransformFeedback functionality
authorMarek Olšák <marek.olsak@amd.com>
Mon, 26 Aug 2013 16:17:09 +0000 (18:17 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 12 Sep 2013 23:04:44 +0000 (01:04 +0200)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state_draw.c
src/gallium/drivers/radeonsi/sid.h

index 650db4f..e1b4e32 100644 (file)
@@ -3241,6 +3241,7 @@ void si_init_config(struct r600_context *rctx)
        si_pm4_set_reg(pm4, R_028A40_VGT_GS_MODE, 0x0);
        si_pm4_set_reg(pm4, R_028A84_VGT_PRIMITIVEID_EN, 0x0);
        si_pm4_set_reg(pm4, R_028A8C_VGT_PRIMITIVEID_RESET, 0x0);
+       si_pm4_set_reg(pm4, R_028B28_VGT_STRMOUT_DRAW_OPAQUE_OFFSET, 0);
        si_pm4_set_reg(pm4, R_028B94_VGT_STRMOUT_CONFIG, 0x0);
        si_pm4_set_reg(pm4, R_028B98_VGT_STRMOUT_BUFFER_CONFIG, 0x0);
        si_pm4_set_reg(pm4, R_028AA8_IA_MULTI_VGT_PARAM,
index e65b0cf..687410c 100644 (file)
@@ -557,6 +557,29 @@ static void si_state_draw(struct r600_context *rctx,
                               S_02800C_NOOP_CULL_DISABLE(1));
        }
 
+       if (info->count_from_stream_output) {
+               struct r600_so_target *t =
+                       (struct r600_so_target*)info->count_from_stream_output;
+               uint64_t va = r600_resource_va(&rctx->screen->b.b,
+                                              &t->buf_filled_size->b.b);
+               va += t->buf_filled_size_offset;
+
+               si_pm4_set_reg(pm4, R_028B30_VGT_STRMOUT_DRAW_OPAQUE_VERTEX_STRIDE,
+                              t->stride_in_dw);
+
+               si_pm4_cmd_begin(pm4, PKT3_COPY_DATA);
+               si_pm4_cmd_add(pm4,
+                              COPY_DATA_SRC_SEL(COPY_DATA_MEM) |
+                              COPY_DATA_DST_SEL(COPY_DATA_REG) |
+                              COPY_DATA_WR_CONFIRM);
+               si_pm4_cmd_add(pm4, va);     /* src address lo */
+               si_pm4_cmd_add(pm4, va >> 32UL); /* src address hi */
+               si_pm4_cmd_add(pm4, R_028B2C_VGT_STRMOUT_DRAW_OPAQUE_BUFFER_FILLED_SIZE >> 2);
+               si_pm4_cmd_add(pm4, 0); /* unused */
+               si_pm4_add_bo(pm4, t->buf_filled_size, RADEON_USAGE_READ);
+               si_pm4_cmd_end(pm4, true);
+       }
+
        /* draw packet */
        si_pm4_cmd_begin(pm4, PKT3_INDEX_TYPE);
        if (ib->index_size == 4) {
index c6688b3..021f4eb 100644 (file)
 #define                WAIT_REG_MEM_EQUAL              3
 #define PKT3_MEM_WRITE                         0x3D /* not on CIK */
 #define PKT3_INDIRECT_BUFFER                   0x32
+#define PKT3_COPY_DATA                        0x40
+#define                COPY_DATA_SRC_SEL(x)            ((x) & 0xf)
+#define                        COPY_DATA_REG           0
+#define                        COPY_DATA_MEM           1
+#define                COPY_DATA_DST_SEL(x)            (((x) & 0xf) << 8)
+#define                COPY_DATA_WR_CONFIRM            (1 << 20)
 #define PKT3_SURFACE_SYNC                      0x43 /* deprecated on CIK, use ACQUIRE_MEM */
 #define PKT3_ME_INITIALIZE                     0x44 /* not on CIK */
 #define PKT3_COND_WRITE                        0x45