aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r--mesalib/src/mesa/main/api_arrayelt.c10
-rw-r--r--mesalib/src/mesa/main/context.c2
-rw-r--r--mesalib/src/mesa/main/dlist.c32
-rw-r--r--mesalib/src/mesa/main/extensions.c2
-rw-r--r--mesalib/src/mesa/main/fbobject.c14
-rw-r--r--mesalib/src/mesa/main/mtypes.h19
-rw-r--r--mesalib/src/mesa/main/teximage.c32
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_rasterpos.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c14
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw_feedback.c2
-rw-r--r--mesalib/src/mesa/tnl/t_draw.c3
-rw-r--r--mesalib/src/mesa/tnl/tnl.h1
-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
27 files changed, 217 insertions, 91 deletions
diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c
index 7bf55f319..6de6de2b7 100644
--- a/mesalib/src/mesa/main/api_arrayelt.c
+++ b/mesalib/src/mesa/main/api_arrayelt.c
@@ -1643,12 +1643,20 @@ void GLAPIENTRY _ae_ArrayElement( GLint elt )
const struct _glapi_table * const disp = GET_DISPATCH();
GLboolean do_map;
+ /* If PrimitiveRestart is enabled and the index is the RestartIndex
+ * then we call PrimitiveRestartNV and return.
+ */
+ if (ctx->Array.PrimitiveRestart && (elt == ctx->Array.RestartIndex)) {
+ CALL_PrimitiveRestartNV((struct _glapi_table *)disp, ());
+ return;
+ }
+
if (actx->NewState) {
assert(!actx->mapped_vbos);
_ae_update_state( ctx );
}
- /* Determine if w need to map/unmap VBOs */
+ /* Determine if we need to map/unmap VBOs */
do_map = actx->nr_vbos && !actx->mapped_vbos;
if (do_map)
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index d75351c85..7e2ac98b9 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -792,6 +792,7 @@ init_attrib_groups(struct gl_context *ctx)
/* Miscellaneous */
ctx->NewState = _NEW_ALL;
+ ctx->NewDriverState = ~0;
ctx->ErrorValue = (GLenum) GL_NO_ERROR;
ctx->ResetStatus = (GLenum) GL_NO_ERROR;
ctx->varying_vp_inputs = VERT_BIT_ALL;
@@ -1290,6 +1291,7 @@ _mesa_copy_context( const struct gl_context *src, struct gl_context *dst,
/* XXX FIXME: Call callbacks?
*/
dst->NewState = _NEW_ALL;
+ dst->NewDriverState = ~0;
}
#endif
diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c
index 8cfb97c26..c1c65ea25 100644
--- a/mesalib/src/mesa/main/dlist.c
+++ b/mesalib/src/mesa/main/dlist.c
@@ -134,7 +134,7 @@ do { \
do { \
if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
return retval; \
} \
} while (0)
@@ -149,7 +149,7 @@ do { \
do { \
if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
return; \
} \
} while (0)
@@ -5673,17 +5673,25 @@ save_Indexfv(const GLfloat * v)
static void GLAPIENTRY
save_EdgeFlag(GLboolean x)
{
- save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0);
+ save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? 1.0f : 0.0f);
}
-static inline GLboolean compare4fv( const GLfloat *a,
- const GLfloat *b,
- GLuint count )
+
+/**
+ * Compare 'count' elements of vectors 'a' and 'b'.
+ * \return GL_TRUE if equal, GL_FALSE if different.
+ */
+static inline GLboolean
+compare_vec(const GLfloat *a, const GLfloat *b, GLuint count)
{
return memcmp( a, b, count * sizeof(GLfloat) ) == 0;
}
-
+
+/**
+ * This glMaterial function is used for glMaterial calls that are outside
+ * a glBegin/End pair. For glMaterial inside glBegin/End, see the VBO code.
+ */
static void GLAPIENTRY
save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
{
@@ -5698,7 +5706,7 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
case GL_FRONT_AND_BACK:
break;
default:
- _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)");
+ _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)");
return;
}
@@ -5717,7 +5725,7 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
args = 3;
break;
default:
- _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)");
+ _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)");
return;
}
@@ -5734,7 +5742,8 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
if (bitmask & (1 << i)) {
if (ctx->ListState.ActiveMaterialSize[i] == args &&
- compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) {
+ compare_vec(ctx->ListState.CurrentMaterial[i], param, args)) {
+ /* no change in material value */
bitmask &= ~(1 << i);
}
else {
@@ -5744,8 +5753,7 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
}
}
- /* If this call has effect, return early:
- */
+ /* If this call has no effect, return early */
if (bitmask == 0)
return;
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 5f2c74a75..a843a4092 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -754,7 +754,7 @@ get_extension_override( struct gl_context *ctx )
/* Remove trailing space. */
len = strlen(extra_exts);
- if (extra_exts[len - 1] == ' ')
+ if (len > 0 && extra_exts[len - 1] == ' ')
extra_exts[len - 1] = '\0';
return extra_exts;
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 26ae1087c..f56369483 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -2023,7 +2023,11 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
_glthread_LOCK_MUTEX(fb->Mutex);
if (texObj) {
if (attachment == GL_DEPTH_ATTACHMENT &&
- texObj == fb->Attachment[BUFFER_STENCIL].Texture) {
+ texObj == fb->Attachment[BUFFER_STENCIL].Texture &&
+ level == fb->Attachment[BUFFER_STENCIL].TextureLevel &&
+ _mesa_tex_target_to_face(textarget) ==
+ fb->Attachment[BUFFER_STENCIL].CubeMapFace &&
+ zoffset == fb->Attachment[BUFFER_STENCIL].Zoffset) {
/* The texture object is already attached to the stencil attachment
* point. Don't create a new renderbuffer; just reuse the stencil
* attachment's. This is required to prevent a GL error in
@@ -2032,8 +2036,12 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
reuse_framebuffer_texture_attachment(fb, BUFFER_DEPTH,
BUFFER_STENCIL);
} else if (attachment == GL_STENCIL_ATTACHMENT &&
- texObj == fb->Attachment[BUFFER_DEPTH].Texture) {
- /* As above, but with depth and stencil juxtaposed. */
+ texObj == fb->Attachment[BUFFER_DEPTH].Texture &&
+ level == fb->Attachment[BUFFER_DEPTH].TextureLevel &&
+ _mesa_tex_target_to_face(textarget) ==
+ fb->Attachment[BUFFER_DEPTH].CubeMapFace &&
+ zoffset == fb->Attachment[BUFFER_DEPTH].Zoffset) {
+ /* As above, but with depth and stencil transposed. */
reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL,
BUFFER_DEPTH);
} else {
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 2b709ded6..06ca0d5df 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1636,6 +1636,11 @@ struct gl_array_attrib
/* GL_ARB_vertex_buffer_object */
struct gl_buffer_object *ArrayBufferObj;
+
+ /**
+ * Vertex arrays as consumed by a driver.
+ * The array pointer is set up only by the VBO module. */
+ const struct gl_client_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */
};
@@ -3252,6 +3257,17 @@ typedef enum
API_OPENGLES2
} gl_api;
+/**
+ * Driver-specific state flags.
+ *
+ * These are or'd with gl_context::NewDriverState to notify a driver about
+ * a state change. The driver sets the flags at context creation and
+ * the meaning of the bits set is opaque to core Mesa.
+ */
+struct gl_driver_flags
+{
+ GLbitfield NewArray; /**< Vertex array state */
+};
/**
* Mesa rendering context.
@@ -3411,6 +3427,9 @@ struct gl_context
GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
+ GLbitfield NewDriverState;/**< bitwise-or of flags from DriverFlags */
+
+ struct gl_driver_flags DriverFlags;
GLboolean ViewportInitialized; /**< has viewport size been initialized? */
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 50095d2c6..694f6fa00 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -531,6 +531,32 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
/**
+ * Is the given texture format a generic compressed format?
+ */
+static GLboolean
+is_generic_compressed_format(GLenum format)
+{
+ switch (format) {
+ case GL_COMPRESSED_RED:
+ case GL_COMPRESSED_RG:
+ case GL_COMPRESSED_RGB:
+ case GL_COMPRESSED_RGBA:
+ case GL_COMPRESSED_ALPHA:
+ case GL_COMPRESSED_LUMINANCE:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ case GL_COMPRESSED_INTENSITY:
+ case GL_COMPRESSED_SRGB:
+ case GL_COMPRESSED_SRGB_ALPHA:
+ case GL_COMPRESSED_SLUMINANCE:
+ case GL_COMPRESSED_SLUMINANCE_ALPHA:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
* For cube map faces, return a face index in [0,5].
* For other targets return 0;
*/
@@ -1705,7 +1731,8 @@ texture_error_check( struct gl_context *ctx,
}
/* additional checks for compressed textures */
- if (_mesa_is_compressed_format(ctx, internalFormat)) {
+ if (_mesa_is_compressed_format(ctx, internalFormat) ||
+ is_generic_compressed_format(internalFormat)) {
if (!target_can_be_compressed(ctx, target, internalFormat)) {
if (!isProxy)
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -2036,7 +2063,8 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
return GL_TRUE;
}
- if (_mesa_is_compressed_format(ctx, internalFormat)) {
+ if (_mesa_is_compressed_format(ctx, internalFormat) ||
+ is_generic_compressed_format(internalFormat)) {
if (!target_can_be_compressed(ctx, target, internalFormat)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glCopyTexImage%dD(target)", dimensions);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c
index 2c21dc9a7..8337f4624 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -225,6 +225,7 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
struct st_context *st = st_context(ctx);
struct draw_context *draw = st->draw;
struct rastpos_stage *rs;
+ const struct gl_client_array **saved_arrays = ctx->Array._DrawArrays;
if (st->rastpos_stage) {
/* get rastpos stage info */
@@ -250,9 +251,14 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
*/
rs->array[0].Ptr = (GLubyte *) v;
- /* draw the point */
- st_feedback_draw_vbo(ctx, rs->arrays, &rs->prim, 1, NULL, GL_TRUE, 0, 1,
+ /* Draw the point.
+ *
+ * Don't set DriverFlags.NewArray.
+ * st_feedback_draw_vbo doesn't check for that flag. */
+ ctx->Array._DrawArrays = rs->arrays;
+ st_feedback_draw_vbo(ctx, &rs->prim, 1, NULL, GL_TRUE, 0, 1,
NULL);
+ ctx->Array._DrawArrays = saved_arrays;
/* restore draw's rasterization stage depending on rendermode */
if (ctx->RenderMode == GL_FEEDBACK) {
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 19d9da131..ce7dbb3f3 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -203,6 +203,10 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe )
return st;
}
+static void st_init_driver_flags(struct gl_driver_flags *f)
+{
+ f->NewArray = ST_NEW_VERTEX_ARRAYS;
+}
struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
const struct gl_config *visual,
@@ -225,6 +229,8 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
return NULL;
}
+ st_init_driver_flags(&ctx->DriverFlags);
+
/* XXX: need a capability bit in gallium to query if the pipe
* driver prefers DP4 or MUL/MAD for vertex transformation.
*/
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 3ec98ada1..4786ed22f 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -50,6 +50,7 @@ struct u_vbuf;
#define ST_NEW_FRAMEBUFFER (1 << 3)
#define ST_NEW_EDGEFLAGS_DATA (1 << 4)
#define ST_NEW_GEOMETRY_PROGRAM (1 << 5)
+#define ST_NEW_VERTEX_ARRAYS (1 << 6)
struct st_state_flags {
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index edab76bf5..42dc37576 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -966,7 +966,6 @@ st_validate_varrays(struct gl_context *ctx,
*/
void
st_draw_vbo(struct gl_context *ctx,
- const struct gl_client_array **arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
@@ -979,15 +978,22 @@ st_draw_vbo(struct gl_context *ctx,
struct pipe_context *pipe = st->pipe;
struct pipe_index_buffer ibuffer;
struct pipe_draw_info info;
+ const struct gl_client_array **arrays = ctx->Array._DrawArrays;
unsigned i, num_instances = 1;
unsigned max_index_plus_base;
- GLboolean new_array =
- st->dirty.st &&
- (st->dirty.mesa & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) != 0;
+ GLboolean new_array;
/* Mesa core state should have been validated already */
assert(ctx->NewState == 0x0);
+ /* Get Mesa driver state. */
+ st->dirty.st |= ctx->NewDriverState;
+ ctx->NewDriverState = 0;
+
+ new_array =
+ (st->dirty.st & (ST_NEW_VERTEX_ARRAYS | ST_NEW_VERTEX_PROGRAM)) ||
+ (st->dirty.mesa & (_NEW_PROGRAM | _NEW_BUFFER_OBJECT)) != 0;
+
if (ib) {
int max_base_vertex = 0;
diff --git a/mesalib/src/mesa/state_tracker/st_draw.h b/mesalib/src/mesa/state_tracker/st_draw.h
index 47bdb11f8..c608051eb 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.h
+++ b/mesalib/src/mesa/state_tracker/st_draw.h
@@ -49,7 +49,6 @@ void st_destroy_draw( struct st_context *st );
extern void
st_draw_vbo(struct gl_context *ctx,
- const struct gl_client_array **arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
@@ -60,7 +59,6 @@ st_draw_vbo(struct gl_context *ctx,
extern void
st_feedback_draw_vbo(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/state_tracker/st_draw_feedback.c b/mesalib/src/mesa/state_tracker/st_draw_feedback.c
index a559b733a..257618aa9 100644
--- a/mesalib/src/mesa/state_tracker/st_draw_feedback.c
+++ b/mesalib/src/mesa/state_tracker/st_draw_feedback.c
@@ -91,7 +91,6 @@ set_feedback_vertex_format(struct gl_context *ctx)
*/
void
st_feedback_draw_vbo(struct gl_context *ctx,
- const struct gl_client_array **arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
@@ -110,6 +109,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
struct pipe_index_buffer ibuffer;
struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
struct pipe_transfer *ib_transfer = NULL;
+ const struct gl_client_array **arrays = ctx->Array._DrawArrays;
GLuint attr, i;
const GLubyte *low_addr = NULL;
const void *mapped_indices = NULL;
diff --git a/mesalib/src/mesa/tnl/t_draw.c b/mesalib/src/mesa/tnl/t_draw.c
index 17042cf8f..6a3c9662e 100644
--- a/mesalib/src/mesa/tnl/t_draw.c
+++ b/mesalib/src/mesa/tnl/t_draw.c
@@ -408,7 +408,6 @@ static void unmap_vbos( struct gl_context *ctx,
void _tnl_vbo_draw_prims(struct gl_context *ctx,
- const struct gl_client_array *arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
@@ -417,6 +416,8 @@ void _tnl_vbo_draw_prims(struct gl_context *ctx,
GLuint max_index,
struct gl_transform_feedback_object *tfb_vertcount)
{
+ const struct gl_client_array **arrays = ctx->Array._DrawArrays;
+
if (!index_bounds_valid)
vbo_get_minmax_indices(ctx, prim, ib, &min_index, &max_index, nr_prims);
diff --git a/mesalib/src/mesa/tnl/tnl.h b/mesalib/src/mesa/tnl/tnl.h
index 434bd7fcd..f6b70e323 100644
--- a/mesalib/src/mesa/tnl/tnl.h
+++ b/mesalib/src/mesa/tnl/tnl.h
@@ -86,7 +86,6 @@ _tnl_draw_prims( struct gl_context *ctx,
void
_tnl_vbo_draw_prims( struct gl_context *ctx,
- const struct gl_client_array *arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
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;