radeon/r600: Fix remaining warnings when building 64 bit binary.
[mesa.git] / src / mesa / vbo / vbo_save_api.c
index 971a338af42deee02b6830cf66daeea4f23f350c..cdbbc9c1876b5512e65cb525cc6f9cc126e6b588 100644 (file)
@@ -667,19 +667,33 @@ do {                                                              \
  *     -- Flush current buffer
  *     -- Fallback to opcodes for the rest of the begin/end object.
  */
-#define DO_FALLBACK(ctx)                                                       \
-do {                                                                   \
-   struct vbo_save_context *save = &vbo_context(ctx)->save;                                    \
-                                                                       \
-   if (save->vert_count || save->prim_count)                                           \
-      _save_compile_vertex_list( ctx );                                        \
-                                                                       \
-   _save_copy_to_current( ctx );                                       \
-   _save_reset_vertex( ctx );                                          \
-   _save_reset_counters( ctx );  \
-   _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );       \
-   ctx->Driver.SaveNeedFlush = 0;                                      \
-} while (0)
+static void DO_FALLBACK( GLcontext *ctx )
+{
+   struct vbo_save_context *save = &vbo_context(ctx)->save;
+
+   if (save->vert_count || save->prim_count) {
+      GLint i = save->prim_count - 1;
+
+      /* Close off in-progress primitive.
+       */
+      save->prim[i].count = (save->vert_count - 
+                             save->prim[i].start);
+
+      /* Need to replay this display list with loopback,
+       * unfortunately, otherwise this primitive won't be handled
+       * properly:
+       */
+      save->dangling_attr_ref = 1;
+      
+      _save_compile_vertex_list( ctx );
+   }
+
+   _save_copy_to_current( ctx );
+   _save_reset_vertex( ctx );
+   _save_reset_counters( ctx );
+   _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
+   ctx->Driver.SaveNeedFlush = 0;
+}
 
 static void GLAPIENTRY _save_EvalCoord1f( GLfloat u )
 {
@@ -897,7 +911,7 @@ static void GLAPIENTRY _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum
 
    _ae_map_vbos( ctx );
 
-   if (ctx->Array.ElementArrayBufferObj->Name)
+   if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj))
       indices = ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Pointer, indices);
 
    vbo_save_NotifyBegin( ctx, mode | VBO_SAVE_PRIM_WEAK );
@@ -1130,6 +1144,11 @@ static void vbo_destroy_vertex_list( GLcontext *ctx, void *data )
 
    if ( --node->prim_store->refcount == 0 )
       FREE( node->prim_store );
+
+   if (node->current_data) {
+      FREE(node->current_data);
+      node->current_data = NULL;
+   }
 }
 
 
@@ -1139,10 +1158,10 @@ static void vbo_print_vertex_list( GLcontext *ctx, void *data )
    GLuint i;
    (void) ctx;
 
-   _mesa_debug(NULL, "VBO-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n",
-               node->count,
-              node->prim_count,
-              node->vertex_size);
+   _mesa_printf("VBO-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n",
+               node->count,
+               node->prim_count,
+               node->vertex_size);
 
    for (i = 0 ; i < node->prim_count ; i++) {
       struct _mesa_prim *prim = &node->prim[i];