r600g: consolidate r600/evergreen code for resource emission.
authorDave Airlie <airlied@redhat.com>
Tue, 19 Apr 2011 00:00:03 +0000 (10:00 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 19 Apr 2011 00:12:20 +0000 (10:12 +1000)
These really didn't have much difference, and totally not inline material.

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 670cbf7804ee97c0cc1f5e75598602d7ff77660b..4104a1a0c1914173fddc2bc2d7e8d3fab1ed9482 100644 (file)
@@ -633,59 +633,25 @@ out_err:
        return r;
 }
 
-static inline void evergreen_context_pipe_state_set_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset)
-{
-       struct r600_range *range;
-       struct r600_block *block;
-       int i;
-
-       range = &ctx->range[CTX_RANGE_ID(ctx, offset)];
-       block = range->blocks[CTX_BLOCK_ID(ctx, offset)];
-       if (state == NULL) {
-               block->status &= ~(R600_BLOCK_STATUS_ENABLED | R600_BLOCK_STATUS_DIRTY);
-               r600_bo_reference(ctx->radeon, &block->reloc[1].bo, NULL);
-               r600_bo_reference(ctx->radeon , &block->reloc[2].bo, NULL);
-               LIST_DELINIT(&block->list);
-               return;
-       }
-       for (i = 0; i < 8; i++)
-               block->reg[i] = state->regs[i].value;
-
-       r600_bo_reference(ctx->radeon, &block->reloc[1].bo, NULL);
-       r600_bo_reference(ctx->radeon , &block->reloc[2].bo, NULL);
-       if (state->regs[0].bo) {
-               /* VERTEX RESOURCE, we preted there is 2 bo to relocate so
-                * we have single case btw VERTEX & TEXTURE resource
-                */
-               r600_bo_reference(ctx->radeon, &block->reloc[1].bo, state->regs[0].bo);
-               r600_bo_reference(ctx->radeon, &block->reloc[2].bo, state->regs[0].bo);
-       } else {
-               /* TEXTURE RESOURCE */
-               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);
-       }
-       r600_context_dirty_block(ctx, block, R600_BLOCK_STATUS_DIRTY, 7);
-}
-
 void evergreen_context_pipe_state_set_ps_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
 {
        unsigned offset = R_030000_SQ_TEX_RESOURCE_WORD0_0 + 0x20 * rid;
 
-       evergreen_context_pipe_state_set_resource(ctx, state, offset);
+       r600_context_pipe_state_set_resource(ctx, state, offset);
 }
 
 void evergreen_context_pipe_state_set_vs_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
 {
        unsigned offset = R_030000_SQ_TEX_RESOURCE_WORD0_0 + 0x1600 + 0x20 * rid;
 
-       evergreen_context_pipe_state_set_resource(ctx, state, offset);
+       r600_context_pipe_state_set_resource(ctx, state, offset);
 }
 
 void evergreen_context_pipe_state_set_fs_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
 {
        unsigned offset = R_030000_SQ_TEX_RESOURCE_WORD0_0 + 0x7C00 + 0x20 * rid;
 
-       evergreen_context_pipe_state_set_resource(ctx, state, offset);
+       r600_context_pipe_state_set_resource(ctx, state, offset);
 }
 
 static inline void evergreen_context_pipe_state_set_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset)
index d91d8f619280dc63060bc9fc4b2eb77ca1048686..9aa9cefdd565211674b5f573e50686b9d89cda8b 100644 (file)
@@ -875,12 +875,13 @@ void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_stat
        }
 }
 
-static inline void r600_context_pipe_state_set_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset)
+void r600_context_pipe_state_set_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset)
 {
        struct r600_range *range;
        struct r600_block *block;
        int i;
        int dirty;
+       int num_regs = ctx->radeon->chip_class >= EVERGREEN ? 8 : 7;
 
        range = &ctx->range[CTX_RANGE_ID(ctx, offset)];
        block = range->blocks[CTX_BLOCK_ID(ctx, offset)];
@@ -894,7 +895,7 @@ static inline void r600_context_pipe_state_set_resource(struct r600_context *ctx
 
        dirty = block->status & R600_BLOCK_STATUS_DIRTY;
 
-       for (i = 0; i < 7; i++) {
+       for (i = 0; i < num_regs; i++) {
                if (block->reg[i] != state->regs[i].value) {
                        dirty |= R600_BLOCK_STATUS_DIRTY;
                        block->reg[i] = state->regs[i].value;
@@ -941,7 +942,7 @@ static inline void r600_context_pipe_state_set_resource(struct r600_context *ctx
                        state->regs[3].bo->fence = ctx->radeon->fence;
                }
        }
-       r600_context_dirty_block(ctx, block, dirty, 6);
+       r600_context_dirty_block(ctx, block, dirty, num_regs - 1);
 }
 
 void r600_context_pipe_state_set_ps_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
index faf47e82ab8911bb91c48a936650d2576788c256..b48287d7d14839d54b0d680b3d1a2134c4d4370f 100644 (file)
@@ -154,7 +154,7 @@ void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags,
                                unsigned flush_mask, struct r600_bo *rbo);
 struct r600_bo *r600_context_reg_bo(struct r600_context *ctx, unsigned offset);
 int r600_context_add_block(struct r600_context *ctx, const struct r600_reg *reg, unsigned nreg);
-
+void r600_context_pipe_state_set_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset);
 /*
  * r600_bo.c
  */