r600g: optimise the draw emission packets for r600/eg
authorDave Airlie <airlied@redhat.com>
Mon, 6 Jun 2011 10:03:13 +0000 (20:03 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 6 Jun 2011 23:43:09 +0000 (09:43 +1000)
This just reduces code size a bit for this chunk.

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

index 7a1be87f3dc1585370c7d52e211e64ecece63bce..3cf41c1f9f962265d7e7c2d5676d2b23ee1cf7c6 100644 (file)
@@ -1143,6 +1143,7 @@ void evergreen_context_draw(struct r600_context *ctx, const struct r600_draw *dr
        unsigned ndwords = 7;
        struct r600_block *dirty_block = NULL;
        struct r600_block *next_block;
+       uint32_t *pm4;
 
        if (draw->indices) {
                ndwords = 11;
@@ -1184,24 +1185,26 @@ void evergreen_context_draw(struct r600_context *ctx, const struct r600_draw *dr
        }
 
        /* draw packet */
-       ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_INDEX_TYPE, 0, ctx->predicate_drawing);
-       ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_index_type;
-       ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NUM_INSTANCES, 0, ctx->predicate_drawing);
-       ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_num_instances;
+       pm4 = &ctx->pm4[ctx->pm4_cdwords];
+       pm4[0] = PKT3(PKT3_INDEX_TYPE, 0, ctx->predicate_drawing);
+       pm4[1] = draw->vgt_index_type;
+       pm4[2] = PKT3(PKT3_NUM_INSTANCES, 0, ctx->predicate_drawing);
+       pm4[3] = draw->vgt_num_instances;
        if (draw->indices) {
-               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_DRAW_INDEX, 3, ctx->predicate_drawing);
-               ctx->pm4[ctx->pm4_cdwords++] = draw->indices_bo_offset + r600_bo_offset(draw->indices);
-               ctx->pm4[ctx->pm4_cdwords++] = 0;
-               ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_num_indices;
-               ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_draw_initiator;
-               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, ctx->predicate_drawing);
-               ctx->pm4[ctx->pm4_cdwords++] = 0;
-               r600_context_bo_reloc(ctx, &ctx->pm4[ctx->pm4_cdwords - 1], draw->indices);
+               pm4[4] = PKT3(PKT3_DRAW_INDEX, 3, ctx->predicate_drawing);
+               pm4[5] = draw->indices_bo_offset + r600_bo_offset(draw->indices);
+               pm4[6] = 0;
+               pm4[7] = draw->vgt_num_indices;
+               pm4[8] = draw->vgt_draw_initiator;
+               pm4[9] = PKT3(PKT3_NOP, 0, ctx->predicate_drawing);
+               pm4[10] = 0;
+               r600_context_bo_reloc(ctx, &pm4[10], draw->indices);
        } else {
-               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_DRAW_INDEX_AUTO, 1, ctx->predicate_drawing);
-               ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_num_indices;
-               ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_draw_initiator;
+               pm4[4] = PKT3(PKT3_DRAW_INDEX_AUTO, 1, ctx->predicate_drawing);
+               pm4[5] = draw->vgt_num_indices;
+               pm4[6] = draw->vgt_draw_initiator;
        }
+       ctx->pm4_cdwords += ndwords;
 
        ctx->flags |= (R600_CONTEXT_DRAW_PENDING | R600_CONTEXT_DST_CACHES_DIRTY);
 
index c5551b2674c1b3abf14defe90ffee1ed68ed22c2..cb244f2b9eef153f89911844f5fda54ee48efa38 100644 (file)
@@ -1347,6 +1347,7 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
        unsigned ndwords = 7;
        struct r600_block *dirty_block = NULL;
        struct r600_block *next_block;
+       uint32_t *pm4;
 
        if (draw->indices) {
                ndwords = 11;
@@ -1389,24 +1390,27 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
        }
 
        /* draw packet */
-       ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_INDEX_TYPE, 0, ctx->predicate_drawing);
-       ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_index_type;
-       ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NUM_INSTANCES, 0, ctx->predicate_drawing);
-       ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_num_instances;
+       pm4 = &ctx->pm4[ctx->pm4_cdwords];
+
+       pm4[0] = PKT3(PKT3_INDEX_TYPE, 0, ctx->predicate_drawing);
+       pm4[1] = draw->vgt_index_type;
+       pm4[2] = PKT3(PKT3_NUM_INSTANCES, 0, ctx->predicate_drawing);
+       pm4[3] = draw->vgt_num_instances;
        if (draw->indices) {
-               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_DRAW_INDEX, 3, ctx->predicate_drawing);
-               ctx->pm4[ctx->pm4_cdwords++] = draw->indices_bo_offset + r600_bo_offset(draw->indices);
-               ctx->pm4[ctx->pm4_cdwords++] = 0;
-               ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_num_indices;
-               ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_draw_initiator;
-               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, ctx->predicate_drawing);
-               ctx->pm4[ctx->pm4_cdwords++] = 0;
-               r600_context_bo_reloc(ctx, &ctx->pm4[ctx->pm4_cdwords - 1], draw->indices);
+               pm4[4] = PKT3(PKT3_DRAW_INDEX, 3, ctx->predicate_drawing);
+               pm4[5] = draw->indices_bo_offset + r600_bo_offset(draw->indices);
+               pm4[6] = 0;
+               pm4[7] = draw->vgt_num_indices;
+               pm4[8] = draw->vgt_draw_initiator;
+               pm4[9] = PKT3(PKT3_NOP, 0, ctx->predicate_drawing);
+               pm4[10] = 0;
+               r600_context_bo_reloc(ctx, &pm4[10], draw->indices);
        } else {
-               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_DRAW_INDEX_AUTO, 1, ctx->predicate_drawing);
-               ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_num_indices;
-               ctx->pm4[ctx->pm4_cdwords++] = draw->vgt_draw_initiator;
+               pm4[4] = PKT3(PKT3_DRAW_INDEX_AUTO, 1, ctx->predicate_drawing);
+               pm4[5] = draw->vgt_num_indices;
+               pm4[6] = draw->vgt_draw_initiator;
        }
+       ctx->pm4_cdwords += ndwords;
 
        ctx->flags |= (R600_CONTEXT_DST_CACHES_DIRTY | R600_CONTEXT_DRAW_PENDING);