diff options
author | José Fonseca <[email protected]> | 2010-04-20 11:07:08 +0200 |
---|---|---|
committer | José Fonseca <[email protected]> | 2010-04-20 11:07:08 +0200 |
commit | a6171a9dd99713266091982215bf1008c9ac8e64 (patch) | |
tree | 7be00d0ab09dec383d9acc4fd3b135dfd8ed5c45 /src/gallium/drivers | |
parent | 49ba607abab17cc07e9f163f5415636474fd7940 (diff) | |
parent | 3dcdca433a5d6cde1c0b4d69ff0aa3a5eee26473 (diff) |
Merge branch 'gallium-index-bias'
Diffstat (limited to 'src/gallium/drivers')
26 files changed, 161 insertions, 97 deletions
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index 80e94a79df7..b50a30bee80 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -59,6 +59,7 @@ static void cell_draw_range_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned min_index, unsigned max_index, unsigned mode, unsigned start, unsigned count) @@ -84,11 +85,11 @@ cell_draw_range_elements(struct pipe_context *pipe, /* Map index buffer, if present */ if (indexBuffer) { void *mapped_indexes = cell_resource(indexBuffer)->data; - draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); + draw_set_mapped_element_buffer(draw, indexSize, indexBias, mapped_indexes); } else { /* no index/element buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } @@ -117,11 +118,11 @@ cell_draw_range_elements(struct pipe_context *pipe, static void cell_draw_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count) { cell_draw_range_elements( pipe, indexBuffer, - indexSize, + indexSize, indeBias, 0, 0xffffffff, mode, start, count ); } @@ -131,7 +132,7 @@ static void cell_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { - cell_draw_elements(pipe, NULL, 0, mode, start, count); + cell_draw_elements(pipe, NULL, 0, 0, mode, start, count); } diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c index 325a1009541..236c50f4d98 100644 --- a/src/gallium/drivers/failover/fo_context.c +++ b/src/gallium/drivers/failover/fo_context.c @@ -53,6 +53,7 @@ void failover_fail_over( struct failover_context *failover ) static void failover_draw_elements( struct pipe_context *pipe, struct pipe_resource *indexResource, unsigned indexSize, + int indexBias, unsigned prim, unsigned start, unsigned count) @@ -72,6 +73,7 @@ static void failover_draw_elements( struct pipe_context *pipe, failover->hw->draw_elements( failover->hw, indexResource, indexSize, + indexBias, prim, start, count ); @@ -89,6 +91,7 @@ static void failover_draw_elements( struct pipe_context *pipe, failover->sw->draw_elements( failover->sw, indexResource, indexSize, + indexBias, prim, start, count ); @@ -105,7 +108,7 @@ static void failover_draw_elements( struct pipe_context *pipe, static void failover_draw_arrays( struct pipe_context *pipe, unsigned prim, unsigned start, unsigned count) { - failover_draw_elements(pipe, NULL, 0, prim, start, count); + failover_draw_elements(pipe, NULL, 0, 0, prim, start, count); } static unsigned int diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 12dea9f806c..2af9bdac956 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -48,6 +48,7 @@ static void i915_draw_range_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned min_index, unsigned max_index, unsigned prim, unsigned start, unsigned count) @@ -72,12 +73,12 @@ i915_draw_range_elements(struct pipe_context *pipe, */ if (indexBuffer) { void *mapped_indexes = i915_buffer(indexBuffer)->data; - draw_set_mapped_element_buffer_range(draw, indexSize, + draw_set_mapped_element_buffer_range(draw, indexSize, indexBias, min_index, max_index, mapped_indexes); } else { - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } @@ -99,18 +100,18 @@ i915_draw_range_elements(struct pipe_context *pipe, } if (indexBuffer) { - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } } static void i915_draw_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned prim, unsigned start, unsigned count) { i915_draw_range_elements(pipe, indexBuffer, - indexSize, + indexSize, indexBias, 0, 0xffffffff, prim, start, count); } @@ -119,7 +120,7 @@ static void i915_draw_arrays(struct pipe_context *pipe, unsigned prim, unsigned start, unsigned count) { - i915_draw_elements(pipe, NULL, 0, prim, start, count); + i915_draw_elements(pipe, NULL, 0, 0, prim, start, count); } diff --git a/src/gallium/drivers/i965/brw_draw.c b/src/gallium/drivers/i965/brw_draw.c index eb73ec2f272..4625c2048f9 100644 --- a/src/gallium/drivers/i965/brw_draw.c +++ b/src/gallium/drivers/i965/brw_draw.c @@ -179,7 +179,7 @@ try_draw_range_elements(struct brw_context *brw, static void brw_draw_range_elements(struct pipe_context *pipe, struct pipe_resource *index_buffer, - unsigned index_size, + unsigned index_size, int index_bias, unsigned min_index, unsigned max_index, unsigned mode, unsigned start, unsigned count) @@ -194,6 +194,8 @@ brw_draw_range_elements(struct pipe_context *pipe, debug_printf("PRIM: %s start %d count %d index_buffer %p\n", u_prim_name(mode), start, count, (void *)index_buffer); + assert(index_bias == 0); + /* Potentially trigger upload of new index buffer. * * XXX: do we need to go through state validation to achieve this? @@ -233,12 +235,12 @@ brw_draw_range_elements(struct pipe_context *pipe, static void brw_draw_elements(struct pipe_context *pipe, struct pipe_resource *index_buffer, - unsigned index_size, + unsigned index_size, int index_bias, unsigned mode, unsigned start, unsigned count) { brw_draw_range_elements( pipe, index_buffer, - index_size, + index_size, index_bias, 0, 0xffffffff, mode, start, count ); @@ -248,7 +250,7 @@ static void brw_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { - brw_draw_elements(pipe, NULL, 0, mode, start, count); + brw_draw_elements(pipe, NULL, 0, 0, mode, start, count); } diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 3b7eaecc02f..630cdb5e491 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -64,6 +64,7 @@ static void identity_draw_elements(struct pipe_context *_pipe, struct pipe_resource *_indexResource, unsigned indexSize, + int indexBias, unsigned prim, unsigned start, unsigned count) @@ -76,6 +77,7 @@ identity_draw_elements(struct pipe_context *_pipe, pipe->draw_elements(pipe, indexResource, indexSize, + indexBias, prim, start, count); @@ -85,6 +87,7 @@ static void identity_draw_range_elements(struct pipe_context *_pipe, struct pipe_resource *_indexResource, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -99,6 +102,7 @@ identity_draw_range_elements(struct pipe_context *_pipe, pipe->draw_range_elements(pipe, indexResource, indexSize, + indexBias, minIndex, maxIndex, mode, diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index 86525eea9e9..0b63e1c889e 100644 --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -46,7 +46,7 @@ void llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { - llvmpipe_draw_elements(pipe, NULL, 0, mode, start, count); + llvmpipe_draw_elements(pipe, NULL, 0, 0, mode, start, count); } @@ -59,6 +59,7 @@ void llvmpipe_draw_range_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned min_index, unsigned max_index, unsigned mode, unsigned start, unsigned count) @@ -81,14 +82,14 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe, /* Map index buffer, if present */ if (indexBuffer) { void *mapped_indexes = llvmpipe_resource_data(indexBuffer); - draw_set_mapped_element_buffer_range(draw, indexSize, + draw_set_mapped_element_buffer_range(draw, indexSize, indexBias, min_index, max_index, mapped_indexes); } else { /* no index/element buffer */ - draw_set_mapped_element_buffer_range(draw, 0, start, + draw_set_mapped_element_buffer_range(draw, 0, 0, start, start + count - 1, NULL); } @@ -102,7 +103,7 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe, draw_set_mapped_vertex_buffer(draw, i, NULL); } if (indexBuffer) { - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } /* @@ -118,10 +119,11 @@ void llvmpipe_draw_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned mode, unsigned start, unsigned count) { llvmpipe_draw_range_elements( pipe, indexBuffer, - indexSize, + indexSize, indexBias, 0, 0xffffffff, mode, start, count ); } diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index d89c28a2af2..dcbff190b62 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -228,12 +228,12 @@ void llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, void llvmpipe_draw_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count); void llvmpipe_draw_range_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned min_index, unsigned max_index, unsigned mode, unsigned start, unsigned count); diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 8bf465378e3..4875f833054 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -185,12 +185,12 @@ extern void nv50_draw_arrays_instanced(struct pipe_context *, unsigned mode, unsigned instanceCount); extern void nv50_draw_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count); extern void nv50_draw_elements_instanced(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count, unsigned startInstance, diff --git a/src/gallium/drivers/nv50/nv50_push.c b/src/gallium/drivers/nv50/nv50_push.c index 6981e5b919b..c54fed5a36f 100644 --- a/src/gallium/drivers/nv50/nv50_push.c +++ b/src/gallium/drivers/nv50/nv50_push.c @@ -172,7 +172,8 @@ emit_verts(void *priv, unsigned start, unsigned count) void nv50_push_elements_instanced(struct pipe_context *pipe, - struct pipe_resource *idxbuf, unsigned idxsize, + struct pipe_resource *idxbuf, + unsigned idxsize, int idxbias, unsigned mode, unsigned start, unsigned count, unsigned i_start, unsigned i_count) { @@ -269,6 +270,7 @@ nv50_push_elements_instanced(struct pipe_context *pipe, } ctx.idxbuf = bo->map; ctx.idxsize = idxsize; + assert(idxbias == 0); nouveau_bo_unmap(bo); } diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 609145db88a..932c1e89923 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -387,7 +387,7 @@ nv50_draw_elements_inline(struct pipe_context *pipe, void nv50_draw_elements_instanced(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count, unsigned startInstance, unsigned instanceCount) { @@ -401,6 +401,8 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, if (!nv50_state_validate(nv50, 13 + 16*3)) return; + assert(indexBias == 0); + if (nv50->vbo_fifo) { nv50_push_elements_instanced(pipe, indexBuffer, indexSize, mode, start, count, startInstance, @@ -460,10 +462,11 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, void nv50_draw_elements(struct pipe_context *pipe, - struct pipe_resource *indexBuffer, unsigned indexSize, + struct pipe_resource *indexBuffer, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count) { - nv50_draw_elements_instanced(pipe, indexBuffer, indexSize, + nv50_draw_elements_instanced(pipe, indexBuffer, indexSize, indexBias, mode, start, count, 0, 1); } diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h index e2c6d09fa19..e48f9f3aa88 100644 --- a/src/gallium/drivers/nvfx/nvfx_context.h +++ b/src/gallium/drivers/nvfx/nvfx_context.h @@ -175,9 +175,10 @@ extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers, /* nvfx_draw.c */ extern struct draw_stage *nvfx_draw_render_stage(struct nvfx_context *nvfx); extern void nvfx_draw_elements_swtnl(struct pipe_context *pipe, - struct pipe_resource *idxbuf, - unsigned ib_size, unsigned mode, - unsigned start, unsigned count); + struct pipe_resource *idxbuf, + unsigned ib_size, int ib_bias, + unsigned mode, + unsigned start, unsigned count); extern void nvfx_vtxfmt_validate(struct nvfx_context *nvfx); /* nvfx_fb.c */ @@ -237,10 +238,10 @@ extern void nvfx_vbo_relocate(struct nvfx_context *nvfx); extern void nvfx_draw_arrays(struct pipe_context *, unsigned mode, unsigned start, unsigned count); extern void nvfx_draw_elements(struct pipe_context *pipe, - struct pipe_resource *indexBuffer, - unsigned indexSize, - unsigned mode, unsigned start, - unsigned count); + struct pipe_resource *indexBuffer, + unsigned indexSize, int indexBias, + unsigned mode, unsigned start, + unsigned count); /* nvfx_vertprog.c */ extern boolean nvfx_vertprog_validate(struct nvfx_context *nvfx); diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c index 5eadce1f6d4..55b72aced02 100644 --- a/src/gallium/drivers/nvfx/nvfx_draw.c +++ b/src/gallium/drivers/nvfx/nvfx_draw.c @@ -232,7 +232,8 @@ nvfx_draw_render_stage(struct nvfx_context *nvfx) void nvfx_draw_elements_swtnl(struct pipe_context *pipe, - struct pipe_resource *idxbuf, unsigned idxbuf_size, + struct pipe_resource *idxbuf, + unsigned idxbuf_size, int idxbuf_bias, unsigned mode, unsigned start, unsigned count) { struct nvfx_context *nvfx = nvfx_context(pipe); @@ -257,9 +258,9 @@ nvfx_draw_elements_swtnl(struct pipe_context *pipe, map = pipe_buffer_map(pipe, idxbuf, PIPE_TRANSFER_READ, &ib_transfer); - draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, map); + draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, idx_bufbias, map); } else { - draw_set_mapped_element_buffer(nvfx->draw, 0, NULL); + draw_set_mapped_element_buffer(nvfx->draw, 0, 0, NULL); } if (nvfx->constbuf[PIPE_SHADER_VERTEX]) { diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c b/src/gallium/drivers/nvfx/nvfx_vbo.c index b8e94885f04..4d7b7f181d8 100644 --- a/src/gallium/drivers/nvfx/nvfx_vbo.c +++ b/src/gallium/drivers/nvfx/nvfx_vbo.c @@ -168,7 +168,7 @@ nvfx_draw_arrays(struct pipe_context *pipe, nvfx_vbo_set_idxbuf(nvfx, NULL, 0); if (nvfx->screen->force_swtnl || !nvfx_state_validate(nvfx)) { - nvfx_draw_elements_swtnl(pipe, NULL, 0, + nvfx_draw_elements_swtnl(pipe, NULL, 0, 0, mode, start, count); return; } @@ -373,7 +373,8 @@ nvfx_draw_elements_u32(struct nvfx_context *nvfx, void *ib, static void nvfx_draw_elements_inline(struct pipe_context *pipe, - struct pipe_resource *ib, unsigned ib_size, + struct pipe_resource *ib, + unsigned ib_size, int ib_bias, unsigned mode, unsigned start, unsigned count) { struct nvfx_context *nvfx = nvfx_context(pipe); @@ -386,6 +387,8 @@ nvfx_draw_elements_inline(struct pipe_context *pipe, return; } + assert(ib_bias == 0); + switch (ib_size) { case 1: nvfx_draw_elements_u08(nvfx, map, mode, start, count); @@ -461,7 +464,8 @@ nvfx_draw_elements_vbo(struct pipe_context *pipe, void nvfx_draw_elements(struct pipe_context *pipe, - struct pipe_resource *indexBuffer, unsigned indexSize, + struct pipe_resource *indexBuffer, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count) { struct nvfx_context *nvfx = nvfx_context(pipe); @@ -469,15 +473,17 @@ nvfx_draw_elements(struct pipe_context *pipe, idxbuf = nvfx_vbo_set_idxbuf(nvfx, indexBuffer, indexSize); if (nvfx->screen->force_swtnl || !nvfx_state_validate(nvfx)) { - nvfx_draw_elements_swtnl(pipe, indexBuffer, indexSize, - mode, start, count); + nvfx_draw_elements_swtnl(pipe, + indexBuffer, indexSize, indexBias, + mode, start, count); return; } if (idxbuf) { nvfx_draw_elements_vbo(pipe, mode, start, count); } else { - nvfx_draw_elements_inline(pipe, indexBuffer, indexSize, + nvfx_draw_elements_inline(pipe, + indexBuffer, indexSize, indexBias, mode, start, count); } diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 2e8601b65ef..1e4fd9e5edd 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -327,7 +327,8 @@ struct r300_context { void (*emit_draw_elements)( struct r300_context *r300, struct pipe_resource* indexBuffer, - unsigned indexSize, unsigned minIndex, unsigned maxIndex, + unsigned indexSize, int indexBias, + unsigned minIndex, unsigned maxIndex, unsigned mode, unsigned start, unsigned count); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index a3fd8cc67d8..23b61df89cc 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -298,6 +298,7 @@ void r500_emit_draw_arrays(struct r300_context *r300, void r500_emit_draw_elements(struct r300_context *r300, struct pipe_resource* indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -319,6 +320,8 @@ void r500_emit_draw_elements(struct r300_context *r300, return; } + assert(indexBias == 0); + maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index); DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n", @@ -442,6 +445,7 @@ void r300_emit_draw_arrays(struct r300_context *r300, void r300_emit_draw_elements(struct r300_context *r300, struct pipe_resource* indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -449,15 +453,15 @@ void r300_emit_draw_elements(struct r300_context *r300, unsigned count) { if (!r300->stencil_ref_bf_fallback) { - r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, - maxIndex, mode, start, count); + r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + minIndex, maxIndex, mode, start, count); } else { r300_begin_stencil_ref_fallback(r300); - r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, - maxIndex, mode, start, count); + r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + minIndex, maxIndex, mode, start, count); r300_switch_stencil_ref_side(r300); - r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, - maxIndex, mode, start, count); + r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + minIndex, maxIndex, mode, start, count); r300_end_stencil_ref_fallback(r300); } } @@ -528,6 +532,7 @@ static void r300_align_ushort_elts(struct r300_context *r300, void r300_draw_range_elements(struct pipe_context* pipe, struct pipe_resource* indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -574,13 +579,14 @@ void r300_draw_range_elements(struct pipe_context* pipe, u_upload_flush(r300->upload_vb); u_upload_flush(r300->upload_ib); if (alt_num_verts || count <= 65535) { - r300->emit_draw_elements(r300, indexBuffer, indexSize, minIndex, - maxIndex, mode, start, count); + r300->emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + minIndex, maxIndex, mode, start, count); } else { do { short_count = MIN2(count, 65534); - r300->emit_draw_elements(r300, indexBuffer, indexSize, minIndex, - maxIndex, mode, start, short_count); + r300->emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + minIndex, maxIndex, + mode, start, short_count); start += short_count; count -= short_count; @@ -602,13 +608,13 @@ void r300_draw_range_elements(struct pipe_context* pipe, /* Simple helpers for context setup. Should probably be moved to util. */ void r300_draw_elements(struct pipe_context* pipe, struct pipe_resource* indexBuffer, - unsigned indexSize, unsigned mode, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count) { struct r300_context *r300 = r300_context(pipe); - pipe->draw_range_elements(pipe, indexBuffer, indexSize, 0, - r300->vertex_buffer_max_index, + pipe->draw_range_elements(pipe, indexBuffer, indexSize, indexBias, + 0, r300->vertex_buffer_max_index, mode, start, count); } @@ -698,7 +704,7 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe, draw_set_mapped_vertex_buffer(r300->draw, i, buf); } - draw_set_mapped_element_buffer(r300->draw, 0, NULL); + draw_set_mapped_element_buffer(r300->draw, 0, 0, NULL); draw_arrays(r300->draw, mode, start, count); @@ -713,6 +719,7 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe, void r300_swtcl_draw_range_elements(struct pipe_context* pipe, struct pipe_resource* indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -743,7 +750,7 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe, indices = pipe_buffer_map(pipe, indexBuffer, PIPE_TRANSFER_READ, &ib_transfer); - draw_set_mapped_element_buffer_range(r300->draw, indexSize, + draw_set_mapped_element_buffer_range(r300->draw, indexSize, indexBias, minIndex, maxIndex, indices); draw_arrays(r300->draw, mode, start, count); @@ -756,8 +763,9 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe, pipe_buffer_unmap(pipe, indexBuffer, ib_transfer); - draw_set_mapped_element_buffer_range(r300->draw, 0, start, - start + count - 1, NULL); + draw_set_mapped_element_buffer_range(r300->draw, 0, 0, + start, start + count - 1, + NULL); } /* Object for rendering using Draw. */ diff --git a/src/gallium/drivers/r300/r300_render.h b/src/gallium/drivers/r300/r300_render.h index 85da6135f58..4e78914c1ba 100644 --- a/src/gallium/drivers/r300/r300_render.h +++ b/src/gallium/drivers/r300/r300_render.h @@ -35,6 +35,7 @@ void r500_emit_draw_arrays(struct r300_context *r300, void r500_emit_draw_elements(struct r300_context *r300, struct pipe_resource* indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -53,6 +54,7 @@ void r300_emit_draw_arrays(struct r300_context *r300, void r300_emit_draw_elements(struct r300_context *r300, struct pipe_resource* indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -62,6 +64,7 @@ void r300_emit_draw_elements(struct r300_context *r300, void r300_draw_range_elements(struct pipe_context* pipe, struct pipe_resource* indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -70,7 +73,7 @@ void r300_draw_range_elements(struct pipe_context* pipe, void r300_draw_elements(struct pipe_context* pipe, struct pipe_resource* indexBuffer, - unsigned indexSize, unsigned mode, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count); void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, @@ -84,6 +87,7 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe, void r300_swtcl_draw_range_elements(struct pipe_context* pipe, struct pipe_resource* indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 461c9a6c4d4..b30036e2303 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -57,6 +57,7 @@ static void softpipe_draw_range_elements_instanced(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -74,6 +75,7 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, NULL, 0, 0, + 0, 0xffffffff, mode, start, @@ -87,6 +89,7 @@ void softpipe_draw_range_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned min_index, unsigned max_index, unsigned mode, unsigned start, unsigned count) @@ -94,6 +97,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe, softpipe_draw_range_elements_instanced(pipe, indexBuffer, indexSize, + indexBias, min_index, max_index, mode, @@ -107,12 +111,13 @@ softpipe_draw_range_elements(struct pipe_context *pipe, void softpipe_draw_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count) { softpipe_draw_range_elements_instanced(pipe, indexBuffer, indexSize, + indexBias, 0, 0xffffffff, mode, @@ -134,6 +139,7 @@ softpipe_draw_arrays_instanced(struct pipe_context *pipe, NULL, 0, 0, + 0, 0xffffffff, mode, start, @@ -146,6 +152,7 @@ void softpipe_draw_elements_instanced(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned mode, unsigned start, unsigned count, @@ -155,6 +162,7 @@ softpipe_draw_elements_instanced(struct pipe_context *pipe, softpipe_draw_range_elements_instanced(pipe, indexBuffer, indexSize, + indexBias, 0, 0xffffffff, mode, @@ -168,6 +176,7 @@ static void softpipe_draw_range_elements_instanced(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -202,13 +211,14 @@ softpipe_draw_range_elements_instanced(struct pipe_context *pipe, void *mapped_indexes = softpipe_resource(indexBuffer)->data; draw_set_mapped_element_buffer_range(draw, indexSize, + indexBias, minIndex, maxIndex, mapped_indexes); } else { /* no index/element buffer */ draw_set_mapped_element_buffer_range(draw, - 0, + 0, 0, start, start + count - 1, NULL); @@ -222,7 +232,7 @@ softpipe_draw_range_elements_instanced(struct pipe_context *pipe, draw_set_mapped_vertex_buffer(draw, i, NULL); } if (indexBuffer) { - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } /* diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index 3c04c8bb07e..f97fc6eca8f 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -211,12 +211,13 @@ void softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, void softpipe_draw_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count); void softpipe_draw_range_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned min_index, unsigned max_index, unsigned mode, unsigned start, unsigned count); @@ -233,6 +234,7 @@ void softpipe_draw_elements_instanced(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned mode, unsigned start, unsigned count, diff --git a/src/gallium/drivers/svga/svga_draw.h b/src/gallium/drivers/svga/svga_draw.h index 81c7f8377de..a2403d802be 100644 --- a/src/gallium/drivers/svga/svga_draw.h +++ b/src/gallium/drivers/svga/svga_draw.h @@ -69,12 +69,12 @@ enum pipe_error svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, struct pipe_resource *indexBuffer, unsigned index_size, + int index_bias, unsigned min_index, unsigned max_index, unsigned prim, unsigned start, - unsigned count, - unsigned bias ); + unsigned count ); enum pipe_error svga_hwtnl_flush( struct svga_hwtnl *hwtnl ); diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index 7ec4a058fc7..c4579177b77 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -99,12 +99,12 @@ enum pipe_error svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, struct pipe_resource *index_buffer, unsigned index_size, + int index_bias, unsigned min_index, unsigned max_index, unsigned prim, unsigned start, - unsigned count, - unsigned bias ) + unsigned count ) { struct pipe_resource *upload_buffer = NULL; SVGA3dPrimitiveRange range; @@ -143,7 +143,7 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, range.indexArray.offset = index_offset; range.indexArray.stride = index_size; range.indexWidth = index_size; - range.indexBias = bias; + range.indexBias = index_bias; ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer ); if (ret) @@ -163,10 +163,10 @@ enum pipe_error svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, struct pipe_resource *index_buffer, unsigned index_size, + int index_bias, unsigned min_index, unsigned max_index, - unsigned prim, unsigned start, unsigned count, - unsigned bias) + unsigned prim, unsigned start, unsigned count) { unsigned gen_prim, gen_size, gen_nr, gen_type; u_translate_func gen_func; @@ -204,9 +204,10 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, */ return svga_hwtnl_simple_draw_range_elements( hwtnl, index_buffer, index_size, + index_bias, min_index, max_index, - gen_prim, start, count, bias ); + gen_prim, start, count ); } else { struct pipe_resource *gen_buf = NULL; @@ -231,12 +232,12 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl, ret = svga_hwtnl_simple_draw_range_elements( hwtnl, gen_buf, gen_size, + index_bias, min_index, max_index, gen_prim, 0, - gen_nr, - bias ); + gen_nr ); if (ret) goto done; diff --git a/src/gallium/drivers/svga/svga_draw_private.h b/src/gallium/drivers/svga/svga_draw_private.h index b6fcd6854c5..11afb59875b 100644 --- a/src/gallium/drivers/svga/svga_draw_private.h +++ b/src/gallium/drivers/svga/svga_draw_private.h @@ -147,12 +147,12 @@ enum pipe_error svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl, struct pipe_resource *indexBuffer, unsigned index_size, + int index_bias, unsigned min_index, unsigned max_index, unsigned prim, unsigned start, - unsigned count, - unsigned bias ); + unsigned count ); #endif diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c index a05272b2e40..58e930d9835 100644 --- a/src/gallium/drivers/svga/svga_pipe_draw.c +++ b/src/gallium/drivers/svga/svga_pipe_draw.c @@ -44,6 +44,7 @@ static enum pipe_error retry_draw_range_elements( struct svga_context *svga, struct pipe_resource *index_buffer, unsigned index_size, + int index_bias, unsigned min_index, unsigned max_index, unsigned prim, @@ -66,9 +67,9 @@ retry_draw_range_elements( struct svga_context *svga, goto retry; ret = svga_hwtnl_draw_range_elements( svga->hwtnl, - index_buffer, index_size, + index_buffer, index_size, index_bias, min_index, max_index, - prim, start, count, 0 ); + prim, start, count ); if (ret) goto retry; @@ -86,7 +87,7 @@ retry: if (do_retry) { return retry_draw_range_elements( svga, - index_buffer, index_size, + index_buffer, index_size, index_bias, min_index, max_index, prim, start, count, FALSE ); @@ -152,6 +153,7 @@ static void svga_draw_range_elements( struct pipe_context *pipe, struct pipe_resource *index_buffer, unsigned index_size, + int index_bias, unsigned min_index, unsigned max_index, unsigned prim, unsigned start, unsigned count) @@ -190,6 +192,7 @@ svga_draw_range_elements( struct pipe_context *pipe, ret = svga_swtnl_draw_range_elements( svga, index_buffer, index_size, + index_bias, min_index, max_index, prim, start, count ); @@ -199,6 +202,7 @@ svga_draw_range_elements( struct pipe_context *pipe, ret = retry_draw_range_elements( svga, index_buffer, index_size, + index_bias, min_index, max_index, prim, @@ -225,11 +229,11 @@ svga_draw_range_elements( struct pipe_context *pipe, static void svga_draw_elements( struct pipe_context *pipe, struct pipe_resource *index_buffer, - unsigned index_size, + unsigned index_size, int index_bias, unsigned prim, unsigned start, unsigned count) { svga_draw_range_elements( pipe, index_buffer, - index_size, + index_size, index_bias, 0, 0xffffffff, prim, start, count ); } @@ -238,7 +242,7 @@ static void svga_draw_arrays( struct pipe_context *pipe, unsigned prim, unsigned start, unsigned count) { - svga_draw_range_elements(pipe, NULL, 0, + svga_draw_range_elements(pipe, NULL, 0, 0, start, start + count - 1, prim, start, count); diff --git a/src/gallium/drivers/svga/svga_swtnl.h b/src/gallium/drivers/svga/svga_swtnl.h index 096ed410b5b..8724690f7e1 100644 --- a/src/gallium/drivers/svga/svga_swtnl.h +++ b/src/gallium/drivers/svga/svga_swtnl.h @@ -42,6 +42,7 @@ enum pipe_error svga_swtnl_draw_range_elements(struct svga_context *svga, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned min_index, unsigned max_index, unsigned prim, diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c index e6498136083..b0cbead8a5c 100644 --- a/src/gallium/drivers/svga/svga_swtnl_backend.c +++ b/src/gallium/drivers/svga/svga_swtnl_backend.c @@ -247,7 +247,7 @@ svga_vbuf_render_draw( struct vbuf_render *render, struct svga_vbuf_render *svga_render = svga_vbuf_render(render); struct svga_context *svga = svga_render->svga; struct pipe_screen *screen = svga->pipe.screen; - unsigned bias = (svga_render->vbuf_offset - svga_render->vdecl_offset) / svga_render->vertex_size; + int bias = (svga_render->vbuf_offset - svga_render->vdecl_offset) / svga_render->vertex_size; boolean ret; size_t size = 2 * nr_indices; @@ -280,19 +280,21 @@ svga_vbuf_render_draw( struct vbuf_render *render, ret = svga_hwtnl_draw_range_elements(svga->hwtnl, svga_render->ibuf, 2, + bias, svga_render->min_index, svga_render->max_index, svga_render->prim, - svga_render->ibuf_offset / 2, nr_indices, bias); + svga_render->ibuf_offset / 2, nr_indices); if(ret != PIPE_OK) { svga_context_flush(svga, NULL); ret = svga_hwtnl_draw_range_elements(svga->hwtnl, svga_render->ibuf, 2, + bias, svga_render->min_index, svga_render->max_index, svga_render->prim, - svga_render->ibuf_offset / 2, nr_indices, bias); + svga_render->ibuf_offset / 2, nr_indices); svga->swtnl.new_vbuf = TRUE; assert(ret == PIPE_OK); } diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c index 0981d85929f..eb71c23195b 100644 --- a/src/gallium/drivers/svga/svga_swtnl_draw.c +++ b/src/gallium/drivers/svga/svga_swtnl_draw.c @@ -39,6 +39,7 @@ enum pipe_error svga_swtnl_draw_range_elements(struct svga_context *svga, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned min_index, unsigned max_index, unsigned prim, unsigned start, unsigned count) @@ -82,7 +83,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, &ib_transfer); draw_set_mapped_element_buffer_range(draw, - indexSize, + indexSize, indexBias, min_index, max_index, map); @@ -118,7 +119,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, if (indexBuffer) { pipe_buffer_unmap(&svga->pipe, indexBuffer, ib_transfer); - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } if (svga->curr.cb[PIPE_SHADER_VERTEX]) { diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 512acb7d13c..8216c06260f 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -176,9 +176,9 @@ trace_context_draw_arrays(struct pipe_context *_pipe, static INLINE void trace_context_draw_elements(struct pipe_context *_pipe, - struct pipe_resource *_indexBuffer, - unsigned indexSize, - unsigned mode, unsigned start, unsigned count) + struct pipe_resource *_indexBuffer, + unsigned indexSize, int indexBias, + unsigned mode, unsigned start, unsigned count) { struct trace_context *tr_ctx = trace_context(_pipe); struct trace_resource *tr_buf = trace_resource(_indexBuffer); @@ -195,11 +195,13 @@ trace_context_draw_elements(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, indexBuffer); trace_dump_arg(uint, indexSize); + trace_dump_arg(int, indexBias); trace_dump_arg(uint, mode); trace_dump_arg(uint, start); trace_dump_arg(uint, count); - pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count); + pipe->draw_elements(pipe, indexBuffer, indexSize, indexBias, + mode, start, count); trace_dump_call_end(); @@ -211,6 +213,7 @@ static INLINE void trace_context_draw_range_elements(struct pipe_context *_pipe, struct pipe_resource *_indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -232,6 +235,7 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, indexBuffer); trace_dump_arg(uint, indexSize); + trace_dump_arg(int, indexBias); trace_dump_arg(uint, minIndex); trace_dump_arg(uint, maxIndex); trace_dump_arg(uint, mode); @@ -239,8 +243,8 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, trace_dump_arg(uint, count); pipe->draw_range_elements(pipe, - indexBuffer, - indexSize, minIndex, maxIndex, + indexBuffer, indexSize, indexBias, + minIndex, maxIndex, mode, start, count); trace_dump_call_end(); |