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
;
39 * Compute the index of the last array element that can be safely accessed in
40 * a vertex array. We can really only do this when the array lives in a VBO.
41 * The array->_MaxElement field will be updated.
42 * Later in glDrawArrays/Elements/etc we can do some bounds checking.
45 _mesa_update_array_max_element(struct gl_client_array
*array
)
47 assert(array
->Enabled
);
49 if (array
->BufferObj
->Name
) {
50 GLsizeiptrARB offset
= (GLsizeiptrARB
) array
->Ptr
;
51 GLsizeiptrARB bufSize
= (GLsizeiptrARB
) array
->BufferObj
->Size
;
53 if (offset
< bufSize
) {
54 const GLuint stride
= array
->StrideB
?
55 array
->StrideB
: array
->_ElementSize
;
56 array
->_MaxElement
= (bufSize
- offset
+ stride
57 - array
->_ElementSize
) / stride
;
60 array
->_MaxElement
= 0;
64 /* user-space array, no idea how big it is */
65 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
71 * Returns a pointer to the vertex attribute data in a client array,
72 * or the offset into the vertex buffer for an array that resides in
75 static inline const GLubyte
*
76 _mesa_vertex_attrib_address(const struct gl_vertex_attrib_array
*array
,
77 const struct gl_vertex_buffer_binding
*binding
)
79 if (_mesa_is_bufferobj(binding
->BufferObj
))
80 return (const GLubyte
*) (binding
->Offset
+ array
->RelativeOffset
);
86 * Sets the fields in a gl_client_array to values derived from a
87 * gl_vertex_attrib_array and a gl_vertex_buffer_binding.
90 _mesa_update_client_array(struct gl_context
*ctx
,
91 struct gl_client_array
*dst
,
92 const struct gl_vertex_attrib_array
*src
,
93 const struct gl_vertex_buffer_binding
*binding
)
95 dst
->Size
= src
->Size
;
96 dst
->Type
= src
->Type
;
97 dst
->Format
= src
->Format
;
98 dst
->Stride
= src
->Stride
;
99 dst
->StrideB
= binding
->Stride
;
100 dst
->Ptr
= _mesa_vertex_attrib_address(src
, binding
);
101 dst
->Enabled
= src
->Enabled
;
102 dst
->Normalized
= src
->Normalized
;
103 dst
->Integer
= src
->Integer
;
104 dst
->InstanceDivisor
= binding
->InstanceDivisor
;
105 dst
->_ElementSize
= src
->_ElementSize
;
106 _mesa_reference_buffer_object(ctx
, &dst
->BufferObj
, binding
->BufferObj
);
109 extern void GLAPIENTRY
110 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
,
114 extern void GLAPIENTRY
115 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
118 extern void GLAPIENTRY
119 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
122 extern void GLAPIENTRY
123 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
126 extern void GLAPIENTRY
127 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
131 extern void GLAPIENTRY
132 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
);
135 extern void GLAPIENTRY
136 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
137 GLsizei count
, const GLvoid
*ptr
);
140 extern void GLAPIENTRY
141 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
145 extern void GLAPIENTRY
146 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
150 extern void GLAPIENTRY
151 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
155 extern void GLAPIENTRY
156 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
157 GLsizei count
, const GLvoid
*ptr
);
160 extern void GLAPIENTRY
161 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
);
164 extern void GLAPIENTRY
165 _mesa_FogCoordPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
168 extern void GLAPIENTRY
169 _mesa_SecondaryColorPointer(GLint size
, GLenum type
,
170 GLsizei stride
, const GLvoid
*ptr
);
173 extern void GLAPIENTRY
174 _mesa_PointSizePointerOES(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
177 extern void GLAPIENTRY
178 _mesa_VertexAttribPointer(GLuint index
, GLint size
, GLenum type
,
179 GLboolean normalized
, GLsizei stride
,
180 const GLvoid
*pointer
);
183 _mesa_VertexAttribIPointer(GLuint index
, GLint size
, GLenum type
,
184 GLsizei stride
, const GLvoid
*ptr
);
187 extern void GLAPIENTRY
188 _mesa_EnableVertexAttribArray(GLuint index
);
191 extern void GLAPIENTRY
192 _mesa_DisableVertexAttribArray(GLuint index
);
195 extern void GLAPIENTRY
196 _mesa_GetVertexAttribdv(GLuint index
, GLenum pname
, GLdouble
*params
);
199 extern void GLAPIENTRY
200 _mesa_GetVertexAttribfv(GLuint index
, GLenum pname
, GLfloat
*params
);
203 extern void GLAPIENTRY
204 _mesa_GetVertexAttribiv(GLuint index
, GLenum pname
, GLint
*params
);
207 extern void GLAPIENTRY
208 _mesa_GetVertexAttribIiv(GLuint index
, GLenum pname
, GLint
*params
);
211 extern void GLAPIENTRY
212 _mesa_GetVertexAttribIuiv(GLuint index
, GLenum pname
, GLuint
*params
);
215 extern void GLAPIENTRY
216 _mesa_GetVertexAttribPointerv(GLuint index
, GLenum pname
, GLvoid
**pointer
);
219 extern void GLAPIENTRY
220 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
);
223 extern void GLAPIENTRY
224 _mesa_MultiDrawArrays( GLenum mode
, const GLint
*first
,
225 const GLsizei
*count
, GLsizei primcount
);
227 extern void GLAPIENTRY
228 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
229 const GLvoid
**indices
, GLsizei primcount
);
231 extern void GLAPIENTRY
232 _mesa_MultiDrawElementsBaseVertex( GLenum mode
,
233 const GLsizei
*count
, GLenum type
,
234 const GLvoid
**indices
, GLsizei primcount
,
235 const GLint
*basevertex
);
237 extern void GLAPIENTRY
238 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
239 const GLsizei
* count
,
240 GLsizei primcount
, GLint modestride
);
243 extern void GLAPIENTRY
244 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
245 GLenum type
, const GLvoid
* const * indices
,
246 GLsizei primcount
, GLint modestride
);
248 extern void GLAPIENTRY
249 _mesa_LockArraysEXT(GLint first
, GLsizei count
);
251 extern void GLAPIENTRY
252 _mesa_UnlockArraysEXT( void );
255 extern void GLAPIENTRY
256 _mesa_DrawArrays(GLenum mode
, GLint first
, GLsizei count
);
258 extern void GLAPIENTRY
259 _mesa_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
260 const GLvoid
*indices
);
262 extern void GLAPIENTRY
263 _mesa_DrawRangeElements(GLenum mode
, GLuint start
, GLuint end
, GLsizei count
,
264 GLenum type
, const GLvoid
*indices
);
266 extern void GLAPIENTRY
267 _mesa_DrawElementsBaseVertex(GLenum mode
, GLsizei count
, GLenum type
,
268 const GLvoid
*indices
, GLint basevertex
);
270 extern void GLAPIENTRY
271 _mesa_DrawRangeElementsBaseVertex(GLenum mode
, GLuint start
, GLuint end
,
272 GLsizei count
, GLenum type
,
273 const GLvoid
*indices
,
276 extern void GLAPIENTRY
277 _mesa_DrawTransformFeedback(GLenum mode
, GLuint name
);
279 extern void GLAPIENTRY
280 _mesa_PrimitiveRestartIndex(GLuint index
);
283 extern void GLAPIENTRY
284 _mesa_VertexAttribDivisor(GLuint index
, GLuint divisor
);
287 _mesa_primitive_restart_index(const struct gl_context
*ctx
, GLenum ib_type
);
289 extern void GLAPIENTRY
290 _mesa_BindVertexBuffer(GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
293 extern void GLAPIENTRY
294 _mesa_VertexAttribFormat(GLuint attribIndex
, GLint size
, GLenum type
,
295 GLboolean normalized
, GLuint relativeOffset
);
297 extern void GLAPIENTRY
298 _mesa_VertexAttribIFormat(GLuint attribIndex
, GLint size
, GLenum type
,
299 GLuint relativeOffset
);
301 extern void GLAPIENTRY
302 _mesa_VertexAttribLFormat(GLuint attribIndex
, GLint size
, GLenum type
,
303 GLuint relativeOffset
);
305 extern void GLAPIENTRY
306 _mesa_VertexAttribBinding(GLuint attribIndex
, GLuint bindingIndex
);
308 extern void GLAPIENTRY
309 _mesa_VertexBindingDivisor(GLuint bindingIndex
, GLuint divisor
);
313 _mesa_copy_client_array(struct gl_context
*ctx
,
314 struct gl_client_array
*dst
,
315 struct gl_client_array
*src
);
318 _mesa_copy_vertex_attrib_array(struct gl_context
*ctx
,
319 struct gl_vertex_attrib_array
*dst
,
320 const struct gl_vertex_attrib_array
*src
);
323 _mesa_copy_vertex_buffer_binding(struct gl_context
*ctx
,
324 struct gl_vertex_buffer_binding
*dst
,
325 const struct gl_vertex_buffer_binding
*src
);
328 _mesa_print_arrays(struct gl_context
*ctx
);
331 _mesa_init_varray( struct gl_context
* ctx
);
334 _mesa_free_varray_data(struct gl_context
*ctx
);