r600g: fix draw-elements and draw-elements-base-vertex
authorDave Airlie <airlied@redhat.com>
Fri, 24 Sep 2010 02:32:45 +0000 (12:32 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 24 Sep 2010 02:34:43 +0000 (12:34 +1000)
src/gallium/drivers/r600/r600_context.h
src/gallium/drivers/r600/r600_draw.c
src/gallium/drivers/r600/r600_hw_states.c

index 8778f23a819d5b9ab83bdac25ad908be479a1ad7..c15e64329d8018ad5baefb5e5baeae30c51e6661 100644 (file)
@@ -129,6 +129,7 @@ struct r600_draw {
        struct pipe_resource    *index_buffer;
        unsigned                index_buffer_offset;
        unsigned                min_index, max_index;
+       unsigned                index_bias;
 };
 
 struct r600_context_hw_states {
index 0fa48ae23ab7f29820a6a5a00fef9f9cf14ae361..4978a3cab2af5a93800f528c4eb010d7cfa6c1c5 100644 (file)
@@ -149,8 +149,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
        struct r600_draw draw;
        int r;
 
-       assert(info->index_bias == 0);
-
        memset(&draw, 0, sizeof(draw));
 
        if (rctx->any_user_vbs) {
@@ -166,16 +164,17 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
                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;
 
                r600_translate_index_buffer(rctx, &rctx->index_buffer.buffer,
                                            &rctx->index_buffer.index_size,
-                                           rctx->index_buffer.offset, &draw.start,
+                                           0, &draw.start,
                                            info->count);
 
                draw.index_size = rctx->index_buffer.index_size;
                draw.index_buffer = rctx->index_buffer.buffer;
-               draw.index_buffer_offset = rctx->index_buffer.offset;
-
+               draw.index_buffer_offset = draw.start * draw.index_size;
+               draw.start = 0;
                r600_upload_index_buffer(rctx, &draw);
        }
        else {
@@ -184,7 +183,9 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
                draw.min_index = 0;
                draw.max_index = 0xffffff;
                draw.index_buffer_offset = 0;
+               draw.index_bias = draw.start;
        }
+
        r = r600_draw_common(&draw);
        if (r)
          fprintf(stderr,"draw common failed %d\n", r);
index 9e54c6a9215d8653cc155cb6c3029c6171ebca9f..1e9c5ffbfc726d7e1df6a323497f6a56774c142e 100644 (file)
@@ -983,7 +983,7 @@ static int r600_draw_vgt_prim(struct r600_draw *draw,
        draw->vgt.states[R600_VGT__VGT_PRIMITIVE_TYPE] = prim;
        draw->vgt.states[R600_VGT__VGT_MAX_VTX_INDX] = draw->max_index;
        draw->vgt.states[R600_VGT__VGT_MIN_VTX_INDX] = draw->min_index;
-       draw->vgt.states[R600_VGT__VGT_INDX_OFFSET] = draw->start;
+       draw->vgt.states[R600_VGT__VGT_INDX_OFFSET] = draw->index_bias;
        draw->vgt.states[R600_VGT__VGT_MULTI_PRIM_IB_RESET_INDX] = 0x00000000;
        draw->vgt.states[R600_VGT__VGT_DMA_INDEX_TYPE] = vgt_dma_index_type;
        draw->vgt.states[R600_VGT__VGT_PRIMITIVEID_EN] = 0x00000000;