r600g: emit SURFACE_BASE_UPDATE packet on rv6xx
authorAlex Deucher <alexdeucher@gmail.com>
Mon, 14 Mar 2011 20:58:27 +0000 (16:58 -0400)
committerAlex Deucher <alexdeucher@gmail.com>
Mon, 14 Mar 2011 21:42:19 +0000 (17:42 -0400)
This packet is required when updating the DB, CB,
or STRMOUT base addresses on rv6xx for the surface
sync logic to work correctly.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
src/gallium/winsys/r600/drm/r600_hw_context.c
src/gallium/winsys/r600/drm/r600d.h

index 6b3baa2c9093996a898714064a79f73190dc88ce..ff662a2c8573cd2180dc32a5ae4132e8516454db 100644 (file)
@@ -760,6 +760,17 @@ out_err:
        return r;
 }
 
+static void rv6xx_context_surface_base_update(struct r600_context *ctx,
+                                             unsigned base_update_flags)
+{
+       /* need to emit surface base update on rv6xx */
+       if ((ctx->radeon->family > CHIP_R600) ||
+           (ctx->radeon->family < CHIP_RV770)) {
+               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_BASE_UPDATE, 0, 0);
+               ctx->pm4[ctx->pm4_cdwords++] = base_update_flags;
+       }
+}
+
 void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags,
                                unsigned flush_mask, struct r600_bo *rbo)
 {
@@ -991,6 +1002,7 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
        unsigned ndwords = 9;
        struct r600_block *dirty_block = NULL;
        struct r600_block *next_block;
+       unsigned rv6xx_surface_base_update = 0;
 
        if (draw->indices) {
                ndwords = 13;
@@ -1013,10 +1025,14 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
        for (int i = 0; i < 8; i++) {
                if (cb[i]) {
                        ndwords += 7;
+                       rv6xx_surface_base_update |= SURFACE_BASE_UPDATE_COLOR(i);
                }
        }
-       if (db)
+       if (db) {
                ndwords += 7;
+               rv6xx_surface_base_update |= SURFACE_BASE_UPDATE_DEPTH;
+       }
+       /* XXX also need to update SURFACE_BASE_UPDATE_STRMOUT when we support it */
 
        /* queries need some special values */
        if (ctx->num_query_running) {
@@ -1043,10 +1059,14 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
        }
 
        /* enough room to copy packet */
-       LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &ctx->dirty,list) {
+       LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &ctx->dirty, list) {
                r600_context_block_emit_dirty(ctx, dirty_block);
        }
 
+       /* rv6xx surface base udpate */
+       if (rv6xx_surface_base_update)
+               rv6xx_context_surface_base_update(ctx, rv6xx_surface_base_update);
+
        /* draw packet */
        ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_INDEX_TYPE, 0, ctx->predicate_drawing);
        ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_index_type;
index cb12865ff018c2ae825a2e36b93c03fd749f8ce8..80424818044b81c2b8f9cf4699257148954e0b45 100644 (file)
@@ -90,6 +90,9 @@
 #define PKT3_SET_SAMPLER                       0x6E
 #define PKT3_SET_CTL_CONST                     0x6F
 #define PKT3_SURFACE_BASE_UPDATE               0x73
+#define                SURFACE_BASE_UPDATE_DEPTH      (1 << 0)
+#define                SURFACE_BASE_UPDATE_COLOR(x)   (2 << (x))
+#define                SURFACE_BASE_UPDATE_STRMOUT(x) (0x200 << (x))
 
 #define EVENT_TYPE_PS_PARTIAL_FLUSH            0x10
 #define EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT 0x14