2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
32 #include "bufferobj.h"
34 struct gl_client_array
;
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
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
)
46 if (_mesa_is_bufferobj(binding
->BufferObj
))
47 return (const GLubyte
*) (binding
->Offset
+ array
->RelativeOffset
);
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.
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
)
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
);
78 _mesa_attr_zero_aliases_vertex(struct gl_context
*ctx
)
80 const bool is_forward_compatible_context
=
81 ctx
->Const
.ContextFlags
& GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT
;
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
88 return (ctx
->API
== API_OPENGLES
89 || (ctx
->API
== API_OPENGL_COMPAT
90 && !is_forward_compatible_context
));
94 _mesa_update_array_format(struct gl_context
*ctx
,
95 struct gl_vertex_array_object
*vao
,
96 GLuint attrib
, GLint size
, GLenum type
,
97 GLenum format
, GLboolean normalized
,
98 GLboolean integer
, GLboolean doubles
,
99 GLuint relativeOffset
, bool flush_vertices
);
102 _mesa_enable_vertex_array_attrib(struct gl_context
*ctx
,
103 struct gl_vertex_array_object
*vao
,
107 _mesa_bind_vertex_buffer(struct gl_context
*ctx
,
108 struct gl_vertex_array_object
*vao
,
110 struct gl_buffer_object
*vbo
,
111 GLintptr offset
, GLsizei stride
);
113 extern void GLAPIENTRY
114 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
,
118 extern void GLAPIENTRY
119 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
122 extern void GLAPIENTRY
123 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
126 extern void GLAPIENTRY
127 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
130 extern void GLAPIENTRY
131 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
135 extern void GLAPIENTRY
136 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
);
139 extern void GLAPIENTRY
140 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
141 GLsizei count
, const GLvoid
*ptr
);
144 extern void GLAPIENTRY
145 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
149 extern void GLAPIENTRY
150 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
154 extern void GLAPIENTRY
155 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
159 extern void GLAPIENTRY
160 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
161 GLsizei count
, const GLvoid
*ptr
);
164 extern void GLAPIENTRY
165 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
);
168 extern void GLAPIENTRY
169 _mesa_FogCoordPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
172 extern void GLAPIENTRY
173 _mesa_SecondaryColorPointer(GLint size
, GLenum type
,
174 GLsizei stride
, const GLvoid
*ptr
);
177 extern void GLAPIENTRY
178 _mesa_PointSizePointerOES(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
181 extern void GLAPIENTRY
182 _mesa_VertexAttribPointer(GLuint index
, GLint size
, GLenum type
,
183 GLboolean normalized
, GLsizei stride
,
184 const GLvoid
*pointer
);
187 _mesa_VertexAttribIPointer(GLuint index
, GLint size
, GLenum type
,
188 GLsizei stride
, const GLvoid
*ptr
);
190 extern void GLAPIENTRY
191 _mesa_VertexAttribLPointer(GLuint index
, GLint size
, GLenum type
,
192 GLsizei stride
, const GLvoid
*pointer
);
194 extern void GLAPIENTRY
195 _mesa_EnableVertexAttribArray(GLuint index
);
198 extern void GLAPIENTRY
199 _mesa_EnableVertexArrayAttrib(GLuint vaobj
, GLuint index
);
202 extern void GLAPIENTRY
203 _mesa_DisableVertexAttribArray(GLuint index
);
206 extern void GLAPIENTRY
207 _mesa_DisableVertexArrayAttrib(GLuint vaobj
, GLuint index
);
210 extern void GLAPIENTRY
211 _mesa_GetVertexAttribdv(GLuint index
, GLenum pname
, GLdouble
*params
);
213 extern void GLAPIENTRY
214 _mesa_GetVertexAttribfv(GLuint index
, GLenum pname
, GLfloat
*params
);
216 extern void GLAPIENTRY
217 _mesa_GetVertexAttribLdv(GLuint index
, GLenum pname
, GLdouble
*params
);
219 extern void GLAPIENTRY
220 _mesa_GetVertexAttribiv(GLuint index
, GLenum pname
, GLint
*params
);
223 extern void GLAPIENTRY
224 _mesa_GetVertexAttribIiv(GLuint index
, GLenum pname
, GLint
*params
);
227 extern void GLAPIENTRY
228 _mesa_GetVertexAttribIuiv(GLuint index
, GLenum pname
, GLuint
*params
);
231 extern void GLAPIENTRY
232 _mesa_GetVertexAttribPointerv(GLuint index
, GLenum pname
, GLvoid
**pointer
);
236 _mesa_GetVertexArrayIndexediv(GLuint vaobj
, GLuint index
,
237 GLenum pname
, GLint
*param
);
241 _mesa_GetVertexArrayIndexed64iv(GLuint vaobj
, GLuint index
,
242 GLenum pname
, GLint64
*param
);
245 extern void GLAPIENTRY
246 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
);
249 extern void GLAPIENTRY
250 _mesa_MultiDrawArrays( GLenum mode
, const GLint
*first
,
251 const GLsizei
*count
, GLsizei primcount
);
253 extern void GLAPIENTRY
254 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
255 const GLvoid
**indices
, GLsizei primcount
);
257 extern void GLAPIENTRY
258 _mesa_MultiDrawElementsBaseVertex( GLenum mode
,
259 const GLsizei
*count
, GLenum type
,
260 const GLvoid
**indices
, GLsizei primcount
,
261 const GLint
*basevertex
);
263 extern void GLAPIENTRY
264 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
265 const GLsizei
* count
,
266 GLsizei primcount
, GLint modestride
);
269 extern void GLAPIENTRY
270 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
271 GLenum type
, const GLvoid
* const * indices
,
272 GLsizei primcount
, GLint modestride
);
274 extern void GLAPIENTRY
275 _mesa_LockArraysEXT(GLint first
, GLsizei count
);
277 extern void GLAPIENTRY
278 _mesa_UnlockArraysEXT( void );
281 extern void GLAPIENTRY
282 _mesa_DrawArrays(GLenum mode
, GLint first
, GLsizei count
);
284 extern void GLAPIENTRY
285 _mesa_DrawArraysInstanced(GLenum mode
, GLint first
, GLsizei count
,
288 extern void GLAPIENTRY
289 _mesa_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
290 const GLvoid
*indices
);
292 extern void GLAPIENTRY
293 _mesa_DrawRangeElements(GLenum mode
, GLuint start
, GLuint end
, GLsizei count
,
294 GLenum type
, const GLvoid
*indices
);
296 extern void GLAPIENTRY
297 _mesa_DrawElementsBaseVertex(GLenum mode
, GLsizei count
, GLenum type
,
298 const GLvoid
*indices
, GLint basevertex
);
300 extern void GLAPIENTRY
301 _mesa_DrawRangeElementsBaseVertex(GLenum mode
, GLuint start
, GLuint end
,
302 GLsizei count
, GLenum type
,
303 const GLvoid
*indices
,
306 extern void GLAPIENTRY
307 _mesa_DrawTransformFeedback(GLenum mode
, GLuint name
);
309 extern void GLAPIENTRY
310 _mesa_PrimitiveRestartIndex(GLuint index
);
313 extern void GLAPIENTRY
314 _mesa_VertexAttribDivisor(GLuint index
, GLuint divisor
);
317 _mesa_primitive_restart_index(const struct gl_context
*ctx
, GLenum ib_type
);
319 extern void GLAPIENTRY
320 _mesa_BindVertexBuffer(GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
323 extern void GLAPIENTRY
324 _mesa_VertexArrayVertexBuffer(GLuint vaobj
, GLuint bindingIndex
, GLuint buffer
,
325 GLintptr offset
, GLsizei stride
);
327 extern void GLAPIENTRY
328 _mesa_BindVertexBuffers(GLuint first
, GLsizei count
, const GLuint
*buffers
,
329 const GLintptr
*offsets
, const GLsizei
*strides
);
331 extern void GLAPIENTRY
332 _mesa_VertexArrayVertexBuffers(GLuint vaobj
, GLuint first
, GLsizei count
,
333 const GLuint
*buffers
,
334 const GLintptr
*offsets
, const GLsizei
*strides
);
336 extern void GLAPIENTRY
337 _mesa_VertexAttribFormat(GLuint attribIndex
, GLint size
, GLenum type
,
338 GLboolean normalized
, GLuint relativeOffset
);
340 extern void GLAPIENTRY
341 _mesa_VertexArrayAttribFormat(GLuint vaobj
, GLuint attribIndex
, GLint size
,
342 GLenum type
, GLboolean normalized
,
343 GLuint relativeOffset
);
345 extern void GLAPIENTRY
346 _mesa_VertexAttribIFormat(GLuint attribIndex
, GLint size
, GLenum type
,
347 GLuint relativeOffset
);
349 extern void GLAPIENTRY
350 _mesa_VertexArrayAttribIFormat(GLuint vaobj
, GLuint attribIndex
,
351 GLint size
, GLenum type
,
352 GLuint relativeOffset
);
354 extern void GLAPIENTRY
355 _mesa_VertexAttribLFormat(GLuint attribIndex
, GLint size
, GLenum type
,
356 GLuint relativeOffset
);
358 extern void GLAPIENTRY
359 _mesa_VertexArrayAttribLFormat(GLuint vaobj
, GLuint attribIndex
,
360 GLint size
, GLenum type
,
361 GLuint relativeOffset
);
363 extern void GLAPIENTRY
364 _mesa_VertexAttribBinding(GLuint attribIndex
, GLuint bindingIndex
);
366 extern void GLAPIENTRY
367 _mesa_VertexArrayAttribBinding(GLuint vaobj
, GLuint attribIndex
,
368 GLuint bindingIndex
);
370 extern void GLAPIENTRY
371 _mesa_VertexBindingDivisor(GLuint bindingIndex
, GLuint divisor
);
373 extern void GLAPIENTRY
374 _mesa_VertexArrayBindingDivisor(GLuint vaobj
, GLuint bindingIndex
, GLuint divisor
);
377 _mesa_copy_client_array(struct gl_context
*ctx
,
378 struct gl_client_array
*dst
,
379 struct gl_client_array
*src
);
382 _mesa_copy_vertex_attrib_array(struct gl_context
*ctx
,
383 struct gl_vertex_attrib_array
*dst
,
384 const struct gl_vertex_attrib_array
*src
);
387 _mesa_copy_vertex_buffer_binding(struct gl_context
*ctx
,
388 struct gl_vertex_buffer_binding
*dst
,
389 const struct gl_vertex_buffer_binding
*src
);
392 _mesa_print_arrays(struct gl_context
*ctx
);
395 _mesa_init_varray( struct gl_context
* ctx
);
398 _mesa_free_varray_data(struct gl_context
*ctx
);