varray.h revision b9abf16e
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 32void 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 */ 44static 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 55static inline bool 56_mesa_attr_zero_aliases_vertex(const struct gl_context *ctx) 57{ 58 return ctx->_AttribZeroAliasesVertex; 59} 60 61 62extern 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 70extern void 71_mesa_enable_vertex_array_attribs(struct gl_context *ctx, 72 struct gl_vertex_array_object *vao, 73 GLbitfield attrib_bits); 74 75static 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 85extern void 86_mesa_disable_vertex_array_attribs(struct gl_context *ctx, 87 struct gl_vertex_array_object *vao, 88 GLbitfield attrib_bits); 89 90static 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 100extern 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 107extern 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 114extern void GLAPIENTRY 115_mesa_VertexPointer_no_error(GLint size, GLenum type, GLsizei stride, 116 const GLvoid *ptr); 117extern void GLAPIENTRY 118_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, 119 const GLvoid *ptr); 120 121extern void GLAPIENTRY 122_mesa_NormalPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr); 123extern void GLAPIENTRY 124_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr); 125 126extern void GLAPIENTRY 127_mesa_ColorPointer_no_error(GLint size, GLenum type, GLsizei stride, 128 const GLvoid *ptr); 129extern void GLAPIENTRY 130_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); 131 132 133extern void GLAPIENTRY 134_mesa_IndexPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr); 135extern void GLAPIENTRY 136_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr); 137 138 139extern void GLAPIENTRY 140_mesa_TexCoordPointer_no_error(GLint size, GLenum type, GLsizei stride, 141 const GLvoid *ptr); 142extern void GLAPIENTRY 143_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, 144 const GLvoid *ptr); 145 146 147extern void GLAPIENTRY 148_mesa_EdgeFlagPointer_no_error(GLsizei stride, const GLvoid *ptr); 149extern void GLAPIENTRY 150_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr); 151 152 153extern void GLAPIENTRY 154_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, 155 GLsizei count, const GLvoid *ptr); 156 157 158extern void GLAPIENTRY 159_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, 160 const GLvoid *ptr); 161 162 163extern void GLAPIENTRY 164_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, 165 const GLvoid *ptr); 166 167 168extern void GLAPIENTRY 169_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, 170 const GLvoid *ptr); 171 172 173extern void GLAPIENTRY 174_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, 175 GLsizei count, const GLvoid *ptr); 176 177 178extern void GLAPIENTRY 179_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr); 180 181extern void GLAPIENTRY 182_mesa_FogCoordPointer_no_error(GLenum type, GLsizei stride, 183 const GLvoid *ptr); 184extern void GLAPIENTRY 185_mesa_FogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr); 186 187 188extern void GLAPIENTRY 189_mesa_SecondaryColorPointer_no_error(GLint size, GLenum type, 190 GLsizei stride, const GLvoid *ptr); 191extern void GLAPIENTRY 192_mesa_SecondaryColorPointer(GLint size, GLenum type, 193 GLsizei stride, const GLvoid *ptr); 194 195 196extern void GLAPIENTRY 197_mesa_PointSizePointerOES_no_error(GLenum type, GLsizei stride, 198 const GLvoid *ptr); 199extern void GLAPIENTRY 200_mesa_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *ptr); 201 202 203extern void GLAPIENTRY 204_mesa_VertexAttribPointer_no_error(GLuint index, GLint size, GLenum type, 205 GLboolean normalized, GLsizei stride, 206 const GLvoid *pointer); 207extern void GLAPIENTRY 208_mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type, 209 GLboolean normalized, GLsizei stride, 210 const GLvoid *pointer); 211 212void GLAPIENTRY 213_mesa_VertexAttribIPointer_no_error(GLuint index, GLint size, GLenum type, 214 GLsizei stride, const GLvoid *ptr); 215void GLAPIENTRY 216_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, 217 GLsizei stride, const GLvoid *ptr); 218 219extern void GLAPIENTRY 220_mesa_VertexAttribLPointer_no_error(GLuint index, GLint size, GLenum type, 221 GLsizei stride, const GLvoid *pointer); 222extern void GLAPIENTRY 223_mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type, 224 GLsizei stride, const GLvoid *pointer); 225 226extern void GLAPIENTRY 227_mesa_EnableVertexAttribArray(GLuint index); 228 229extern void GLAPIENTRY 230_mesa_EnableVertexAttribArray_no_error(GLuint index); 231 232 233extern void GLAPIENTRY 234_mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index); 235 236extern void GLAPIENTRY 237_mesa_EnableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index); 238 239 240 241extern void GLAPIENTRY 242_mesa_DisableVertexAttribArray(GLuint index); 243 244extern void GLAPIENTRY 245_mesa_DisableVertexAttribArray_no_error(GLuint index); 246 247 248extern void GLAPIENTRY 249_mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index); 250 251extern void GLAPIENTRY 252_mesa_DisableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index); 253 254 255extern void GLAPIENTRY 256_mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params); 257 258extern void GLAPIENTRY 259_mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params); 260 261extern void GLAPIENTRY 262_mesa_GetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params); 263 264extern void GLAPIENTRY 265_mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params); 266 267extern void GLAPIENTRY 268_mesa_GetVertexAttribLui64vARB(GLuint index, GLenum pname, GLuint64EXT *params); 269 270 271extern void GLAPIENTRY 272_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params); 273 274 275extern void GLAPIENTRY 276_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params); 277 278 279extern void GLAPIENTRY 280_mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer); 281 282 283void GLAPIENTRY 284_mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index, 285 GLenum pname, GLint *param); 286 287 288void GLAPIENTRY 289_mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index, 290 GLenum pname, GLint64 *param); 291 292 293extern void GLAPIENTRY 294_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); 295 296 297extern void GLAPIENTRY 298_mesa_LockArraysEXT(GLint first, GLsizei count); 299 300extern void GLAPIENTRY 301_mesa_UnlockArraysEXT(void); 302 303 304void GLAPIENTRY 305_mesa_PrimitiveRestartIndex_no_error(GLuint index); 306 307extern void GLAPIENTRY 308_mesa_PrimitiveRestartIndex(GLuint index); 309 310extern void GLAPIENTRY 311_mesa_VertexAttribDivisor_no_error(GLuint index, GLuint divisor); 312extern void GLAPIENTRY 313_mesa_VertexAttribDivisor(GLuint index, GLuint divisor); 314 315static 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 335extern void GLAPIENTRY 336_mesa_BindVertexBuffer_no_error(GLuint bindingIndex, GLuint buffer, 337 GLintptr offset, GLsizei stride); 338extern void GLAPIENTRY 339_mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset, 340 GLsizei stride); 341 342void GLAPIENTRY 343_mesa_VertexArrayVertexBuffer_no_error(GLuint vaobj, GLuint bindingIndex, 344 GLuint buffer, GLintptr offset, 345 GLsizei stride); 346extern void GLAPIENTRY 347_mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer, 348 GLintptr offset, GLsizei stride); 349 350void GLAPIENTRY 351_mesa_BindVertexBuffers_no_error(GLuint first, GLsizei count, 352 const GLuint *buffers, const GLintptr *offsets, 353 const GLsizei *strides); 354 355extern void GLAPIENTRY 356_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, 357 const GLintptr *offsets, const GLsizei *strides); 358 359void 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 365extern void GLAPIENTRY 366_mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count, 367 const GLuint *buffers, 368 const GLintptr *offsets, const GLsizei *strides); 369 370extern void GLAPIENTRY 371_mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type, 372 GLboolean normalized, GLuint relativeOffset); 373 374extern void GLAPIENTRY 375_mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size, 376 GLenum type, GLboolean normalized, 377 GLuint relativeOffset); 378 379extern void GLAPIENTRY 380_mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type, 381 GLuint relativeOffset); 382 383extern void GLAPIENTRY 384_mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex, 385 GLint size, GLenum type, 386 GLuint relativeOffset); 387 388extern void GLAPIENTRY 389_mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type, 390 GLuint relativeOffset); 391 392extern void GLAPIENTRY 393_mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex, 394 GLint size, GLenum type, 395 GLuint relativeOffset); 396 397void GLAPIENTRY 398_mesa_VertexAttribBinding_no_error(GLuint attribIndex, GLuint bindingIndex); 399 400extern void GLAPIENTRY 401_mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex); 402 403void GLAPIENTRY 404_mesa_VertexArrayAttribBinding_no_error(GLuint vaobj, GLuint attribIndex, 405 GLuint bindingIndex); 406 407extern void GLAPIENTRY 408_mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, 409 GLuint bindingIndex); 410 411void GLAPIENTRY 412_mesa_VertexBindingDivisor_no_error(GLuint bindingIndex, GLuint divisor); 413 414extern void GLAPIENTRY 415_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor); 416 417void GLAPIENTRY 418_mesa_VertexArrayBindingDivisor_no_error(GLuint vaobj, GLuint bindingIndex, 419 GLuint divisor); 420 421extern void GLAPIENTRY 422_mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, 423 GLuint divisor); 424 425 426extern 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 431extern 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 436extern void 437_mesa_print_arrays(struct gl_context *ctx); 438 439extern void 440_mesa_init_varray(struct gl_context *ctx); 441 442extern void 443_mesa_free_varray_data(struct gl_context *ctx); 444 445#endif 446