radeon: move streamout buffer config to streamout enable function. (v2)
authorDave Airlie <airlied@redhat.com>
Sun, 26 Jul 2015 00:27:17 +0000 (01:27 +0100)
committerDave Airlie <airlied@redhat.com>
Wed, 29 Jul 2015 09:48:10 +0000 (10:48 +0100)
This will be used here later.

v2: update atom sizes
add check for old vs new enabled mask

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_streamout.c

index d225f2528ab27934981bc3772dce60119a7e094b..74d747f730bf94ebed1b4399f86eff22448f6071 100644 (file)
@@ -329,6 +329,9 @@ struct r600_streamout {
         * it must be set explicitly when binding a shader. */
        unsigned                        *stride_in_dw;
 
+       /* The state of VGT_STRMOUT_BUFFER_(CONFIG|EN). */
+       unsigned                        hw_enabled_mask;
+
        /* The state of VGT_STRMOUT_(CONFIG|EN). */
        struct r600_atom                enable_atom;
        bool                            streamout_enabled;
index bc8bf97ef89378d4263b55062890b529eda6ca80..815b641579caa90a43bd42034965da0fb7f707ba 100644 (file)
@@ -88,8 +88,7 @@ void r600_streamout_buffers_dirty(struct r600_common_context *rctx)
                12 + /* flush_vgt_streamout */
                num_bufs * 11; /* STRMOUT_BUFFER_UPDATE, BUFFER_SIZE */
 
-       begin->num_dw = 12 + /* flush_vgt_streamout */
-                       3; /* VGT_STRMOUT_BUFFER_CONFIG */
+       begin->num_dw = 12; /* flush_vgt_streamout */
 
        if (rctx->chip_class >= SI) {
                begin->num_dw += num_bufs * 4; /* SET_CONTEXT_REG */
@@ -192,11 +191,6 @@ static void r600_emit_streamout_begin(struct r600_common_context *rctx, struct r
 
        r600_flush_vgt_streamout(rctx);
 
-       r600_write_context_reg(cs, rctx->chip_class >= EVERGREEN ?
-                                      R_028B98_VGT_STRMOUT_BUFFER_CONFIG :
-                                      R_028B20_VGT_STRMOUT_BUFFER_EN,
-                              rctx->streamout.enabled_mask);
-
        for (i = 0; i < rctx->streamout.num_targets; i++) {
                if (!t[i])
                        continue;
@@ -326,6 +320,12 @@ static bool r600_get_strmout_en(struct r600_common_context *rctx)
 static void r600_emit_streamout_enable(struct r600_common_context *rctx,
                                       struct r600_atom *atom)
 {
+       r600_write_context_reg(rctx->rings.gfx.cs,
+                              rctx->chip_class >= EVERGREEN ?
+                                      R_028B98_VGT_STRMOUT_BUFFER_CONFIG :
+                                      R_028B20_VGT_STRMOUT_BUFFER_EN,
+                              rctx->streamout.hw_enabled_mask);
+
        r600_write_context_reg(rctx->rings.gfx.cs,
                               rctx->chip_class >= EVERGREEN ?
                                       R_028B94_VGT_STRMOUT_CONFIG :
@@ -336,9 +336,12 @@ static void r600_emit_streamout_enable(struct r600_common_context *rctx,
 static void r600_set_streamout_enable(struct r600_common_context *rctx, bool enable)
 {
        bool old_strmout_en = r600_get_strmout_en(rctx);
+       unsigned old_hw_enabled_mask = rctx->streamout.hw_enabled_mask;
 
        rctx->streamout.streamout_enabled = enable;
-       if (old_strmout_en != r600_get_strmout_en(rctx))
+       rctx->streamout.hw_enabled_mask = rctx->streamout.enabled_mask;
+       if ((old_strmout_en != r600_get_strmout_en(rctx)) ||
+            (old_hw_enabled_mask != rctx->streamout.hw_enabled_mask))
                rctx->streamout.enable_atom.dirty = true;
 }
 
@@ -365,5 +368,5 @@ void r600_streamout_init(struct r600_common_context *rctx)
        rctx->b.stream_output_target_destroy = r600_so_target_destroy;
        rctx->streamout.begin_atom.emit = r600_emit_streamout_begin;
        rctx->streamout.enable_atom.emit = r600_emit_streamout_enable;
-       rctx->streamout.enable_atom.num_dw = 3;
+       rctx->streamout.enable_atom.num_dw = 6;
 }