aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/vbo
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/vbo')
-rw-r--r--mesalib/src/mesa/vbo/vbo.h1
-rw-r--r--mesalib/src/mesa/vbo/vbo_context.h50
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec.h36
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_api.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c16
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_draw.c5
-rw-r--r--mesalib/src/mesa/vbo/vbo_rebase.c10
-rw-r--r--mesalib/src/mesa/vbo/vbo_save.c3
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c5
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_draw.c8
-rw-r--r--mesalib/src/mesa/vbo/vbo_split_copy.c11
-rw-r--r--mesalib/src/mesa/vbo/vbo_split_inplace.c11
12 files changed, 97 insertions, 61 deletions
diff --git a/mesalib/src/mesa/vbo/vbo.h b/mesalib/src/mesa/vbo/vbo.h
index 2d01d9823..3cff8987e 100644
--- a/mesalib/src/mesa/vbo/vbo.h
+++ b/mesalib/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/mesalib/src/mesa/vbo/vbo_context.h b/mesalib/src/mesa/vbo/vbo_context.h
index b9a8affa5..1c49de0ca 100644
--- a/mesalib/src/mesa/vbo/vbo_context.h
+++ b/mesalib/src/mesa/vbo/vbo_context.h
@@ -58,6 +58,18 @@
#include "vbo_save.h"
+/** Used to signal when transitioning from one kind of drawing method
+ * to another.
+ */
+enum draw_method
+{
+ DRAW_NONE, /**< Initial value only */
+ DRAW_BEGIN_END,
+ DRAW_DISPLAY_LIST,
+ DRAW_ARRAYS
+};
+
+
struct vbo_context {
struct gl_client_array currval[VBO_ATTRIB_MAX];
@@ -74,6 +86,8 @@ struct vbo_context {
* is responsible for initiating any fallback actions required:
*/
vbo_draw_func draw_prims;
+
+ enum draw_method last_draw_method;
};
@@ -101,4 +115,40 @@ get_program_mode( struct gl_context *ctx )
}
+/**
+ * This is called by glBegin, glDrawArrays and glDrawElements (and
+ * variations of those calls). When we transition from immediate mode
+ * drawing to array drawing we need to invalidate the array state.
+ *
+ * glBegin/End builds vertex arrays. Those arrays may look identical
+ * to glDrawArrays arrays except that the position of the elements may
+ * be different. For example, arrays of (position3v, normal3f) vs. arrays
+ * of (normal3f, position3f). So we need to make sure we notify drivers
+ * that arrays may be changing.
+ */
+static inline void
+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->NewDriverState |= ctx->DriverFlags.NewArray;
+ vbo->last_draw_method = method;
+ }
+}
+
#endif
diff --git a/mesalib/src/mesa/vbo/vbo_exec.h b/mesalib/src/mesa/vbo/vbo_exec.h
index be9f3d78d..4ac7d168d 100644
--- a/mesalib/src/mesa/vbo/vbo_exec.h
+++ b/mesalib/src/mesa/vbo/vbo_exec.h
@@ -78,26 +78,12 @@ struct vbo_exec_copied_vtx {
};
-/** Used to signal when transitioning from one kind of drawing method
- * to another.
- */
-enum draw_method
-{
- DRAW_NONE, /**< Initial value only */
- DRAW_BEGIN_END,
- DRAW_DISPLAY_LIST,
- DRAW_ARRAYS
-};
-
-
struct vbo_exec_context
{
struct gl_context *ctx;
GLvertexformat vtxfmt;
GLvertexformat vtxfmt_noop;
- enum draw_method last_draw_method;
-
struct {
struct gl_buffer_object *bufferobj;
@@ -174,28 +160,6 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec );
void vbo_exec_vtx_destroy( struct vbo_exec_context *exec );
-/**
- * This is called by glBegin, glDrawArrays and glDrawElements (and
- * variations of those calls). When we transition from immediate mode
- * drawing to array drawing we need to invalidate the array state.
- *
- * glBegin/End builds vertex arrays. Those arrays may look identical
- * to glDrawArrays arrays except that the position of the elements may
- * be different. For example, arrays of (position3v, normal3f) vs. arrays
- * of (normal3f, position3f). So we need to make sure we notify drivers
- * that arrays may be changing.
- */
-static inline void
-vbo_draw_method(struct vbo_exec_context *exec, enum draw_method method)
-{
- if (exec->last_draw_method != method) {
- struct gl_context *ctx = exec->ctx;
- ctx->Driver.UpdateState(ctx, _NEW_ARRAY);
- exec->last_draw_method = method;
- }
-}
-
-
#if FEATURE_beginend
void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap );
diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c
index 3f9541089..b87da18f3 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_api.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_api.c
@@ -700,7 +700,7 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
return;
}
- vbo_draw_method(exec, DRAW_BEGIN_END);
+ vbo_draw_method(vbo_context(ctx), DRAW_BEGIN_END);
if (ctx->Driver.PrepareExecBegin)
ctx->Driver.PrepareExecBegin(ctx);
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 2dcfb8e5b..cc94e761b 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -506,7 +506,7 @@ recalculate_input_bindings(struct gl_context *ctx)
}
_mesa_set_varying_vp_inputs( ctx, VERT_BIT_ALL & (~const_inputs) );
- ctx->Driver.UpdateState(ctx, _NEW_ARRAY);
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
}
@@ -523,7 +523,7 @@ vbo_bind_arrays(struct gl_context *ctx)
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
- vbo_draw_method(exec, DRAW_ARRAYS);
+ vbo_draw_method(vbo, DRAW_ARRAYS);
if (exec->array.recalculate_inputs) {
recalculate_input_bindings(ctx);
@@ -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/mesalib/src/mesa/vbo/vbo_exec_draw.c b/mesalib/src/mesa/vbo/vbo_exec_draw.c
index da5ca695e..77db8ec7f 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_draw.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_draw.c
@@ -257,7 +257,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
}
_mesa_set_varying_vp_inputs( ctx, varying_inputs );
- ctx->Driver.UpdateState(ctx, _NEW_ARRAY);
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
}
@@ -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/mesalib/src/mesa/vbo/vbo_rebase.c b/mesalib/src/mesa/vbo/vbo_rebase.c
index 597a8f469..fff9df0c2 100644
--- a/mesalib/src/mesa/vbo/vbo_rebase.c
+++ b/mesalib/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,20 @@ void vbo_rebase_prims( struct gl_context *ctx,
/* Re-issue the draw call.
*/
+ ctx->Array._DrawArrays = tmp_array_pointers;
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+
draw( ctx,
- tmp_array_pointers,
- prim,
+ prim,
nr_prims,
ib,
GL_TRUE,
0,
max_index - min_index,
NULL );
+
+ ctx->Array._DrawArrays = saved_arrays;
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
if (tmp_indices)
free(tmp_indices);
diff --git a/mesalib/src/mesa/vbo/vbo_save.c b/mesalib/src/mesa/vbo/vbo_save.c
index 040c9b7a9..7a97d3c65 100644
--- a/mesalib/src/mesa/vbo/vbo_save.c
+++ b/mesalib/src/mesa/vbo/vbo_save.c
@@ -49,6 +49,9 @@ static void vbo_save_callback_init( struct gl_context *ctx )
+/**
+ * Called at context creation time.
+ */
void vbo_save_init( struct gl_context *ctx )
{
struct vbo_context *vbo = vbo_context(ctx);
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index 13604333e..74f5dc9ce 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -1506,6 +1506,9 @@ vbo_print_vertex_list(struct gl_context *ctx, void *data)
}
+/**
+ * Called during context creation/init.
+ */
static void
_save_current_init(struct gl_context *ctx)
{
@@ -1529,7 +1532,7 @@ _save_current_init(struct gl_context *ctx)
/**
- * Initialize the display list compiler
+ * Initialize the display list compiler. Called during context creation.
*/
void
vbo_save_api_init(struct vbo_save_context *save)
diff --git a/mesalib/src/mesa/vbo/vbo_save_draw.c b/mesalib/src/mesa/vbo/vbo_save_draw.c
index 88a9a7e34..c6425ab1b 100644
--- a/mesalib/src/mesa/vbo/vbo_save_draw.c
+++ b/mesalib/src/mesa/vbo/vbo_save_draw.c
@@ -213,7 +213,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
}
_mesa_set_varying_vp_inputs( ctx, varying_inputs );
- ctx->Driver.UpdateState(ctx, _NEW_ARRAY);
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
}
@@ -250,7 +250,6 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data)
const struct vbo_save_vertex_list *node =
(const struct vbo_save_vertex_list *) data;
struct vbo_save_context *save = &vbo_context(ctx)->save;
- struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
GLboolean remap_vertex_store = GL_FALSE;
if (save->vertex_store->buffer) {
@@ -304,7 +303,7 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data)
vbo_bind_vertex_list( ctx, node );
- vbo_draw_method(exec, DRAW_DISPLAY_LIST);
+ vbo_draw_method(vbo_context(ctx), DRAW_DISPLAY_LIST);
/* Again...
*/
@@ -313,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/mesalib/src/mesa/vbo/vbo_split_copy.c b/mesalib/src/mesa/vbo/vbo_split_copy.c
index b53293c31..528fcfd7f 100644
--- a/mesalib/src/mesa/vbo/vbo_split_copy.c
+++ b/mesalib/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,10 @@ flush( struct copy_context *copy )
(void) dump_draw_info;
#endif
- copy->draw( copy->ctx,
- copy->dstarray_ptr,
+ ctx->Array._DrawArrays = copy->dstarray_ptr;
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+
+ copy->draw( ctx,
copy->dstprim,
copy->dstprim_nr,
&copy->dstib,
@@ -199,6 +203,9 @@ flush( struct copy_context *copy )
copy->dstbuf_nr - 1,
NULL );
+ ctx->Array._DrawArrays = saved_arrays;
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+
/* Reset all pointers:
*/
copy->dstprim_nr = 0;
diff --git a/mesalib/src/mesa/vbo/vbo_split_inplace.c b/mesalib/src/mesa/vbo/vbo_split_inplace.c
index 9e596f668..00464049d 100644
--- a/mesalib/src/mesa/vbo/vbo_split_inplace.c
+++ b/mesalib/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,10 @@ 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;
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+
+ split->draw(ctx,
split->dstprim,
split->dstprim_nr,
split->ib ? &ib : NULL,
@@ -92,6 +96,9 @@ static void flush_vertex( struct split_context *split )
split->max_index,
NULL);
+ ctx->Array._DrawArrays = saved_arrays;
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+
split->dstprim_nr = 0;
split->min_index = ~0;
split->max_index = 0;