summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-04-23 18:20:56 +0200
committerMarek Olšák <[email protected]>2012-05-08 15:57:51 +0200
commit50f7e75f9e945cfbb2ae868cc961a2205a0b6e73 (patch)
treed55b1c38416040b9df653df6327dbaa0e82866fc /src/mesa/vbo
parenta7ac9c9c7dc7401ca6143d1e7476df5e3c2758b7 (diff)
mesa: move gl_client_array*[] from vbo_draw_func into gl_context
In the future we'd like to treat vertex arrays as a state and not as a parameter to the draw function. This is the first step towards that goal. Part of the goal is to avoid array re-validation for every draw call. This commit adds: const struct gl_client_array **gl_context::Array::_DrawArrays. The pointer is changed in: * vbo_draw_method * vbo_rebase_prims - unused by gallium * vbo_split_prims - unused by gallium * st_RasterPos Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r--src/mesa/vbo/vbo.h1
-rw-r--r--src/mesa/vbo/vbo_context.h15
-rw-r--r--src/mesa/vbo/vbo_exec_array.c12
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c3
-rw-r--r--src/mesa/vbo/vbo_rebase.c8
-rw-r--r--src/mesa/vbo/vbo_save_draw.c3
-rw-r--r--src/mesa/vbo/vbo_split_copy.c9
-rw-r--r--src/mesa/vbo/vbo_split_inplace.c9
8 files changed, 43 insertions, 17 deletions
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 2d01d9823cc..3cff8987e78 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -72,7 +72,6 @@ void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state );
typedef void (*vbo_draw_func)( struct gl_context *ctx,
- const struct gl_client_array **arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
index a6397ba2f8f..93c48cd029b 100644
--- a/src/mesa/vbo/vbo_context.h
+++ b/src/mesa/vbo/vbo_context.h
@@ -131,6 +131,21 @@ vbo_draw_method(struct vbo_context *vbo, enum draw_method method)
{
if (vbo->last_draw_method != method) {
struct gl_context *ctx = vbo->exec.ctx;
+
+ switch (method) {
+ case DRAW_ARRAYS:
+ ctx->Array._DrawArrays = vbo->exec.array.inputs;
+ break;
+ case DRAW_BEGIN_END:
+ ctx->Array._DrawArrays = vbo->exec.vtx.inputs;
+ break;
+ case DRAW_DISPLAY_LIST:
+ ctx->Array._DrawArrays = vbo->save.inputs;
+ break;
+ default:
+ ASSERT(0);
+ }
+
ctx->Driver.UpdateState(ctx, _NEW_ARRAY);
vbo->last_draw_method = method;
}
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 6c8a32e6452..d39324d12bc 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -600,7 +600,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
if (primCount > 0) {
/* draw one or two prims */
check_buffers_are_unmapped(exec->array.inputs);
- vbo->draw_prims(ctx, exec->array.inputs, prim, primCount, NULL,
+ vbo->draw_prims(ctx, prim, primCount, NULL,
GL_TRUE, start, start + count - 1, NULL);
}
}
@@ -610,7 +610,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
prim[0].count = count;
check_buffers_are_unmapped(exec->array.inputs);
- vbo->draw_prims(ctx, exec->array.inputs, prim, 1, NULL,
+ vbo->draw_prims(ctx, prim, 1, NULL,
GL_TRUE, start, start + count - 1,
NULL);
}
@@ -801,7 +801,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
*/
check_buffers_are_unmapped(exec->array.inputs);
- vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib,
+ vbo->draw_prims( ctx, prim, 1, &ib,
index_bounds_valid, start, end, NULL );
}
@@ -1096,7 +1096,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
}
check_buffers_are_unmapped(exec->array.inputs);
- vbo->draw_prims(ctx, exec->array.inputs, prim, primcount, &ib,
+ vbo->draw_prims(ctx, prim, primcount, &ib,
GL_FALSE, ~0, ~0, NULL);
} else {
/* render one prim at a time */
@@ -1121,7 +1121,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
prim[0].basevertex = 0;
check_buffers_are_unmapped(exec->array.inputs);
- vbo->draw_prims(ctx, exec->array.inputs, prim, 1, &ib,
+ vbo->draw_prims(ctx, prim, 1, &ib,
GL_FALSE, ~0, ~0, NULL);
}
}
@@ -1199,7 +1199,7 @@ vbo_draw_transform_feedback(struct gl_context *ctx, GLenum mode,
* will be rendered. */
check_buffers_are_unmapped(exec->array.inputs);
- vbo->draw_prims(ctx, exec->array.inputs, prim, 1, NULL,
+ vbo->draw_prims(ctx, prim, 1, NULL,
GL_TRUE, 0, 0, obj);
}
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index da5ca695eaf..6e8bb15d1e2 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -407,8 +407,7 @@ vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped)
exec->vtx.vert_count);
vbo_context(ctx)->draw_prims( ctx,
- exec->vtx.inputs,
- exec->vtx.prim,
+ exec->vtx.prim,
exec->vtx.prim_count,
NULL,
GL_TRUE,
diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c
index 597a8f46994..9a98ef7d449 100644
--- a/src/mesa/vbo/vbo_rebase.c
+++ b/src/mesa/vbo/vbo_rebase.c
@@ -129,6 +129,7 @@ void vbo_rebase_prims( struct gl_context *ctx,
struct _mesa_index_buffer tmp_ib;
struct _mesa_prim *tmp_prims = NULL;
+ const struct gl_client_array **saved_arrays = ctx->Array._DrawArrays;
void *tmp_indices = NULL;
GLuint i;
@@ -226,15 +227,18 @@ void vbo_rebase_prims( struct gl_context *ctx,
/* Re-issue the draw call.
*/
+ ctx->Array._DrawArrays = tmp_array_pointers;
+
draw( ctx,
- tmp_array_pointers,
- prim,
+ prim,
nr_prims,
ib,
GL_TRUE,
0,
max_index - min_index,
NULL );
+
+ ctx->Array._DrawArrays = saved_arrays;
if (tmp_indices)
free(tmp_indices);
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 47564d340eb..bb5961549ef 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -312,8 +312,7 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data)
if (node->count > 0) {
vbo_context(ctx)->draw_prims(ctx,
- save->inputs,
- node->prim,
+ node->prim,
node->prim_count,
NULL,
GL_TRUE,
diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c
index b53293c3120..9665c4fcd2f 100644
--- a/src/mesa/vbo/vbo_split_copy.c
+++ b/src/mesa/vbo/vbo_split_copy.c
@@ -171,6 +171,8 @@ dump_draw_info(struct gl_context *ctx,
static void
flush( struct copy_context *copy )
{
+ struct gl_context *ctx = copy->ctx;
+ const struct gl_client_array **saved_arrays = ctx->Array._DrawArrays;
GLuint i;
/* Set some counters:
@@ -189,8 +191,9 @@ flush( struct copy_context *copy )
(void) dump_draw_info;
#endif
- copy->draw( copy->ctx,
- copy->dstarray_ptr,
+ ctx->Array._DrawArrays = copy->dstarray_ptr;
+
+ copy->draw( ctx,
copy->dstprim,
copy->dstprim_nr,
&copy->dstib,
@@ -199,6 +202,8 @@ flush( struct copy_context *copy )
copy->dstbuf_nr - 1,
NULL );
+ ctx->Array._DrawArrays = saved_arrays;
+
/* Reset all pointers:
*/
copy->dstprim_nr = 0;
diff --git a/src/mesa/vbo/vbo_split_inplace.c b/src/mesa/vbo/vbo_split_inplace.c
index 9e596f66891..7c2cc3ece5a 100644
--- a/src/mesa/vbo/vbo_split_inplace.c
+++ b/src/mesa/vbo/vbo_split_inplace.c
@@ -62,6 +62,8 @@ struct split_context {
static void flush_vertex( struct split_context *split )
{
+ struct gl_context *ctx = split->ctx;
+ const struct gl_client_array **saved_arrays = ctx->Array._DrawArrays;
struct _mesa_index_buffer ib;
GLuint i;
@@ -82,8 +84,9 @@ static void flush_vertex( struct split_context *split )
assert(split->max_index >= split->min_index);
- split->draw(split->ctx,
- split->array,
+ ctx->Array._DrawArrays = split->array;
+
+ split->draw(ctx,
split->dstprim,
split->dstprim_nr,
split->ib ? &ib : NULL,
@@ -92,6 +95,8 @@ static void flush_vertex( struct split_context *split )
split->max_index,
NULL);
+ ctx->Array._DrawArrays = saved_arrays;
+
split->dstprim_nr = 0;
split->min_index = ~0;
split->max_index = 0;