summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-04-08 21:14:58 -0600
committerBrian <[email protected]>2008-04-08 21:20:10 -0600
commit1f888abf16ce4de00231505b8d1bc68426b04e8f (patch)
tree51636dca1c41a9e8906f5f51cbd99a61f804d89b /src
parent28cf8c8fdcbd2817b93f27cad2bba3b4fb8aecf5 (diff)
i915: keep track of num_vertex_attribs/buffers for shorter loops
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/i915simple/i915_context.c22
-rw-r--r--src/gallium/drivers/i915simple/i915_context.h2
-rw-r--r--src/gallium/drivers/i915simple/i915_state.c3
3 files changed, 14 insertions, 13 deletions
diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c
index fee33d82de4..58a5854f0d9 100644
--- a/src/gallium/drivers/i915simple/i915_context.c
+++ b/src/gallium/drivers/i915simple/i915_context.c
@@ -65,14 +65,12 @@ i915_draw_elements( struct pipe_context *pipe,
/*
* Map vertex buffers
*/
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (i915->vertex_buffer[i].buffer) {
- void *buf
- = pipe->winsys->buffer_map(pipe->winsys,
- i915->vertex_buffer[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
+ for (i = 0; i < i915->num_vertex_buffers; i++) {
+ void *buf
+ = pipe->winsys->buffer_map(pipe->winsys,
+ i915->vertex_buffer[i].buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_vertex_buffer(draw, i, buf);
}
/* Map index buffer, if present */
if (indexBuffer) {
@@ -96,11 +94,9 @@ i915_draw_elements( struct pipe_context *pipe,
/*
* unmap vertex/index buffers
*/
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (i915->vertex_buffer[i].buffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, i915->vertex_buffer[i].buffer);
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- }
+ for (i = 0; i < i915->num_vertex_buffers; i++) {
+ pipe->winsys->buffer_unmap(pipe->winsys, i915->vertex_buffer[i].buffer);
+ draw_set_mapped_vertex_buffer(draw, i, NULL);
}
if (indexBuffer) {
pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h
index 8e707ea574a..38e6a348845 100644
--- a/src/gallium/drivers/i915simple/i915_context.h
+++ b/src/gallium/drivers/i915simple/i915_context.h
@@ -238,6 +238,8 @@ struct i915_context
unsigned num_samplers;
unsigned num_textures;
+ unsigned num_vertex_elements;
+ unsigned num_vertex_buffers;
unsigned *batch_start;
diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c
index 4404bc45901..24d31ad740e 100644
--- a/src/gallium/drivers/i915simple/i915_state.c
+++ b/src/gallium/drivers/i915simple/i915_state.c
@@ -694,6 +694,8 @@ static void i915_set_vertex_buffers(struct pipe_context *pipe,
struct i915_context *i915 = i915_context(pipe);
memcpy(i915->vertex_buffer, buffers, count * sizeof(buffers[0]));
+ i915->num_vertex_buffers = count;
+
/* pass-through to draw module */
draw_set_vertex_buffers(i915->draw, count, buffers);
}
@@ -703,6 +705,7 @@ static void i915_set_vertex_elements(struct pipe_context *pipe,
const struct pipe_vertex_element *elements)
{
struct i915_context *i915 = i915_context(pipe);
+ i915->num_vertex_elements = count;
/* pass-through to draw module */
draw_set_vertex_elements(i915->draw, count, elements);
}