summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-04-20 11:07:08 +0200
committerJosé Fonseca <jfonseca@vmware.com>2010-04-20 11:07:08 +0200
commita6171a9dd99713266091982215bf1008c9ac8e64 (patch)
tree7be00d0ab09dec383d9acc4fd3b135dfd8ed5c45 /src/gallium
parent49ba607abab17cc07e9f163f5415636474fd7940 (diff)
parent3dcdca433a5d6cde1c0b4d69ff0aa3a5eee26473 (diff)
Merge branch 'gallium-index-bias'
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_context.h2
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.h1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h3
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache.c12
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h77
-rw-r--r--src/gallium/docs/source/context.rst6
-rw-r--r--src/gallium/drivers/cell/ppu/cell_draw_arrays.c11
-rw-r--r--src/gallium/drivers/failover/fo_context.c5
-rw-r--r--src/gallium/drivers/i915/i915_context.c13
-rw-r--r--src/gallium/drivers/i965/brw_draw.c10
-rw-r--r--src/gallium/drivers/identity/id_context.c4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_draw_arrays.c12
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state.h4
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h4
-rw-r--r--src/gallium/drivers/nv50/nv50_push.c4
-rw-r--r--src/gallium/drivers/nv50/nv50_vbo.c9
-rw-r--r--src/gallium/drivers/nvfx/nvfx_context.h15
-rw-r--r--src/gallium/drivers/nvfx/nvfx_draw.c7
-rw-r--r--src/gallium/drivers/nvfx/nvfx_vbo.c18
-rw-r--r--src/gallium/drivers/r300/r300_context.h3
-rw-r--r--src/gallium/drivers/r300/r300_render.c42
-rw-r--r--src/gallium/drivers/r300/r300_render.h6
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c16
-rw-r--r--src/gallium/drivers/softpipe/sp_state.h4
-rw-r--r--src/gallium/drivers/svga/svga_draw.h4
-rw-r--r--src/gallium/drivers/svga/svga_draw_elements.c17
-rw-r--r--src/gallium/drivers/svga/svga_draw_private.h4
-rw-r--r--src/gallium/drivers/svga/svga_pipe_draw.c16
-rw-r--r--src/gallium/drivers/svga/svga_swtnl.h1
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_backend.c8
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_draw.c5
-rw-r--r--src/gallium/drivers/trace/tr_context.c16
-rw-r--r--src/gallium/include/pipe/p_context.h3
-rw-r--r--src/gallium/state_trackers/python/p_context.i10
-rwxr-xr-xsrc/gallium/tests/python/retrace/interpreter.py16
38 files changed, 247 insertions, 152 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index d490d3325c2..4196f01e0b2 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -456,12 +456,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;
}
@@ -470,10 +472,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 51767bb214d..7b41bb48dd3 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -140,12 +140,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 fa20c8ecc63..0b3c9e69bd5 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -150,6 +150,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 cea186c1bf3..b5876bb1bdb 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 );
@@ -224,8 +225,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 c2797a759ee..3e3ea320cc0 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 f0aec5febab..a292346be95 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 757c4874545..37ffbac4f92 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;
@@ -346,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");
@@ -362,8 +363,11 @@ 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 (min_index == 0 &&
- index_size == 2)
+ index_size == 2)
{
transformed_elts = (const ushort *)elts;
}
@@ -433,7 +437,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 );
@@ -447,7 +451,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 7cba8547f15..f7a63de3ba9 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);
}
}
}
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index 7439d100973..c82e681a254 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -153,6 +153,12 @@ 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.
+
+``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.
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();
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 1aa0cbe4dca..6f47845f3b8 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,
diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i
index 13c8d1a95e9..3c5509cb5e4 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);
}
diff --git a/src/gallium/tests/python/retrace/interpreter.py b/src/gallium/tests/python/retrace/interpreter.py
index 88b3bbd143b..7118ff85ed8 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):