r600g: make r600_drawl inherit pipe_draw_info
authorMarek Olšák <maraeo@gmail.com>
Fri, 28 Jan 2011 20:55:28 +0000 (21:55 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sun, 30 Jan 2011 02:29:48 +0000 (03:29 +0100)
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_buffer.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c

index 2c9dd4799795a45318d3400dd525433e05da46d8..7fb64d2b6583587df1fc18fbc506c2cf1f8d8b87 100644 (file)
@@ -1432,43 +1432,34 @@ void evergreen_vertex_buffer_update(struct r600_pipe_context *rctx)
 }
 
 int r600_conv_pipe_prim(unsigned pprim, unsigned *prim);
-void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info)
+
+void evergreen_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 {
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_resource *rbuffer;
        u32 vgt_dma_index_type, vgt_draw_initiator, mask;
        struct r600_draw rdraw;
        struct r600_pipe_state vgt;
-       struct r600_drawl draw;
+       struct r600_drawl draw = {};
        unsigned prim;
 
-       memset(&draw, 0, sizeof(struct r600_drawl));
+       draw.info = *info;
        draw.ctx = ctx;
-       draw.mode = info->mode;
-       draw.start = info->start;
-       draw.count = info->count;
        if (info->indexed && rctx->index_buffer.buffer) {
-               draw.start += rctx->index_buffer.offset / rctx->index_buffer.index_size;
-               draw.min_index = info->min_index;
-               draw.max_index = info->max_index;
-               draw.index_bias = info->index_bias;
+               draw.info.start += rctx->index_buffer.offset / rctx->index_buffer.index_size;
 
                r600_translate_index_buffer(rctx, &rctx->index_buffer.buffer,
                                            &rctx->index_buffer.index_size,
-                                           &draw.start,
+                                           &draw.info.start,
                                            info->count);
 
                draw.index_size = rctx->index_buffer.index_size;
                pipe_resource_reference(&draw.index_buffer, rctx->index_buffer.buffer);
-               draw.index_buffer_offset = draw.start * draw.index_size;
-               draw.start = 0;
+               draw.index_buffer_offset = draw.info.start * draw.index_size;
+               draw.info.start = 0;
                r600_upload_index_buffer(rctx, &draw);
        } else {
-               draw.index_size = 0;
-               draw.index_buffer = NULL;
-               draw.min_index = info->min_index;
-               draw.max_index = info->max_index;
-               draw.index_bias = info->start;
+               draw.info.index_bias = info->start;
        }
 
        switch (draw.index_size) {
@@ -1488,7 +1479,7 @@ void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info)
                R600_ERR("unsupported index size %d\n", draw.index_size);
                return;
        }
