jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 3 | * Version: 7.6 |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 4 | * |
Brian Paul | 37c74af | 2008-09-04 14:58:02 -0600 | [diff] [blame] | 5 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 6 | * Copyright (C) 2009 VMware, Inc. All Rights Reserved. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 7 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the "Software"), |
| 10 | * to deal in the Software without restriction, including without limitation |
| 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 | * and/or sell copies of the Software, and to permit persons to whom the |
| 13 | * Software is furnished to do so, subject to the following conditions: |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 14 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 15 | * The above copyright notice and this permission notice shall be included |
| 16 | * in all copies or substantial portions of the Software. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 17 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 21 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 22 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 26 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 27 | #include "glheader.h" |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 28 | #include "imports.h" |
Brian Paul | 26895aa | 2004-03-03 15:35:08 +0000 | [diff] [blame] | 29 | #include "bufferobj.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 30 | #include "context.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 31 | #include "enable.h" |
| 32 | #include "enums.h" |
Brian Paul | 12cf98f | 2009-06-19 17:58:47 -0600 | [diff] [blame] | 33 | #include "hash.h" |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 34 | #include "image.h" |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 35 | #include "macros.h" |
Vinson Lee | db61b9c | 2011-01-07 00:08:24 -0800 | [diff] [blame] | 36 | #include "mfeatures.h" |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 37 | #include "mtypes.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 38 | #include "varray.h" |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 39 | #include "arrayobj.h" |
Chia-I Wu | 2cf4439 | 2010-02-24 12:01:14 +0800 | [diff] [blame] | 40 | #include "main/dispatch.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 41 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 42 | |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 43 | /** Used to do error checking for GL_EXT_vertex_array_bgra */ |
| 44 | #define BGRA_OR_4 5 |
| 45 | |
| 46 | |
| 47 | /** Used to indicate which GL datatypes are accepted by each of the |
| 48 | * glVertex/Color/Attrib/EtcPointer() functions. |
| 49 | */ |
| 50 | #define BOOL_BIT 0x1 |
| 51 | #define BYTE_BIT 0x2 |
| 52 | #define UNSIGNED_BYTE_BIT 0x4 |
| 53 | #define SHORT_BIT 0x8 |
| 54 | #define UNSIGNED_SHORT_BIT 0x10 |
| 55 | #define INT_BIT 0x20 |
| 56 | #define UNSIGNED_INT_BIT 0x40 |
| 57 | #define HALF_BIT 0x80 |
| 58 | #define FLOAT_BIT 0x100 |
| 59 | #define DOUBLE_BIT 0x200 |
Marek Olšák | 0f1e59d | 2011-04-29 14:23:15 +0200 | [diff] [blame] | 60 | #define FIXED_ES_BIT 0x400 |
| 61 | #define FIXED_GL_BIT 0x800 |
Dave Airlie | 6cd2d55 | 2011-08-13 15:30:38 +0100 | [diff] [blame] | 62 | #define UNSIGNED_INT_2_10_10_10_REV_BIT 0x1000 |
| 63 | #define INT_2_10_10_10_REV_BIT 0x2000 |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 64 | |
| 65 | |
| 66 | /** Convert GL datatype enum into a <type>_BIT value seen above */ |
| 67 | static GLbitfield |
| 68 | type_to_bit(const struct gl_context *ctx, GLenum type) |
| 69 | { |
| 70 | switch (type) { |
| 71 | case GL_BOOL: |
| 72 | return BOOL_BIT; |
| 73 | case GL_BYTE: |
| 74 | return BYTE_BIT; |
| 75 | case GL_UNSIGNED_BYTE: |
| 76 | return UNSIGNED_BYTE_BIT; |
| 77 | case GL_SHORT: |
| 78 | return SHORT_BIT; |
| 79 | case GL_UNSIGNED_SHORT: |
| 80 | return UNSIGNED_SHORT_BIT; |
| 81 | case GL_INT: |
| 82 | return INT_BIT; |
| 83 | case GL_UNSIGNED_INT: |
| 84 | return UNSIGNED_INT_BIT; |
| 85 | case GL_HALF_FLOAT: |
| 86 | if (ctx->Extensions.ARB_half_float_vertex) |
| 87 | return HALF_BIT; |
| 88 | else |
| 89 | return 0x0; |
| 90 | case GL_FLOAT: |
| 91 | return FLOAT_BIT; |
| 92 | case GL_DOUBLE: |
| 93 | return DOUBLE_BIT; |
| 94 | case GL_FIXED: |
Jordan Justen | 09714c0 | 2012-07-19 11:27:16 -0700 | [diff] [blame] | 95 | return _mesa_is_desktop_gl(ctx) ? FIXED_GL_BIT : FIXED_ES_BIT; |
Dave Airlie | 6cd2d55 | 2011-08-13 15:30:38 +0100 | [diff] [blame] | 96 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 97 | return UNSIGNED_INT_2_10_10_10_REV_BIT; |
| 98 | case GL_INT_2_10_10_10_REV: |
| 99 | return INT_2_10_10_10_REV_BIT; |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 100 | default: |
| 101 | return 0; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 106 | /** |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 107 | * Do error checking and update state for glVertex/Color/TexCoord/...Pointer |
| 108 | * functions. |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 109 | * |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 110 | * \param func name of calling function used for error reporting |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 111 | * \param attrib the attribute array index to update |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 112 | * \param legalTypes bitmask of *_BIT above indicating legal datatypes |
| 113 | * \param sizeMin min allowable size value |
| 114 | * \param sizeMax max allowable size value (may also be BGRA_OR_4) |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 115 | * \param size components per element (1, 2, 3 or 4) |
| 116 | * \param type datatype of each component (GL_FLOAT, GL_INT, etc) |
| 117 | * \param stride stride between elements, in elements |
| 118 | * \param normalized are integer types converted to floats in [-1, 1]? |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 119 | * \param integer integer-valued values (will not be normalized to [-1,1]) |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 120 | * \param ptr the address (or offset inside VBO) of the array data |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 121 | */ |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 122 | static void |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 123 | update_array(struct gl_context *ctx, |
| 124 | const char *func, |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 125 | GLuint attrib, GLbitfield legalTypesMask, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 126 | GLint sizeMin, GLint sizeMax, |
| 127 | GLint size, GLenum type, GLsizei stride, |
| 128 | GLboolean normalized, GLboolean integer, |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 129 | const GLvoid *ptr) |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 130 | { |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 131 | struct gl_client_array *array; |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 132 | GLbitfield typeBit; |
| 133 | GLsizei elementSize; |
| 134 | GLenum format = GL_RGBA; |
| 135 | |
Ian Romanick | bbceed2 | 2012-07-25 14:40:18 -0700 | [diff] [blame] | 136 | if (_mesa_is_gles(ctx)) { |
| 137 | /* Once Mesa gets support for GL_OES_vertex_half_float this mask will |
| 138 | * change. Adding support for this extension isn't quite as trivial as |
| 139 | * we'd like because ES uses a different enum value for GL_HALF_FLOAT. |
| 140 | */ |
| 141 | legalTypesMask &= ~(FIXED_GL_BIT | HALF_BIT | DOUBLE_BIT); |
| 142 | |
| 143 | /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until |
| 144 | * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or |
| 145 | * GL_OES_vertex_type_10_10_10_2. |
| 146 | */ |
| 147 | if (ctx->Version < 30) { |
| 148 | legalTypesMask &= ~(UNSIGNED_INT_BIT |
| 149 | | INT_BIT |
| 150 | | UNSIGNED_INT_2_10_10_10_REV_BIT |
| 151 | | INT_2_10_10_10_REV_BIT); |
| 152 | } |
Ian Romanick | 946ddec | 2012-07-25 14:46:54 -0700 | [diff] [blame] | 153 | |
| 154 | /* BGRA ordering is not supported in ES contexts. |
| 155 | */ |
| 156 | if (sizeMax == BGRA_OR_4) |
| 157 | sizeMax = 4; |
Ian Romanick | bbceed2 | 2012-07-25 14:40:18 -0700 | [diff] [blame] | 158 | } else { |
Marek Olšák | 0f1e59d | 2011-04-29 14:23:15 +0200 | [diff] [blame] | 159 | legalTypesMask &= ~FIXED_ES_BIT; |
Ian Romanick | bbceed2 | 2012-07-25 14:40:18 -0700 | [diff] [blame] | 160 | |
| 161 | if (!ctx->Extensions.ARB_ES2_compatibility) |
| 162 | legalTypesMask &= ~FIXED_GL_BIT; |
| 163 | |
| 164 | if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) |
| 165 | legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | |
| 166 | INT_2_10_10_10_REV_BIT); |
Dave Airlie | 6cd2d55 | 2011-08-13 15:30:38 +0100 | [diff] [blame] | 167 | } |
Brian Paul | 11dd228 | 2010-11-07 18:35:35 -0700 | [diff] [blame] | 168 | |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 169 | typeBit = type_to_bit(ctx, type); |
| 170 | if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) { |
| 171 | _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", |
| 172 | func, _mesa_lookup_enum_by_nr(type)); |
| 173 | return; |
| 174 | } |
| 175 | |
| 176 | /* Do size parameter checking. |
| 177 | * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and |
| 178 | * must be handled specially. |
| 179 | */ |
| 180 | if (ctx->Extensions.EXT_vertex_array_bgra && |
| 181 | sizeMax == BGRA_OR_4 && |
| 182 | size == GL_BGRA) { |
Dave Airlie | 99c1a58 | 2011-09-07 10:19:14 +0100 | [diff] [blame] | 183 | GLboolean bgra_error = GL_FALSE; |
| 184 | |
| 185 | if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) { |
| 186 | if (type != GL_UNSIGNED_INT_2_10_10_10_REV && |
| 187 | type != GL_INT_2_10_10_10_REV && |
| 188 | type != GL_UNSIGNED_BYTE) |
| 189 | bgra_error = GL_TRUE; |
| 190 | } else if (type != GL_UNSIGNED_BYTE) |
| 191 | bgra_error = GL_TRUE; |
| 192 | |
| 193 | if (bgra_error) { |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 194 | _mesa_error(ctx, GL_INVALID_VALUE, "%s(GL_BGRA/GLubyte)", func); |
| 195 | return; |
| 196 | } |
| 197 | format = GL_BGRA; |
| 198 | size = 4; |
| 199 | } |
| 200 | else if (size < sizeMin || size > sizeMax || size > 4) { |
| 201 | _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size); |
| 202 | return; |
| 203 | } |
| 204 | |
Dave Airlie | 6cd2d55 | 2011-08-13 15:30:38 +0100 | [diff] [blame] | 205 | if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev && |
| 206 | (type == GL_UNSIGNED_INT_2_10_10_10_REV || |
| 207 | type == GL_INT_2_10_10_10_REV) && size != 4) { |
| 208 | _mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=%d)", func, size); |
Brian Paul | e14b357 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 209 | return; |
Dave Airlie | 6cd2d55 | 2011-08-13 15:30:38 +0100 | [diff] [blame] | 210 | } |
| 211 | |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 212 | ASSERT(size <= 4); |
| 213 | |
| 214 | if (stride < 0) { |
| 215 | _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride ); |
| 216 | return; |
| 217 | } |
Brian Paul | e2b7249 | 2009-06-22 16:56:35 -0600 | [diff] [blame] | 218 | |
Ian Romanick | 0963990 | 2012-01-23 14:22:38 -0800 | [diff] [blame] | 219 | if (ctx->Array.ArrayObj->ARBsemantics && |
Brian Paul | efcf5aa | 2011-11-29 07:44:20 -0700 | [diff] [blame] | 220 | !_mesa_is_bufferobj(ctx->Array.ArrayBufferObj)) { |
Brian Paul | e2b7249 | 2009-06-22 16:56:35 -0600 | [diff] [blame] | 221 | /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs. |
| 222 | * Generate GL_INVALID_OPERATION if that's not true. |
| 223 | */ |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 224 | _mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-VBO array)", func); |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 225 | return; |
Brian Paul | e2b7249 | 2009-06-22 16:56:35 -0600 | [diff] [blame] | 226 | } |
| 227 | |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 228 | elementSize = _mesa_sizeof_type(type) * size; |
| 229 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 230 | array = &ctx->Array.ArrayObj->VertexAttrib[attrib]; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 231 | array->Size = size; |
| 232 | array->Type = type; |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 233 | array->Format = format; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 234 | array->Stride = stride; |
| 235 | array->StrideB = stride ? stride : elementSize; |
| 236 | array->Normalized = normalized; |
Paul Berry | 8f84c23 | 2011-10-31 17:29:17 -0700 | [diff] [blame] | 237 | array->Integer = integer; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 238 | array->Ptr = (const GLubyte *) ptr; |
Brian Paul | 0077c87 | 2009-05-06 13:00:35 -0600 | [diff] [blame] | 239 | array->_ElementSize = elementSize; |
| 240 | |
Brian Paul | 37c74af | 2008-09-04 14:58:02 -0600 | [diff] [blame] | 241 | _mesa_reference_buffer_object(ctx, &array->BufferObj, |
| 242 | ctx->Array.ArrayBufferObj); |
| 243 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 244 | ctx->NewState |= _NEW_ARRAY; |
Brian Paul | b0e048f | 2012-04-18 10:47:10 -0600 | [diff] [blame] | 245 | ctx->Array.ArrayObj->NewArrays |= VERT_BIT(attrib); |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 249 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 250 | _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 251 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 252 | GET_CURRENT_CONTEXT(ctx); |
Ian Romanick | e2cf14d | 2012-07-25 15:19:31 -0700 | [diff] [blame] | 253 | GLbitfield legalTypes = (ctx->API == API_OPENGLES) |
| 254 | ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT) |
| 255 | : (SHORT_BIT | INT_BIT | FLOAT_BIT | |
| 256 | DOUBLE_BIT | HALF_BIT | |
| 257 | UNSIGNED_INT_2_10_10_10_REV_BIT | |
| 258 | INT_2_10_10_10_REV_BIT); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 259 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 260 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 261 | update_array(ctx, "glVertexPointer", VERT_ATTRIB_POS, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 262 | legalTypes, 2, 4, |
| 263 | size, type, stride, GL_FALSE, GL_FALSE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 267 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 268 | _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 269 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 270 | GET_CURRENT_CONTEXT(ctx); |
Ian Romanick | e5ef0cb | 2012-07-25 15:10:21 -0700 | [diff] [blame] | 271 | const GLbitfield legalTypes = (ctx->API == API_OPENGLES) |
| 272 | ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT) |
| 273 | : (BYTE_BIT | SHORT_BIT | INT_BIT | |
| 274 | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | |
| 275 | UNSIGNED_INT_2_10_10_10_REV_BIT | |
| 276 | INT_2_10_10_10_REV_BIT); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 277 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 278 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 279 | update_array(ctx, "glNormalPointer", VERT_ATTRIB_NORMAL, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 280 | legalTypes, 3, 3, |
| 281 | 3, type, stride, GL_TRUE, GL_FALSE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 285 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 286 | _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 287 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 288 | GET_CURRENT_CONTEXT(ctx); |
Ian Romanick | 07ccfef | 2012-07-25 14:53:01 -0700 | [diff] [blame] | 289 | const GLbitfield legalTypes = (ctx->API == API_OPENGLES) |
| 290 | ? (UNSIGNED_BYTE_BIT | HALF_BIT | FLOAT_BIT | FIXED_ES_BIT) |
| 291 | : (BYTE_BIT | UNSIGNED_BYTE_BIT | |
| 292 | SHORT_BIT | UNSIGNED_SHORT_BIT | |
| 293 | INT_BIT | UNSIGNED_INT_BIT | |
| 294 | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | |
| 295 | UNSIGNED_INT_2_10_10_10_REV_BIT | |
| 296 | INT_2_10_10_10_REV_BIT); |
Ian Romanick | fb82185 | 2012-07-25 14:58:36 -0700 | [diff] [blame] | 297 | const GLint sizeMin = (ctx->API == API_OPENGLES) ? 4 : 3; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 298 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 299 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 300 | update_array(ctx, "glColorPointer", VERT_ATTRIB_COLOR0, |
Ian Romanick | fb82185 | 2012-07-25 14:58:36 -0700 | [diff] [blame] | 301 | legalTypes, sizeMin, BGRA_OR_4, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 302 | size, type, stride, GL_TRUE, GL_FALSE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 306 | void GLAPIENTRY |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 307 | _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) |
| 308 | { |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 309 | const GLbitfield legalTypes = (HALF_BIT | FLOAT_BIT | DOUBLE_BIT); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 310 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 311 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 312 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 313 | update_array(ctx, "glFogCoordPointer", VERT_ATTRIB_FOG, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 314 | legalTypes, 1, 1, |
| 315 | 1, type, stride, GL_FALSE, GL_FALSE, ptr); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 319 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 320 | _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 321 | { |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 322 | const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT | INT_BIT | |
| 323 | FLOAT_BIT | DOUBLE_BIT); |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 324 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 325 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 326 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 327 | update_array(ctx, "glIndexPointer", VERT_ATTRIB_COLOR_INDEX, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 328 | legalTypes, 1, 1, |
| 329 | 1, type, stride, GL_FALSE, GL_FALSE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 333 | void GLAPIENTRY |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 334 | _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 335 | GLsizei stride, const GLvoid *ptr) |
| 336 | { |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 337 | const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | |
| 338 | SHORT_BIT | UNSIGNED_SHORT_BIT | |
| 339 | INT_BIT | UNSIGNED_INT_BIT | |
Dave Airlie | 6cd2d55 | 2011-08-13 15:30:38 +0100 | [diff] [blame] | 340 | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | |
| 341 | UNSIGNED_INT_2_10_10_10_REV_BIT | |
| 342 | INT_2_10_10_10_REV_BIT); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 343 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 344 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 345 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 346 | update_array(ctx, "glSecondaryColorPointer", VERT_ATTRIB_COLOR1, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 347 | legalTypes, 3, BGRA_OR_4, |
| 348 | size, type, stride, GL_TRUE, GL_FALSE, ptr); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 352 | void GLAPIENTRY |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 353 | _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, |
| 354 | const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 355 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 356 | GET_CURRENT_CONTEXT(ctx); |
Ian Romanick | c3e9a20 | 2012-07-25 15:13:00 -0700 | [diff] [blame] | 357 | GLbitfield legalTypes = (ctx->API == API_OPENGLES) |
| 358 | ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT) |
| 359 | : (SHORT_BIT | INT_BIT | |
| 360 | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | |
| 361 | UNSIGNED_INT_2_10_10_10_REV_BIT | |
| 362 | INT_2_10_10_10_REV_BIT); |
Ian Romanick | a8f475d | 2012-07-25 15:13:51 -0700 | [diff] [blame] | 363 | const GLint sizeMin = (ctx->API == API_OPENGLES) ? 2 : 1; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 364 | const GLuint unit = ctx->Array.ActiveTexture; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 365 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 366 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 367 | update_array(ctx, "glTexCoordPointer", VERT_ATTRIB_TEX(unit), |
Ian Romanick | a8f475d | 2012-07-25 15:13:51 -0700 | [diff] [blame] | 368 | legalTypes, sizeMin, 4, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 369 | size, type, stride, GL_FALSE, GL_FALSE, |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 370 | ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 374 | void GLAPIENTRY |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 375 | _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 376 | { |
Brian Paul | ee1f047 | 2010-11-02 08:22:40 -0600 | [diff] [blame] | 377 | const GLbitfield legalTypes = UNSIGNED_BYTE_BIT; |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 378 | /* see table 2.4 edits in GL_EXT_gpu_shader4 spec: */ |
| 379 | const GLboolean integer = GL_TRUE; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 380 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 381 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 382 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 383 | update_array(ctx, "glEdgeFlagPointer", VERT_ATTRIB_EDGEFLAG, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 384 | legalTypes, 1, 1, |
Brian Paul | ee1f047 | 2010-11-02 08:22:40 -0600 | [diff] [blame] | 385 | 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, integer, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | |
Brian Paul | 1cf2c8a | 2008-06-25 08:45:14 -0600 | [diff] [blame] | 389 | void GLAPIENTRY |
| 390 | _mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr) |
| 391 | { |
Marek Olšák | 0f1e59d | 2011-04-29 14:23:15 +0200 | [diff] [blame] | 392 | const GLbitfield legalTypes = (FLOAT_BIT | FIXED_ES_BIT); |
Brian Paul | 1cf2c8a | 2008-06-25 08:45:14 -0600 | [diff] [blame] | 393 | GET_CURRENT_CONTEXT(ctx); |
| 394 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 395 | |
Brian Paul | 11dd228 | 2010-11-07 18:35:35 -0700 | [diff] [blame] | 396 | if (ctx->API != API_OPENGLES) { |
| 397 | _mesa_error(ctx, GL_INVALID_OPERATION, |
| 398 | "glPointSizePointer(ES 1.x only)"); |
| 399 | return; |
| 400 | } |
| 401 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 402 | update_array(ctx, "glPointSizePointer", VERT_ATTRIB_POINT_SIZE, |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 403 | legalTypes, 1, 1, |
| 404 | 1, type, stride, GL_FALSE, GL_FALSE, ptr); |
Brian Paul | 1cf2c8a | 2008-06-25 08:45:14 -0600 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 408 | #if FEATURE_NV_vertex_program |
Brian Paul | a554d7c | 2009-05-21 15:55:33 -0600 | [diff] [blame] | 409 | /** |
| 410 | * Set a vertex attribute array. |
| 411 | * Note that these arrays DO alias the conventional GL vertex arrays |
| 412 | * (position, normal, color, fog, texcoord, etc). |
| 413 | * The generic attribute slots at #16 and above are not touched. |
| 414 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 415 | void GLAPIENTRY |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 416 | _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, |
| 417 | GLsizei stride, const GLvoid *ptr) |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 418 | { |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 419 | const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT | |
| 420 | FLOAT_BIT | DOUBLE_BIT); |
Markus Amsler | 29fbf72 | 2008-03-09 17:53:22 -0600 | [diff] [blame] | 421 | GLboolean normalized = GL_FALSE; |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 422 | GET_CURRENT_CONTEXT(ctx); |
| 423 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 424 | |
Brian Paul | d2a74d7 | 2009-05-21 17:03:21 -0600 | [diff] [blame] | 425 | if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 426 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); |
| 427 | return; |
| 428 | } |
| 429 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 430 | if (type == GL_UNSIGNED_BYTE && size != 4) { |
| 431 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)"); |
| 432 | return; |
| 433 | } |
| 434 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 435 | update_array(ctx, "glVertexAttribPointerNV", VERT_ATTRIB_GENERIC(index), |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 436 | legalTypes, 1, BGRA_OR_4, |
| 437 | size, type, stride, normalized, GL_FALSE, ptr); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 438 | } |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 439 | #endif |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 440 | |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 441 | |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 442 | #if FEATURE_ARB_vertex_program |
Brian Paul | a554d7c | 2009-05-21 15:55:33 -0600 | [diff] [blame] | 443 | /** |
| 444 | * Set a generic vertex attribute array. |
| 445 | * Note that these arrays DO NOT alias the conventional GL vertex arrays |
| 446 | * (position, normal, color, fog, texcoord, etc). |
| 447 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 448 | void GLAPIENTRY |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 449 | _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, |
| 450 | GLboolean normalized, |
| 451 | GLsizei stride, const GLvoid *ptr) |
| 452 | { |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 453 | const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | |
| 454 | SHORT_BIT | UNSIGNED_SHORT_BIT | |
| 455 | INT_BIT | UNSIGNED_INT_BIT | |
| 456 | HALF_BIT | FLOAT_BIT | DOUBLE_BIT | |
Dave Airlie | 6cd2d55 | 2011-08-13 15:30:38 +0100 | [diff] [blame] | 457 | FIXED_ES_BIT | FIXED_GL_BIT | |
| 458 | UNSIGNED_INT_2_10_10_10_REV_BIT | |
| 459 | INT_2_10_10_10_REV_BIT); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 460 | GET_CURRENT_CONTEXT(ctx); |
| 461 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 462 | |
Brian Paul | 0505103 | 2005-11-01 04:36:33 +0000 | [diff] [blame] | 463 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 464 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); |
| 465 | return; |
| 466 | } |
| 467 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 468 | update_array(ctx, "glVertexAttribPointer", VERT_ATTRIB_GENERIC(index), |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 469 | legalTypes, 1, BGRA_OR_4, |
| 470 | size, type, stride, normalized, GL_FALSE, ptr); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 471 | } |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 472 | #endif |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 473 | |
| 474 | |
Brian Paul | e00d07c | 2010-05-25 21:12:24 -0600 | [diff] [blame] | 475 | /** |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 476 | * GL_EXT_gpu_shader4 / GL 3.0. |
Brian Paul | e00d07c | 2010-05-25 21:12:24 -0600 | [diff] [blame] | 477 | * Set an integer-valued vertex attribute array. |
| 478 | * Note that these arrays DO NOT alias the conventional GL vertex arrays |
| 479 | * (position, normal, color, fog, texcoord, etc). |
| 480 | */ |
| 481 | void GLAPIENTRY |
| 482 | _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, |
Brian Paul | e00d07c | 2010-05-25 21:12:24 -0600 | [diff] [blame] | 483 | GLsizei stride, const GLvoid *ptr) |
| 484 | { |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 485 | const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | |
| 486 | SHORT_BIT | UNSIGNED_SHORT_BIT | |
| 487 | INT_BIT | UNSIGNED_INT_BIT); |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 488 | const GLboolean normalized = GL_FALSE; |
| 489 | const GLboolean integer = GL_TRUE; |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 490 | GET_CURRENT_CONTEXT(ctx); |
| 491 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 492 | |
| 493 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
| 494 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIPointer(index)"); |
| 495 | return; |
| 496 | } |
| 497 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 498 | update_array(ctx, "glVertexAttribIPointer", VERT_ATTRIB_GENERIC(index), |
Brian Paul | 433e5e6 | 2010-10-28 21:17:42 -0600 | [diff] [blame] | 499 | legalTypes, 1, 4, |
| 500 | size, type, stride, normalized, integer, ptr); |
Brian Paul | e00d07c | 2010-05-25 21:12:24 -0600 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | |
| 504 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 505 | void GLAPIENTRY |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 506 | _mesa_EnableVertexAttribArrayARB(GLuint index) |
| 507 | { |
Brian Paul | 45453d8 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 508 | struct gl_array_object *arrayObj; |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 509 | GET_CURRENT_CONTEXT(ctx); |
| 510 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 511 | |
| 512 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
| 513 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 514 | "glEnableVertexAttribArrayARB(index)"); |
| 515 | return; |
| 516 | } |
| 517 | |
Brian Paul | 45453d8 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 518 | arrayObj = ctx->Array.ArrayObj; |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 519 | |
Brian Paul | 45453d8 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 520 | ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->VertexAttrib)); |
| 521 | |
| 522 | if (!arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) { |
| 523 | /* was disabled, now being enabled */ |
| 524 | FLUSH_VERTICES(ctx, _NEW_ARRAY); |
| 525 | arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE; |
| 526 | arrayObj->_Enabled |= VERT_BIT_GENERIC(index); |
Brian Paul | b0e048f | 2012-04-18 10:47:10 -0600 | [diff] [blame] | 527 | arrayObj->NewArrays |= VERT_BIT_GENERIC(index); |
Brian Paul | 45453d8 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 528 | } |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | |
| 532 | void GLAPIENTRY |
| 533 | _mesa_DisableVertexAttribArrayARB(GLuint index) |
| 534 | { |
Brian Paul | 45453d8 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 535 | struct gl_array_object *arrayObj; |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 536 | GET_CURRENT_CONTEXT(ctx); |
| 537 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 538 | |
| 539 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
| 540 | _mesa_error(ctx, GL_INVALID_VALUE, |
Brian Paul | 95368f2 | 2011-04-06 14:22:39 -0600 | [diff] [blame] | 541 | "glDisableVertexAttribArrayARB(index)"); |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 542 | return; |
| 543 | } |
| 544 | |
Brian Paul | 45453d8 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 545 | arrayObj = ctx->Array.ArrayObj; |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 546 | |
Brian Paul | 45453d8 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 547 | ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->VertexAttrib)); |
| 548 | |
| 549 | if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) { |
| 550 | /* was enabled, now being disabled */ |
| 551 | FLUSH_VERTICES(ctx, _NEW_ARRAY); |
| 552 | arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE; |
| 553 | arrayObj->_Enabled &= ~VERT_BIT_GENERIC(index); |
Brian Paul | b0e048f | 2012-04-18 10:47:10 -0600 | [diff] [blame] | 554 | arrayObj->NewArrays |= VERT_BIT_GENERIC(index); |
Brian Paul | 45453d8 | 2012-02-19 19:50:31 -0700 | [diff] [blame] | 555 | } |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | |
| 559 | /** |
| 560 | * Return info for a vertex attribute array (no alias with legacy |
| 561 | * vertex attributes (pos, normal, color, etc)). This function does |
| 562 | * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query. |
| 563 | */ |
| 564 | static GLuint |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 565 | get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname, |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 566 | const char *caller) |
| 567 | { |
| 568 | const struct gl_client_array *array; |
| 569 | |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 570 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 571 | _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index); |
| 572 | return 0; |
| 573 | } |
| 574 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 575 | ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 576 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 577 | array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)]; |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 578 | |
| 579 | switch (pname) { |
| 580 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB: |
| 581 | return array->Enabled; |
| 582 | case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB: |
| 583 | return array->Size; |
| 584 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB: |
| 585 | return array->Stride; |
| 586 | case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB: |
| 587 | return array->Type; |
| 588 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB: |
| 589 | return array->Normalized; |
| 590 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB: |
| 591 | return array->BufferObj->Name; |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 592 | case GL_VERTEX_ATTRIB_ARRAY_INTEGER: |
Ian Romanick | 2c87030 | 2012-07-25 16:21:49 -0700 | [diff] [blame^] | 593 | if ((_mesa_is_desktop_gl(ctx) |
| 594 | && (ctx->Version >= 30 || ctx->Extensions.EXT_gpu_shader4)) |
| 595 | || _mesa_is_gles3(ctx)) { |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 596 | return array->Integer; |
| 597 | } |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 598 | goto error; |
| 599 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB: |
Ian Romanick | 2c87030 | 2012-07-25 16:21:49 -0700 | [diff] [blame^] | 600 | if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_instanced_arrays) |
| 601 | || _mesa_is_gles3(ctx)) { |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 602 | return array->InstanceDivisor; |
| 603 | } |
| 604 | goto error; |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 605 | default: |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 606 | ; /* fall-through */ |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 607 | } |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 608 | |
| 609 | error: |
| 610 | _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname); |
| 611 | return 0; |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 615 | static const GLfloat * |
| 616 | get_current_attrib(struct gl_context *ctx, GLuint index, const char *function) |
| 617 | { |
| 618 | if (index == 0) { |
Ian Romanick | 2c87030 | 2012-07-25 16:21:49 -0700 | [diff] [blame^] | 619 | /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES |
| 620 | * 2.0. Note that we cannot just check for API_OPENGL_CORE here because |
| 621 | * that will erroneously allow this usage in a 3.0 forward-compatible |
| 622 | * context too. |
| 623 | */ |
| 624 | if ((ctx->API != API_OPENGL_CORE || ctx->Version < 31) |
| 625 | && ctx->API != API_OPENGLES2) { |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 626 | _mesa_error(ctx, GL_INVALID_OPERATION, "%s(index==0)", function); |
| 627 | return NULL; |
| 628 | } |
| 629 | } |
| 630 | else if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
| 631 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 632 | "%s(index>=GL_MAX_VERTEX_ATTRIBS)", function); |
| 633 | return NULL; |
| 634 | } |
| 635 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 636 | ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); |
| 637 | |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 638 | FLUSH_CURRENT(ctx, 0); |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 639 | return ctx->Current.Attrib[VERT_ATTRIB_GENERIC(index)]; |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 640 | } |
| 641 | |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 642 | void GLAPIENTRY |
| 643 | _mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params) |
| 644 | { |
| 645 | GET_CURRENT_CONTEXT(ctx); |
| 646 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 647 | |
| 648 | if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 649 | const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribfv"); |
| 650 | if (v != NULL) { |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 651 | COPY_4V(params, v); |
| 652 | } |
| 653 | } |
| 654 | else { |
| 655 | params[0] = (GLfloat) get_vertex_array_attrib(ctx, index, pname, |
| 656 | "glGetVertexAttribfv"); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | |
| 661 | void GLAPIENTRY |
| 662 | _mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params) |
| 663 | { |
| 664 | GET_CURRENT_CONTEXT(ctx); |
| 665 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 666 | |
| 667 | if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 668 | const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribdv"); |
| 669 | if (v != NULL) { |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 670 | params[0] = (GLdouble) v[0]; |
| 671 | params[1] = (GLdouble) v[1]; |
| 672 | params[2] = (GLdouble) v[2]; |
| 673 | params[3] = (GLdouble) v[3]; |
| 674 | } |
| 675 | } |
| 676 | else { |
| 677 | params[0] = (GLdouble) get_vertex_array_attrib(ctx, index, pname, |
| 678 | "glGetVertexAttribdv"); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | |
| 683 | void GLAPIENTRY |
| 684 | _mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params) |
| 685 | { |
| 686 | GET_CURRENT_CONTEXT(ctx); |
| 687 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 688 | |
| 689 | if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 690 | const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribiv"); |
| 691 | if (v != NULL) { |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 692 | /* XXX should floats in[0,1] be scaled to full int range? */ |
| 693 | params[0] = (GLint) v[0]; |
| 694 | params[1] = (GLint) v[1]; |
| 695 | params[2] = (GLint) v[2]; |
| 696 | params[3] = (GLint) v[3]; |
| 697 | } |
| 698 | } |
| 699 | else { |
| 700 | params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname, |
| 701 | "glGetVertexAttribiv"); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | |
| 706 | /** GL 3.0 */ |
| 707 | void GLAPIENTRY |
| 708 | _mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params) |
| 709 | { |
| 710 | GET_CURRENT_CONTEXT(ctx); |
| 711 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 712 | |
| 713 | if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 714 | const GLfloat *v = |
| 715 | get_current_attrib(ctx, index, "glGetVertexAttribIiv"); |
| 716 | if (v != NULL) { |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 717 | /* XXX we don't have true integer-valued vertex attribs yet */ |
| 718 | params[0] = (GLint) v[0]; |
| 719 | params[1] = (GLint) v[1]; |
| 720 | params[2] = (GLint) v[2]; |
| 721 | params[3] = (GLint) v[3]; |
| 722 | } |
| 723 | } |
| 724 | else { |
| 725 | params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname, |
| 726 | "glGetVertexAttribIiv"); |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | |
| 731 | /** GL 3.0 */ |
| 732 | void GLAPIENTRY |
| 733 | _mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) |
| 734 | { |
| 735 | GET_CURRENT_CONTEXT(ctx); |
| 736 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 737 | |
| 738 | if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { |
Ian Romanick | 5c3f1cd | 2011-02-03 17:56:44 -0800 | [diff] [blame] | 739 | const GLfloat *v = |
| 740 | get_current_attrib(ctx, index, "glGetVertexAttribIuiv"); |
| 741 | if (v != NULL) { |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 742 | /* XXX we don't have true integer-valued vertex attribs yet */ |
| 743 | params[0] = (GLuint) v[0]; |
| 744 | params[1] = (GLuint) v[1]; |
| 745 | params[2] = (GLuint) v[2]; |
| 746 | params[3] = (GLuint) v[3]; |
| 747 | } |
| 748 | } |
| 749 | else { |
| 750 | params[0] = get_vertex_array_attrib(ctx, index, pname, |
| 751 | "glGetVertexAttribIuiv"); |
| 752 | } |
| 753 | } |
| 754 | |
| 755 | |
| 756 | void GLAPIENTRY |
| 757 | _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer) |
| 758 | { |
| 759 | GET_CURRENT_CONTEXT(ctx); |
| 760 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 761 | |
| 762 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
| 763 | _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)"); |
| 764 | return; |
| 765 | } |
| 766 | |
| 767 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) { |
| 768 | _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerARB(pname)"); |
| 769 | return; |
| 770 | } |
| 771 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 772 | ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 773 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 774 | *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr; |
Brian Paul | d3f598a | 2010-05-25 21:42:13 -0600 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | |
| 778 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 779 | _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, |
| 780 | GLsizei count, const GLvoid *ptr) |
| 781 | { |
| 782 | (void) count; |
| 783 | _mesa_VertexPointer(size, type, stride, ptr); |
| 784 | } |
| 785 | |
| 786 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 787 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 788 | _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, |
| 789 | const GLvoid *ptr) |
| 790 | { |
| 791 | (void) count; |
| 792 | _mesa_NormalPointer(type, stride, ptr); |
| 793 | } |
| 794 | |
| 795 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 796 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 797 | _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, |
| 798 | const GLvoid *ptr) |
| 799 | { |
| 800 | (void) count; |
| 801 | _mesa_ColorPointer(size, type, stride, ptr); |
| 802 | } |
| 803 | |
| 804 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 805 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 806 | _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, |
| 807 | const GLvoid *ptr) |
| 808 | { |
| 809 | (void) count; |
| 810 | _mesa_IndexPointer(type, stride, ptr); |
| 811 | } |
| 812 | |
| 813 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 814 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 815 | _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, |
| 816 | GLsizei count, const GLvoid *ptr) |
| 817 | { |
| 818 | (void) count; |
| 819 | _mesa_TexCoordPointer(size, type, stride, ptr); |
| 820 | } |
| 821 | |
| 822 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 823 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 824 | _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) |
| 825 | { |
| 826 | (void) count; |
| 827 | _mesa_EdgeFlagPointer(stride, ptr); |
| 828 | } |
| 829 | |
| 830 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 831 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 832 | _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 833 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 834 | GET_CURRENT_CONTEXT(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 835 | GLboolean tflag, cflag, nflag; /* enable/disable flags */ |
| 836 | GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ |
Keith Whitwell | f4b02d1 | 2001-01-05 05:31:42 +0000 | [diff] [blame] | 837 | GLenum ctype = 0; /* color type */ |
| 838 | GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 839 | const GLint toffset = 0; /* always zero */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 840 | GLint defstride; /* default stride */ |
| 841 | GLint c, f; |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 842 | |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 843 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 844 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 845 | f = sizeof(GLfloat); |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 846 | c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 847 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 848 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 849 | _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 850 | return; |
| 851 | } |
| 852 | |
| 853 | switch (format) { |
| 854 | case GL_V2F: |
| 855 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 856 | tcomps = 0; ccomps = 0; vcomps = 2; |
| 857 | voffset = 0; |
| 858 | defstride = 2*f; |
| 859 | break; |
| 860 | case GL_V3F: |
| 861 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 862 | tcomps = 0; ccomps = 0; vcomps = 3; |
| 863 | voffset = 0; |
| 864 | defstride = 3*f; |
| 865 | break; |
| 866 | case GL_C4UB_V2F: |
| 867 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 868 | tcomps = 0; ccomps = 4; vcomps = 2; |
| 869 | ctype = GL_UNSIGNED_BYTE; |
| 870 | coffset = 0; |
| 871 | voffset = c; |
| 872 | defstride = c + 2*f; |
| 873 | break; |
| 874 | case GL_C4UB_V3F: |
| 875 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 876 | tcomps = 0; ccomps = 4; vcomps = 3; |
| 877 | ctype = GL_UNSIGNED_BYTE; |
| 878 | coffset = 0; |
| 879 | voffset = c; |
| 880 | defstride = c + 3*f; |
| 881 | break; |
| 882 | case GL_C3F_V3F: |
| 883 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 884 | tcomps = 0; ccomps = 3; vcomps = 3; |
| 885 | ctype = GL_FLOAT; |
| 886 | coffset = 0; |
| 887 | voffset = 3*f; |
| 888 | defstride = 6*f; |
| 889 | break; |
| 890 | case GL_N3F_V3F: |
| 891 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; |
| 892 | tcomps = 0; ccomps = 0; vcomps = 3; |
| 893 | noffset = 0; |
| 894 | voffset = 3*f; |
| 895 | defstride = 6*f; |
| 896 | break; |
| 897 | case GL_C4F_N3F_V3F: |
| 898 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 899 | tcomps = 0; ccomps = 4; vcomps = 3; |
| 900 | ctype = GL_FLOAT; |
| 901 | coffset = 0; |
| 902 | noffset = 4*f; |
| 903 | voffset = 7*f; |
| 904 | defstride = 10*f; |
| 905 | break; |
| 906 | case GL_T2F_V3F: |
| 907 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 908 | tcomps = 2; ccomps = 0; vcomps = 3; |
| 909 | voffset = 2*f; |
| 910 | defstride = 5*f; |
| 911 | break; |
| 912 | case GL_T4F_V4F: |
| 913 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 914 | tcomps = 4; ccomps = 0; vcomps = 4; |
| 915 | voffset = 4*f; |
| 916 | defstride = 8*f; |
| 917 | break; |
| 918 | case GL_T2F_C4UB_V3F: |
| 919 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 920 | tcomps = 2; ccomps = 4; vcomps = 3; |
| 921 | ctype = GL_UNSIGNED_BYTE; |
| 922 | coffset = 2*f; |
| 923 | voffset = c+2*f; |
| 924 | defstride = c+5*f; |
| 925 | break; |
| 926 | case GL_T2F_C3F_V3F: |
| 927 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 928 | tcomps = 2; ccomps = 3; vcomps = 3; |
| 929 | ctype = GL_FLOAT; |
| 930 | coffset = 2*f; |
| 931 | voffset = 5*f; |
| 932 | defstride = 8*f; |
| 933 | break; |
| 934 | case GL_T2F_N3F_V3F: |
| 935 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; |
| 936 | tcomps = 2; ccomps = 0; vcomps = 3; |
| 937 | noffset = 2*f; |
| 938 | voffset = 5*f; |
| 939 | defstride = 8*f; |
| 940 | break; |
| 941 | case GL_T2F_C4F_N3F_V3F: |
| 942 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 943 | tcomps = 2; ccomps = 4; vcomps = 3; |
| 944 | ctype = GL_FLOAT; |
| 945 | coffset = 2*f; |
| 946 | noffset = 6*f; |
| 947 | voffset = 9*f; |
| 948 | defstride = 12*f; |
| 949 | break; |
| 950 | case GL_T4F_C4F_N3F_V4F: |
| 951 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 952 | tcomps = 4; ccomps = 4; vcomps = 4; |
| 953 | ctype = GL_FLOAT; |
| 954 | coffset = 4*f; |
| 955 | noffset = 8*f; |
| 956 | voffset = 11*f; |
| 957 | defstride = 15*f; |
| 958 | break; |
| 959 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 960 | _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 961 | return; |
| 962 | } |
| 963 | |
| 964 | if (stride==0) { |
| 965 | stride = defstride; |
| 966 | } |
| 967 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 968 | _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); |
| 969 | _mesa_DisableClientState( GL_INDEX_ARRAY ); |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 970 | /* XXX also disable secondary color and generic arrays? */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 971 | |
| 972 | /* Texcoords */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 973 | if (tflag) { |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 974 | _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); |
| 975 | _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, |
Brian Paul | ab928e5 | 2004-03-10 16:17:35 +0000 | [diff] [blame] | 976 | (GLubyte *) pointer + toffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 977 | } |
| 978 | else { |
Brian Paul | ab928e5 | 2004-03-10 16:17:35 +0000 | [diff] [blame] | 979 | _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 980 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 981 | |
| 982 | /* Color */ |
| 983 | if (cflag) { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 984 | _mesa_EnableClientState( GL_COLOR_ARRAY ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 985 | _mesa_ColorPointer( ccomps, ctype, stride, |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 986 | (GLubyte *) pointer + coffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 987 | } |
| 988 | else { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 989 | _mesa_DisableClientState( GL_COLOR_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | |
| 993 | /* Normals */ |
| 994 | if (nflag) { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 995 | _mesa_EnableClientState( GL_NORMAL_ARRAY ); |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 996 | _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 997 | } |
| 998 | else { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 999 | _mesa_DisableClientState( GL_NORMAL_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1000 | } |
| 1001 | |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 1002 | /* Vertices */ |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1003 | _mesa_EnableClientState( GL_VERTEX_ARRAY ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1004 | _mesa_VertexPointer( vcomps, GL_FLOAT, stride, |
| 1005 | (GLubyte *) pointer + voffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1009 | void GLAPIENTRY |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1010 | _mesa_LockArraysEXT(GLint first, GLsizei count) |
| 1011 | { |
| 1012 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1013 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1014 | |
| 1015 | if (MESA_VERBOSE & VERBOSE_API) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 1016 | _mesa_debug(ctx, "glLockArrays %d %d\n", first, count); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1017 | |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 1018 | if (first < 0) { |
| 1019 | _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" ); |
| 1020 | return; |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 1021 | } |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 1022 | if (count <= 0) { |
| 1023 | _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" ); |
| 1024 | return; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1025 | } |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 1026 | if (ctx->Array.LockCount != 0) { |
| 1027 | _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" ); |
| 1028 | return; |
| 1029 | } |
| 1030 | |
| 1031 | ctx->Array.LockFirst = first; |
| 1032 | ctx->Array.LockCount = count; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1033 | |
| 1034 | ctx->NewState |= _NEW_ARRAY; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1038 | void GLAPIENTRY |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1039 | _mesa_UnlockArraysEXT( void ) |
| 1040 | { |
| 1041 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1042 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1043 | |
| 1044 | if (MESA_VERBOSE & VERBOSE_API) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 1045 | _mesa_debug(ctx, "glUnlockArrays\n"); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1046 | |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 1047 | if (ctx->Array.LockCount == 0) { |
| 1048 | _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" ); |
| 1049 | return; |
| 1050 | } |
| 1051 | |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1052 | ctx->Array.LockFirst = 0; |
| 1053 | ctx->Array.LockCount = 0; |
| 1054 | ctx->NewState |= _NEW_ARRAY; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 1055 | } |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 1056 | |
| 1057 | |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 1058 | /* GL_EXT_multi_draw_arrays */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1059 | void GLAPIENTRY |
Brian Paul | 7993832 | 2010-09-14 09:37:35 -0600 | [diff] [blame] | 1060 | _mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, |
| 1061 | const GLsizei *count, GLsizei primcount ) |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 1062 | { |
| 1063 | GET_CURRENT_CONTEXT(ctx); |
| 1064 | GLint i; |
| 1065 | |
| 1066 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1067 | |
| 1068 | for (i = 0; i < primcount; i++) { |
| 1069 | if (count[i] > 0) { |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 1070 | CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i])); |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1076 | /* GL_IBM_multimode_draw_arrays */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1077 | void GLAPIENTRY |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1078 | _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, |
| 1079 | const GLsizei * count, |
| 1080 | GLsizei primcount, GLint modestride ) |
| 1081 | { |
| 1082 | GET_CURRENT_CONTEXT(ctx); |
| 1083 | GLint i; |
| 1084 | |
| 1085 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1086 | |
| 1087 | for ( i = 0 ; i < primcount ; i++ ) { |
| 1088 | if ( count[i] > 0 ) { |
Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 1089 | GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 1090 | CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] )); |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1091 | } |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | |
| 1096 | /* GL_IBM_multimode_draw_arrays */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1097 | void GLAPIENTRY |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1098 | _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, |
| 1099 | GLenum type, const GLvoid * const * indices, |
| 1100 | GLsizei primcount, GLint modestride ) |
| 1101 | { |
| 1102 | GET_CURRENT_CONTEXT(ctx); |
| 1103 | GLint i; |
| 1104 | |
| 1105 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1106 | |
Brian Paul | d2afb39 | 2003-09-17 18:15:13 +0000 | [diff] [blame] | 1107 | /* XXX not sure about ARB_vertex_buffer_object handling here */ |
| 1108 | |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1109 | for ( i = 0 ; i < primcount ; i++ ) { |
| 1110 | if ( count[i] > 0 ) { |
Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 1111 | GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 1112 | CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] )); |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1113 | } |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 1118 | /** |
Brian Paul | 7f26ad8 | 2010-10-21 19:03:38 -0600 | [diff] [blame] | 1119 | * GL_NV_primitive_restart and GL 3.1 |
Brian Paul | a40e6f2 | 2010-04-20 21:02:09 -0600 | [diff] [blame] | 1120 | */ |
| 1121 | void GLAPIENTRY |
| 1122 | _mesa_PrimitiveRestartIndex(GLuint index) |
| 1123 | { |
| 1124 | GET_CURRENT_CONTEXT(ctx); |
| 1125 | |
Eric Anholt | 9c1b418 | 2012-07-26 14:43:56 -0700 | [diff] [blame] | 1126 | if (!ctx->Extensions.NV_primitive_restart && ctx->Version < 31) { |
Brian Paul | 7f26ad8 | 2010-10-21 19:03:38 -0600 | [diff] [blame] | 1127 | _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartIndexNV()"); |
Brian Paul | a40e6f2 | 2010-04-20 21:02:09 -0600 | [diff] [blame] | 1128 | return; |
| 1129 | } |
| 1130 | |
Brian Paul | d2003ee | 2012-02-19 19:50:32 -0700 | [diff] [blame] | 1131 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
Brian Paul | a40e6f2 | 2010-04-20 21:02:09 -0600 | [diff] [blame] | 1132 | |
Brian Paul | d2003ee | 2012-02-19 19:50:32 -0700 | [diff] [blame] | 1133 | if (ctx->Array.RestartIndex != index) { |
| 1134 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
| 1135 | ctx->Array.RestartIndex = index; |
| 1136 | } |
Brian Paul | a40e6f2 | 2010-04-20 21:02:09 -0600 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | |
| 1140 | /** |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 1141 | * See GL_ARB_instanced_arrays. |
| 1142 | * Note that the instance divisor only applies to generic arrays, not |
| 1143 | * the legacy vertex arrays. |
| 1144 | */ |
| 1145 | void GLAPIENTRY |
| 1146 | _mesa_VertexAttribDivisor(GLuint index, GLuint divisor) |
| 1147 | { |
Brian Paul | 738482e | 2012-02-27 20:28:09 -0700 | [diff] [blame] | 1148 | struct gl_client_array *array; |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 1149 | GET_CURRENT_CONTEXT(ctx); |
Brian Paul | 738482e | 2012-02-27 20:28:09 -0700 | [diff] [blame] | 1150 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 1151 | |
| 1152 | if (!ctx->Extensions.ARB_instanced_arrays) { |
| 1153 | _mesa_error(ctx, GL_INVALID_OPERATION, "glVertexAttribDivisor()"); |
| 1154 | return; |
| 1155 | } |
| 1156 | |
| 1157 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
| 1158 | _mesa_error(ctx, GL_INVALID_ENUM, "glVertexAttribDivisor(index = %u)", |
| 1159 | index); |
| 1160 | return; |
| 1161 | } |
| 1162 | |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 1163 | ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); |
| 1164 | |
Brian Paul | 738482e | 2012-02-27 20:28:09 -0700 | [diff] [blame] | 1165 | array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)]; |
| 1166 | if (array->InstanceDivisor != divisor) { |
| 1167 | FLUSH_VERTICES(ctx, _NEW_ARRAY); |
| 1168 | array->InstanceDivisor = divisor; |
Brian Paul | b0e048f | 2012-04-18 10:47:10 -0600 | [diff] [blame] | 1169 | ctx->Array.ArrayObj->NewArrays |= VERT_BIT(VERT_ATTRIB_GENERIC(index)); |
Brian Paul | 738482e | 2012-02-27 20:28:09 -0700 | [diff] [blame] | 1170 | } |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 1171 | } |
| 1172 | |
| 1173 | |
| 1174 | |
| 1175 | /** |
Brian Paul | b288540 | 2009-08-06 13:53:06 -0600 | [diff] [blame] | 1176 | * Copy one client vertex array to another. |
| 1177 | */ |
| 1178 | void |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 1179 | _mesa_copy_client_array(struct gl_context *ctx, |
Brian Paul | b288540 | 2009-08-06 13:53:06 -0600 | [diff] [blame] | 1180 | struct gl_client_array *dst, |
| 1181 | struct gl_client_array *src) |
| 1182 | { |
| 1183 | dst->Size = src->Size; |
| 1184 | dst->Type = src->Type; |
| 1185 | dst->Format = src->Format; |
| 1186 | dst->Stride = src->Stride; |
| 1187 | dst->StrideB = src->StrideB; |
| 1188 | dst->Ptr = src->Ptr; |
| 1189 | dst->Enabled = src->Enabled; |
| 1190 | dst->Normalized = src->Normalized; |
Brian Paul | d1184d2 | 2010-10-28 21:17:41 -0600 | [diff] [blame] | 1191 | dst->Integer = src->Integer; |
Brian Paul | 1d1eb95 | 2011-01-15 10:32:34 -0700 | [diff] [blame] | 1192 | dst->InstanceDivisor = src->InstanceDivisor; |
Brian Paul | b288540 | 2009-08-06 13:53:06 -0600 | [diff] [blame] | 1193 | dst->_ElementSize = src->_ElementSize; |
| 1194 | _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); |
| 1195 | dst->_MaxElement = src->_MaxElement; |
| 1196 | } |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | /** |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1201 | * Print vertex array's fields. |
| 1202 | */ |
| 1203 | static void |
| 1204 | print_array(const char *name, GLint index, const struct gl_client_array *array) |
| 1205 | { |
| 1206 | if (index >= 0) |
Kristian Høgsberg | 298be2b | 2010-02-19 12:32:24 -0500 | [diff] [blame] | 1207 | printf(" %s[%d]: ", name, index); |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1208 | else |
Kristian Høgsberg | 298be2b | 2010-02-19 12:32:24 -0500 | [diff] [blame] | 1209 | printf(" %s: ", name); |
Brian Paul | 4beea12 | 2010-07-14 14:36:25 -0600 | [diff] [blame] | 1210 | printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu), MaxElem=%u\n", |
Kristian Høgsberg | 298be2b | 2010-02-19 12:32:24 -0500 | [diff] [blame] | 1211 | array->Ptr, array->Type, array->Size, |
| 1212 | array->_ElementSize, array->StrideB, |
Brian Paul | 4beea12 | 2010-07-14 14:36:25 -0600 | [diff] [blame] | 1213 | array->BufferObj->Name, (unsigned long) array->BufferObj->Size, |
Kristian Høgsberg | 298be2b | 2010-02-19 12:32:24 -0500 | [diff] [blame] | 1214 | array->_MaxElement); |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1215 | } |
| 1216 | |
| 1217 | |
| 1218 | /** |
| 1219 | * Print current vertex object/array info. For debug. |
| 1220 | */ |
| 1221 | void |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 1222 | _mesa_print_arrays(struct gl_context *ctx) |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1223 | { |
Brian Paul | 6a2211f | 2009-05-21 15:55:50 -0600 | [diff] [blame] | 1224 | struct gl_array_object *arrayObj = ctx->Array.ArrayObj; |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1225 | GLuint i; |
| 1226 | |
Brian Paul | 8fe3134 | 2009-05-21 15:36:25 -0600 | [diff] [blame] | 1227 | _mesa_update_array_object_max_element(ctx, arrayObj); |
| 1228 | |
Kristian Høgsberg | 298be2b | 2010-02-19 12:32:24 -0500 | [diff] [blame] | 1229 | printf("Array Object %u\n", arrayObj->Name); |
Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 1230 | if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) |
| 1231 | print_array("Vertex", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]); |
| 1232 | if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) |
| 1233 | print_array("Normal", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); |
| 1234 | if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) |
| 1235 | print_array("Color", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); |
| 1236 | for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) |
| 1237 | if (arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled) |
| 1238 | print_array("TexCoord", i, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]); |
| 1239 | for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) |
| 1240 | if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) |
| 1241 | print_array("Attrib", i, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]); |
Kristian Høgsberg | 298be2b | 2010-02-19 12:32:24 -0500 | [diff] [blame] | 1242 | printf(" _MaxElement = %u\n", arrayObj->_MaxElement); |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | |
| 1246 | /** |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 1247 | * Initialize vertex array state for given context. |
| 1248 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1249 | void |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 1250 | _mesa_init_varray(struct gl_context *ctx) |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1251 | { |
Mathias Fröhlich | 86f53e6 | 2011-11-02 19:54:26 +0100 | [diff] [blame] | 1252 | ctx->Array.DefaultArrayObj = ctx->Driver.NewArrayObject(ctx, 0); |
Brian Paul | 1030bf0 | 2009-05-07 13:52:26 -0600 | [diff] [blame] | 1253 | _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, |
| 1254 | ctx->Array.DefaultArrayObj); |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 1255 | ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */ |
Brian Paul | 12cf98f | 2009-06-19 17:58:47 -0600 | [diff] [blame] | 1256 | |
| 1257 | ctx->Array.Objects = _mesa_NewHashTable(); |
| 1258 | } |
| 1259 | |
| 1260 | |
| 1261 | /** |
| 1262 | * Callback for deleting an array object. Called by _mesa_HashDeleteAll(). |
| 1263 | */ |
| 1264 | static void |
| 1265 | delete_arrayobj_cb(GLuint id, void *data, void *userData) |
| 1266 | { |
| 1267 | struct gl_array_object *arrayObj = (struct gl_array_object *) data; |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 1268 | struct gl_context *ctx = (struct gl_context *) userData; |
Brian Paul | 12cf98f | 2009-06-19 17:58:47 -0600 | [diff] [blame] | 1269 | _mesa_delete_array_object(ctx, arrayObj); |
| 1270 | } |
| 1271 | |
| 1272 | |
| 1273 | /** |
| 1274 | * Free vertex array state for given context. |
| 1275 | */ |
| 1276 | void |
Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 1277 | _mesa_free_varray_data(struct gl_context *ctx) |
Brian Paul | 12cf98f | 2009-06-19 17:58:47 -0600 | [diff] [blame] | 1278 | { |
| 1279 | _mesa_HashDeleteAll(ctx->Array.Objects, delete_arrayobj_cb, ctx); |
| 1280 | _mesa_DeleteHashTable(ctx->Array.Objects); |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1281 | } |