summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-05-25 09:44:53 -0600
committerBrian Paul <[email protected]>2012-05-31 09:40:35 -0600
commit185ed2105829d6f5eb19edb9abbf0d7977e157c3 (patch)
tree91716430893902305c60756e64b2ec8328895640 /src/gallium/drivers
parent151bf6e6cf8f9de4067cfcf15f6ac448ff295533 (diff)
draw: simplify index buffer specification
Replace draw_set_index_buffer() and draw_set_mapped_index_buffer() with draw_set_indexes() which simply takes a pointer and an index size.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/i915/i915_context.c6
-rw-r--r--src/gallium/drivers/i915/i915_state.c3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_draw_arrays.c8
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_vertex.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_draw.c7
-rw-r--r--src/gallium/drivers/r300/r300_state.c12
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c7
-rw-r--r--src/gallium/drivers/softpipe/sp_state_vertex.c2
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_draw.c9
9 files changed, 28 insertions, 28 deletions
diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c
index f3c7b30527c..988d6591519 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -71,8 +71,10 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
mapped_indices = i915->index_buffer.user_buffer;
if (!mapped_indices)
mapped_indices = i915_buffer(i915->index_buffer.buffer)->data;
+ draw_set_indexes(draw,
+ (ubyte *) mapped_indices + i915->index_buffer.offset,
+ i915->index_buffer.index_size);
}
- draw_set_mapped_index_buffer(draw, mapped_indices);
if (i915->constants[PIPE_SHADER_VERTEX])
draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
@@ -91,7 +93,7 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
draw_vbo(i915->draw, info);
if (mapped_indices)
- draw_set_mapped_index_buffer(draw, NULL);
+ draw_set_indexes(draw, NULL, 0);
if (i915->num_vertex_sampler_views > 0)
i915_cleanup_vertex_sampling(i915);
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 1ff53884ada..f4b5d6f37b7 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -1048,9 +1048,6 @@ static void i915_set_index_buffer(struct pipe_context *pipe,
memcpy(&i915->index_buffer, ib, sizeof(i915->index_buffer));
else
memset(&i915->index_buffer, 0, sizeof(i915->index_buffer));
-
- /* pass-through to draw module */
- draw_set_index_buffer(i915->draw, ib);
}
static void
diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
index 225b80e3dfb..96259d7144f 100644
--- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
+++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
@@ -78,9 +78,11 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
mapped_indices = lp->index_buffer.user_buffer;
if (!mapped_indices)
mapped_indices = llvmpipe_resource_data(lp->index_buffer.buffer);
- }
- draw_set_mapped_index_buffer(draw, mapped_indices);
+ draw_set_indexes(draw,
+ (ubyte *) mapped_indices + lp->index_buffer.offset,
+ lp->index_buffer.index_size);
+ }
llvmpipe_prepare_vertex_sampling(lp,
lp->num_vertex_sampler_views,
@@ -96,7 +98,7 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
if (mapped_indices) {
- draw_set_mapped_index_buffer(draw, NULL);
+ draw_set_indexes(draw, NULL, 0);
}
llvmpipe_cleanup_vertex_sampling(lp);
diff --git a/src/gallium/drivers/llvmpipe/lp_state_vertex.c b/src/gallium/drivers/llvmpipe/lp_state_vertex.c
index a62cfd55334..4a74cd7c9d4 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_vertex.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_vertex.c
@@ -102,8 +102,6 @@ llvmpipe_set_index_buffer(struct pipe_context *pipe,
memcpy(&llvmpipe->index_buffer, ib, sizeof(llvmpipe->index_buffer));
else
memset(&llvmpipe->index_buffer, 0, sizeof(llvmpipe->index_buffer));
-
- draw_set_index_buffer(llvmpipe->draw, ib);
}
void
diff --git a/src/gallium/drivers/nv30/nv30_draw.c b/src/gallium/drivers/nv30/nv30_draw.c
index 29e63953838..46e85362815 100644
--- a/src/gallium/drivers/nv30/nv30_draw.c
+++ b/src/gallium/drivers/nv30/nv30_draw.c
@@ -417,10 +417,11 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
pipe_buffer_map(pipe, nv30->idxbuf.buffer,
PIPE_TRANSFER_UNSYNCHRONIZED |
PIPE_TRANSFER_READ, &transferi);
- draw_set_index_buffer(draw, &nv30->idxbuf);
- draw_set_mapped_index_buffer(draw, map);
+ draw_set_indexes(draw,
+ (ubyte *) map + nv30->idxbuf.offset,
+ nv30->idxbuf.index_size);
} else {
- draw_set_mapped_index_buffer(draw, NULL);
+ draw_set_indexes(draw, NULL, 0);
}
draw_vbo(draw, info);
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index e025c2fcd1e..6f9feb10564 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1649,16 +1649,16 @@ static void r300_set_index_buffer_swtcl(struct pipe_context* pipe,
{
struct r300_context* r300 = r300_context(pipe);
- draw_set_index_buffer(r300->draw, ib);
-
if (ib) {
+ const void *buf = NULL;
if (ib->user_buffer) {
- draw_set_mapped_index_buffer(r300->draw,
- ib->user_buffer);
+ buf = ib->user_buffer;
} else if (ib->buffer) {
- draw_set_mapped_index_buffer(r300->draw,
- r300_resource(ib->buffer)->malloced_buffer);
+ buf = r300_resource(ib->buffer)->malloced_buffer;
}
+ draw_set_indexes(r300->draw,
+ (const ubyte *) buf + ib->offset,
+ ib->index_size);
}
}
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 7a2274565d5..f9fc923a184 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -88,9 +88,12 @@ softpipe_draw_vbo(struct pipe_context *pipe,
mapped_indices = sp->index_buffer.user_buffer;
if (!mapped_indices)
mapped_indices = softpipe_resource(sp->index_buffer.buffer)->data;
+
+ draw_set_indexes(draw,
+ (ubyte *) mapped_indices + sp->index_buffer.offset,
+ sp->index_buffer.index_size);
}
- draw_set_mapped_index_buffer(draw, mapped_indices);
for (i = 0; i < sp->num_so_targets; i++) {
void *buf = softpipe_resource(sp->so_targets[i]->target.buffer)->data;
@@ -108,7 +111,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
if (mapped_indices) {
- draw_set_mapped_index_buffer(draw, NULL);
+ draw_set_indexes(draw, NULL, 0);
}
draw_set_mapped_so_targets(draw, 0, NULL);
diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c
index 1dbd79807d0..95acecd3be4 100644
--- a/src/gallium/drivers/softpipe/sp_state_vertex.c
+++ b/src/gallium/drivers/softpipe/sp_state_vertex.c
@@ -106,8 +106,6 @@ softpipe_set_index_buffer(struct pipe_context *pipe,
memcpy(&softpipe->index_buffer, ib, sizeof(softpipe->index_buffer));
else
memset(&softpipe->index_buffer, 0, sizeof(softpipe->index_buffer));
-
- draw_set_index_buffer(softpipe->draw, ib);
}
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
index bb6870f6572..212f11a8230 100644
--- a/src/gallium/drivers/svga/svga_swtnl_draw.c
+++ b/src/gallium/drivers/svga/svga_swtnl_draw.c
@@ -76,17 +76,16 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
}
}
- /* TODO move this to update_swtnl_draw */
- draw_set_index_buffer(draw, &svga->curr.ib);
-
/* Map index buffer, if present */
map = NULL;
if (info->indexed && svga->curr.ib.buffer) {
map = pipe_buffer_map(&svga->pipe, svga->curr.ib.buffer,
PIPE_TRANSFER_READ,
&ib_transfer);
+ draw_set_indexes(draw,
+ (const ubyte *) map + svga->curr.ib.offset,
+ svga->curr.ib.index_size);
}
- draw_set_mapped_index_buffer(draw, map);
if (svga->curr.cb[PIPE_SHADER_VERTEX]) {
map = pipe_buffer_map(&svga->pipe,
@@ -119,7 +118,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
if (ib_transfer) {
pipe_buffer_unmap(&svga->pipe, ib_transfer);
- draw_set_mapped_index_buffer(draw, NULL);
+ draw_set_indexes(draw, NULL, 0);
}
if (svga->curr.cb[PIPE_SHADER_VERTEX]) {