Cell: generalize the batch buffer code for vertex buffers...
[mesa.git] / src / mesa / vbo / vbo.h
index 96b25f18ee6eb31bee60981b005ffce2b6dacc9c..79d33d09c16c475a06fd0da8cb2f05cfa8462a5b 100644 (file)
 #ifndef _VBO_H
 #define _VBO_H
 
+#include "main/mtypes.h"
+
+struct _mesa_prim {
+   GLuint mode:8;
+   GLuint indexed:1;
+   GLuint begin:1;
+   GLuint end:1;
+   GLuint weak:1;
+   GLuint pad:20;
+
+   GLuint start;
+   GLuint count;
+};
+
+/* Would like to call this a "vbo_index_buffer", but this would be
+ * confusing as the indices are not neccessarily yet in a non-null
+ * buffer object.
+ */
+struct _mesa_index_buffer {
+   GLuint count;
+   GLenum type;
+   struct gl_buffer_object *obj;
+   const void *ptr;
+};
+
+
+
 GLboolean _vbo_CreateContext( GLcontext *ctx );
 void _vbo_DestroyContext( GLcontext *ctx );
 void _vbo_InvalidateState( GLcontext *ctx, GLuint new_state );
 
 
+typedef void (*vbo_draw_func)( GLcontext *ctx,
+                              const struct gl_client_array **arrays,
+                              const struct _mesa_prim *prims,
+                              GLuint nr_prims,
+                              const struct _mesa_index_buffer *ib,
+                              GLuint min_index,
+                              GLuint max_index );
+
+
+
+
+/* Utility function to cope with various constraints on tnl modules or
+ * hardware.  This can be used to split an incoming set of arrays and
+ * primitives against the following constraints:
+ *    - Maximum number of indices in index buffer.
+ *    - Maximum number of vertices referenced by index buffer.
+ *    - Maximum hardware vertex buffer size.
+ */
+struct split_limits {
+   GLuint max_verts;
+   GLuint max_indices;
+   GLuint max_vb_size;         /* bytes */
+};
+
+
+void vbo_split_prims( GLcontext *ctx,
+                     const struct gl_client_array *arrays[],
+                     const struct _mesa_prim *prim,
+                     GLuint nr_prims,
+                     const struct _mesa_index_buffer *ib,
+                     GLuint min_index,
+                     GLuint max_index,
+                     vbo_draw_func draw,
+                     const struct split_limits *limits );
+
+
+/* Helpers for dealing translating away non-zero min_index.
+ */
+GLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] );
+
+void vbo_rebase_prims( GLcontext *ctx,
+                      const struct gl_client_array *arrays[],
+                      const struct _mesa_prim *prim,
+                      GLuint nr_prims,
+                      const struct _mesa_index_buffer *ib,
+                      GLuint min_index,
+                      GLuint max_index,
+                      vbo_draw_func draw );
+
+
+void vbo_use_buffer_objects(GLcontext *ctx);
+
+
+void vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func);
+
+
 #endif