From c184da9505e04fdbdda1bb1ff6990d5defaa25d4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 08:56:46 +0200 Subject: gallium: Add index bias parameter to draw_elements and friends. indexBias corresponds to: - BaseVertexIndex parameter of D3D9's IDirect3DDevice9::DrawIndexedPrimitive method - BaseVertexLocation parameter of ID3D10Device::DrawIndexed Although a positive indexBias can be easily be implemented in Gallium by adding indexBias*stride to each vertex buffer base offset, a negative indexBias cannot, as the final vertex buffer offset could be negative. I'm not aware of this functionality being exposed to GL drivers, so for now all hardware drivers will just assert(indexBias == 0). See also: - http://msdn.microsoft.com/en-us/library/bb174369.aspx (D3D9) - http://msdn.microsoft.com/en-us/library/ff556126.aspx (D3D10 DDI) --- src/gallium/include/pipe/p_context.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 1aa0cbe4dc..6f47845f3b 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -67,6 +67,7 @@ struct pipe_context { void (*draw_elements)( struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned mode, unsigned start, unsigned count); void (*draw_arrays_instanced)(struct pipe_context *pipe, @@ -79,6 +80,7 @@ struct pipe_context { void (*draw_elements_instanced)(struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned mode, unsigned start, unsigned count, @@ -93,6 +95,7 @@ struct pipe_context { void (*draw_range_elements)( struct pipe_context *pipe, struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, -- cgit v1.2.3 From 857c7c7ca266df4be8d4c725e056f69d4ee96624 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 15:08:14 +0200 Subject: docs: Document indexBias. --- src/gallium/docs/source/context.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 7439d10097..69e0fccc03 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -153,6 +153,9 @@ vertex attributes. If ``indexBuffer`` is NULL, the sequential numbers are used directly as indices to fetch vertex attributes. +``indexBias`` is a value which is added to every index read from the index +buffer before fetching vertex attributes. + If a given vertex element has ``instance_divisor`` set to 0, it is said it contains per-vertex data and effective vertex attribute address needs to be recalculated for every index. -- cgit v1.2.3 From 2197fac47cb1f87387820678357cc67c9a2536b9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:14:04 +0200 Subject: draw: Implement index bias. --- src/gallium/auxiliary/draw/draw_context.c | 4 ++ src/gallium/auxiliary/draw/draw_context.h | 2 + src/gallium/auxiliary/draw/draw_private.h | 1 + src/gallium/auxiliary/draw/draw_pt.c | 6 +- src/gallium/auxiliary/draw/draw_pt.h | 1 + .../auxiliary/draw/draw_pt_varray_tmp_linear.h | 3 + src/gallium/auxiliary/draw/draw_pt_vcache.c | 17 +++-- src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h | 77 +++++++++++----------- 8 files changed, 65 insertions(+), 46 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 99f4e6dd2a..b6c558ba9b 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -427,12 +427,14 @@ void draw_set_render( struct draw_context *draw, void draw_set_mapped_element_buffer_range( struct draw_context *draw, unsigned eltSize, + int eltBias, unsigned min_index, unsigned max_index, const void *elements ) { draw->pt.user.elts = elements; draw->pt.user.eltSize = eltSize; + draw->pt.user.eltBias = eltBias; draw->pt.user.min_index = min_index; draw->pt.user.max_index = max_index; } @@ -441,10 +443,12 @@ draw_set_mapped_element_buffer_range( struct draw_context *draw, void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, + int eltBias, const void *elements ) { draw->pt.user.elts = elements; draw->pt.user.eltSize = eltSize; + draw->pt.user.eltBias = eltBias; draw->pt.user.min_index = 0; draw->pt.user.max_index = 0xffffffff; } diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 1af4961716..cfa0ad88d0 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -139,12 +139,14 @@ void draw_set_vertex_elements(struct draw_context *draw, void draw_set_mapped_element_buffer_range( struct draw_context *draw, unsigned eltSize, + int eltBias, unsigned min_index, unsigned max_index, const void *elements ); void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, + int eltBias, const void *elements ); void draw_set_mapped_vertex_buffer(struct draw_context *draw, diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index da64102d9d..33b0c196d4 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -148,6 +148,7 @@ struct draw_context const void *elts; /** bytes per index (0, 1, 2 or 4) */ unsigned eltSize; + int eltBias; unsigned min_index; unsigned max_index; diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 43f6c5650a..aa1f7064a3 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -111,6 +111,7 @@ draw_pt_arrays(struct draw_context *draw, frontend->run(frontend, draw_pt_elt_func(draw), draw_pt_elt_ptr(draw, start), + draw->pt.user.eltBias, count); frontend->finish( frontend ); @@ -222,8 +223,11 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count) break; default: assert(0); + return; } - debug_printf("Element[%u + %u] -> Vertex %u:\n", start, i, ii); + ii += draw->pt.user.eltBias; + debug_printf("Element[%u + %u] + %i -> Vertex %u:\n", start, i, + draw->pt.user.eltBias, ii); } else { /* non-indexed arrays */ diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index c2797a759e..3e3ea320cc 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -67,6 +67,7 @@ struct draw_pt_front_end { void (*run)( struct draw_pt_front_end *, pt_elt_func elt_func, const void *elt_ptr, + int elt_bias, unsigned count ); void (*finish)( struct draw_pt_front_end * ); diff --git a/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h b/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h index f0aec5feba..a292346be9 100644 --- a/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h +++ b/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h @@ -6,6 +6,7 @@ static unsigned trim( unsigned count, unsigned first, unsigned incr ) static void FUNC(struct draw_pt_front_end *frontend, pt_elt_func get_elt, const void *elts, + int elt_bias, unsigned count) { struct varray_frontend *varray = (struct varray_frontend *)frontend; @@ -14,6 +15,8 @@ static void FUNC(struct draw_pt_front_end *frontend, unsigned j; unsigned first, incr; + assert(elt_bias == 0); + draw_pt_split_prim(varray->input_prim, &first, &incr); /* Sanitize primitive length: diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 757c487454..a513188b91 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -329,6 +329,7 @@ static INLINE void vcache_check_run( struct draw_pt_front_end *frontend, pt_elt_func get_elt, const void *elts, + int elt_bias, unsigned draw_count ) { struct vcache_frontend *vcache = (struct vcache_frontend *)frontend; @@ -362,8 +363,9 @@ vcache_check_run( struct draw_pt_front_end *frontend, } - if (min_index == 0 && - index_size == 2) + if (elt_bias <= 0 && + min_index == (unsigned)-elt_bias && + index_size == 2) { transformed_elts = (const ushort *)elts; } @@ -373,7 +375,8 @@ vcache_check_run( struct draw_pt_front_end *frontend, if (!storage) goto fail; - if (min_index == 0) { + if (elt_bias <= 0 && + min_index == (unsigned)-elt_bias) { switch(index_size) { case 1: translate_ubyte_elts( (const ubyte *)elts, @@ -404,21 +407,21 @@ vcache_check_run( struct draw_pt_front_end *frontend, case 1: rebase_ubyte_elts( (const ubyte *)elts, draw_count, - 0 - (int)min_index, + elt_bias - (int)min_index, storage ); break; case 2: rebase_ushort_elts( (const ushort *)elts, draw_count, - 0 - (int)min_index, + elt_bias - (int)min_index, storage ); break; case 4: rebase_uint_elts( (const uint *)elts, draw_count, - 0 - (int)min_index, + elt_bias - (int)min_index, storage ); break; @@ -447,7 +450,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, fetch_count, draw_count); fail: - vcache_run( frontend, get_elt, elts, draw_count ); + vcache_run( frontend, get_elt, elts, elt_bias, draw_count ); } diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h index 7cba8547f1..eedd31b7f8 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h +++ b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h @@ -3,6 +3,7 @@ static void FUNC( struct draw_pt_front_end *frontend, pt_elt_func get_elt, const void *elts, + int elt_bias, unsigned count ) { struct vcache_frontend *vcache = (struct vcache_frontend *)frontend; @@ -20,7 +21,7 @@ static void FUNC( struct draw_pt_front_end *frontend, case PIPE_PRIM_POINTS: for (i = 0; i < count; i ++) { POINT( vcache, - get_elt(elts, i + 0) ); + get_elt(elts, i + 0) + elt_bias ); } break; @@ -28,8 +29,8 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 0; i+1 < count; i += 2) { LINE( vcache, DRAW_PIPE_RESET_STIPPLE, - get_elt(elts, i + 0), - get_elt(elts, i + 1)); + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias); } break; @@ -40,14 +41,14 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 1; i < count; i++, flags = 0) { LINE( vcache, flags, - get_elt(elts, i - 1), - get_elt(elts, i )); + get_elt(elts, i - 1) + elt_bias, + get_elt(elts, i ) + elt_bias); } LINE( vcache, flags, - get_elt(elts, i - 1), - get_elt(elts, 0 )); + get_elt(elts, i - 1) + elt_bias, + get_elt(elts, 0 ) + elt_bias); } break; @@ -56,8 +57,8 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 1; i < count; i++, flags = 0) { LINE( vcache, flags, - get_elt(elts, i - 1), - get_elt(elts, i )); + get_elt(elts, i - 1) + elt_bias, + get_elt(elts, i ) + elt_bias); } break; @@ -65,9 +66,9 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 0; i+2 < count; i += 3) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2 )); + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2 ) + elt_bias); } break; @@ -76,18 +77,18 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 0), - get_elt(elts, i + 1 + (i&1)), - get_elt(elts, i + 2 - (i&1))); + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1 + (i&1) + elt_bias), + get_elt(elts, i + 2 - (i&1) + elt_bias)); } } else { for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 0 + (i&1)), - get_elt(elts, i + 1 - (i&1)), - get_elt(elts, i + 2 )); + get_elt(elts, i + 0 + (i&1) + elt_bias), + get_elt(elts, i + 1 - (i&1) + elt_bias), + get_elt(elts, i + 2 ) + elt_bias); } } break; @@ -98,18 +99,18 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 1), - get_elt(elts, i + 2), - get_elt(elts, 0 )); + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2) + elt_bias, + get_elt(elts, 0 ) + elt_bias); } } else { for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2 )); + get_elt(elts, 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2 ) + elt_bias); } } } @@ -119,20 +120,20 @@ static void FUNC( struct draw_pt_front_end *frontend, case PIPE_PRIM_QUADS: for (i = 0; i+3 < count; i += 4) { QUAD( vcache, - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2), - get_elt(elts, i + 3) ); + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2) + elt_bias, + get_elt(elts, i + 3) + elt_bias ); } break; case PIPE_PRIM_QUAD_STRIP: for (i = 0; i+3 < count; i += 2) { QUAD( vcache, - get_elt(elts, i + 2), - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 3) ); + get_elt(elts, i + 2) + elt_bias, + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 3) + elt_bias ); } break; @@ -165,16 +166,16 @@ static void FUNC( struct draw_pt_front_end *frontend, if (flatfirst) { TRIANGLE( vcache, flags, - get_elt(elts, 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2) ); + get_elt(elts, 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2) + elt_bias ); } else { TRIANGLE( vcache, flags, - get_elt(elts, i + 1), - get_elt(elts, i + 2), - get_elt(elts, 0)); + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2) + elt_bias, + get_elt(elts, 0) + elt_bias); } } } -- cgit v1.2.3 From 150d12679d4d2550e0e54d76a43d153c4254ddfe Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:14:23 +0200 Subject: cell: Implement index bias. --- src/gallium/drivers/cell/ppu/cell_draw_arrays.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index 80e94a79df..b50a30bee8 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); } -- cgit v1.2.3 From f8d4638a092d44c0746ff124d3414c20c735e9f6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:14:35 +0200 Subject: failover: Implement index bias. --- src/gallium/drivers/failover/fo_context.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c index 325a100954..236c50f4d9 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 -- cgit v1.2.3 From 1e7facdd8fbbccbf6f384a4c9bbb394c176f2c4b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:14:48 +0200 Subject: i915: Implement index bias. --- src/gallium/drivers/i915/i915_context.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 4ae5291115..beddc13996 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); } -- cgit v1.2.3 From 9ca0f45d8af5aa3152350594093797210d052b6e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:14:58 +0200 Subject: i965g: Implement index bias. --- src/gallium/drivers/i965/brw_draw.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/i965/brw_draw.c b/src/gallium/drivers/i965/brw_draw.c index eb73ec2f27..4625c2048f 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); } -- cgit v1.2.3 From 382e9cc07b9193924b0eaf840a4d34cade2c7d92 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:15:05 +0200 Subject: identity: Implement index bias. --- src/gallium/drivers/identity/id_context.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 3b7eaecc02..630cdb5e49 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, -- cgit v1.2.3 From d27a53d46931d2286c90b21ff7f06f44a7a726bc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:15:11 +0200 Subject: llvmpipe: Implement index bias. --- src/gallium/drivers/llvmpipe/lp_draw_arrays.c | 12 +++++++----- src/gallium/drivers/llvmpipe/lp_state.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index 86525eea9e..0b63e1c889 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 d89c28a2af..dcbff190b6 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); -- cgit v1.2.3 From 989861fc5ea1792e7ea1be07389db7c3e3b8e383 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:15:39 +0200 Subject: softpipe: Implement index bias. --- src/gallium/drivers/softpipe/sp_draw_arrays.c | 16 +++++++++++++--- src/gallium/drivers/softpipe/sp_state.h | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 461c9a6c4d..b30036e230 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 3c04c8bb07..f97fc6eca8 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, -- cgit v1.2.3 From 9515b78859b52b4532cc9e06366428f2c49c7869 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:16:08 +0200 Subject: svga: Implement index bias. Untested. --- src/gallium/drivers/svga/svga_draw.h | 4 ++-- src/gallium/drivers/svga/svga_draw_elements.c | 17 +++++++++-------- src/gallium/drivers/svga/svga_draw_private.h | 4 ++-- src/gallium/drivers/svga/svga_pipe_draw.c | 16 ++++++++++------ src/gallium/drivers/svga/svga_swtnl.h | 1 + src/gallium/drivers/svga/svga_swtnl_backend.c | 8 +++++--- src/gallium/drivers/svga/svga_swtnl_draw.c | 5 +++-- 7 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/gallium/drivers/svga/svga_draw.h b/src/gallium/drivers/svga/svga_draw.h index 81c7f8377d..a2403d802b 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 7ec4a058fc..c4579177b7 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 b6fcd6854c..11afb59875 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 a05272b2e4..58e930d983 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 096ed410b5..8724690f7e 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 e649813608..b0cbead8a5 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 f771dd59d3..4504bf71fd 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]) { -- cgit v1.2.3 From 8b658580ee2ad33aa9c7438b1efc6c35d6bfab00 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:16:20 +0200 Subject: trace: Implement index bias. --- src/gallium/drivers/trace/tr_context.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 512acb7d13..8216c06260 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(); -- cgit v1.2.3 From 5620216c984cdbc8983bc1861ebb09380f3467e4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:16:34 +0200 Subject: st/python: Use index bias. --- src/gallium/state_trackers/python/p_context.i | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 13c8d1a95e..3c5509cb5e 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -312,22 +312,24 @@ struct st_context { } void draw_elements( struct pipe_resource *indexBuffer, - unsigned indexSize, + unsigned indexSize, int indexBias, unsigned mode, unsigned start, unsigned count) { $self->pipe->draw_elements($self->pipe, indexBuffer, indexSize, + indexBias, mode, start, count); } void draw_range_elements( struct pipe_resource *indexBuffer, - unsigned indexSize, unsigned minIndex, unsigned maxIndex, + unsigned indexSize, int indexBias, + unsigned minIndex, unsigned maxIndex, unsigned mode, unsigned start, unsigned count) { $self->pipe->draw_range_elements($self->pipe, - indexBuffer, - indexSize, minIndex, maxIndex, + indexBuffer, indexSize, indexBias, + minIndex, maxIndex, mode, start, count); } -- cgit v1.2.3 From 17a43c1718605e4c95bcd7f554b0a5b8293d2578 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:16:57 +0200 Subject: mesa/st: Update for index bias interface change. --- src/mesa/state_tracker/st_draw.c | 6 +++--- src/mesa/state_tracker/st_draw_feedback.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4f4368ac9e..a3620359db 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -676,7 +676,7 @@ st_draw_vbo(GLcontext *ctx, for (i = 0; i < nr_prims; i++) { prim = translate_prim( ctx, prims[i].mode ); - pipe->draw_range_elements(pipe, indexBuf, indexSize, + pipe->draw_range_elements(pipe, indexBuf, indexSize, 0, min_index, max_index, prim, prims[i].start + indexOffset, prims[i].count); } @@ -686,12 +686,12 @@ st_draw_vbo(GLcontext *ctx, prim = translate_prim( ctx, prims[i].mode ); if (prims[i].num_instances == 1) { - pipe->draw_elements(pipe, indexBuf, indexSize, prim, + pipe->draw_elements(pipe, indexBuf, indexSize, 0, prim, prims[i].start + indexOffset, prims[i].count); } else { - pipe->draw_elements_instanced(pipe, indexBuf, indexSize, prim, + pipe->draw_elements_instanced(pipe, indexBuf, indexSize, 0, prim, prims[i].start + indexOffset, prims[i].count, 0, prims[i].num_instances); diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 04730464e5..a28ad8eebb 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -229,16 +229,16 @@ st_feedback_draw_vbo(GLcontext *ctx, map = pipe_buffer_map(pipe, index_buffer_handle, PIPE_TRANSFER_READ, &ib_transfer); - draw_set_mapped_element_buffer(draw, indexSize, map); + draw_set_mapped_element_buffer(draw, indexSize, 0, map); } else { - draw_set_mapped_element_buffer(draw, indexSize, (void *) ib->ptr); + draw_set_mapped_element_buffer(draw, indexSize, 0, (void *) ib->ptr); ib_transfer = NULL; } } else { /* no index/element buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } @@ -275,7 +275,7 @@ st_feedback_draw_vbo(GLcontext *ctx, } if (index_buffer_handle) { pipe_buffer_unmap(pipe, index_buffer_handle, ib_transfer); - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } } -- cgit v1.2.3 From 583f51ba4bb1029d9d4f338ca3c8f4702ab6666c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:17:11 +0200 Subject: retrace: Support index bias. --- src/gallium/tests/python/retrace/interpreter.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gallium/tests/python/retrace/interpreter.py b/src/gallium/tests/python/retrace/interpreter.py index 88b3bbd143..7118ff85ed 100755 --- a/src/gallium/tests/python/retrace/interpreter.py +++ b/src/gallium/tests/python/retrace/interpreter.py @@ -496,7 +496,7 @@ class Context(Object): sys.stdout.write('\t},\n') sys.stdout.flush() - def dump_indices(self, ibuf, isize, start, count): + def dump_indices(self, ibuf, isize, ibias, start, count): if not self.interpreter.verbosity(2): return @@ -524,7 +524,7 @@ class Context(Object): sys.stdout.write('\t},\n') sys.stdout.flush() - return minindex, maxindex + return minindex + ibias, maxindex + ibias def draw_arrays(self, mode, start, count): self.dump_vertices(start, count) @@ -532,22 +532,22 @@ class Context(Object): self.real.draw_arrays(mode, start, count) self._set_dirty() - def draw_elements(self, indexBuffer, indexSize, mode, start, count): + def draw_elements(self, indexBuffer, indexSize, indexBias, mode, start, count): if self.interpreter.verbosity(2): - minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) + minindex, maxindex = self.dump_indices(indexBuffer, indexSize, indexBias, start, count) self.dump_vertices(minindex, maxindex - minindex) - self.real.draw_elements(indexBuffer, indexSize, mode, start, count) + self.real.draw_elements(indexBuffer, indexSize, indexBias, mode, start, count) self._set_dirty() - def draw_range_elements(self, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count): + def draw_range_elements(self, indexBuffer, indexSize, indexBias, minIndex, maxIndex, mode, start, count): if self.interpreter.verbosity(2): - minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) + minindex, maxindex = self.dump_indices(indexBuffer, indexSize, indexBias, start, count) minindex = min(minindex, minIndex) maxindex = min(maxindex, maxIndex) self.dump_vertices(minindex, maxindex - minindex) - self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count) + self.real.draw_range_elements(indexBuffer, indexSize, indexBias, minIndex, maxIndex, mode, start, count) self._set_dirty() def surface_copy(self, dest, destx, desty, src, srcx, srcy, width, height): -- cgit v1.2.3 From f6f7324bbf03494dc26e266d96919fec6a1f08ba Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:17:45 +0200 Subject: nv50: Adapt for index bias interface change. --- src/gallium/drivers/nv50/nv50_context.h | 4 ++-- src/gallium/drivers/nv50/nv50_push.c | 4 +++- src/gallium/drivers/nv50/nv50_vbo.c | 9 ++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 8bf465378e..4875f83305 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 6981e5b919..c54fed5a36 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 609145db88..932c1e8992 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); } -- cgit v1.2.3 From 7c785c0d2c2b5f3ead4b3cf31ad6af02bd90f3a5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:18:28 +0200 Subject: nvfx: Adapt for index bias interface change. --- src/gallium/drivers/nvfx/nvfx_context.h | 15 ++++++++------- src/gallium/drivers/nvfx/nvfx_draw.c | 7 ++++--- src/gallium/drivers/nvfx/nvfx_vbo.c | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h index e2c6d09fa1..e48f9f3aa8 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 5eadce1f6d..55b72aced0 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 5ffbdfcb2a..d441d032d9 100644 --- a/src/gallium/drivers/nvfx/nvfx_vbo.c +++ b/src/gallium/drivers/nvfx/nvfx_vbo.c @@ -167,7 +167,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; } @@ -372,7 +372,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); @@ -385,6 +386,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); @@ -460,7 +463,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); @@ -468,15 +472,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); } -- cgit v1.2.3 From dfadf5a579281c6dd4ecdd4ecd5568fbbb1de17e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:18:45 +0200 Subject: r300g: Adapt for index bias interface change. --- src/gallium/drivers/r300/r300_context.h | 3 ++- src/gallium/drivers/r300/r300_render.c | 42 ++++++++++++++++++++------------- src/gallium/drivers/r300/r300_render.h | 6 ++++- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 2e8601b65e..1e4fd9e5ed 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 f6bc68c43a..007f01ace3 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 85da6135f5..4e78914c1b 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, -- cgit v1.2.3 From f1d3f42c47ee0d3c5f13f5b30e6b113d6b542f64 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 20 Apr 2010 10:19:42 +0200 Subject: draw: Fix typo resulting from bad regular expression in index bias addition. --- src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h index eedd31b7f8..f7a63de3ba 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h +++ b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h @@ -78,16 +78,16 @@ static void FUNC( struct draw_pt_front_end *frontend, TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, get_elt(elts, i + 0) + elt_bias, - get_elt(elts, i + 1 + (i&1) + elt_bias), - get_elt(elts, i + 2 - (i&1) + elt_bias)); + get_elt(elts, i + 1 + (i&1)) + elt_bias, + get_elt(elts, i + 2 - (i&1)) + elt_bias); } } else { for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 0 + (i&1) + elt_bias), - get_elt(elts, i + 1 - (i&1) + elt_bias), + get_elt(elts, i + 0 + (i&1)) + elt_bias, + get_elt(elts, i + 1 - (i&1)) + elt_bias, get_elt(elts, i + 2 ) + elt_bias); } } -- cgit v1.2.3 From 493a1bb822f80f48cf284cb572acb5dd393a07e1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 20 Apr 2010 10:22:28 +0200 Subject: gallium/docs: Make it clear that minIndex, maxIndex is exclusively a index buffer characteristic. Unlike the indexBias which is specific to a draw call. This are the semantics of both D3D and GL ARB_draw_elements_base_vertex extension. --- src/gallium/docs/source/context.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 69e0fccc03..c82e681a25 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -156,6 +156,9 @@ as indices to fetch vertex attributes. ``indexBias`` is a value which is added to every index read from the index buffer before fetching vertex attributes. +``minIndex`` and ``maxIndex`` describe minimum and maximum index contained in +the index buffer. + If a given vertex element has ``instance_divisor`` set to 0, it is said it contains per-vertex data and effective vertex attribute address needs to be recalculated for every index. -- cgit v1.2.3 From 4e8154e8666ec9375936bbe3fa2ca925ff9be5df Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 20 Apr 2010 10:32:06 +0200 Subject: draw: Fix cache elt_bias implementation. --- src/gallium/auxiliary/draw/draw_pt_vcache.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index a513188b91..28dc514888 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -347,7 +347,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, vcache->fetch_max, draw_count); - if (max_index >= DRAW_PIPE_MAX_VERTICES || + if (elt_bias + max_index >= DRAW_PIPE_MAX_VERTICES || fetch_count >= UNDEFINED_VERTEX_ID || fetch_count > draw_count) { if (0) debug_printf("fail\n"); @@ -363,6 +363,9 @@ vcache_check_run( struct draw_pt_front_end *frontend, } + assert((elt_bias >= 0 && min_index + elt_bias >= min_index) || + (elt_bias < 0 && min_index + elt_bias < min_index)); + if (elt_bias <= 0 && min_index == (unsigned)-elt_bias && index_size == 2) @@ -407,21 +410,21 @@ vcache_check_run( struct draw_pt_front_end *frontend, case 1: rebase_ubyte_elts( (const ubyte *)elts, draw_count, - elt_bias - (int)min_index, + -elt_bias - (int)min_index, storage ); break; case 2: rebase_ushort_elts( (const ushort *)elts, draw_count, - elt_bias - (int)min_index, + -elt_bias - (int)min_index, storage ); break; case 4: rebase_uint_elts( (const uint *)elts, draw_count, - elt_bias - (int)min_index, + -elt_bias - (int)min_index, storage ); break; @@ -436,7 +439,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, if (fetch_count < UNDEFINED_VERTEX_ID) ok = vcache->middle->run_linear_elts( vcache->middle, - min_index, /* start */ + min_index + elt_bias, /* start */ fetch_count, transformed_elts, draw_count ); -- cgit v1.2.3 From 3dcdca433a5d6cde1c0b4d69ff0aa3a5eee26473 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 20 Apr 2010 11:06:05 +0200 Subject: draw: No need to rebase for elt_bias. As we are rebasing to min_index + elt_bias, and the vertex buffer has no elt_bias. I still don't know how to exercise this code. I hope this is now right. --- src/gallium/auxiliary/draw/draw_pt_vcache.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 28dc514888..37ffbac4f9 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -366,8 +366,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, assert((elt_bias >= 0 && min_index + elt_bias >= min_index) || (elt_bias < 0 && min_index + elt_bias < min_index)); - if (elt_bias <= 0 && - min_index == (unsigned)-elt_bias && + if (min_index == 0 && index_size == 2) { transformed_elts = (const ushort *)elts; @@ -378,8 +377,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, if (!storage) goto fail; - if (elt_bias <= 0 && - min_index == (unsigned)-elt_bias) { + if (min_index == 0) { switch(index_size) { case 1: translate_ubyte_elts( (const ubyte *)elts, @@ -410,21 +408,21 @@ vcache_check_run( struct draw_pt_front_end *frontend, case 1: rebase_ubyte_elts( (const ubyte *)elts, draw_count, - -elt_bias - (int)min_index, + 0 - (int)min_index, storage ); break; case 2: rebase_ushort_elts( (const ushort *)elts, draw_count, - -elt_bias - (int)min_index, + 0 - (int)min_index, storage ); break; case 4: rebase_uint_elts( (const uint *)elts, draw_count, - -elt_bias - (int)min_index, + 0 - (int)min_index, storage ); break; -- cgit v1.2.3