summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-20 17:25:38 -0600
committerBrian <[email protected]>2007-08-20 17:25:38 -0600
commit3239532795a027ddc578261f556e13e2c80f9676 (patch)
tree97aba148d20a028022ff899fe41ab3ad01f1946f /src
parenta17d5361b257cb44614a926a7f994b4a46a07890 (diff)
Use new draw_arrays() code.
The i915 driver now uses the software-based vertex shader interpreter and draws everything through pipe->draw_arrays().
Diffstat (limited to 'src')
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c58
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h2
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c35
3 files changed, 92 insertions, 3 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index b34899a8671..fdb1a7422dd 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -148,18 +148,69 @@ static void i915_destroy( struct pipe_context *pipe )
}
-static void i915_draw_arrays( struct pipe_context *pipe,
- unsigned mode, unsigned start, unsigned count)
+
+static void i915_draw_elements( struct pipe_context *pipe,
+ struct pipe_buffer_handle *indexBuffer,
+ unsigned indexSize,
+ unsigned prim, unsigned start, unsigned count)
{
struct i915_context *i915 = i915_context( pipe );
+ struct draw_context *draw = i915->draw;
+ unsigned i;
if (i915->dirty)
i915_update_derived( i915 );
- draw_arrays(i915->draw, mode, start, count);
+
+ /*
+ * Map vertex buffers
+ */
+ for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
+ if (i915->vertex_buffer[i].buffer) {
+ void *buf
+ = pipe->winsys->buffer_map(pipe->winsys,
+ i915->vertex_buffer[i].buffer,
+ PIPE_BUFFER_FLAG_READ);
+ draw_set_mapped_vertex_buffer(draw, i, buf);
+ }
+ }
+ /* Map index buffer, if present */
+ if (indexBuffer) {
+ void *mapped_indexes
+ = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
+ PIPE_BUFFER_FLAG_READ);
+ draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
+ }
+ else {
+ /* no index/element buffer */
+ draw_set_mapped_element_buffer(draw, 0, NULL);
+ }
+
+ /* draw! */
+ draw_arrays(i915->draw, prim, start, count);
+
+ /*
+ * unmap vertex/index buffers
+ */
+ for (i = 0; i < PIPE_ATTRIB_MAX; 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);
+ }
+ }
+ if (indexBuffer) {
+ pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+ draw_set_mapped_element_buffer(draw, 0, NULL);
+ }
}
+static void i915_draw_arrays( struct pipe_context *pipe,
+ unsigned prim, unsigned start, unsigned count)
+{
+ i915_draw_elements(pipe, NULL, 0, prim, start, count);
+}
+
struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
@@ -205,6 +256,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915->pipe.get_occlusion_counter = NULL;
i915->pipe.draw_arrays = i915_draw_arrays;
+ i915->pipe.draw_elements = i915_draw_elements;
/*
* Create drawing context and plug our rendering stage into it.
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index 1e48485c568..a3927bf8b8d 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -113,6 +113,8 @@ struct i915_context
struct pipe_stencil_state stencil;
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
+ struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
+
unsigned dirty;
unsigned *batch_start;
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 06fa716c4fa..1de6fea2e90 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -121,6 +121,16 @@ static void i915_set_fs_state( struct pipe_context *pipe,
}
+static void i915_set_vs_state( struct pipe_context *pipe,
+ const struct pipe_shader_state *vs )
+{
+ struct i915_context *i915 = i915_context(pipe);
+
+ /* just pass-through to draw module */
+ draw_set_vertex_shader(i915->draw, vs);
+}
+
+
static void i915_set_sampler_state(struct pipe_context *pipe,
unsigned unit,
const struct pipe_sampler_state *sampler)
@@ -216,6 +226,28 @@ static void i915_set_setup_state( struct pipe_context *pipe,
}
+static void i915_set_vertex_buffer( struct pipe_context *pipe,
+ unsigned index,
+ const struct pipe_vertex_buffer *buffer )
+{
+ struct i915_context *i915 = i915_context(pipe);
+ i915->vertex_buffer[index] = *buffer;
+ /* pass-through to draw module */
+ draw_set_vertex_buffer(i915->draw, index, buffer);
+}
+
+
+static void i915_set_vertex_element( struct pipe_context *pipe,
+ unsigned index,
+ const struct pipe_vertex_element *element)
+{
+ struct i915_context *i915 = i915_context(pipe);
+ /* pass-through to draw module */
+ draw_set_vertex_element(i915->draw, index, element);
+}
+
+
+
void
i915_init_state_functions( struct i915_context *i915 )
{
@@ -227,6 +259,7 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.set_depth_state = i915_set_depth_test_state;
i915->pipe.set_framebuffer_state = i915_set_framebuffer_state;
i915->pipe.set_fs_state = i915_set_fs_state;
+ i915->pipe.set_vs_state = i915_set_vs_state;
i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
i915->pipe.set_sampler_state = i915_set_sampler_state;
i915->pipe.set_scissor_state = i915_set_scissor_state;
@@ -234,4 +267,6 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.set_stencil_state = i915_set_stencil_state;
i915->pipe.set_texture_state = i915_set_texture_state;
i915->pipe.set_viewport_state = i915_set_viewport_state;
+ i915->pipe.set_vertex_buffer = i915_set_vertex_buffer;
+ i915->pipe.set_vertex_element = i915_set_vertex_element;
}