r600g: consolidate the same piece of cut-n-paste code into a function.
authorDave Airlie <airlied@redhat.com>
Sun, 17 Apr 2011 07:11:36 +0000 (17:11 +1000)
committerDave Airlie <airlied@redhat.com>
Sun, 17 Apr 2011 07:11:36 +0000 (17:11 +1000)
Signed-off-by: Dave Airlie <airlied@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 66398afa6984417b57dcabaf5558ae48efd446a1..28d071b6bc565e6cf4599dd11bf19804913f2008 100644 (file)
@@ -668,12 +668,7 @@ static inline void evergreen_context_pipe_state_set_resource(struct r600_context
                r600_bo_reference(ctx->radeon, &block->reloc[1].bo, state->regs[2].bo);
                r600_bo_reference(ctx->radeon, &block->reloc[2].bo, state->regs[3].bo);
        }
-       if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
-               block->status |= R600_BLOCK_STATUS_ENABLED;
-               block->status |= R600_BLOCK_STATUS_DIRTY;
-               ctx->pm4_dirty_cdwords += block->pm4_ndwords + block->pm4_flush_ndwords;
-               LIST_ADDTAIL(&block->list,&ctx->dirty);
-       }
+       r600_context_dirty_block(ctx, block);
 }
 
 void evergreen_context_pipe_state_set_ps_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
@@ -712,12 +707,8 @@ static inline void evergreen_context_pipe_state_set_sampler(struct r600_context
        block->reg[0] = state->regs[0].value;
        block->reg[1] = state->regs[1].value;
        block->reg[2] = state->regs[2].value;
-       if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
-               block->status |= R600_BLOCK_STATUS_ENABLED;
-               block->status |= R600_BLOCK_STATUS_DIRTY;
-               ctx->pm4_dirty_cdwords += block->pm4_ndwords + block->pm4_flush_ndwords;
-               LIST_ADDTAIL(&block->list,&ctx->dirty);
-       }
+
+       r600_context_dirty_block(ctx, block);
 }
 
 static inline void evergreen_context_pipe_state_set_sampler_border(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset, unsigned id)
@@ -741,12 +732,8 @@ static inline void evergreen_context_pipe_state_set_sampler_border(struct r600_c
        block->reg[2] = state->regs[4].value;
        block->reg[3] = state->regs[5].value;
        block->reg[4] = state->regs[6].value;
-       if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
-               block->status |= R600_BLOCK_STATUS_ENABLED;
-               block->status |= R600_BLOCK_STATUS_DIRTY;
-               ctx->pm4_dirty_cdwords += block->pm4_ndwords + block->pm4_flush_ndwords;
-               LIST_ADDTAIL(&block->list,&ctx->dirty);
-       }
+
+       r600_context_dirty_block(ctx, block);
 }
 
 void evergreen_context_pipe_state_set_ps_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id)
index 7f8da12da467fe466ae44f9828d361230e9c2ce0..3ecf4eb2fcaab0116114bf35af90b5636596dbc8 100644 (file)
@@ -851,12 +851,7 @@ void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_stat
                        r600_bo_reference(ctx->radeon, &block->reloc[id].bo, state->regs[i].bo);
                        state->regs[i].bo->fence = ctx->radeon->fence;
                }
-               if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
-                       block->status |= R600_BLOCK_STATUS_ENABLED;
-                       block->status |= R600_BLOCK_STATUS_DIRTY;
-                       ctx->pm4_dirty_cdwords += block->pm4_ndwords + block->pm4_flush_ndwords;
-                       LIST_ADDTAIL(&block->list,&ctx->dirty);
-               }
+               r600_context_dirty_block(ctx, block);
        }
 }
 
@@ -897,12 +892,7 @@ static inline void r600_context_pipe_state_set_resource(struct r600_context *ctx
                state->regs[2].bo->fence = ctx->radeon->fence;
                state->regs[3].bo->fence = ctx->radeon->fence;
        }
-       if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
-               block->status |= R600_BLOCK_STATUS_ENABLED;
-               block->status |= R600_BLOCK_STATUS_DIRTY;
-               ctx->pm4_dirty_cdwords += block->pm4_ndwords + block->pm4_flush_ndwords;
-               LIST_ADDTAIL(&block->list,&ctx->dirty);
-       }
+       r600_context_dirty_block(ctx, block);
 }
 
 void r600_context_pipe_state_set_ps_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
@@ -941,12 +931,8 @@ static inline void r600_context_pipe_state_set_sampler(struct r600_context *ctx,
        block->reg[0] = state->regs[0].value;
        block->reg[1] = state->regs[1].value;
        block->reg[2] = state->regs[2].value;
-       if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
-               block->status |= R600_BLOCK_STATUS_ENABLED;
-               block->status |= R600_BLOCK_STATUS_DIRTY;
-               ctx->pm4_dirty_cdwords += block->pm4_ndwords + block->pm4_flush_ndwords;
-               LIST_ADDTAIL(&block->list,&ctx->dirty);
-       }
+
+       r600_context_dirty_block(ctx, block);
 }
 
 static inline void r600_context_pipe_state_set_sampler_border(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset)
@@ -968,12 +954,8 @@ static inline void r600_context_pipe_state_set_sampler_border(struct r600_contex
        block->reg[1] = state->regs[4].value;
        block->reg[2] = state->regs[5].value;
        block->reg[3] = state->regs[6].value;
-       if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
-               block->status |= R600_BLOCK_STATUS_ENABLED;
-               block->status |= R600_BLOCK_STATUS_DIRTY;
-               ctx->pm4_dirty_cdwords += block->pm4_ndwords + block->pm4_flush_ndwords;
-               LIST_ADDTAIL(&block->list,&ctx->dirty);
-       }
+
+       r600_context_dirty_block(ctx, block);
 }
 
 void r600_context_pipe_state_set_ps_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id)
index a958c95ab6298fa1a468603ea3a440db803508cc..0e9dba70cd6ea6087548c5f4999444184232946b 100644 (file)
@@ -194,6 +194,16 @@ static void inline r600_context_reg(struct r600_context *ctx,
        }
 }
 
+static inline void r600_context_dirty_block(struct r600_context *ctx, struct r600_block *block)
+{
+       if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+               block->status |= R600_BLOCK_STATUS_ENABLED;
+               block->status |= R600_BLOCK_STATUS_DIRTY;
+               ctx->pm4_dirty_cdwords += block->pm4_ndwords + block->pm4_flush_ndwords;
+               LIST_ADDTAIL(&block->list,&ctx->dirty);
+       }
+}
+
 static inline void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block *block)
 {
        int id;