diff options
author | Brian Paul <[email protected]> | 2011-12-26 14:43:07 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2011-12-26 15:21:32 -0700 |
commit | 0a7602b938893e1b04a01ca8680376cbeec053ab (patch) | |
tree | 41c39c77028d1e940e61f33a22c5d094961babcd /src/mesa/vbo/vbo_exec.h | |
parent | 31bf243a92454758fb4b8efc6bd8ccac99b67b6e (diff) |
vbo: signal _NEW_ARRAY when transitioning between glBegin/End, glDrawArrays
This fixes a regression seen with the isosurf demo when switching between
glBegin/End and glDrawArrays (do it several times). The problem was the
driver wasn't getting _NEW_ARRAY when the arrays were subtly changed:
(vertex3f, normal3f) vs. (normal3f, vertex3f).
This patch fixes that by signaling _NEW_ARRAY whenever we transition
between glBegin/End and glDrawArrays mode and display lists.
The patch also fixes up the initialization of the map_vp_none[] array
to stop putting strange values in the last five elements of the array.
v2: remove DRAW_ELEMENTS, don't distinguish between glDrawArrays and
glDrawElements
v3: add DRAW_DISPLAY_LIST for the display list case, just to be safe.
Reviewed-by: Mathias Froehlich <[email protected]>
Tested-by: Mathias Froehlich <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_exec.h')
-rw-r--r-- | src/mesa/vbo/vbo_exec.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index cfed8e86dc0..e85798da4c4 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -78,12 +78,26 @@ 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; @@ -164,6 +178,28 @@ void vbo_exec_array_destroy( struct vbo_exec_context *exec ); 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) { + exec->ctx->NewState |= _NEW_ARRAY; + exec->last_draw_method = method; + } +} + + #if FEATURE_beginend void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ); |