• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_vertex_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 *
_mesa_vertex_attrib_address(const struct gl_array_attributes * array,const struct gl_vertex_buffer_binding * binding)43 _mesa_vertex_attrib_address(const struct gl_array_attributes *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_vertex_array to values derived from a
54  * gl_vertex_attrib_array and a gl_vertex_buffer_binding.
55  */
56 static inline void
_mesa_update_client_array(struct gl_context * ctx,struct gl_vertex_array * dst,const struct gl_array_attributes * src,const struct gl_vertex_buffer_binding * binding)57 _mesa_update_client_array(struct gl_context *ctx,
58                           struct gl_vertex_array *dst,
59                           const struct gl_array_attributes *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->StrideB = binding->Stride;
66    dst->Ptr = _mesa_vertex_attrib_address(src, binding);
67    dst->Normalized = src->Normalized;
68    dst->Integer = src->Integer;
69    dst->Doubles = src->Doubles;
70    dst->InstanceDivisor = binding->InstanceDivisor;
71    dst->_ElementSize = src->_ElementSize;
72    _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
73 }
74 
75 static inline bool
_mesa_attr_zero_aliases_vertex(struct gl_context * ctx)76 _mesa_attr_zero_aliases_vertex(struct gl_context *ctx)
77 {
78    const bool is_forward_compatible_context =
79       ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
80 
81    /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
82     * 2.0.  Note that we cannot just check for API_OPENGL_COMPAT here because
83     * that will erroneously allow this usage in a 3.0 forward-compatible
84     * context too.
85     */
86    return (ctx->API == API_OPENGLES
87            || (ctx->API == API_OPENGL_COMPAT
88                && !is_forward_compatible_context));
89 }
90 
91 extern void
92 _mesa_update_array_format(struct gl_context *ctx,
93                           struct gl_vertex_array_object *vao,
94                           GLuint attrib, GLint size, GLenum type,
95                           GLenum format, GLboolean normalized,
96                           GLboolean integer, GLboolean doubles,
97                           GLuint relativeOffset, bool flush_vertices);
98 
99 extern void
100 _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
101                                  struct gl_vertex_array_object *vao,
102                                  unsigned attrib);
103 
104 extern void
105 _mesa_bind_vertex_buffer(struct gl_context *ctx,
106                          struct gl_vertex_array_object *vao,
107                          GLuint index,
108                          struct gl_buffer_object *vbo,
109                          GLintptr offset, GLsizei stride);
110 
111 extern void GLAPIENTRY
112 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride,
113                     const GLvoid *ptr);
114 
115 
116 extern void GLAPIENTRY
117 _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
118 
119 
120 extern void GLAPIENTRY
121 _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
122 
123 
124 extern void GLAPIENTRY
125 _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
126 
127 
128 extern void GLAPIENTRY
129 _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
130                       const GLvoid *ptr);
131 
132 
133 extern void GLAPIENTRY
134 _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr);
135 
136 
137 extern void GLAPIENTRY
138 _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
139                        GLsizei count, const GLvoid *ptr);
140 
141 
142 extern void GLAPIENTRY
143 _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
144                        const GLvoid *ptr);
145 
146 
147 extern void GLAPIENTRY
148 _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
149                       const GLvoid *ptr);
150 
151 
152 extern void GLAPIENTRY
153 _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
154                       const GLvoid *ptr);
155 
156 
157 extern void GLAPIENTRY
158 _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
159                          GLsizei count, const GLvoid *ptr);
160 
161 
162 extern void GLAPIENTRY
163 _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr);
164 
165 
166 extern void GLAPIENTRY
167 _mesa_FogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
168 
169 
170 extern void GLAPIENTRY
171 _mesa_SecondaryColorPointer(GLint size, GLenum type,
172 			       GLsizei stride, const GLvoid *ptr);
173 
174 
175 extern void GLAPIENTRY
176 _mesa_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *ptr);
177 
178 
179 extern void GLAPIENTRY
180 _mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type,
181                              GLboolean normalized, GLsizei stride,
182                              const GLvoid *pointer);
183 
184 void GLAPIENTRY
185 _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
186                            GLsizei stride, const GLvoid *ptr);
187 
188 extern void GLAPIENTRY
189 _mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type,
190                            GLsizei stride, const GLvoid *pointer);
191 
192 extern void GLAPIENTRY
193 _mesa_EnableVertexAttribArray(GLuint index);
194 
195 
196 extern void GLAPIENTRY
197 _mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index);
198 
199 
200 extern void GLAPIENTRY
201 _mesa_DisableVertexAttribArray(GLuint index);
202 
203 
204 extern void GLAPIENTRY
205 _mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index);
206 
207 
208 extern void GLAPIENTRY
209 _mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params);
210 
211 extern void GLAPIENTRY
212 _mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params);
213 
214 extern void GLAPIENTRY
215 _mesa_GetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params);
216 
217 extern void GLAPIENTRY
218 _mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params);
219 
220 
221 extern void GLAPIENTRY
222 _mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params);
223 
224 
225 extern void GLAPIENTRY
226 _mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params);
227 
228 
229 extern void GLAPIENTRY
230 _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer);
231 
232 
233 void GLAPIENTRY
234 _mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index,
235                               GLenum pname, GLint *param);
236 
237 
238 void GLAPIENTRY
239 _mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index,
240                                 GLenum pname, GLint64 *param);
241 
242 
243 extern void GLAPIENTRY
244 _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
245 
246 
247 extern void GLAPIENTRY
248 _mesa_MultiDrawArrays( GLenum mode, const GLint *first,
249                           const GLsizei *count, GLsizei primcount );
250 
251 extern void GLAPIENTRY
252 _mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
253                             const GLvoid **indices, GLsizei primcount );
254 
255 extern void GLAPIENTRY
256 _mesa_MultiDrawElementsBaseVertex( GLenum mode,
257 				   const GLsizei *count, GLenum type,
258 				   const GLvoid **indices, GLsizei primcount,
259 				   const GLint *basevertex);
260 
261 extern void GLAPIENTRY
262 _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
263 			      const GLsizei * count,
264 			      GLsizei primcount, GLint modestride );
265 
266 
267 extern void GLAPIENTRY
268 _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
269 				GLenum type, const GLvoid * const * indices,
270 				GLsizei primcount, GLint modestride );
271 
272 extern void GLAPIENTRY
273 _mesa_LockArraysEXT(GLint first, GLsizei count);
274 
275 extern void GLAPIENTRY
276 _mesa_UnlockArraysEXT( void );
277 
278 
279 extern void GLAPIENTRY
280 _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count);
281 
282 extern void GLAPIENTRY
283 _mesa_DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
284                           GLsizei primcount);
285 
286 extern void GLAPIENTRY
287 _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
288                    const GLvoid *indices);
289 
290 extern void GLAPIENTRY
291 _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
292                         GLenum type, const GLvoid *indices);
293 
294 extern void GLAPIENTRY
295 _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
296 			     const GLvoid *indices, GLint basevertex);
297 
298 extern void GLAPIENTRY
299 _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
300 				  GLsizei count, GLenum type,
301 				  const GLvoid *indices,
302 				  GLint basevertex);
303 
304 extern void GLAPIENTRY
305 _mesa_DrawTransformFeedback(GLenum mode, GLuint name);
306 
307 extern void GLAPIENTRY
308 _mesa_PrimitiveRestartIndex(GLuint index);
309 
310 
311 extern void GLAPIENTRY
312 _mesa_VertexAttribDivisor(GLuint index, GLuint divisor);
313 
314 extern unsigned
315 _mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type);
316 
317 extern void GLAPIENTRY
318 _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
319                        GLsizei stride);
320 
321 extern void GLAPIENTRY
322 _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
323                               GLintptr offset, GLsizei stride);
324 
325 extern void GLAPIENTRY
326 _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
327                         const GLintptr *offsets, const GLsizei *strides);
328 
329 extern void GLAPIENTRY
330 _mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
331                                const GLuint *buffers,
332                                const GLintptr *offsets, const GLsizei *strides);
333 
334 extern void GLAPIENTRY
335 _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
336                          GLboolean normalized, GLuint relativeOffset);
337 
338 extern void GLAPIENTRY
339 _mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size,
340                               GLenum type, GLboolean normalized,
341                               GLuint relativeOffset);
342 
343 extern void GLAPIENTRY
344 _mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
345                           GLuint relativeOffset);
346 
347 extern void GLAPIENTRY
348 _mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex,
349                                GLint size, GLenum type,
350                                GLuint relativeOffset);
351 
352 extern void GLAPIENTRY
353 _mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
354                           GLuint relativeOffset);
355 
356 extern void GLAPIENTRY
357 _mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
358                                GLint size, GLenum type,
359                                GLuint relativeOffset);
360 
361 extern void GLAPIENTRY
362 _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);
363 
364 extern void GLAPIENTRY
365 _mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex,
366                                GLuint bindingIndex);
367 
368 extern void GLAPIENTRY
369 _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor);
370 
371 extern void GLAPIENTRY
372 _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint divisor);
373 
374 extern void
375 _mesa_copy_client_array(struct gl_context *ctx,
376                         struct gl_vertex_array *dst,
377                         struct gl_vertex_array *src);
378 
379 extern void
380 _mesa_copy_vertex_attrib_array(struct gl_context *ctx,
381                                struct gl_array_attributes *dst,
382                                const struct gl_array_attributes *src);
383 
384 extern void
385 _mesa_copy_vertex_buffer_binding(struct gl_context *ctx,
386                                  struct gl_vertex_buffer_binding *dst,
387                                  const struct gl_vertex_buffer_binding *src);
388 
389 extern void
390 _mesa_print_arrays(struct gl_context *ctx);
391 
392 extern void
393 _mesa_init_varray( struct gl_context * ctx );
394 
395 extern void
396 _mesa_free_varray_data(struct gl_context *ctx);
397 
398 #endif
399