Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1901 | serge | 1 | /************************************************************************** |
2 | |||
3 | Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. |
||
4 | |||
5 | All Rights Reserved. |
||
6 | |||
7 | Permission is hereby granted, free of charge, to any person obtaining a |
||
8 | copy of this software and associated documentation files (the "Software"), |
||
9 | to deal in the Software without restriction, including without limitation |
||
10 | on the rights to use, copy, modify, merge, publish, distribute, sub |
||
11 | license, and/or sell copies of the Software, and to permit persons to whom |
||
12 | the Software is furnished to do so, subject to the following conditions: |
||
13 | |||
14 | The above copyright notice and this permission notice (including the next |
||
15 | paragraph) shall be included in all copies or substantial portions of the |
||
16 | Software. |
||
17 | |||
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
20 | FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
21 | TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, |
||
22 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
||
23 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
||
24 | USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
25 | |||
26 | **************************************************************************/ |
||
27 | |||
28 | /* |
||
29 | * Authors: |
||
30 | * Keith Whitwell |
||
31 | * |
||
32 | */ |
||
33 | |||
34 | #ifndef VBO_SAVE_H |
||
35 | #define VBO_SAVE_H |
||
36 | |||
37 | #include "main/mtypes.h" |
||
38 | #include "vbo.h" |
||
39 | #include "vbo_attrib.h" |
||
40 | |||
41 | |||
42 | struct vbo_save_copied_vtx { |
||
43 | GLfloat buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; |
||
44 | GLuint nr; |
||
45 | }; |
||
46 | |||
47 | |||
48 | /* For display lists, this structure holds a run of vertices of the |
||
49 | * same format, and a strictly well-formed set of begin/end pairs, |
||
50 | * starting on the first vertex and ending at the last. Vertex |
||
51 | * copying on buffer breaks is precomputed according to these |
||
52 | * primitives, though there are situations where the copying will need |
||
53 | * correction at execute-time, perhaps by replaying the list as |
||
54 | * immediate mode commands. |
||
55 | * |
||
56 | * On executing this list, the 'current' values may be updated with |
||
57 | * the values of the final vertex, and often no fixup of the start of |
||
58 | * the vertex list is required. |
||
59 | * |
||
60 | * Eval and other commands that don't fit into these vertex lists are |
||
61 | * compiled using the fallback opcode mechanism provided by dlist.c. |
||
62 | */ |
||
63 | struct vbo_save_vertex_list { |
||
64 | GLubyte attrsz[VBO_ATTRIB_MAX]; |
||
65 | GLuint vertex_size; |
||
66 | |||
67 | /* Copy of the final vertex from node->vertex_store->bufferobj. |
||
68 | * Keep this in regular (non-VBO) memory to avoid repeated |
||
69 | * map/unmap of the VBO when updating GL current data. |
||
70 | */ |
||
71 | GLfloat *current_data; |
||
72 | GLuint current_size; |
||
73 | |||
74 | GLuint buffer_offset; |
||
75 | GLuint count; |
||
76 | GLuint wrap_count; /* number of copied vertices at start */ |
||
77 | GLboolean dangling_attr_ref; /* current attr implicitly referenced |
||
78 | outside the list */ |
||
79 | |||
80 | struct _mesa_prim *prim; |
||
81 | GLuint prim_count; |
||
82 | |||
83 | struct vbo_save_vertex_store *vertex_store; |
||
84 | struct vbo_save_primitive_store *prim_store; |
||
85 | }; |
||
86 | |||
87 | /* These buffers should be a reasonable size to support upload to |
||
88 | * hardware. Current vbo implementation will re-upload on any |
||
89 | * changes, so don't make too big or apps which dynamically create |
||
90 | * dlists and use only a few times will suffer. |
||
91 | * |
||
92 | * Consider stategy of uploading regions from the VBO on demand in the |
||
93 | * case of dynamic vbos. Then make the dlist code signal that |
||
94 | * likelyhood as it occurs. No reason we couldn't change usage |
||
95 | * internally even though this probably isn't allowed for client VBOs? |
||
96 | */ |
||
97 | #define VBO_SAVE_BUFFER_SIZE (8*1024) /* dwords */ |
||
98 | #define VBO_SAVE_PRIM_SIZE 128 |
||
99 | #define VBO_SAVE_PRIM_WEAK 0x40 |
||
100 | |||
101 | #define VBO_SAVE_FALLBACK 0x10000000 |
||
102 | |||
103 | /* Storage to be shared among several vertex_lists. |
||
104 | */ |
||
105 | struct vbo_save_vertex_store { |
||
106 | struct gl_buffer_object *bufferobj; |
||
107 | GLfloat *buffer; |
||
108 | GLuint used; |
||
109 | GLuint refcount; |
||
110 | }; |
||
111 | |||
112 | struct vbo_save_primitive_store { |
||
113 | struct _mesa_prim buffer[VBO_SAVE_PRIM_SIZE]; |
||
114 | GLuint used; |
||
115 | GLuint refcount; |
||
116 | }; |
||
117 | |||
118 | |||
119 | struct vbo_save_context { |
||
120 | struct gl_context *ctx; |
||
121 | GLvertexformat vtxfmt; |
||
122 | struct gl_client_array arrays[VBO_ATTRIB_MAX]; |
||
123 | const struct gl_client_array *inputs[VBO_ATTRIB_MAX]; |
||
124 | |||
125 | GLubyte attrsz[VBO_ATTRIB_MAX]; |
||
126 | GLubyte active_sz[VBO_ATTRIB_MAX]; |
||
127 | GLuint vertex_size; |
||
128 | |||
129 | GLfloat *buffer; |
||
130 | GLuint count; |
||
131 | GLuint wrap_count; |
||
132 | GLuint replay_flags; |
||
133 | |||
134 | struct _mesa_prim *prim; |
||
135 | GLuint prim_count, prim_max; |
||
136 | |||
137 | struct vbo_save_vertex_store *vertex_store; |
||
138 | struct vbo_save_primitive_store *prim_store; |
||
139 | |||
140 | GLfloat *buffer_ptr; /* cursor, points into buffer */ |
||
141 | GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current values */ |
||
142 | GLfloat *attrptr[VBO_ATTRIB_MAX]; |
||
143 | GLuint vert_count; |
||
144 | GLuint max_vert; |
||
145 | GLboolean dangling_attr_ref; |
||
146 | GLboolean have_materials; |
||
147 | |||
148 | GLuint opcode_vertex_list; |
||
149 | |||
150 | struct vbo_save_copied_vtx copied; |
||
151 | |||
152 | GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ |
||
153 | GLubyte *currentsz[VBO_ATTRIB_MAX]; |
||
154 | }; |
||
155 | |||
156 | #if FEATURE_dlist |
||
157 | |||
158 | void vbo_save_init( struct gl_context *ctx ); |
||
159 | void vbo_save_destroy( struct gl_context *ctx ); |
||
160 | void vbo_save_fallback( struct gl_context *ctx, GLboolean fallback ); |
||
161 | |||
162 | /* save_loopback.c: |
||
163 | */ |
||
164 | void vbo_loopback_vertex_list( struct gl_context *ctx, |
||
165 | const GLfloat *buffer, |
||
166 | const GLubyte *attrsz, |
||
167 | const struct _mesa_prim *prim, |
||
168 | GLuint prim_count, |
||
169 | GLuint wrap_count, |
||
170 | GLuint vertex_size); |
||
171 | |||
172 | /* Callbacks: |
||
173 | */ |
||
174 | void vbo_save_EndList( struct gl_context *ctx ); |
||
175 | void vbo_save_NewList( struct gl_context *ctx, GLuint list, GLenum mode ); |
||
176 | void vbo_save_EndCallList( struct gl_context *ctx ); |
||
177 | void vbo_save_BeginCallList( struct gl_context *ctx, struct gl_display_list *list ); |
||
178 | void vbo_save_SaveFlushVertices( struct gl_context *ctx ); |
||
179 | GLboolean vbo_save_NotifyBegin( struct gl_context *ctx, GLenum mode ); |
||
180 | |||
181 | void vbo_save_playback_vertex_list( struct gl_context *ctx, void *data ); |
||
182 | |||
183 | void vbo_save_api_init( struct vbo_save_context *save ); |
||
184 | |||
185 | #else /* FEATURE_dlist */ |
||
186 | |||
187 | static INLINE void |
||
188 | vbo_save_init( struct gl_context *ctx ) |
||
189 | { |
||
190 | } |
||
191 | |||
192 | static INLINE void |
||
193 | vbo_save_destroy( struct gl_context *ctx ) |
||
194 | { |
||
195 | } |
||
196 | |||
197 | #endif /* FEATURE_dlist */ |
||
198 | |||
199 | #endif /* VBO_SAVE_H */ |