-       if (r600_conv_pipe_prim(draw.mode, &prim))
+       if (r600_conv_pipe_prim(draw.info.mode, &prim))
                return;
        if (unlikely(rctx->ps_shader == NULL)) {
                R600_ERR("missing vertex shader\n");
@@ -1515,15 +1506,15 @@ void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info)
        vgt.id = R600_PIPE_STATE_VGT;
        vgt.nregs = 0;
        r600_pipe_state_add_reg(&vgt, R_008958_VGT_PRIMITIVE_TYPE, prim, 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(&vgt, R_028408_VGT_INDX_OFFSET, draw.index_bias, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(&vgt, R_028408_VGT_INDX_OFFSET, draw.info.index_bias, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(&vgt, R_028238_CB_TARGET_MASK, rctx->cb_target_mask & mask, 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(&vgt, R_028400_VGT_MAX_VTX_INDX, draw.max_index, 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(&vgt, R_028404_VGT_MIN_VTX_INDX, draw.min_index, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(&vgt, R_028400_VGT_MAX_VTX_INDX, draw.info.max_index, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(&vgt, R_028404_VGT_MIN_VTX_INDX, draw.info.min_index, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(&vgt, R_03CFF0_SQ_VTX_BASE_VTX_LOC, 0, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(&vgt, R_03CFF4_SQ_VTX_START_INST_LOC, 0, 0xFFFFFFFF, NULL);
        r600_context_pipe_state_set(&rctx->ctx, &vgt);
 
-       rdraw.vgt_num_indices = draw.count;
+       rdraw.vgt_num_indices = draw.info.count;
        rdraw.vgt_num_instances = 1;
        rdraw.vgt_index_type = vgt_dma_index_type;
        rdraw.vgt_draw_initiator = vgt_draw_initiator;
index f22475460623c6fe6076cd4e2ece6495c031b338..024bbc29168dbf2efa9934cf9e587cc42fbee38f 100644 (file)
@@ -207,7 +207,7 @@ void r600_upload_index_buffer(struct r600_pipe_context *rctx, struct r600_drawl
                boolean flushed;
 
                u_upload_data(rctx->upload_vb, 0,
-                             draw->count * draw->index_size,
+                             draw->info.count * draw->index_size,
                              rbuffer->user_buffer,
                              &draw->index_buffer_offset,
                              &draw->index_buffer, &flushed);
index 824cf7fc46a55dd4e48c4e466de409b29d627e9a..71054fe4d575dc082c7186bf9d1120ba25397fee 100644 (file)
@@ -154,7 +154,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        case CHIP_BARTS:
        case CHIP_TURKS:
        case CHIP_CAICOS:
-               rctx->context.draw_vbo = evergreen_draw;
+               rctx->context.draw_vbo = evergreen_draw_vbo;
                evergreen_init_state_functions(rctx);
                if (evergreen_context_init(&rctx->ctx, rctx->radeon)) {
                        r600_destroy_context(&rctx->context);
index 8d5e3c3b55337e7d1c9d00e82fb27dc9b88666eb..94912680c203ddb6108e872005a47d0104c4ecde 100644 (file)
@@ -171,13 +171,8 @@ struct r600_pipe_context {
 };
 
 struct r600_drawl {
+       struct pipe_draw_info   info;
        struct pipe_context     *ctx;
-       unsigned                mode;
-       unsigned                min_index;
-       unsigned                max_index;
-       unsigned                index_bias;
-       unsigned                start;
-       unsigned                count;
        unsigned                index_size;
        unsigned                index_buffer_offset;
        struct pipe_resource    *index_buffer;
@@ -186,7 +181,7 @@ struct r600_drawl {
 /* evergreen_state.c */
 void evergreen_init_state_functions(struct r600_pipe_context *rctx);
 void evergreen_init_config(struct r600_pipe_context *rctx);
-void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info);
+void evergreen_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info);
 void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader);
 void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader);
 void *evergreen_create_db_flush_dsa(struct r600_pipe_context *rctx);
index 0191a119d5d6735405db7e54b371ef10138b865f..8501caf09e2db41bc6a9326c7fe1b01780f332dc 100644 (file)
@@ -223,7 +223,7 @@ static void r600_draw_common(struct r600_drawl *draw)
                R600_ERR("unsupported index size %d\n", draw->index_size);
                return;
        }
-       if (r600_conv_pipe_prim(draw->mode, &prim))
+       if (r600_conv_pipe_prim(draw->info.mode, &prim))
                return;
        if (unlikely(rctx->ps_shader == NULL)) {
                R600_ERR("missing vertex shader\n");
@@ -250,15 +250,15 @@ static void r600_draw_common(struct r600_drawl *draw)
        vgt.id = R600_PIPE_STATE_VGT;
        vgt.nregs = 0;
        r600_pipe_state_add_reg(&vgt, R_008958_VGT_PRIMITIVE_TYPE, prim, 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(&vgt, R_028408_VGT_INDX_OFFSET, draw->index_bias, 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(&vgt, R_028400_VGT_MAX_VTX_INDX, draw->max_index, 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(&vgt, R_028404_VGT_MIN_VTX_INDX, draw->min_index, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(&vgt, R_028408_VGT_INDX_OFFSET, draw->info.index_bias, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(&vgt, R_028400_VGT_MAX_VTX_INDX, draw->info.max_index, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(&vgt, R_028404_VGT_MIN_VTX_INDX, draw->info.min_index, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(&vgt, R_028238_CB_TARGET_MASK, rctx->cb_target_mask & mask, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(&vgt, R_03CFF0_SQ_VTX_BASE_VTX_LOC, 0, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(&vgt, R_03CFF4_SQ_VTX_START_INST_LOC, 0, 0xFFFFFFFF, NULL);
        r600_context_pipe_state_set(&rctx->ctx, &vgt);
 
-       rdraw.vgt_num_indices = draw->count;
+       rdraw.vgt_num_indices = draw->info.count;
        rdraw.vgt_num_instances = 1;
        rdraw.vgt_index_type = vgt_dma_index_type;
        rdraw.vgt_draw_initiator = vgt_draw_initiator;
@@ -274,35 +274,25 @@ static void r600_draw_common(struct r600_drawl *draw)
 void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 {
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
-       struct r600_drawl draw;
+       struct r600_drawl draw = {};
 
-       memset(&draw, 0, sizeof(struct r600_drawl));
+       draw.info = *info;
        draw.ctx = ctx;
-       draw.mode = info->mode;
-       draw.start = info->start;
-       draw.count = info->count;
        if (info->indexed && rctx->index_buffer.buffer) {
-               draw.start += rctx->index_buffer.offset / rctx->index_buffer.index_size;
-               draw.min_index = info->min_index;
-               draw.max_index = info->max_index;
-               draw.index_bias = info->index_bias;
+               draw.info.start += rctx->index_buffer.offset / rctx->index_buffer.index_size;
 
                r600_translate_index_buffer(rctx, &rctx->index_buffer.buffer,
                                            &rctx->index_buffer.index_size,
-                                           &draw.start,
+                                           &draw.info.start,
                                            info->count);
 
                draw.index_size = rctx->index_buffer.index_size;
                pipe_resource_reference(&draw.index_buffer, rctx->index_buffer.buffer);
-               draw.index_buffer_offset = draw.start * draw.index_size;
-               draw.start = 0;
+               draw.index_buffer_offset = draw.info.start * draw.index_size;
+               draw.info.start = 0;
                r600_upload_index_buffer(rctx, &draw);
        } else {
-               draw.index_size = 0;
-               draw.index_buffer = NULL;
-               draw.min_index = info->min_index;
-               draw.max_index = info->max_index;
-               draw.index_bias = info->start;
+               draw.info.index_bias = info->start;
        }
        r600_draw_common(&draw);