mesa/vbo: add support for 64-bit vertex attributes. (v1)
[mesa.git] / src / mesa / main / varray.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. 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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 #ifndef VARRAY_H
28 #define VARRAY_H
29
30
31 #include "glheader.h"
32 #include "bufferobj.h"
33
34 struct gl_client_array;
35 struct gl_context;
36
37 /**
38 * Returns a pointer to the vertex attribute data in a client array,
39 * or the offset into the vertex buffer for an array that resides in
40 * a vertex buffer.
41 */
42 static inline const GLubyte *
43 _mesa_vertex_attrib_address(const struct gl_vertex_attrib_array *array,
44 const struct gl_vertex_buffer_binding *binding)
45 {
46 if (_mesa_is_bufferobj(binding->BufferObj))
47 return (const GLubyte *) (binding->Offset + array->RelativeOffset);
48 else
49 return array->Ptr;
50 }
51
52 /**
53 * Sets the fields in a gl_client_array to values derived from a
54 * gl_vertex_attrib_array and a gl_vertex_buffer_binding.
55 */
56 static inline void
57 _mesa_update_client_array(struct gl_context *ctx,
58 struct gl_client_array *dst,
59 const struct gl_vertex_attrib_array *src,
60 const struct gl_vertex_buffer_binding *binding)
61 {
62 dst->Size = src->Size;
63 dst->Type = src->Type;
64 dst->Format = src->Format;
65 dst->Stride = src->Stride;
66 dst->StrideB = binding->Stride;
67 dst->Ptr = _mesa_vertex_attrib_address(src, binding);
68 dst->Enabled = src->Enabled;
69 dst->Normalized = src->Normalized;
70 dst->Integer = src->Integer;
71 dst->Doubles = src->Doubles;
72 dst->InstanceDivisor = binding->InstanceDivisor;
73 dst->_ElementSize = src->_ElementSize;
74 _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
75 }
76
77 static inline bool
78 _mesa_attr_zero_aliases_vertex(struct gl_context *ctx)
79 {
80 const bool is_forward_compatible_context =
81 ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
82
83 /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
84 * 2.0. Note that we cannot just check for API_OPENGL_COMPAT here because
85 * that will erroneously allow this usage in a 3.0 forward-compatible
86 * context too.
87 */
88 return (ctx->API == API_OPENGLES
89 || (ctx->API == API_OPENGL_COMPAT
90 && !is_forward_compatible_context));
91 }
92
93 extern void GLAPIENTRY
94 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride,
95 const GLvoid *ptr);
96
97
98 extern void GLAPIENTRY
99 _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
100
101
102 extern void GLAPIENTRY
103 _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
104
105
106 extern void GLAPIENTRY
107 _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
108
109
110 extern void GLAPIENTRY
111 _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
112 const GLvoid *ptr);
113
114
115 extern void GLAPIENTRY
116 _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr);
117
118
119 extern void GLAPIENTRY
120 _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
121 GLsizei count, const GLvoid *ptr);
122
123
124 extern void GLAPIENTRY
125 _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
126 const GLvoid *ptr);
127
128
129 extern void GLAPIENTRY
130 _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
131 const GLvoid *ptr);
132
133
134 extern void GLAPIENTRY
135 _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
136 const GLvoid *ptr);
137
138
139 extern void GLAPIENTRY
140 _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
141 GLsizei count, const GLvoid *ptr);
142
143
144 extern void GLAPIENTRY
145 _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr);
146
147
148 extern void GLAPIENTRY
149 _mesa_FogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
150
151
152 extern void GLAPIENTRY
153 _mesa_SecondaryColorPointer(GLint size, GLenum type,
154 GLsizei stride, const GLvoid *ptr);
155
156
157 extern void GLAPIENTRY
158 _mesa_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *ptr);
159
160
161 extern void GLAPIENTRY
162 _mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type,
163 GLboolean normalized, GLsizei stride,
164 const GLvoid *pointer);
165
166 void GLAPIENTRY
167 _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
168 GLsizei stride, const GLvoid *ptr);
169
170 extern void GLAPIENTRY
171 _mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type,
172 GLsizei stride, const GLvoid *pointer);
173
174 extern void GLAPIENTRY
175 _mesa_EnableVertexAttribArray(GLuint index);
176
177
178 extern void GLAPIENTRY
179 _mesa_DisableVertexAttribArray(GLuint index);
180
181
182 extern void GLAPIENTRY
183 _mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params);
184
185 extern void GLAPIENTRY
186 _mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params);
187
188 extern void GLAPIENTRY
189 _mesa_GetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params);
190
191 extern void GLAPIENTRY
192 _mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params);
193
194
195 extern void GLAPIENTRY
196 _mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params);
197
198
199 extern void GLAPIENTRY
200 _mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params);
201
202
203 extern void GLAPIENTRY
204 _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer);
205
206
207 extern void GLAPIENTRY
208 _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
209
210
211 extern void GLAPIENTRY
212 _mesa_MultiDrawArrays( GLenum mode, const GLint *first,
213 const GLsizei *count, GLsizei primcount );
214
215 extern void GLAPIENTRY
216 _mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
217 const GLvoid **indices, GLsizei primcount );
218
219 extern void GLAPIENTRY
220 _mesa_MultiDrawElementsBaseVertex( GLenum mode,
221 const GLsizei *count, GLenum type,
222 const GLvoid **indices, GLsizei primcount,
223 const GLint *basevertex);
224
225 extern void GLAPIENTRY
226 _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
227 const GLsizei * count,
228 GLsizei primcount, GLint modestride );
229
230
231 extern void GLAPIENTRY
232 _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
233 GLenum type, const GLvoid * const * indices,
234 GLsizei primcount, GLint modestride );
235
236 extern void GLAPIENTRY
237 _mesa_LockArraysEXT(GLint first, GLsizei count);
238
239 extern void GLAPIENTRY
240 _mesa_UnlockArraysEXT( void );
241
242
243 extern void GLAPIENTRY
244 _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count);
245
246 extern void GLAPIENTRY
247 _mesa_DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
248 GLsizei primcount);
249
250 extern void GLAPIENTRY
251 _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
252 const GLvoid *indices);
253
254 extern void GLAPIENTRY
255 _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
256 GLenum type, const GLvoid *indices);
257
258 extern void GLAPIENTRY
259 _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
260 const GLvoid *indices, GLint basevertex);
261
262 extern void GLAPIENTRY
263 _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
264 GLsizei count, GLenum type,
265 const GLvoid *indices,
266 GLint basevertex);
267
268 extern void GLAPIENTRY
269 _mesa_DrawTransformFeedback(GLenum mode, GLuint name);
270
271 extern void GLAPIENTRY
272 _mesa_PrimitiveRestartIndex(GLuint index);
273
274
275 extern void GLAPIENTRY
276 _mesa_VertexAttribDivisor(GLuint index, GLuint divisor);
277
278 extern unsigned
279 _mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type);
280
281 extern void GLAPIENTRY
282 _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
283 GLsizei stride);
284
285 extern void GLAPIENTRY
286 _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
287 const GLintptr *offsets, const GLsizei *strides);
288
289 extern void GLAPIENTRY
290 _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
291 GLboolean normalized, GLuint relativeOffset);
292
293 extern void GLAPIENTRY
294 _mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
295 GLuint relativeOffset);
296
297 extern void GLAPIENTRY
298 _mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
299 GLuint relativeOffset);
300
301 extern void GLAPIENTRY
302 _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);
303
304 extern void GLAPIENTRY
305 _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor);
306
307
308 extern void
309 _mesa_copy_client_array(struct gl_context *ctx,
310 struct gl_client_array *dst,
311 struct gl_client_array *src);
312
313 extern void
314 _mesa_copy_vertex_attrib_array(struct gl_context *ctx,
315 struct gl_vertex_attrib_array *dst,
316 const struct gl_vertex_attrib_array *src);
317
318 extern void
319 _mesa_copy_vertex_buffer_binding(struct gl_context *ctx,
320 struct gl_vertex_buffer_binding *dst,
321 const struct gl_vertex_buffer_binding *src);
322
323 extern void
324 _mesa_print_arrays(struct gl_context *ctx);
325
326 extern void
327 _mesa_init_varray( struct gl_context * ctx );
328
329 extern void
330 _mesa_free_varray_data(struct gl_context *ctx);
331
332 #endif