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 32struct gl_interleaved_layout { 33 bool tflag, cflag, nflag; /* enable/disable flags */ 34 int tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ 35 GLenum ctype; /* color type */ 36 int coffset, noffset, voffset; /* color, normal, vertex offsets */ 37 int toffset; /* always zero */ 38 int defstride; /* default stride */ 39}; 40 41bool 42_mesa_get_interleaved_layout(GLenum format, 43 struct gl_interleaved_layout *layout); 44 45void 46_mesa_set_vertex_format(struct gl_vertex_format *vertex_format, 47 GLubyte size, GLenum16 type, GLenum16 format, 48 GLboolean normalized, GLboolean integer, 49 GLboolean doubles); 50 51 52/** 53 * Returns a pointer to the vertex attribute data in a client array, 54 * or the offset into the vertex buffer for an array that resides in 55 * a vertex buffer. 56 */ 57static inline const GLubyte * 58_mesa_vertex_attrib_address(const struct gl_array_attributes *array, 59 const struct gl_vertex_buffer_binding *binding) 60{ 61 if (binding->BufferObj) 62 return (const GLubyte *) (binding->Offset + array->RelativeOffset); 63 else 64 return array->Ptr; 65} 66 67 68static inline bool 69_mesa_attr_zero_aliases_vertex(const struct gl_context *ctx) 70{ 71 return ctx->_AttribZeroAliasesVertex; 72} 73 74 75extern void 76_mesa_update_array_format(struct gl_context *ctx, 77 struct gl_vertex_array_object *vao, 78 gl_vert_attrib attrib, GLint size, GLenum type, 79 GLenum format, GLboolean normalized, 80 GLboolean integer, GLboolean doubles, 81 GLuint relativeOffset); 82 83extern void 84_mesa_enable_vertex_array_attribs(struct gl_context *ctx, 85 struct gl_vertex_array_object *vao, 86 GLbitfield attrib_bits); 87 88static inline void 89_mesa_enable_vertex_array_attrib(struct gl_context *ctx, 90 struct gl_vertex_array_object *vao, 91 gl_vert_attrib attrib) 92{ 93 assert(attrib < VERT_ATTRIB_MAX); 94 _mesa_enable_vertex_array_attribs(ctx, vao, VERT_BIT(attrib)); 95} 96 97 98extern void 99_mesa_disable_vertex_array_attribs(struct gl_context *ctx, 100 struct gl_vertex_array_object *vao, 101 GLbitfield attrib_bits); 102 103static inline void 104_mesa_disable_vertex_array_attrib(struct gl_context *ctx, 105 struct gl_vertex_array_object *vao, 106 gl_vert_attrib attrib) 107{ 108 assert(attrib < VERT_ATTRIB_MAX); 109 _mesa_disable_vertex_array_attribs(ctx, vao, VERT_BIT(attrib)); 110} 111 112 113extern void 114_mesa_vertex_attrib_binding(struct gl_context *ctx, 115 struct gl_vertex_array_object *vao, 116 gl_vert_attrib attribIndex, 117 GLuint bindingIndex); 118 119 120extern void 121_mesa_bind_vertex_buffer(struct gl_context *ctx, 122 struct gl_vertex_array_object *vao, 123 GLuint index, 124 struct gl_buffer_object *vbo, 125 GLintptr offset, GLsizei stride, 126 bool offset_is_int32, bool take_vbo_ownership); 127 128extern void GLAPIENTRY 129_mesa_VertexPointer_no_error(GLint size, GLenum type, GLsizei stride, 130 const GLvoid *ptr); 131extern void GLAPIENTRY 132_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, 133 const GLvoid *ptr); 134 135extern void GLAPIENTRY 136_mesa_NormalPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr); 137extern void GLAPIENTRY 138_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr); 139 140extern void GLAPIENTRY 141_mesa_ColorPointer_no_error(GLint size, GLenum type, GLsizei stride, 142 const GLvoid *ptr); 143extern void GLAPIENTRY 144_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); 145 146 147extern void GLAPIENTRY 148_mesa_IndexPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr); 149extern void GLAPIENTRY 150_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr); 151 152 153extern void GLAPIENTRY 154_mesa_TexCoordPointer_no_error(GLint size, GLenum type, GLsizei stride, 155 const GLvoid *ptr); 156extern void GLAPIENTRY 157_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, 158 const GLvoid *ptr); 159extern void GLAPIENTRY 160_mesa_MultiTexCoordPointerEXT(GLenum texunit, GLint size, GLenum type, 161 GLsizei stride, const GLvoid *ptr); 162 163extern void GLAPIENTRY 164_mesa_EdgeFlagPointer_no_error(GLsizei stride, const GLvoid *ptr); 165extern void GLAPIENTRY 166_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr); 167 168 169extern void GLAPIENTRY 170_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, 171 GLsizei count, const GLvoid *ptr); 172 173 174extern void GLAPIENTRY 175_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, 176 const GLvoid *ptr); 177 178 179extern void GLAPIENTRY 180_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, 181 const GLvoid *ptr); 182 183 184extern void GLAPIENTRY 185_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, 186 const GLvoid *ptr); 187 188 189extern void GLAPIENTRY 190_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, 191 GLsizei count, const GLvoid *ptr); 192 193 194extern void GLAPIENTRY 195_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr); 196 197extern void GLAPIENTRY 198_mesa_FogCoordPointer_no_error(GLenum type, GLsizei stride, 199 const GLvoid *ptr); 200extern void GLAPIENTRY 201_mesa_FogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr); 202 203 204extern void GLAPIENTRY 205_mesa_SecondaryColorPointer_no_error(GLint size, GLenum type, 206 GLsizei stride, const GLvoid *ptr); 207extern void GLAPIENTRY 208_mesa_SecondaryColorPointer(GLint size, GLenum type, 209 GLsizei stride, const GLvoid *ptr); 210 211 212extern void GLAPIENTRY 213_mesa_PointSizePointerOES_no_error(GLenum type, GLsizei stride, 214 const GLvoid *ptr); 215extern void GLAPIENTRY 216_mesa_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *ptr); 217 218 219extern void GLAPIENTRY 220_mesa_VertexAttribPointer_no_error(GLuint index, GLint size, GLenum type, 221 GLboolean normalized, GLsizei stride, 222 const GLvoid *pointer); 223extern void GLAPIENTRY 224_mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type, 225 GLboolean normalized, GLsizei stride, 226 const GLvoid *pointer); 227 228void GLAPIENTRY 229_mesa_VertexAttribIPointer_no_error(GLuint index, GLint size, GLenum type, 230 GLsizei stride, const GLvoid *ptr); 231void GLAPIENTRY 232_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, 233 GLsizei stride, const GLvoid *ptr); 234 235extern void GLAPIENTRY 236_mesa_VertexAttribLPointer_no_error(GLuint index, GLint size, GLenum type, 237 GLsizei stride, const GLvoid *pointer); 238extern void GLAPIENTRY 239_mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type, 240 GLsizei stride, const GLvoid *pointer); 241 242extern void GLAPIENTRY 243_mesa_EnableVertexAttribArray(GLuint index); 244 245extern void GLAPIENTRY 246_mesa_EnableVertexAttribArray_no_error(GLuint index); 247 248 249extern void GLAPIENTRY 250_mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index); 251 252extern void GLAPIENTRY 253_mesa_EnableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index); 254 255extern void GLAPIENTRY 256_mesa_EnableVertexArrayAttribEXT( GLuint vaobj, GLuint index ); 257 258 259extern void GLAPIENTRY 260_mesa_DisableVertexAttribArray(GLuint index); 261 262extern void GLAPIENTRY 263_mesa_DisableVertexAttribArray_no_error(GLuint index); 264 265 266extern void GLAPIENTRY 267_mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index); 268 269extern void GLAPIENTRY 270_mesa_DisableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index); 271 272extern void GLAPIENTRY 273_mesa_DisableVertexArrayAttribEXT( GLuint vaobj, GLuint index ); 274 275extern void GLAPIENTRY 276_mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params); 277 278extern void GLAPIENTRY 279_mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params); 280 281extern void GLAPIENTRY 282_mesa_GetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params); 283 284extern void GLAPIENTRY 285_mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params); 286 287extern void GLAPIENTRY 288_mesa_GetVertexAttribLui64vARB(GLuint index, GLenum pname, GLuint64EXT *params); 289 290 291extern void GLAPIENTRY 292_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params); 293 294 295extern void GLAPIENTRY 296_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params); 297 298 299extern void GLAPIENTRY 300_mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer); 301 302 303void GLAPIENTRY 304_mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index, 305 GLenum pname, GLint *param); 306 307 308void GLAPIENTRY 309_mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index, 310 GLenum pname, GLint64 *param); 311 312 313extern void GLAPIENTRY 314_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); 315 316 317extern void GLAPIENTRY 318_mesa_LockArraysEXT(GLint first, GLsizei count); 319 320extern void GLAPIENTRY 321_mesa_UnlockArraysEXT(void); 322 323 324void GLAPIENTRY 325_mesa_PrimitiveRestartIndex_no_error(GLuint index); 326 327extern void GLAPIENTRY 328_mesa_PrimitiveRestartIndex(GLuint index); 329 330extern void GLAPIENTRY 331_mesa_VertexAttribDivisor_no_error(GLuint index, GLuint divisor); 332extern void GLAPIENTRY 333_mesa_VertexAttribDivisor(GLuint index, GLuint divisor); 334extern void GLAPIENTRY 335_mesa_VertexArrayVertexAttribDivisorEXT(GLuint vaobj, GLuint index, GLuint divisor); 336 337static inline unsigned 338_mesa_get_prim_restart_index(bool fixed_index, unsigned restart_index, 339 unsigned index_size) 340{ 341 /* The index_size parameter is meant to be in bytes. */ 342 assert(index_size == 1 || index_size == 2 || index_size == 4); 343 344 /* From the OpenGL 4.3 core specification, page 302: 345 * "If both PRIMITIVE_RESTART and PRIMITIVE_RESTART_FIXED_INDEX are 346 * enabled, the index value determined by PRIMITIVE_RESTART_FIXED_INDEX 347 * is used." 348 */ 349 if (fixed_index) { 350 /* 1 -> 0xff, 2 -> 0xffff, 4 -> 0xffffffff */ 351 return 0xffffffffu >> 8 * (4 - index_size); 352 } 353 354 return restart_index; 355} 356 357static inline unsigned 358_mesa_primitive_restart_index(const struct gl_context *ctx, 359 unsigned index_size) 360{ 361 return _mesa_get_prim_restart_index(ctx->Array.PrimitiveRestartFixedIndex, 362 ctx->Array.RestartIndex, index_size); 363} 364 365extern void GLAPIENTRY 366_mesa_BindVertexBuffer_no_error(GLuint bindingIndex, GLuint buffer, 367 GLintptr offset, GLsizei stride); 368extern void GLAPIENTRY 369_mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset, 370 GLsizei stride); 371 372void GLAPIENTRY 373_mesa_VertexArrayVertexBuffer_no_error(GLuint vaobj, GLuint bindingIndex, 374 GLuint buffer, GLintptr offset, 375 GLsizei stride); 376extern void GLAPIENTRY 377_mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer, 378 GLintptr offset, GLsizei stride); 379 380extern void GLAPIENTRY 381_mesa_VertexArrayBindVertexBufferEXT(GLuint vaobj, GLuint bindingIndex, GLuint buffer, 382 GLintptr offset, GLsizei stride); 383 384void GLAPIENTRY 385_mesa_BindVertexBuffers_no_error(GLuint first, GLsizei count, 386 const GLuint *buffers, const GLintptr *offsets, 387 const GLsizei *strides); 388 389extern void GLAPIENTRY 390_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, 391 const GLintptr *offsets, const GLsizei *strides); 392 393void 394_mesa_InternalBindVertexBuffers(struct gl_context *ctx, 395 const struct glthread_attrib_binding *buffers, 396 GLbitfield buffer_mask, 397 GLboolean restore_pointers); 398 399void GLAPIENTRY 400_mesa_VertexArrayVertexBuffers_no_error(GLuint vaobj, GLuint first, 401 GLsizei count, const GLuint *buffers, 402 const GLintptr *offsets, 403 const GLsizei *strides); 404 405extern void GLAPIENTRY 406_mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count, 407 const GLuint *buffers, 408 const GLintptr *offsets, const GLsizei *strides); 409 410extern void GLAPIENTRY 411_mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type, 412 GLboolean normalized, GLuint relativeOffset); 413 414extern void GLAPIENTRY 415_mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size, 416 GLenum type, GLboolean normalized, 417 GLuint relativeOffset); 418 419extern void GLAPIENTRY 420_mesa_VertexArrayVertexAttribFormatEXT(GLuint vaobj, GLuint attribIndex, GLint size, 421 GLenum type, GLboolean normalized, 422 GLuint relativeOffset); 423 424extern void GLAPIENTRY 425_mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type, 426 GLuint relativeOffset); 427 428extern void GLAPIENTRY 429_mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex, 430 GLint size, GLenum type, 431 GLuint relativeOffset); 432 433extern void GLAPIENTRY 434_mesa_VertexArrayVertexAttribIFormatEXT(GLuint vaobj, GLuint attribIndex, 435 GLint size, GLenum type, 436 GLuint relativeOffset); 437 438extern void GLAPIENTRY 439_mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type, 440 GLuint relativeOffset); 441 442extern void GLAPIENTRY 443_mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex, 444 GLint size, GLenum type, 445 GLuint relativeOffset); 446 447extern void GLAPIENTRY 448_mesa_VertexArrayVertexAttribLFormatEXT(GLuint vaobj, GLuint attribIndex, 449 GLint size, GLenum type, 450 GLuint relativeOffset); 451 452void GLAPIENTRY 453_mesa_VertexAttribBinding_no_error(GLuint attribIndex, GLuint bindingIndex); 454 455extern void GLAPIENTRY 456_mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex); 457 458void GLAPIENTRY 459_mesa_VertexArrayAttribBinding_no_error(GLuint vaobj, GLuint attribIndex, 460 GLuint bindingIndex); 461 462extern void GLAPIENTRY 463_mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, 464 GLuint bindingIndex); 465 466extern void GLAPIENTRY 467_mesa_VertexArrayVertexAttribBindingEXT(GLuint vaobj, GLuint attribIndex, 468 GLuint bindingIndex); 469 470void GLAPIENTRY 471_mesa_VertexBindingDivisor_no_error(GLuint bindingIndex, GLuint divisor); 472 473extern void GLAPIENTRY 474_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor); 475 476void GLAPIENTRY 477_mesa_VertexArrayBindingDivisor_no_error(GLuint vaobj, GLuint bindingIndex, 478 GLuint divisor); 479 480extern void GLAPIENTRY 481_mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, 482 GLuint divisor); 483 484extern void GLAPIENTRY 485_mesa_VertexArrayVertexBindingDivisorEXT(GLuint vaobj, GLuint bindingIndex, 486 GLuint divisor); 487 488extern void 489_mesa_print_arrays(struct gl_context *ctx); 490 491extern void 492_mesa_init_varray(struct gl_context *ctx); 493 494extern void 495_mesa_free_varray_data(struct gl_context *ctx); 496 497extern void GLAPIENTRY 498_mesa_VertexArrayVertexOffsetEXT(GLuint vaobj, GLuint buffer, GLint size, 499 GLenum type, GLsizei stride, GLintptr offset); 500 501extern void GLAPIENTRY 502_mesa_VertexArrayColorOffsetEXT(GLuint vaobj, GLuint buffer, GLint size, 503 GLenum type, GLsizei stride, GLintptr offset); 504 505extern void GLAPIENTRY 506_mesa_VertexArrayEdgeFlagOffsetEXT(GLuint vaobj, GLuint buffer, GLsizei stride, 507 GLintptr offset); 508 509extern void GLAPIENTRY 510_mesa_VertexArrayIndexOffsetEXT(GLuint vaobj, GLuint buffer, GLenum type, 511 GLsizei stride, GLintptr offset); 512 513extern void GLAPIENTRY 514_mesa_VertexArrayNormalOffsetEXT(GLuint vaobj, GLuint buffer, GLenum type, 515 GLsizei stride, GLintptr offset); 516 517extern void GLAPIENTRY 518_mesa_VertexArrayTexCoordOffsetEXT(GLuint vaobj, GLuint buffer, GLint size, 519 GLenum type, GLsizei stride, GLintptr offset); 520 521extern void GLAPIENTRY 522_mesa_VertexArrayMultiTexCoordOffsetEXT(GLuint vaobj, GLuint buffer, GLenum texunit, 523 GLint size, GLenum type, GLsizei stride, 524 GLintptr offset); 525 526extern void GLAPIENTRY 527_mesa_VertexArrayFogCoordOffsetEXT(GLuint vaobj, GLuint buffer, GLenum type, 528 GLsizei stride, GLintptr offset); 529 530extern void GLAPIENTRY 531_mesa_VertexArraySecondaryColorOffsetEXT(GLuint vaobj, GLuint buffer, GLint size, 532 GLenum type, GLsizei stride, GLintptr offset); 533 534extern void GLAPIENTRY 535_mesa_VertexArrayVertexAttribOffsetEXT(GLuint vaobj, GLuint buffer, GLuint index, GLint size, 536 GLenum type, GLboolean normalized, 537 GLsizei stride, GLintptr offset); 538 539extern void GLAPIENTRY 540_mesa_VertexArrayVertexAttribIOffsetEXT(GLuint vaobj, GLuint buffer, GLuint index, GLint size, 541 GLenum type, GLsizei stride, GLintptr offset); 542 543extern void GLAPIENTRY 544_mesa_VertexArrayVertexAttribLOffsetEXT(GLuint vaobj, GLuint buffer, GLuint index, GLint size, 545 GLenum type, GLsizei stride, GLintptr offset); 546 547extern void GLAPIENTRY 548_mesa_GetVertexArrayIntegervEXT(GLuint vaobj, GLenum pname, GLint *param); 549 550extern void GLAPIENTRY 551_mesa_GetVertexArrayPointervEXT(GLuint vaobj, GLenum pname, GLvoid** param); 552 553extern void GLAPIENTRY 554_mesa_GetVertexArrayIntegeri_vEXT(GLuint vaobj, GLuint index, GLenum pname, GLint *param); 555 556extern void GLAPIENTRY 557_mesa_GetVertexArrayPointeri_vEXT(GLuint vaobj, GLuint index, GLenum pname, GLvoid** param); 558 559#endif 560