| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
| Brian | a3c3bc9 | 2007-08-20 12:55:34 +0100 | [diff] [blame] | 3 | * Version: 7.1 |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 4 | * |
| Brian | 37ece4d | 2007-07-08 09:20:42 -0600 | [diff] [blame] | 5 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 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 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 21 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include "glheader.h" |
| Brian Paul | 8446d1b | 2001-01-02 21:40:57 +0000 | [diff] [blame] | 26 | #include "api_validate.h" |
| Brian Paul | 434ec3a | 2009-08-12 13:46:16 -0600 | [diff] [blame] | 27 | #include "bufferobj.h" |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 28 | #include "context.h" |
| Brian Paul | 3c63452 | 2002-10-24 23:57:19 +0000 | [diff] [blame] | 29 | #include "imports.h" |
| Vinson Lee | 6bf0ac0 | 2010-11-06 21:13:40 -0700 | [diff] [blame] | 30 | #include "mfeatures.h" |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 31 | #include "mtypes.h" |
| Eric Anholt | 56118ef | 2012-03-14 14:44:22 -0700 | [diff] [blame] | 32 | #include "enums.h" |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 33 | #include "vbo/vbo.h" |
| Keith Whitwell | 58e9917 | 2001-01-05 02:26:48 +0000 | [diff] [blame] | 34 | |
| Brian Paul | bb1fb2a | 2009-05-06 12:37:10 -0600 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * \return number of bytes in array [count] of type. |
| 38 | */ |
| 39 | static GLsizei |
| 40 | index_bytes(GLenum type, GLsizei count) |
| 41 | { |
| 42 | if (type == GL_UNSIGNED_INT) { |
| 43 | return count * sizeof(GLuint); |
| 44 | } |
| 45 | else if (type == GL_UNSIGNED_BYTE) { |
| 46 | return count * sizeof(GLubyte); |
| 47 | } |
| 48 | else { |
| 49 | ASSERT(type == GL_UNSIGNED_SHORT); |
| 50 | return count * sizeof(GLushort); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | |
| Brian | d8c6719 | 2007-08-20 13:12:20 +0100 | [diff] [blame] | 55 | /** |
| Brian Paul | e5d29eb | 2009-09-21 14:07:35 -0600 | [diff] [blame] | 56 | * Find the max index in the given element/index buffer |
| 57 | */ |
| 58 | GLuint |
| Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 59 | _mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, |
| Brian Paul | e5d29eb | 2009-09-21 14:07:35 -0600 | [diff] [blame] | 60 | const void *indices, |
| 61 | struct gl_buffer_object *elementBuf) |
| 62 | { |
| 63 | const GLubyte *map = NULL; |
| 64 | GLuint max = 0; |
| 65 | GLuint i; |
| 66 | |
| 67 | if (_mesa_is_bufferobj(elementBuf)) { |
| 68 | /* elements are in a user-defined buffer object. need to map it */ |
| Ian Romanick | 28249bd | 2011-08-21 18:34:27 -0700 | [diff] [blame] | 69 | map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size, |
| 70 | GL_MAP_READ_BIT, elementBuf); |
| Brian Paul | e5d29eb | 2009-09-21 14:07:35 -0600 | [diff] [blame] | 71 | /* Actual address is the sum of pointers */ |
| 72 | indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); |
| 73 | } |
| 74 | |
| 75 | if (type == GL_UNSIGNED_INT) { |
| 76 | for (i = 0; i < count; i++) |
| 77 | if (((GLuint *) indices)[i] > max) |
| 78 | max = ((GLuint *) indices)[i]; |
| 79 | } |
| 80 | else if (type == GL_UNSIGNED_SHORT) { |
| 81 | for (i = 0; i < count; i++) |
| 82 | if (((GLushort *) indices)[i] > max) |
| 83 | max = ((GLushort *) indices)[i]; |
| 84 | } |
| 85 | else { |
| 86 | ASSERT(type == GL_UNSIGNED_BYTE); |
| 87 | for (i = 0; i < count; i++) |
| 88 | if (((GLubyte *) indices)[i] > max) |
| 89 | max = ((GLubyte *) indices)[i]; |
| 90 | } |
| 91 | |
| 92 | if (map) { |
| Ian Romanick | 56f0c00 | 2011-08-21 16:59:30 -0700 | [diff] [blame] | 93 | ctx->Driver.UnmapBuffer(ctx, elementBuf); |
| Brian Paul | e5d29eb | 2009-09-21 14:07:35 -0600 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | return max; |
| 97 | } |
| 98 | |
| 99 | |
| 100 | /** |
| Brian Paul | b6e5600 | 2009-08-14 10:48:31 -0600 | [diff] [blame] | 101 | * Check if OK to draw arrays/elements. |
| Brian Paul | 88af3f8 | 2009-05-06 12:27:38 -0600 | [diff] [blame] | 102 | */ |
| Alan Hourihane | 263b96e | 2009-01-15 11:51:39 +0000 | [diff] [blame] | 103 | static GLboolean |
| Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 104 | check_valid_to_render(struct gl_context *ctx, const char *function) |
| Alan Hourihane | 263b96e | 2009-01-15 11:51:39 +0000 | [diff] [blame] | 105 | { |
| Brian Paul | b6e5600 | 2009-08-14 10:48:31 -0600 | [diff] [blame] | 106 | if (!_mesa_valid_to_render(ctx, function)) { |
| Alan Hourihane | 263b96e | 2009-01-15 11:51:39 +0000 | [diff] [blame] | 107 | return GL_FALSE; |
| 108 | } |
| 109 | |
| Kristian Høgsberg | f67b020 | 2010-05-24 10:01:38 -0400 | [diff] [blame] | 110 | switch (ctx->API) { |
| Brian Paul | 97dd2dd | 2009-03-02 12:27:16 -0700 | [diff] [blame] | 111 | #if FEATURE_es2_glsl |
| Kristian Høgsberg | f67b020 | 2010-05-24 10:01:38 -0400 | [diff] [blame] | 112 | case API_OPENGLES2: |
| 113 | /* For ES2, we can draw if any vertex array is enabled (and we |
| 114 | * should always have a vertex program/shader). */ |
| 115 | if (ctx->Array.ArrayObj->_Enabled == 0x0 || !ctx->VertexProgram._Current) |
| 116 | return GL_FALSE; |
| 117 | break; |
| Brian Paul | 97dd2dd | 2009-03-02 12:27:16 -0700 | [diff] [blame] | 118 | #endif |
| Alan Hourihane | 263b96e | 2009-01-15 11:51:39 +0000 | [diff] [blame] | 119 | |
| Brian Paul | 43bdabd | 2011-05-18 16:19:06 -0600 | [diff] [blame] | 120 | #if FEATURE_ES1 |
| Kristian Høgsberg | f67b020 | 2010-05-24 10:01:38 -0400 | [diff] [blame] | 121 | case API_OPENGLES: |
| Brian Paul | 43bdabd | 2011-05-18 16:19:06 -0600 | [diff] [blame] | 122 | /* For OpenGL ES, only draw if we have vertex positions |
| 123 | */ |
| Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 124 | if (!ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) |
| Kristian Høgsberg | f67b020 | 2010-05-24 10:01:38 -0400 | [diff] [blame] | 125 | return GL_FALSE; |
| 126 | break; |
| 127 | #endif |
| 128 | |
| Brian Paul | 43bdabd | 2011-05-18 16:19:06 -0600 | [diff] [blame] | 129 | #if FEATURE_GL |
| 130 | case API_OPENGL: |
| Jordan Justen | 09714c0 | 2012-07-19 11:27:16 -0700 | [diff] [blame^] | 131 | case API_OPENGL_CORE: |
| Brian Paul | 43bdabd | 2011-05-18 16:19:06 -0600 | [diff] [blame] | 132 | { |
| 133 | const struct gl_shader_program *vsProg = |
| 134 | ctx->Shader.CurrentVertexProgram; |
| 135 | GLboolean haveVertexShader = (vsProg && vsProg->LinkStatus); |
| 136 | GLboolean haveVertexProgram = ctx->VertexProgram._Enabled; |
| 137 | if (haveVertexShader || haveVertexProgram) { |
| 138 | /* Draw regardless of whether or not we have any vertex arrays. |
| 139 | * (Ex: could draw a point using a constant vertex pos) |
| 140 | */ |
| 141 | return GL_TRUE; |
| 142 | } |
| 143 | else { |
| 144 | /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic |
| 145 | * array [0]). |
| 146 | */ |
| Mathias Fröhlich | 762c976 | 2011-10-31 22:23:51 +0100 | [diff] [blame] | 147 | return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled || |
| 148 | ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled); |
| Brian Paul | 43bdabd | 2011-05-18 16:19:06 -0600 | [diff] [blame] | 149 | } |
| 150 | } |
| 151 | break; |
| 152 | #endif |
| 153 | |
| Kristian Høgsberg | f67b020 | 2010-05-24 10:01:38 -0400 | [diff] [blame] | 154 | default: |
| 155 | ASSERT_NO_FEATURE(); |
| 156 | } |
| 157 | |
| Alan Hourihane | 263b96e | 2009-01-15 11:51:39 +0000 | [diff] [blame] | 158 | return GL_TRUE; |
| 159 | } |
| Brian | d8c6719 | 2007-08-20 13:12:20 +0100 | [diff] [blame] | 160 | |
| Brian Paul | e9968eb | 2010-03-05 12:32:32 -0700 | [diff] [blame] | 161 | |
| 162 | /** |
| 163 | * Do bounds checking on array element indexes. Check that the vertices |
| 164 | * pointed to by the indices don't lie outside buffer object bounds. |
| 165 | * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds |
| 166 | */ |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 167 | static GLboolean |
| Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 168 | check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type, |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 169 | const GLvoid *indices, GLint basevertex) |
| 170 | { |
| 171 | struct _mesa_prim prim; |
| 172 | struct _mesa_index_buffer ib; |
| 173 | GLuint min, max; |
| 174 | |
| 175 | /* Only the X Server needs to do this -- otherwise, accessing outside |
| 176 | * array/BO bounds allows application termination. |
| 177 | */ |
| 178 | if (!ctx->Const.CheckArrayBounds) |
| 179 | return GL_TRUE; |
| 180 | |
| 181 | memset(&prim, 0, sizeof(prim)); |
| 182 | prim.count = count; |
| 183 | |
| 184 | memset(&ib, 0, sizeof(ib)); |
| 185 | ib.type = type; |
| 186 | ib.ptr = indices; |
| Yuanhan Liu | a0a5bd4 | 2011-11-23 15:59:06 +0800 | [diff] [blame] | 187 | ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj; |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 188 | |
| Yuanhan Liu | 42d4972 | 2011-12-31 14:22:46 +0800 | [diff] [blame] | 189 | vbo_get_minmax_indices(ctx, &prim, &ib, &min, &max, 1); |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 190 | |
| Michel Dänzer | 391b396 | 2010-03-05 00:15:40 +0100 | [diff] [blame] | 191 | if ((int)(min + basevertex) < 0 || |
| Roland Scheidegger | 1f4a853 | 2012-02-06 01:04:28 +0100 | [diff] [blame] | 192 | max + basevertex >= ctx->Array.ArrayObj->_MaxElement) { |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 193 | /* the max element is out of bounds of one or more enabled arrays */ |
| Brian Paul | e9968eb | 2010-03-05 12:32:32 -0700 | [diff] [blame] | 194 | _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)", |
| 195 | max, ctx->Array.ArrayObj->_MaxElement); |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 196 | return GL_FALSE; |
| 197 | } |
| 198 | |
| 199 | return GL_TRUE; |
| 200 | } |
| Brian Paul | 88af3f8 | 2009-05-06 12:27:38 -0600 | [diff] [blame] | 201 | |
| Brian Paul | e9968eb | 2010-03-05 12:32:32 -0700 | [diff] [blame] | 202 | |
| Brian Paul | 88af3f8 | 2009-05-06 12:27:38 -0600 | [diff] [blame] | 203 | /** |
| Brian Paul | 0e6646d | 2011-09-21 08:22:07 -0600 | [diff] [blame] | 204 | * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(), |
| 205 | * etc? The set of legal values depends on whether geometry shaders/programs |
| 206 | * are supported. |
| 207 | */ |
| 208 | GLboolean |
| Eric Anholt | 7ca4f07 | 2012-03-14 14:39:15 -0700 | [diff] [blame] | 209 | _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) |
| Brian Paul | 0e6646d | 2011-09-21 08:22:07 -0600 | [diff] [blame] | 210 | { |
| 211 | if (ctx->Extensions.ARB_geometry_shader4 && |
| 212 | mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { |
| Eric Anholt | 7ca4f07 | 2012-03-14 14:39:15 -0700 | [diff] [blame] | 213 | _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode); |
| Brian Paul | 0e6646d | 2011-09-21 08:22:07 -0600 | [diff] [blame] | 214 | return GL_FALSE; |
| 215 | } |
| 216 | else if (mode > GL_POLYGON) { |
| Eric Anholt | 7ca4f07 | 2012-03-14 14:39:15 -0700 | [diff] [blame] | 217 | _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode); |
| Brian Paul | 0e6646d | 2011-09-21 08:22:07 -0600 | [diff] [blame] | 218 | return GL_FALSE; |
| 219 | } |
| Eric Anholt | 56118ef | 2012-03-14 14:44:22 -0700 | [diff] [blame] | 220 | |
| 221 | /* From the GL_EXT_transform_feedback spec: |
| 222 | * |
| 223 | * "The error INVALID_OPERATION is generated if Begin, or any command |
| 224 | * that performs an explicit Begin, is called when: |
| 225 | * |
| 226 | * * a geometry shader is not active and <mode> does not match the |
| 227 | * allowed begin modes for the current transform feedback state as |
| 228 | * given by table X.1. |
| 229 | * |
| 230 | * * a geometry shader is active and the output primitive type of the |
| 231 | * geometry shader does not match the allowed begin modes for the |
| 232 | * current transform feedback state as given by table X.1. |
| 233 | * |
| 234 | */ |
| 235 | if (ctx->TransformFeedback.CurrentObject->Active && |
| 236 | !ctx->TransformFeedback.CurrentObject->Paused) { |
| 237 | GLboolean pass = GL_TRUE; |
| 238 | |
| 239 | switch (mode) { |
| 240 | case GL_POINTS: |
| 241 | pass = ctx->TransformFeedback.Mode == GL_POINTS; |
| 242 | break; |
| 243 | case GL_LINES: |
| 244 | case GL_LINE_STRIP: |
| 245 | case GL_LINE_LOOP: |
| 246 | pass = ctx->TransformFeedback.Mode == GL_LINES; |
| 247 | break; |
| 248 | default: |
| 249 | pass = ctx->TransformFeedback.Mode == GL_TRIANGLES; |
| 250 | break; |
| 251 | } |
| 252 | if (!pass) { |
| 253 | _mesa_error(ctx, GL_INVALID_OPERATION, |
| 254 | "%s(mode=%s vs transform feedback %s)", |
| 255 | name, |
| 256 | _mesa_lookup_prim_by_nr(mode), |
| 257 | _mesa_lookup_prim_by_nr(ctx->TransformFeedback.Mode)); |
| 258 | return GL_FALSE; |
| 259 | } |
| Brian Paul | 0e6646d | 2011-09-21 08:22:07 -0600 | [diff] [blame] | 260 | } |
| Eric Anholt | 56118ef | 2012-03-14 14:44:22 -0700 | [diff] [blame] | 261 | |
| 262 | return GL_TRUE; |
| Brian Paul | 0e6646d | 2011-09-21 08:22:07 -0600 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | |
| 266 | /** |
| Brian Paul | 88af3f8 | 2009-05-06 12:27:38 -0600 | [diff] [blame] | 267 | * Error checking for glDrawElements(). Includes parameter checking |
| 268 | * and VBO bounds checking. |
| 269 | * \return GL_TRUE if OK to render, GL_FALSE if error found |
| 270 | */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 271 | GLboolean |
| Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 272 | _mesa_validate_DrawElements(struct gl_context *ctx, |
| Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 273 | GLenum mode, GLsizei count, GLenum type, |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 274 | const GLvoid *indices, GLint basevertex) |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 275 | { |
| Marek Olšák | 9f0f2f9 | 2012-07-02 17:10:09 +0200 | [diff] [blame] | 276 | ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); |
| 277 | FLUSH_CURRENT(ctx, 0); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 278 | |
| 279 | if (count <= 0) { |
| 280 | if (count < 0) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 281 | _mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" ); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 282 | return GL_FALSE; |
| 283 | } |
| 284 | |
| Eric Anholt | 7ca4f07 | 2012-03-14 14:39:15 -0700 | [diff] [blame] | 285 | if (!_mesa_valid_prim_mode(ctx, mode, "glDrawElements")) { |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 286 | return GL_FALSE; |
| 287 | } |
| 288 | |
| Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 289 | if (type != GL_UNSIGNED_INT && |
| 290 | type != GL_UNSIGNED_BYTE && |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 291 | type != GL_UNSIGNED_SHORT) |
| 292 | { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 293 | _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 294 | return GL_FALSE; |
| 295 | } |
| 296 | |
| Brian Paul | a48b0a5 | 2009-08-14 10:41:03 -0600 | [diff] [blame] | 297 | if (!check_valid_to_render(ctx, "glDrawElements")) |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 298 | return GL_FALSE; |
| 299 | |
| Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 300 | /* Vertex buffer object tests */ |
| Yuanhan Liu | a0a5bd4 | 2011-11-23 15:59:06 +0800 | [diff] [blame] | 301 | if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) { |
| Brian | d8c6719 | 2007-08-20 13:12:20 +0100 | [diff] [blame] | 302 | /* use indices in the buffer object */ |
| Brian | d8c6719 | 2007-08-20 13:12:20 +0100 | [diff] [blame] | 303 | /* make sure count doesn't go outside buffer bounds */ |
| Yuanhan Liu | a0a5bd4 | 2011-11-23 15:59:06 +0800 | [diff] [blame] | 304 | if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) { |
| Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 305 | _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); |
| 306 | return GL_FALSE; |
| 307 | } |
| Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 308 | } |
| Brian | 37ece4d | 2007-07-08 09:20:42 -0600 | [diff] [blame] | 309 | else { |
| 310 | /* not using a VBO */ |
| 311 | if (!indices) |
| 312 | return GL_FALSE; |
| 313 | } |
| Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 314 | |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 315 | if (!check_index_bounds(ctx, count, type, indices, basevertex)) |
| 316 | return GL_FALSE; |
| Xiang, Haihao | 2394d20 | 2007-07-30 23:50:52 +0800 | [diff] [blame] | 317 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 318 | return GL_TRUE; |
| 319 | } |
| 320 | |
| Brian Paul | 88af3f8 | 2009-05-06 12:27:38 -0600 | [diff] [blame] | 321 | |
| 322 | /** |
| Marek Olšák | fcebb15 | 2012-06-27 06:29:42 +0200 | [diff] [blame] | 323 | * Error checking for glMultiDrawElements(). Includes parameter checking |
| 324 | * and VBO bounds checking. |
| 325 | * \return GL_TRUE if OK to render, GL_FALSE if error found |
| 326 | */ |
| 327 | GLboolean |
| 328 | _mesa_validate_MultiDrawElements(struct gl_context *ctx, |
| 329 | GLenum mode, const GLsizei *count, |
| 330 | GLenum type, const GLvoid * const *indices, |
| 331 | GLuint primcount, const GLint *basevertex) |
| 332 | { |
| 333 | unsigned i; |
| 334 | |
| Marek Olšák | 9f0f2f9 | 2012-07-02 17:10:09 +0200 | [diff] [blame] | 335 | ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); |
| 336 | FLUSH_CURRENT(ctx, 0); |
| Marek Olšák | fcebb15 | 2012-06-27 06:29:42 +0200 | [diff] [blame] | 337 | |
| 338 | for (i = 0; i < primcount; i++) { |
| 339 | if (count[i] <= 0) { |
| 340 | if (count[i] < 0) |
| 341 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 342 | "glMultiDrawElements(count)" ); |
| 343 | return GL_FALSE; |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | if (!_mesa_valid_prim_mode(ctx, mode, "glMultiDrawElements")) { |
| 348 | return GL_FALSE; |
| 349 | } |
| 350 | |
| 351 | if (type != GL_UNSIGNED_INT && |
| 352 | type != GL_UNSIGNED_BYTE && |
| 353 | type != GL_UNSIGNED_SHORT) |
| 354 | { |
| 355 | _mesa_error(ctx, GL_INVALID_ENUM, "glMultiDrawElements(type)" ); |
| 356 | return GL_FALSE; |
| 357 | } |
| 358 | |
| 359 | if (!check_valid_to_render(ctx, "glMultiDrawElements")) |
| 360 | return GL_FALSE; |
| 361 | |
| 362 | /* Vertex buffer object tests */ |
| 363 | if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) { |
| 364 | /* use indices in the buffer object */ |
| 365 | /* make sure count doesn't go outside buffer bounds */ |
| 366 | for (i = 0; i < primcount; i++) { |
| 367 | if (index_bytes(type, count[i]) > |
| 368 | ctx->Array.ArrayObj->ElementArrayBufferObj->Size) { |
| 369 | _mesa_warning(ctx, |
| 370 | "glMultiDrawElements index out of buffer bounds"); |
| 371 | return GL_FALSE; |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | else { |
| 376 | /* not using a VBO */ |
| 377 | for (i = 0; i < primcount; i++) { |
| 378 | if (!indices[i]) |
| 379 | return GL_FALSE; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | for (i = 0; i < primcount; i++) { |
| 384 | if (!check_index_bounds(ctx, count[i], type, indices[i], |
| 385 | basevertex ? basevertex[i] : 0)) |
| 386 | return GL_FALSE; |
| 387 | } |
| 388 | |
| 389 | return GL_TRUE; |
| 390 | } |
| 391 | |
| 392 | |
| 393 | /** |
| Brian Paul | 88af3f8 | 2009-05-06 12:27:38 -0600 | [diff] [blame] | 394 | * Error checking for glDrawRangeElements(). Includes parameter checking |
| 395 | * and VBO bounds checking. |
| 396 | * \return GL_TRUE if OK to render, GL_FALSE if error found |
| 397 | */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 398 | GLboolean |
| Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 399 | _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, |
| Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 400 | GLuint start, GLuint end, |
| 401 | GLsizei count, GLenum type, |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 402 | const GLvoid *indices, GLint basevertex) |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 403 | { |
| Marek Olšák | 9f0f2f9 | 2012-07-02 17:10:09 +0200 | [diff] [blame] | 404 | ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); |
| 405 | FLUSH_CURRENT(ctx, 0); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 406 | |
| 407 | if (count <= 0) { |
| 408 | if (count < 0) |
| Brian Paul | a2b9bad | 2003-11-10 19:08:37 +0000 | [diff] [blame] | 409 | _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(count)" ); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 410 | return GL_FALSE; |
| 411 | } |
| 412 | |
| Eric Anholt | 7ca4f07 | 2012-03-14 14:39:15 -0700 | [diff] [blame] | 413 | if (!_mesa_valid_prim_mode(ctx, mode, "glDrawRangeElements")) { |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 414 | return GL_FALSE; |
| 415 | } |
| 416 | |
| 417 | if (end < start) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 418 | _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(end<start)"); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 419 | return GL_FALSE; |
| 420 | } |
| 421 | |
| Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 422 | if (type != GL_UNSIGNED_INT && |
| 423 | type != GL_UNSIGNED_BYTE && |
| Brian Paul | 61bac60 | 2002-04-21 21:04:46 +0000 | [diff] [blame] | 424 | type != GL_UNSIGNED_SHORT) { |
| Brian Paul | a2b9bad | 2003-11-10 19:08:37 +0000 | [diff] [blame] | 425 | _mesa_error(ctx, GL_INVALID_ENUM, "glDrawRangeElements(type)" ); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 426 | return GL_FALSE; |
| 427 | } |
| 428 | |
| Brian Paul | a48b0a5 | 2009-08-14 10:41:03 -0600 | [diff] [blame] | 429 | if (!check_valid_to_render(ctx, "glDrawRangeElements")) |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 430 | return GL_FALSE; |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 431 | |
| Brian | 37ece4d | 2007-07-08 09:20:42 -0600 | [diff] [blame] | 432 | /* Vertex buffer object tests */ |
| Yuanhan Liu | a0a5bd4 | 2011-11-23 15:59:06 +0800 | [diff] [blame] | 433 | if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) { |
| Brian | d8c6719 | 2007-08-20 13:12:20 +0100 | [diff] [blame] | 434 | /* use indices in the buffer object */ |
| Brian | d8c6719 | 2007-08-20 13:12:20 +0100 | [diff] [blame] | 435 | /* make sure count doesn't go outside buffer bounds */ |
| Yuanhan Liu | a0a5bd4 | 2011-11-23 15:59:06 +0800 | [diff] [blame] | 436 | if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) { |
| Brian | ef5935b | 2007-09-23 13:56:46 -0600 | [diff] [blame] | 437 | _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds"); |
| Brian | d8c6719 | 2007-08-20 13:12:20 +0100 | [diff] [blame] | 438 | return GL_FALSE; |
| 439 | } |
| Brian | 37ece4d | 2007-07-08 09:20:42 -0600 | [diff] [blame] | 440 | } |
| 441 | else { |
| Brian | d8c6719 | 2007-08-20 13:12:20 +0100 | [diff] [blame] | 442 | /* not using a VBO */ |
| Brian | 37ece4d | 2007-07-08 09:20:42 -0600 | [diff] [blame] | 443 | if (!indices) |
| 444 | return GL_FALSE; |
| 445 | } |
| 446 | |
| Eric Anholt | 92d7ed8 | 2009-08-27 10:09:24 -0700 | [diff] [blame] | 447 | if (!check_index_bounds(ctx, count, type, indices, basevertex)) |
| 448 | return GL_FALSE; |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 449 | |
| Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 450 | return GL_TRUE; |
| 451 | } |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 452 | |
| Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 453 | |
| 454 | /** |
| 455 | * Called from the tnl module to error check the function parameters and |
| 456 | * verify that we really can draw something. |
| Brian Paul | 88af3f8 | 2009-05-06 12:27:38 -0600 | [diff] [blame] | 457 | * \return GL_TRUE if OK to render, GL_FALSE if error found |
| Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 458 | */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 459 | GLboolean |
| Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 460 | _mesa_validate_DrawArrays(struct gl_context *ctx, |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 461 | GLenum mode, GLint start, GLsizei count) |
| 462 | { |
| Marek Olšák | 9f0f2f9 | 2012-07-02 17:10:09 +0200 | [diff] [blame] | 463 | ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); |
| 464 | FLUSH_CURRENT(ctx, 0); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 465 | |
| Brian | 5cb2034 | 2007-10-31 09:38:51 -0600 | [diff] [blame] | 466 | if (count <= 0) { |
| 467 | if (count < 0) |
| 468 | _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" ); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 469 | return GL_FALSE; |
| 470 | } |
| 471 | |
| Eric Anholt | 7ca4f07 | 2012-03-14 14:39:15 -0700 | [diff] [blame] | 472 | if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArrays")) { |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 473 | return GL_FALSE; |
| 474 | } |
| 475 | |
| Brian Paul | a48b0a5 | 2009-08-14 10:41:03 -0600 | [diff] [blame] | 476 | if (!check_valid_to_render(ctx, "glDrawArrays")) |
| Brian Paul | a2b9bad | 2003-11-10 19:08:37 +0000 | [diff] [blame] | 477 | return GL_FALSE; |
| 478 | |
| 479 | if (ctx->Const.CheckArrayBounds) { |
| Brian Paul | a185bcb | 2009-05-14 13:24:24 -0600 | [diff] [blame] | 480 | if (start + count > (GLint) ctx->Array.ArrayObj->_MaxElement) |
| Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 481 | return GL_FALSE; |
| 482 | } |
| Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 483 | |
| 484 | return GL_TRUE; |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 485 | } |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 486 | |
| 487 | |
| 488 | GLboolean |
| Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 489 | _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint first, |
| Brian Paul | 72f2551 | 2011-01-17 09:33:47 -0700 | [diff] [blame] | 490 | GLsizei count, GLsizei numInstances) |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 491 | { |
| Marek Olšák | 9f0f2f9 | 2012-07-02 17:10:09 +0200 | [diff] [blame] | 492 | ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); |
| 493 | FLUSH_CURRENT(ctx, 0); |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 494 | |
| 495 | if (count <= 0) { |
| 496 | if (count < 0) |
| 497 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 498 | "glDrawArraysInstanced(count=%d)", count); |
| 499 | return GL_FALSE; |
| 500 | } |
| 501 | |
| Eric Anholt | 767ba60 | 2012-02-28 13:33:53 -0800 | [diff] [blame] | 502 | if (first < 0) { |
| 503 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 504 | "glDrawArraysInstanced(start=%d)", first); |
| 505 | return GL_FALSE; |
| 506 | } |
| 507 | |
| Eric Anholt | 7ca4f07 | 2012-03-14 14:39:15 -0700 | [diff] [blame] | 508 | if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArraysInstanced")) { |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 509 | return GL_FALSE; |
| 510 | } |
| 511 | |
| Brian Paul | 72f2551 | 2011-01-17 09:33:47 -0700 | [diff] [blame] | 512 | if (numInstances <= 0) { |
| 513 | if (numInstances < 0) |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 514 | _mesa_error(ctx, GL_INVALID_VALUE, |
| Brian Paul | 72f2551 | 2011-01-17 09:33:47 -0700 | [diff] [blame] | 515 | "glDrawArraysInstanced(numInstances=%d)", numInstances); |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 516 | return GL_FALSE; |
| 517 | } |
| 518 | |
| 519 | if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)")) |
| 520 | return GL_FALSE; |
| 521 | |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 522 | if (ctx->Const.CheckArrayBounds) { |
| 523 | if (first + count > (GLint) ctx->Array.ArrayObj->_MaxElement) |
| 524 | return GL_FALSE; |
| 525 | } |
| 526 | |
| 527 | return GL_TRUE; |
| 528 | } |
| 529 | |
| 530 | |
| 531 | GLboolean |
| Kristian Høgsberg | f9995b3 | 2010-10-12 12:26:10 -0400 | [diff] [blame] | 532 | _mesa_validate_DrawElementsInstanced(struct gl_context *ctx, |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 533 | GLenum mode, GLsizei count, GLenum type, |
| Pierre-Eric Pelloux-Prayer | 09201cc | 2011-05-31 13:33:54 +0200 | [diff] [blame] | 534 | const GLvoid *indices, GLsizei numInstances, |
| 535 | GLint basevertex) |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 536 | { |
| Marek Olšák | 9f0f2f9 | 2012-07-02 17:10:09 +0200 | [diff] [blame] | 537 | ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); |
| 538 | FLUSH_CURRENT(ctx, 0); |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 539 | |
| 540 | if (count <= 0) { |
| 541 | if (count < 0) |
| 542 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 543 | "glDrawElementsInstanced(count=%d)", count); |
| 544 | return GL_FALSE; |
| 545 | } |
| 546 | |
| Eric Anholt | 7ca4f07 | 2012-03-14 14:39:15 -0700 | [diff] [blame] | 547 | if (!_mesa_valid_prim_mode(ctx, mode, "glDrawElementsInstanced")) { |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 548 | return GL_FALSE; |
| 549 | } |
| 550 | |
| 551 | if (type != GL_UNSIGNED_INT && |
| 552 | type != GL_UNSIGNED_BYTE && |
| 553 | type != GL_UNSIGNED_SHORT) { |
| 554 | _mesa_error(ctx, GL_INVALID_ENUM, |
| 555 | "glDrawElementsInstanced(type=0x%x)", type); |
| 556 | return GL_FALSE; |
| 557 | } |
| 558 | |
| Brian Paul | 72f2551 | 2011-01-17 09:33:47 -0700 | [diff] [blame] | 559 | if (numInstances <= 0) { |
| 560 | if (numInstances < 0) |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 561 | _mesa_error(ctx, GL_INVALID_VALUE, |
| Brian Paul | 72f2551 | 2011-01-17 09:33:47 -0700 | [diff] [blame] | 562 | "glDrawElementsInstanced(numInstances=%d)", numInstances); |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 563 | return GL_FALSE; |
| 564 | } |
| 565 | |
| 566 | if (!check_valid_to_render(ctx, "glDrawElementsInstanced")) |
| 567 | return GL_FALSE; |
| 568 | |
| 569 | /* Vertex buffer object tests */ |
| Yuanhan Liu | a0a5bd4 | 2011-11-23 15:59:06 +0800 | [diff] [blame] | 570 | if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) { |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 571 | /* use indices in the buffer object */ |
| 572 | /* make sure count doesn't go outside buffer bounds */ |
| Yuanhan Liu | a0a5bd4 | 2011-11-23 15:59:06 +0800 | [diff] [blame] | 573 | if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) { |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 574 | _mesa_warning(ctx, |
| 575 | "glDrawElementsInstanced index out of buffer bounds"); |
| 576 | return GL_FALSE; |
| 577 | } |
| 578 | } |
| 579 | else { |
| 580 | /* not using a VBO */ |
| 581 | if (!indices) |
| 582 | return GL_FALSE; |
| 583 | } |
| 584 | |
| Pierre-Eric Pelloux-Prayer | 09201cc | 2011-05-31 13:33:54 +0200 | [diff] [blame] | 585 | if (!check_index_bounds(ctx, count, type, indices, basevertex)) |
| Brian Paul | cf3193a | 2010-04-04 18:18:28 -0600 | [diff] [blame] | 586 | return GL_FALSE; |
| 587 | |
| 588 | return GL_TRUE; |
| 589 | } |
| Marek Olšák | 14bb957 | 2011-12-09 17:00:23 +0100 | [diff] [blame] | 590 | |
| 591 | |
| 592 | #if FEATURE_EXT_transform_feedback |
| 593 | |
| 594 | GLboolean |
| 595 | _mesa_validate_DrawTransformFeedback(struct gl_context *ctx, |
| 596 | GLenum mode, |
| Marek Olšák | db7404d | 2011-12-18 04:51:48 +0100 | [diff] [blame] | 597 | struct gl_transform_feedback_object *obj, |
| 598 | GLuint stream, |
| 599 | GLsizei numInstances) |
| Marek Olšák | 14bb957 | 2011-12-09 17:00:23 +0100 | [diff] [blame] | 600 | { |
| Marek Olšák | 9f0f2f9 | 2012-07-02 17:10:09 +0200 | [diff] [blame] | 601 | ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); |
| 602 | FLUSH_CURRENT(ctx, 0); |
| Marek Olšák | 14bb957 | 2011-12-09 17:00:23 +0100 | [diff] [blame] | 603 | |
| Marek Olšák | db7404d | 2011-12-18 04:51:48 +0100 | [diff] [blame] | 604 | if (!_mesa_valid_prim_mode(ctx, mode, "glDrawTransformFeedback*(mode)")) { |
| Marek Olšák | 14bb957 | 2011-12-09 17:00:23 +0100 | [diff] [blame] | 605 | return GL_FALSE; |
| 606 | } |
| 607 | |
| 608 | if (!obj) { |
| Marek Olšák | db7404d | 2011-12-18 04:51:48 +0100 | [diff] [blame] | 609 | _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTransformFeedback*(name)"); |
| Marek Olšák | 14bb957 | 2011-12-09 17:00:23 +0100 | [diff] [blame] | 610 | return GL_FALSE; |
| 611 | } |
| 612 | |
| 613 | if (!obj->EndedAnytime) { |
| Marek Olšák | db7404d | 2011-12-18 04:51:48 +0100 | [diff] [blame] | 614 | _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*"); |
| Marek Olšák | 14bb957 | 2011-12-09 17:00:23 +0100 | [diff] [blame] | 615 | return GL_FALSE; |
| 616 | } |
| 617 | |
| Marek Olšák | db7404d | 2011-12-18 04:51:48 +0100 | [diff] [blame] | 618 | if (stream >= ctx->Const.MaxVertexStreams) { |
| 619 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 620 | "glDrawTransformFeedbackStream*(index>=MaxVertexStream)"); |
| 621 | return GL_FALSE; |
| 622 | } |
| 623 | |
| 624 | if (numInstances <= 0) { |
| 625 | if (numInstances < 0) |
| 626 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 627 | "glDrawTransformFeedback*Instanced(numInstances=%d)", |
| 628 | numInstances); |
| 629 | return GL_FALSE; |
| 630 | } |
| 631 | |
| 632 | if (!check_valid_to_render(ctx, "glDrawTransformFeedback*")) { |
| Marek Olšák | 14bb957 | 2011-12-09 17:00:23 +0100 | [diff] [blame] | 633 | return GL_FALSE; |
| 634 | } |
| 635 | |
| 636 | return GL_TRUE; |
| 637 | } |
| 638 | |
| 639 | #endif |