intel/disasm: brw_label and support functions
[mesa.git] / src / mesa / vbo / vbo_save.h
index b7e9baabf8100e8f4a22d79deaea8a3c573051f1..a9842514011e916edcad5563953ce1463f5f2229 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
 
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
+Copyright 2002 VMware, Inc.
 
 All Rights Reserved.
 
@@ -18,7 +18,7 @@ Software.
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -27,24 +27,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /*
  * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
+ *   Keith Whitwell <keithw@vmware.com>
  *
  */
 
 #ifndef VBO_SAVE_H
 #define VBO_SAVE_H
 
-#include "main/mtypes.h"
 #include "vbo.h"
 #include "vbo_attrib.h"
 
-
-struct vbo_save_copied_vtx {
-   GLfloat buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS];
-   GLuint nr;
-};
-
-
 /* For display lists, this structure holds a run of vertices of the
  * same format, and a strictly well-formed set of begin/end pairs,
  * starting on the first vertex and ending at the last.  Vertex
@@ -61,22 +53,70 @@ struct vbo_save_copied_vtx {
  * compiled using the fallback opcode mechanism provided by dlist.c.
  */
 struct vbo_save_vertex_list {
-   GLubyte attrsz[VBO_ATTRIB_MAX];
-   GLuint vertex_size;
+   struct gl_vertex_array_object *VAO[VP_MODE_MAX];
+
+   /* 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.
+    */
+   fi_type *current_data;
 
-   GLuint buffer_offset;
-   GLuint count;
+   GLuint vertex_count;         /**< number of vertices in this list */
    GLuint wrap_count;          /* number of copied vertices at start */
-   GLboolean dangling_attr_ref;        /* current attr implicitly referenced 
-                                  outside the list */
 
-   struct _mesa_prim *prim;
+   struct _mesa_prim *prims;
    GLuint prim_count;
 
-   struct vbo_save_vertex_store *vertex_store;
    struct vbo_save_primitive_store *prim_store;
 };
 
+
+/**
+ * Return the stride in bytes of the display list node.
+ */
+static inline GLsizei
+_vbo_save_get_stride(const struct vbo_save_vertex_list *node)
+{
+   return node->VAO[0]->BufferBinding[0].Stride;
+}
+
+
+/**
+ * Return the first referenced vertex index in the display list node.
+ */
+static inline GLuint
+_vbo_save_get_min_index(const struct vbo_save_vertex_list *node)
+{
+   assert(node->prim_count > 0);
+   return node->prims[0].start;
+}
+
+
+/**
+ * Return the last referenced vertex index in the display list node.
+ */
+static inline GLuint
+_vbo_save_get_max_index(const struct vbo_save_vertex_list *node)
+{
+   assert(node->prim_count > 0);
+   const struct _mesa_prim *last_prim = &node->prims[node->prim_count - 1];
+   return last_prim->start + last_prim->count - 1;
+}
+
+
+/**
+ * Return the vertex count in the display list node.
+ */
+static inline GLuint
+_vbo_save_get_vertex_count(const struct vbo_save_vertex_list *node)
+{
+   assert(node->prim_count > 0);
+   const struct _mesa_prim *first_prim = &node->prims[0];
+   const struct _mesa_prim *last_prim = &node->prims[node->prim_count - 1];
+   return last_prim->start - first_prim->start + last_prim->count;
+}
+
+
 /* These buffers should be a reasonable size to support upload to
  * hardware.  Current vbo implementation will re-upload on any
  * changes, so don't make too big or apps which dynamically create
@@ -87,91 +127,47 @@ struct vbo_save_vertex_list {
  * likelyhood as it occurs.  No reason we couldn't change usage
  * internally even though this probably isn't allowed for client VBOs?
  */
-#define VBO_SAVE_BUFFER_SIZE (8*1024) /* dwords */
+#define VBO_SAVE_BUFFER_SIZE (256*1024) /* dwords */
 #define VBO_SAVE_PRIM_SIZE   128
-#define VBO_SAVE_PRIM_WEAK 0x40
-
-#define VBO_SAVE_FALLBACK    0x10000000
+#define VBO_SAVE_PRIM_MODE_MASK         0x3f
 
-/* Storage to be shared among several vertex_lists.
- */
 struct vbo_save_vertex_store {
    struct gl_buffer_object *bufferobj;
-   GLfloat *buffer;
-   GLuint used;
-   GLuint refcount;
+   fi_type *buffer_map;
+   GLuint used;           /**< Number of 4-byte words used in buffer */
 };
 
+/* Storage to be shared among several vertex_lists.
+ */
 struct vbo_save_primitive_store {
-   struct _mesa_prim buffer[VBO_SAVE_PRIM_SIZE];
+   struct _mesa_prim prims[VBO_SAVE_PRIM_SIZE];
    GLuint used;
    GLuint refcount;
 };
 
 
-struct vbo_save_context {
-   GLcontext *ctx;
-   GLvertexformat vtxfmt;
-   struct gl_client_array arrays[VBO_ATTRIB_MAX];
-   const struct gl_client_array *inputs[VBO_ATTRIB_MAX];
-
-   GLubyte attrsz[VBO_ATTRIB_MAX];
-   GLubyte active_sz[VBO_ATTRIB_MAX];
-   GLuint vertex_size;
-
-   GLfloat *buffer;
-   GLuint count;
-   GLuint wrap_count;
-   GLuint replay_flags;
-
-   struct _mesa_prim *prim;
-   GLuint prim_count, prim_max;
-
-   struct vbo_save_vertex_store *vertex_store;
-   struct vbo_save_primitive_store *prim_store;
-
-   GLfloat *vbptr;                /* cursor, points into buffer */
-   GLfloat vertex[VBO_ATTRIB_MAX*4];      /* current values */
-   GLfloat *attrptr[VBO_ATTRIB_MAX];
-   GLuint vert_count;
-   GLuint max_vert;
-   GLboolean dangling_attr_ref;
-   GLboolean have_materials;
-
-   GLuint opcode_vertex_list;
-
-   struct vbo_save_copied_vtx copied;
-   
-   GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */
-   GLubyte *currentsz[VBO_ATTRIB_MAX];
-};
-
-
-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);
 
 /* save_loopback.c:
  */
-void vbo_loopback_vertex_list( GLcontext *ctx,
-                              const GLfloat *buffer,
-                              const GLubyte *attrsz,
-                              const struct _mesa_prim *prim,
-                              GLuint prim_count,
-                              GLuint wrap_count,
-                              GLuint vertex_size);
+void _vbo_loopback_vertex_list(struct gl_context *ctx,
+                               const struct vbo_save_vertex_list* node);
 
 /* 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 mesa_display_list *list );
-void vbo_save_SaveFlushVertices( GLcontext *ctx );
-GLboolean vbo_save_NotifyBegin( GLcontext *ctx, GLenum mode );
+void
+vbo_save_playback_vertex_list(struct gl_context *ctx, void *data);
+
+void
+vbo_save_api_init(struct vbo_save_context *save);
 
-void vbo_save_playback_vertex_list( GLcontext *ctx, void *data );
+fi_type *
+vbo_save_map_vertex_store(struct gl_context *ctx,
+                          struct vbo_save_vertex_store *vertex_store);
 
-void vbo_save_api_init( struct vbo_save_context *save );
+void
+vbo_save_unmap_vertex_store(struct gl_context *ctx,
+                            struct vbo_save_vertex_store *vertex_store);
 
-#endif
+#endif /* VBO_SAVE_H */