r600g: fix dirty state handling
authorJerome Glisse <jglisse@redhat.com>
Wed, 6 Oct 2010 16:56:53 +0000 (12:56 -0400)
committerJerome Glisse <jglisse@redhat.com>
Wed, 6 Oct 2010 17:01:31 +0000 (13:01 -0400)
Avoid having object ending up in dead list of dirty object.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/winsys/r600/drm/evergreen_hw_context.c
src/gallium/winsys/r600/drm/r600_hw_context.c
src/gallium/winsys/r600/drm/r600_priv.h

index 9617035c934219b2957ea7c3e12438871aaa2ed5..9b39c0c4f01a2206a6412ed43c6daa6e25d5b9fd 100644 (file)
@@ -762,7 +762,7 @@ void evergreen_context_draw(struct r600_context *ctx, const struct r600_draw *dr
        struct r600_bo *cb[12];
        struct r600_bo *db;
        unsigned ndwords = 9, flush;
-       struct r600_block *dirty_block;
+       struct r600_block *dirty_block, *next_block;
 
        if (draw->indices) {
                ndwords = 13;
@@ -817,10 +817,9 @@ void evergreen_context_draw(struct r600_context *ctx, const struct r600_draw *dr
        }
 
        /* enough room to copy packet */
-       LIST_FOR_EACH_ENTRY(dirty_block,&ctx->dirty,list) {
+       LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &ctx->dirty,list) {
                r600_context_block_emit_dirty(ctx, dirty_block);
        }
-       LIST_INITHEAD(&ctx->dirty);
 
        /* draw packet */
        ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_INDEX_TYPE, 0);
index 72bfb357b3362b1fc91c4ef4e6ab5146fc7ffd80..86bddccbbbb798102f03209c4e3a277b2e099d9c 100644 (file)
@@ -967,7 +967,7 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
        struct r600_bo *cb[8];
        struct r600_bo *db;
        unsigned ndwords = 9;
-       struct r600_block *dirty_block;
+       struct r600_block *dirty_block, *next_block;
 
        if (draw->indices) {
                ndwords = 13;
@@ -1020,10 +1020,9 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
        }
 
        /* enough room to copy packet */
-       LIST_FOR_EACH_ENTRY(dirty_block,&ctx->dirty,list) {
+       LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &ctx->dirty,list) {
                r600_context_block_emit_dirty(ctx, dirty_block);
        }
-       LIST_INITHEAD(&ctx->dirty);
 
        /* draw packet */
        ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_INDEX_TYPE, 0);
@@ -1135,8 +1134,9 @@ void r600_context_flush(struct r600_context *ctx)
         */
        for (int i = 0; i < ctx->nblocks; i++) {
                if (ctx->blocks[i]->status & R600_BLOCK_STATUS_ENABLED) {
-                       if(!(ctx->blocks[i]->status & R600_BLOCK_STATUS_DIRTY))
+                       if(!(ctx->blocks[i]->status & R600_BLOCK_STATUS_DIRTY)) {
                                LIST_ADDTAIL(&ctx->blocks[i]->list,&ctx->dirty);
+                       }
                        ctx->pm4_dirty_cdwords += ctx->blocks[i]->pm4_ndwords + ctx->blocks[i]->pm4_flush_ndwords;
                        ctx->blocks[i]->status |= R600_BLOCK_STATUS_DIRTY;
                }
index a693a5b5ab8a4d50e496f5ae5cd9e4139a820c98..e3868d3cb9a5b6840bc045345ed629daf3d8fbfb 100644 (file)
@@ -162,6 +162,7 @@ static inline void r600_context_block_emit_dirty(struct r600_context *ctx, struc
        memcpy(&ctx->pm4[ctx->pm4_cdwords], block->pm4, block->pm4_ndwords * 4);
        ctx->pm4_cdwords += block->pm4_ndwords;
        block->status ^= R600_BLOCK_STATUS_DIRTY;
+       LIST_DELINIT(&block->list);
 }
 
 static inline int radeon_bo_map(struct radeon *radeon, struct radeon_bo *bo)