varray.h revision 01e04c3f
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#include "bufferobj.h"
31
32
33/**
34 * Returns a pointer to the vertex attribute data in a client array,
35 * or the offset into the vertex buffer for an array that resides in
36 * a vertex buffer.
37 */
38static inline const GLubyte *
39_mesa_vertex_attrib_address(const struct gl_array_attributes *array,
40                            const struct gl_vertex_buffer_binding *binding)
41{
42   if (_mesa_is_bufferobj(binding->BufferObj))
43      return (const GLubyte *) (binding->Offset + array->RelativeOffset);
44   else
45      return array->Ptr;
46}
47
48
49static inline bool
50_mesa_attr_zero_aliases_vertex(const struct gl_context *ctx)
51{
52   return ctx->_AttribZeroAliasesVertex;
53}
54
55
56extern void
57_mesa_update_array_format(struct gl_context *ctx,
58                          struct gl_vertex_array_object *vao,
59                          gl_vert_attrib attrib, GLint size, GLenum type,
60                          GLenum format, GLboolean normalized,
61                          GLboolean integer, GLboolean doubles,
62                          GLuint relativeOffset);
63
64extern void
65_mesa_enable_vertex_array_attrib(struct gl_context *ctx,
66                                 struct gl_vertex_array_object *vao,
67                                 gl_vert_attrib attrib);
68
69
70extern void
71_mesa_disable_vertex_array_attrib(struct gl_context *ctx,
72                                  struct gl_vertex_array_object *vao,
73                                  gl_vert_attrib attrib);
74
75
76extern void
77_mesa_vertex_attrib_binding(struct gl_context *ctx,
78                            struct gl_vertex_array_object *vao,
79                            gl_vert_attrib attribIndex,
80                            GLuint bindingIndex);
81
82
83extern void
84_mesa_bind_vertex_buffer(struct gl_context *ctx,
85                         struct gl_vertex_array_object *vao,
86                         GLuint index,
87                         struct gl_buffer_object *vbo,
88                         GLintptr offset, GLsizei stride);
89
90extern void GLAPIENTRY
91_mesa_VertexPointer_no_error(GLint size, GLenum type, GLsizei stride,
92                             const GLvoid *ptr);
93extern void GLAPIENTRY
94_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride,
95                    const GLvoid *ptr);
96
97extern void GLAPIENTRY
98_mesa_NormalPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr);
99extern void GLAPIENTRY
100_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
101
102extern void GLAPIENTRY
103_mesa_ColorPointer_no_error(GLint size, GLenum type, GLsizei stride,
104                            const GLvoid *ptr);
105extern void GLAPIENTRY
106_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
107
108
109extern void GLAPIENTRY
110_mesa_IndexPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr);
111extern void GLAPIENTRY
112_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
113
114
115extern void GLAPIENTRY
116_mesa_TexCoordPointer_no_error(GLint size, GLenum type, GLsizei stride,
117                               const GLvoid *ptr);
118extern void GLAPIENTRY
119_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
120                      const GLvoid *ptr);
121
122
123extern void GLAPIENTRY
124_mesa_EdgeFlagPointer_no_error(GLsizei stride, const GLvoid *ptr);
125extern void GLAPIENTRY
126_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr);
127
128
129extern void GLAPIENTRY
130_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
131                       GLsizei count, const GLvoid *ptr);
132
133
134extern void GLAPIENTRY
135_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
136                       const GLvoid *ptr);
137
138
139extern void GLAPIENTRY
140_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
141                      const GLvoid *ptr);
142
143
144extern void GLAPIENTRY
145_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
146                      const GLvoid *ptr);
147
148
149extern void GLAPIENTRY
150_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
151                         GLsizei count, const GLvoid *ptr);
152
153
154extern void GLAPIENTRY
155_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr);
156
157extern void GLAPIENTRY
158_mesa_FogCoordPointer_no_error(GLenum type, GLsizei stride,
159                               const GLvoid *ptr);
160extern void GLAPIENTRY
161_mesa_FogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
162
163
164extern void GLAPIENTRY
165_mesa_SecondaryColorPointer_no_error(GLint size, GLenum type,
166                                     GLsizei stride, const GLvoid *ptr);
167extern void GLAPIENTRY
168_mesa_SecondaryColorPointer(GLint size, GLenum type,
169                            GLsizei stride, const GLvoid *ptr);
170
171
172extern void GLAPIENTRY
173_mesa_PointSizePointerOES_no_error(GLenum type, GLsizei stride,
174                                   const GLvoid *ptr);
175extern void GLAPIENTRY
176_mesa_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *ptr);
177
178
179extern void GLAPIENTRY
180_mesa_VertexAttribPointer_no_error(GLuint index, GLint size, GLenum type,
181                                   GLboolean normalized, GLsizei stride,
182                                   const GLvoid *pointer);
183extern void GLAPIENTRY
184_mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type,
185                          GLboolean normalized, GLsizei stride,
186                          const GLvoid *pointer);
187
188void GLAPIENTRY
189_mesa_VertexAttribIPointer_no_error(GLuint index, GLint size, GLenum type,
190                                    GLsizei stride, const GLvoid *ptr);
191void GLAPIENTRY
192_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
193                           GLsizei stride, const GLvoid *ptr);
194
195extern void GLAPIENTRY
196_mesa_VertexAttribLPointer_no_error(GLuint index, GLint size, GLenum type,
197                                    GLsizei stride, const GLvoid *pointer);
198extern void GLAPIENTRY
199_mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type,
200                           GLsizei stride, const GLvoid *pointer);
201
202extern void GLAPIENTRY
203_mesa_EnableVertexAttribArray(GLuint index);
204
205extern void GLAPIENTRY
206_mesa_EnableVertexAttribArray_no_error(GLuint index);
207
208
209extern void GLAPIENTRY
210_mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index);
211
212extern void GLAPIENTRY
213_mesa_EnableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index);
214
215
216
217extern void GLAPIENTRY
218_mesa_DisableVertexAttribArray(GLuint index);
219
220extern void GLAPIENTRY
221_mesa_DisableVertexAttribArray_no_error(GLuint index);
222
223
224extern void GLAPIENTRY
225_mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index);
226
227extern void GLAPIENTRY
228_mesa_DisableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index);
229
230
231extern void GLAPIENTRY
232_mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params);
233
234extern void GLAPIENTRY
235_mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params);
236
237extern void GLAPIENTRY
238_mesa_GetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params);
239
240extern void GLAPIENTRY
241_mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params);
242
243extern void GLAPIENTRY
244_mesa_GetVertexAttribLui64vARB(GLuint index, GLenum pname, GLuint64EXT *params);
245
246
247extern void GLAPIENTRY
248_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params);
249
250
251extern void GLAPIENTRY
252_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params);
253
254
255extern void GLAPIENTRY
256_mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer);
257
258
259void GLAPIENTRY
260_mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index,
261                              GLenum pname, GLint *param);
262
263
264void GLAPIENTRY
265_mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index,
266                                GLenum pname, GLint64 *param);
267
268
269extern void GLAPIENTRY
270_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
271
272
273extern void GLAPIENTRY
274_mesa_LockArraysEXT(GLint first, GLsizei count);
275
276extern void GLAPIENTRY
277_mesa_UnlockArraysEXT(void);
278
279
280void GLAPIENTRY
281_mesa_PrimitiveRestartIndex_no_error(GLuint index);
282
283extern void GLAPIENTRY
284_mesa_PrimitiveRestartIndex(GLuint index);
285
286extern void GLAPIENTRY
287_mesa_VertexAttribDivisor_no_error(GLuint index, GLuint divisor);
288extern void GLAPIENTRY
289_mesa_VertexAttribDivisor(GLuint index, GLuint divisor);
290
291static inline unsigned
292_mesa_primitive_restart_index(const struct gl_context *ctx,
293                              unsigned index_size)
294{
295   /* From the OpenGL 4.3 core specification, page 302:
296    * "If both PRIMITIVE_RESTART and PRIMITIVE_RESTART_FIXED_INDEX are
297    *  enabled, the index value determined by PRIMITIVE_RESTART_FIXED_INDEX
298    *  is used."
299    */
300   if (ctx->Array.PrimitiveRestartFixedIndex) {
301      /* 1 -> 0xff, 2 -> 0xffff, 4 -> 0xffffffff */
302      return 0xffffffffu >> 8 * (4 - index_size);
303   }
304
305   return ctx->Array.RestartIndex;
306}
307
308extern void GLAPIENTRY
309_mesa_BindVertexBuffer_no_error(GLuint bindingIndex, GLuint buffer,
310                                GLintptr offset, GLsizei stride);
311extern void GLAPIENTRY
312_mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
313                       GLsizei stride);
314
315void GLAPIENTRY
316_mesa_VertexArrayVertexBuffer_no_error(GLuint vaobj, GLuint bindingIndex,
317                                       GLuint buffer, GLintptr offset,
318                                       GLsizei stride);
319extern void GLAPIENTRY
320_mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
321                              GLintptr offset, GLsizei stride);
322
323void GLAPIENTRY
324_mesa_BindVertexBuffers_no_error(GLuint first, GLsizei count,
325                                 const GLuint *buffers, const GLintptr *offsets,
326                                 const GLsizei *strides);
327
328extern void GLAPIENTRY
329_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
330                        const GLintptr *offsets, const GLsizei *strides);
331
332void GLAPIENTRY
333_mesa_VertexArrayVertexBuffers_no_error(GLuint vaobj, GLuint first,
334                                        GLsizei count, const GLuint *buffers,
335                                        const GLintptr *offsets,
336                                        const GLsizei *strides);
337
338extern void GLAPIENTRY
339_mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
340                               const GLuint *buffers,
341                               const GLintptr *offsets, const GLsizei *strides);
342
343extern void GLAPIENTRY
344_mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
345                         GLboolean normalized, GLuint relativeOffset);
346
347extern void GLAPIENTRY
348_mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size,
349                              GLenum type, GLboolean normalized,
350                              GLuint relativeOffset);
351
352extern void GLAPIENTRY
353_mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
354                          GLuint relativeOffset);
355
356extern void GLAPIENTRY
357_mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex,
358                               GLint size, GLenum type,
359                               GLuint relativeOffset);
360
361extern void GLAPIENTRY
362_mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
363                          GLuint relativeOffset);
364
365extern void GLAPIENTRY
366_mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
367                               GLint size, GLenum type,
368                               GLuint relativeOffset);
369
370void GLAPIENTRY
371_mesa_VertexAttribBinding_no_error(GLuint attribIndex, GLuint bindingIndex);
372
373extern void GLAPIENTRY
374_mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);
375
376void GLAPIENTRY
377_mesa_VertexArrayAttribBinding_no_error(GLuint vaobj, GLuint attribIndex,
378                                        GLuint bindingIndex);
379
380extern void GLAPIENTRY
381_mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex,
382                               GLuint bindingIndex);
383
384void GLAPIENTRY
385_mesa_VertexBindingDivisor_no_error(GLuint bindingIndex, GLuint divisor);
386
387extern void GLAPIENTRY
388_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor);
389
390void GLAPIENTRY
391_mesa_VertexArrayBindingDivisor_no_error(GLuint vaobj, GLuint bindingIndex,
392                                         GLuint divisor);
393
394extern void GLAPIENTRY
395_mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex,
396                                GLuint divisor);
397
398
399extern void
400_mesa_copy_vertex_attrib_array(struct gl_context *ctx,
401                               struct gl_array_attributes *dst,
402                               const struct gl_array_attributes *src);
403
404extern void
405_mesa_copy_vertex_buffer_binding(struct gl_context *ctx,
406                                 struct gl_vertex_buffer_binding *dst,
407                                 const struct gl_vertex_buffer_binding *src);
408
409extern void
410_mesa_print_arrays(struct gl_context *ctx);
411
412extern void
413_mesa_init_varray(struct gl_context *ctx);
414
415extern void
416_mesa_free_varray_data(struct gl_context *ctx);
417
418#endif
419