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