mesa: add _mesa_unpack_ubyte_rgba_row() function
[mesa.git] / src / mesa / vbo / vbo_save.h
index 9558f83883758571988c8678fb419a19c2422d28..4d4a5bf1710e3d182676cd50e6d14850e0f2f9af 100644 (file)
@@ -34,6 +34,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef VBO_SAVE_H
 #define VBO_SAVE_H
 
+#include "main/mfeatures.h"
 #include "main/mtypes.h"
 #include "vbo.h"
 #include "vbo_attrib.h"
@@ -64,8 +65,15 @@ struct vbo_save_vertex_list {
    GLubyte attrsz[VBO_ATTRIB_MAX];
    GLuint vertex_size;
 
+   /* Copy of the final vertex from node->vertex_store->bufferobj.
+    * Keep this in regular (non-VBO) memory to avoid repeated
+    * map/unmap of the VBO when updating GL current data.
+    */
+   GLfloat *current_data;
+   GLuint current_size;
+
    GLuint buffer_offset;
-   GLuint count;
+   GLuint count;                /**< vertex count */
    GLuint wrap_count;          /* number of copied vertices at start */
    GLboolean dangling_attr_ref;        /* current attr implicitly referenced 
                                   outside the list */
@@ -89,7 +97,9 @@ struct vbo_save_vertex_list {
  */
 #define VBO_SAVE_BUFFER_SIZE (8*1024) /* dwords */
 #define VBO_SAVE_PRIM_SIZE   128
-#define VBO_SAVE_PRIM_WEAK 0x40
+#define VBO_SAVE_PRIM_MODE_MASK         0x3f
+#define VBO_SAVE_PRIM_WEAK              0x40
+#define VBO_SAVE_PRIM_NO_CURRENT_UPDATE 0x80
 
 #define VBO_SAVE_FALLBACK    0x10000000
 
@@ -110,8 +120,9 @@ struct vbo_save_primitive_store {
 
 
 struct vbo_save_context {
-   GLcontext *ctx;
+   struct gl_context *ctx;
    GLvertexformat vtxfmt;
+   GLvertexformat vtxfmt_noop;  /**< Used if out_of_memory is true */
    struct gl_client_array arrays[VBO_ATTRIB_MAX];
    const struct gl_client_array *inputs[VBO_ATTRIB_MAX];
 
@@ -119,6 +130,8 @@ struct vbo_save_context {
    GLubyte active_sz[VBO_ATTRIB_MAX];
    GLuint vertex_size;
 
+   GLboolean out_of_memory;  /**< True if last VBO allocation failed */
+
    GLfloat *buffer;
    GLuint count;
    GLuint wrap_count;
@@ -136,7 +149,6 @@ struct vbo_save_context {
    GLuint vert_count;
    GLuint max_vert;
    GLboolean dangling_attr_ref;
-   GLboolean have_materials;
 
    GLuint opcode_vertex_list;
 
@@ -146,14 +158,15 @@ struct vbo_save_context {
    GLubyte *currentsz[VBO_ATTRIB_MAX];
 };
 
+#if FEATURE_dlist
 
-void vbo_save_init( GLcontext *ctx );
-void vbo_save_destroy( GLcontext *ctx );
-void vbo_save_fallback( GLcontext *ctx, GLboolean fallback );
+void vbo_save_init( struct gl_context *ctx );
+void vbo_save_destroy( struct gl_context *ctx );
+void vbo_save_fallback( struct gl_context *ctx, GLboolean fallback );
 
 /* save_loopback.c:
  */
-void vbo_loopback_vertex_list( GLcontext *ctx,
+void vbo_loopback_vertex_list( struct gl_context *ctx,
                               const GLfloat *buffer,
                               const GLubyte *attrsz,
                               const struct _mesa_prim *prim,
@@ -163,15 +176,29 @@ void vbo_loopback_vertex_list( GLcontext *ctx,
 
 /* Callbacks:
  */
-void vbo_save_EndList( GLcontext *ctx );
-void vbo_save_NewList( GLcontext *ctx, GLuint list, GLenum mode );
-void vbo_save_EndCallList( GLcontext *ctx );
-void vbo_save_BeginCallList( GLcontext *ctx, struct gl_display_list *list );
-void vbo_save_SaveFlushVertices( GLcontext *ctx );
-GLboolean vbo_save_NotifyBegin( GLcontext *ctx, GLenum mode );
+void vbo_save_EndList( struct gl_context *ctx );
+void vbo_save_NewList( struct gl_context *ctx, GLuint list, GLenum mode );
+void vbo_save_EndCallList( struct gl_context *ctx );
+void vbo_save_BeginCallList( struct gl_context *ctx, struct gl_display_list *list );
+void vbo_save_SaveFlushVertices( struct gl_context *ctx );
+GLboolean vbo_save_NotifyBegin( struct gl_context *ctx, GLenum mode );
 
-void vbo_save_playback_vertex_list( GLcontext *ctx, void *data );
+void vbo_save_playback_vertex_list( struct gl_context *ctx, void *data );
 
 void vbo_save_api_init( struct vbo_save_context *save );
 
-#endif
+#else /* FEATURE_dlist */
+
+static inline void
+vbo_save_init( struct gl_context *ctx )
+{
+}
+
+static inline void
+vbo_save_destroy( struct gl_context *ctx )
+{
+}
+
+#endif /* FEATURE_dlist */
+
+#endif /* VBO_SAVE_H */