1cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell/* 2cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * Mesa 3-D graphics library 3a3c3bc9ece7e7c55c8832dbc8c50ab1c34f5bfe9Brian * Version: 7.1 4cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * 537ece4df7c654b30b6720044b35a83694d7e5bb3Brian * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 6cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * 7cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 8cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * copy of this software and associated documentation files (the "Software"), 9cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * to deal in the Software without restriction, including without limitation 10cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * and/or sell copies of the Software, and to permit persons to whom the 12cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * Software is furnished to do so, subject to the following conditions: 13cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * 14cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * The above copyright notice and this permission notice shall be included 15cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * in all copies or substantial portions of the Software. 16cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * 17cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell */ 24cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 2572e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick#include <stdbool.h> 26cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "glheader.h" 278446d1bab15ef82b35b8980a0a56072ace6feb04Brian Paul#include "api_validate.h" 28434ec3ada841915a00ffc23f699401eb3e7b37eeBrian Paul#include "bufferobj.h" 29cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "context.h" 303c63452e64df7e10aa073c6c3b9492b1d7dabbb8Brian Paul#include "imports.h" 316bf0ac0916bf09e049b378d94478035072efed53Vinson Lee#include "mfeatures.h" 32cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "mtypes.h" 3356118ef9292caa947216d6b0a75c6ae588419556Eric Anholt#include "enums.h" 3492d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt#include "vbo/vbo.h" 35a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick#include <stdbool.h> 3658e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell 37bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul 38bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul/** 39bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul * \return number of bytes in array [count] of type. 40bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul */ 41bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paulstatic GLsizei 42bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paulindex_bytes(GLenum type, GLsizei count) 43bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul{ 44bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul if (type == GL_UNSIGNED_INT) { 45bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul return count * sizeof(GLuint); 46bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul } 47bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul else if (type == GL_UNSIGNED_BYTE) { 48bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul return count * sizeof(GLubyte); 49bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul } 50bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul else { 51bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul ASSERT(type == GL_UNSIGNED_SHORT); 52bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul return count * sizeof(GLushort); 53bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul } 54bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul} 55bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul 56bb1fb2a5444c6b7d83ccb47949f60ed9fb4f0f93Brian Paul 57d8c6719f95b1543296ac954f95d13b048ae48634Brian/** 58e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul * Find the max index in the given element/index buffer 59e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul */ 60e5d29ebb5e5dd923c9c60972170d072120007aabBrian PaulGLuint 61f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, 62e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul const void *indices, 63e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul struct gl_buffer_object *elementBuf) 64e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul{ 65e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul const GLubyte *map = NULL; 66e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul GLuint max = 0; 67e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul GLuint i; 68e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul 69e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul if (_mesa_is_bufferobj(elementBuf)) { 70e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul /* elements are in a user-defined buffer object. need to map it */ 7128249bd260f4c52badf3eb61ade2744604b21bcaIan Romanick map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size, 7228249bd260f4c52badf3eb61ade2744604b21bcaIan Romanick GL_MAP_READ_BIT, elementBuf); 73e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul /* Actual address is the sum of pointers */ 74e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); 75e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul } 76e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul 77e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul if (type == GL_UNSIGNED_INT) { 78e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul for (i = 0; i < count; i++) 79e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul if (((GLuint *) indices)[i] > max) 80e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul max = ((GLuint *) indices)[i]; 81e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul } 82e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul else if (type == GL_UNSIGNED_SHORT) { 83e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul for (i = 0; i < count; i++) 84e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul if (((GLushort *) indices)[i] > max) 85e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul max = ((GLushort *) indices)[i]; 86e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul } 87e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul else { 88e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul ASSERT(type == GL_UNSIGNED_BYTE); 89e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul for (i = 0; i < count; i++) 90e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul if (((GLubyte *) indices)[i] > max) 91e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul max = ((GLubyte *) indices)[i]; 92e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul } 93e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul 94e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul if (map) { 9556f0c00f125ee75caeadc1c9e8cab8a488635e5eIan Romanick ctx->Driver.UnmapBuffer(ctx, elementBuf); 96e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul } 97e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul 98e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul return max; 99e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul} 100e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul 101e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul 102e5d29ebb5e5dd923c9c60972170d072120007aabBrian Paul/** 103b6e5600bd460245afef605dbfbcf6650ff677dcbBrian Paul * Check if OK to draw arrays/elements. 10488af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul */ 105263b96e160606975285154c4b8b610fcb8f4c930Alan Hourihanestatic GLboolean 106f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergcheck_valid_to_render(struct gl_context *ctx, const char *function) 107263b96e160606975285154c4b8b610fcb8f4c930Alan Hourihane{ 108b6e5600bd460245afef605dbfbcf6650ff677dcbBrian Paul if (!_mesa_valid_to_render(ctx, function)) { 109263b96e160606975285154c4b8b610fcb8f4c930Alan Hourihane return GL_FALSE; 110263b96e160606975285154c4b8b610fcb8f4c930Alan Hourihane } 111263b96e160606975285154c4b8b610fcb8f4c930Alan Hourihane 112f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg switch (ctx->API) { 11397dd2ddbd97ba95e8bc8ab572ec05e8081556e1eBrian Paul#if FEATURE_es2_glsl 114f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg case API_OPENGLES2: 115f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg /* For ES2, we can draw if any vertex array is enabled (and we 116f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg * should always have a vertex program/shader). */ 117f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg if (ctx->Array.ArrayObj->_Enabled == 0x0 || !ctx->VertexProgram._Current) 118f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg return GL_FALSE; 119f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg break; 120f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg#endif 121f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg 12243bdabd47d98975b56a759954fb5f37d2942c101Brian Paul#if FEATURE_ES1 123f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg case API_OPENGLES: 12443bdabd47d98975b56a759954fb5f37d2942c101Brian Paul /* For OpenGL ES, only draw if we have vertex positions 12543bdabd47d98975b56a759954fb5f37d2942c101Brian Paul */ 126762c9766c93697af8d7fbaa729aed118789dbe8eMathias Fröhlich if (!ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) 127f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg return GL_FALSE; 128f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg break; 12997dd2ddbd97ba95e8bc8ab572ec05e8081556e1eBrian Paul#endif 130263b96e160606975285154c4b8b610fcb8f4c930Alan Hourihane 13143bdabd47d98975b56a759954fb5f37d2942c101Brian Paul#if FEATURE_GL 13243bdabd47d98975b56a759954fb5f37d2942c101Brian Paul case API_OPENGL: 13309714c09a40501d82823e42f7461d7b8d7bf11c0Jordan Justen case API_OPENGL_CORE: 13443bdabd47d98975b56a759954fb5f37d2942c101Brian Paul { 13543bdabd47d98975b56a759954fb5f37d2942c101Brian Paul const struct gl_shader_program *vsProg = 13643bdabd47d98975b56a759954fb5f37d2942c101Brian Paul ctx->Shader.CurrentVertexProgram; 13743bdabd47d98975b56a759954fb5f37d2942c101Brian Paul GLboolean haveVertexShader = (vsProg && vsProg->LinkStatus); 13843bdabd47d98975b56a759954fb5f37d2942c101Brian Paul GLboolean haveVertexProgram = ctx->VertexProgram._Enabled; 13943bdabd47d98975b56a759954fb5f37d2942c101Brian Paul if (haveVertexShader || haveVertexProgram) { 14043bdabd47d98975b56a759954fb5f37d2942c101Brian Paul /* Draw regardless of whether or not we have any vertex arrays. 14143bdabd47d98975b56a759954fb5f37d2942c101Brian Paul * (Ex: could draw a point using a constant vertex pos) 14243bdabd47d98975b56a759954fb5f37d2942c101Brian Paul */ 14343bdabd47d98975b56a759954fb5f37d2942c101Brian Paul return GL_TRUE; 14443bdabd47d98975b56a759954fb5f37d2942c101Brian Paul } 14543bdabd47d98975b56a759954fb5f37d2942c101Brian Paul else { 14643bdabd47d98975b56a759954fb5f37d2942c101Brian Paul /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic 14743bdabd47d98975b56a759954fb5f37d2942c101Brian Paul * array [0]). 14843bdabd47d98975b56a759954fb5f37d2942c101Brian Paul */ 149762c9766c93697af8d7fbaa729aed118789dbe8eMathias Fröhlich return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled || 150762c9766c93697af8d7fbaa729aed118789dbe8eMathias Fröhlich ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled); 15143bdabd47d98975b56a759954fb5f37d2942c101Brian Paul } 15243bdabd47d98975b56a759954fb5f37d2942c101Brian Paul } 15343bdabd47d98975b56a759954fb5f37d2942c101Brian Paul break; 15443bdabd47d98975b56a759954fb5f37d2942c101Brian Paul#endif 15543bdabd47d98975b56a759954fb5f37d2942c101Brian Paul 156f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg default: 157f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg ASSERT_NO_FEATURE(); 158f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg } 159f67b020a942911f80b7b774c6d64701d1981c608Kristian Høgsberg 160263b96e160606975285154c4b8b610fcb8f4c930Alan Hourihane return GL_TRUE; 161263b96e160606975285154c4b8b610fcb8f4c930Alan Hourihane} 162d8c6719f95b1543296ac954f95d13b048ae48634Brian 163e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul 164e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul/** 165e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul * Do bounds checking on array element indexes. Check that the vertices 166e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul * pointed to by the indices don't lie outside buffer object bounds. 167e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds 168e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul */ 16992d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholtstatic GLboolean 170f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergcheck_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type, 17192d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt const GLvoid *indices, GLint basevertex) 17292d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt{ 17392d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt struct _mesa_prim prim; 17492d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt struct _mesa_index_buffer ib; 17592d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt GLuint min, max; 17692d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt 17792d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt /* Only the X Server needs to do this -- otherwise, accessing outside 17892d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt * array/BO bounds allows application termination. 17992d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt */ 18092d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt if (!ctx->Const.CheckArrayBounds) 18192d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt return GL_TRUE; 18292d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt 18392d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt memset(&prim, 0, sizeof(prim)); 18492d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt prim.count = count; 18592d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt 18692d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt memset(&ib, 0, sizeof(ib)); 18792d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt ib.type = type; 18892d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt ib.ptr = indices; 189a0a5bd4bb30a73c10b02c3c3b914940a03f9b790Yuanhan Liu ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj; 19092d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt 19142d4972bf0b147b0241c2be7e6579fd64cf2c216Yuanhan Liu vbo_get_minmax_indices(ctx, &prim, &ib, &min, &max, 1); 19292d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt 193391b396f3fb300a912e6d9bfbf26f49cc30e52dfMichel Dänzer if ((int)(min + basevertex) < 0 || 1941f4a853b1e4691400ab832c589b044b659c20c06Roland Scheidegger max + basevertex >= ctx->Array.ArrayObj->_MaxElement) { 19592d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt /* the max element is out of bounds of one or more enabled arrays */ 196e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)", 197e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul max, ctx->Array.ArrayObj->_MaxElement); 19892d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt return GL_FALSE; 19992d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt } 20092d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt 20192d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt return GL_TRUE; 20292d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt} 20388af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul 204e9968ebfa40b4740601c1596950ebd3f168664b0Brian Paul 20588af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul/** 2060e6646db3248057b7750031d825535cd7a0e5aecBrian Paul * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(), 2070e6646db3248057b7750031d825535cd7a0e5aecBrian Paul * etc? The set of legal values depends on whether geometry shaders/programs 2080e6646db3248057b7750031d825535cd7a0e5aecBrian Paul * are supported. 2090e6646db3248057b7750031d825535cd7a0e5aecBrian Paul */ 2100e6646db3248057b7750031d825535cd7a0e5aecBrian PaulGLboolean 2117ca4f07b5b77ccac0a9b60dc5ac9082906b5947eEric Anholt_mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) 2120e6646db3248057b7750031d825535cd7a0e5aecBrian Paul{ 21372e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick bool valid_enum; 21472e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick 21572e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick switch (mode) { 21672e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_POINTS: 21772e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_LINES: 21872e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_LINE_LOOP: 21972e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_LINE_STRIP: 22072e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_TRIANGLES: 22172e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_TRIANGLE_STRIP: 22272e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_TRIANGLE_FAN: 2236a9b8f897a8b59fae03c73e05203bc708fb17793Ian Romanick valid_enum = true; 2246a9b8f897a8b59fae03c73e05203bc708fb17793Ian Romanick break; 22572e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_QUADS: 22672e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_QUAD_STRIP: 22772e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_POLYGON: 2286a9b8f897a8b59fae03c73e05203bc708fb17793Ian Romanick valid_enum = (ctx->API == API_OPENGL); 22972e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick break; 23072e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_LINES_ADJACENCY: 23172e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_LINE_STRIP_ADJACENCY: 23272e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_TRIANGLES_ADJACENCY: 23372e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick case GL_TRIANGLE_STRIP_ADJACENCY: 2346a9b8f897a8b59fae03c73e05203bc708fb17793Ian Romanick valid_enum = _mesa_is_desktop_gl(ctx) 2356a9b8f897a8b59fae03c73e05203bc708fb17793Ian Romanick && ctx->Extensions.ARB_geometry_shader4; 23672e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick break; 23772e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick default: 23872e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick valid_enum = false; 23972e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick break; 2400e6646db3248057b7750031d825535cd7a0e5aecBrian Paul } 24172e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick 24272e076cb17e47c608fa6534641653cdc6133fb27Ian Romanick if (!valid_enum) { 2437ca4f07b5b77ccac0a9b60dc5ac9082906b5947eEric Anholt _mesa_error(ctx, GL_INVALID_ENUM, "%s(mode=%x)", name, mode); 2440e6646db3248057b7750031d825535cd7a0e5aecBrian Paul return GL_FALSE; 2450e6646db3248057b7750031d825535cd7a0e5aecBrian Paul } 24656118ef9292caa947216d6b0a75c6ae588419556Eric Anholt 24756118ef9292caa947216d6b0a75c6ae588419556Eric Anholt /* From the GL_EXT_transform_feedback spec: 24856118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * 24956118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * "The error INVALID_OPERATION is generated if Begin, or any command 25056118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * that performs an explicit Begin, is called when: 25156118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * 25256118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * * a geometry shader is not active and <mode> does not match the 25356118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * allowed begin modes for the current transform feedback state as 25456118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * given by table X.1. 25556118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * 25656118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * * a geometry shader is active and the output primitive type of the 25756118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * geometry shader does not match the allowed begin modes for the 25856118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * current transform feedback state as given by table X.1. 25956118ef9292caa947216d6b0a75c6ae588419556Eric Anholt * 26056118ef9292caa947216d6b0a75c6ae588419556Eric Anholt */ 26156118ef9292caa947216d6b0a75c6ae588419556Eric Anholt if (ctx->TransformFeedback.CurrentObject->Active && 26256118ef9292caa947216d6b0a75c6ae588419556Eric Anholt !ctx->TransformFeedback.CurrentObject->Paused) { 26356118ef9292caa947216d6b0a75c6ae588419556Eric Anholt GLboolean pass = GL_TRUE; 26456118ef9292caa947216d6b0a75c6ae588419556Eric Anholt 26556118ef9292caa947216d6b0a75c6ae588419556Eric Anholt switch (mode) { 26656118ef9292caa947216d6b0a75c6ae588419556Eric Anholt case GL_POINTS: 26756118ef9292caa947216d6b0a75c6ae588419556Eric Anholt pass = ctx->TransformFeedback.Mode == GL_POINTS; 26856118ef9292caa947216d6b0a75c6ae588419556Eric Anholt break; 26956118ef9292caa947216d6b0a75c6ae588419556Eric Anholt case GL_LINES: 27056118ef9292caa947216d6b0a75c6ae588419556Eric Anholt case GL_LINE_STRIP: 27156118ef9292caa947216d6b0a75c6ae588419556Eric Anholt case GL_LINE_LOOP: 27256118ef9292caa947216d6b0a75c6ae588419556Eric Anholt pass = ctx->TransformFeedback.Mode == GL_LINES; 27356118ef9292caa947216d6b0a75c6ae588419556Eric Anholt break; 27456118ef9292caa947216d6b0a75c6ae588419556Eric Anholt default: 27556118ef9292caa947216d6b0a75c6ae588419556Eric Anholt pass = ctx->TransformFeedback.Mode == GL_TRIANGLES; 27656118ef9292caa947216d6b0a75c6ae588419556Eric Anholt break; 27756118ef9292caa947216d6b0a75c6ae588419556Eric Anholt } 27856118ef9292caa947216d6b0a75c6ae588419556Eric Anholt if (!pass) { 27956118ef9292caa947216d6b0a75c6ae588419556Eric Anholt _mesa_error(ctx, GL_INVALID_OPERATION, 28056118ef9292caa947216d6b0a75c6ae588419556Eric Anholt "%s(mode=%s vs transform feedback %s)", 28156118ef9292caa947216d6b0a75c6ae588419556Eric Anholt name, 28256118ef9292caa947216d6b0a75c6ae588419556Eric Anholt _mesa_lookup_prim_by_nr(mode), 28356118ef9292caa947216d6b0a75c6ae588419556Eric Anholt _mesa_lookup_prim_by_nr(ctx->TransformFeedback.Mode)); 28456118ef9292caa947216d6b0a75c6ae588419556Eric Anholt return GL_FALSE; 28556118ef9292caa947216d6b0a75c6ae588419556Eric Anholt } 2860e6646db3248057b7750031d825535cd7a0e5aecBrian Paul } 28756118ef9292caa947216d6b0a75c6ae588419556Eric Anholt 28856118ef9292caa947216d6b0a75c6ae588419556Eric Anholt return GL_TRUE; 2890e6646db3248057b7750031d825535cd7a0e5aecBrian Paul} 2900e6646db3248057b7750031d825535cd7a0e5aecBrian Paul 291a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick/** 292a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick * Verify that the element type is valid. 293a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick * 294a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick * Generates \c GL_INVALID_ENUM and returns \c false if it is not. 295a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick */ 296a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanickstatic bool 297a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanickvalid_elements_type(struct gl_context *ctx, GLenum type, const char *name) 298a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick{ 299a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick switch (type) { 300a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick case GL_UNSIGNED_BYTE: 301a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick case GL_UNSIGNED_SHORT: 302a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick case GL_UNSIGNED_INT: 303a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick return true; 304a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick 305a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick default: 306a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", name, 307a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick _mesa_lookup_enum_by_nr(type)); 308a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick return false; 309a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick } 310a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick} 3110e6646db3248057b7750031d825535cd7a0e5aecBrian Paul 3120e6646db3248057b7750031d825535cd7a0e5aecBrian Paul/** 31388af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul * Error checking for glDrawElements(). Includes parameter checking 31488af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul * and VBO bounds checking. 31588af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul * \return GL_TRUE if OK to render, GL_FALSE if error found 31688af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul */ 317cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith WhitwellGLboolean 318f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_validate_DrawElements(struct gl_context *ctx, 31922144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes GLenum mode, GLsizei count, GLenum type, 32092d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt const GLvoid *indices, GLint basevertex) 321cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{ 3229f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 3239f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák FLUSH_CURRENT(ctx, 0); 324cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 325cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell if (count <= 0) { 326cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell if (count < 0) 32708836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" ); 328cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 329cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } 330cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 3317ca4f07b5b77ccac0a9b60dc5ac9082906b5947eEric Anholt if (!_mesa_valid_prim_mode(ctx, mode, "glDrawElements")) { 332cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 333cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } 334cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 335a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick if (!valid_elements_type(ctx, type, "glDrawElements")) 336cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 337cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 338a48b0a5ce7fc17eab4daa375fb95768fa2f50825Brian Paul if (!check_valid_to_render(ctx, "glDrawElements")) 339a2b9bad251b058f6255fa037b842c5465c0609a2Brian Paul return GL_FALSE; 340a2b9bad251b058f6255fa037b842c5465c0609a2Brian Paul 34103e29a5f77c13b7b888bd8443cb2752850e47d6aBrian Paul /* Vertex buffer object tests */ 342a0a5bd4bb30a73c10b02c3c3b914940a03f9b790Yuanhan Liu if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) { 34303e29a5f77c13b7b888bd8443cb2752850e47d6aBrian Paul /* use indices in the buffer object */ 344d8c6719f95b1543296ac954f95d13b048ae48634Brian /* make sure count doesn't go outside buffer bounds */ 345a0a5bd4bb30a73c10b02c3c3b914940a03f9b790Yuanhan Liu if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) { 34603e29a5f77c13b7b888bd8443cb2752850e47d6aBrian Paul _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); 34703e29a5f77c13b7b888bd8443cb2752850e47d6aBrian Paul return GL_FALSE; 34803e29a5f77c13b7b888bd8443cb2752850e47d6aBrian Paul } 34903e29a5f77c13b7b888bd8443cb2752850e47d6aBrian Paul } 35037ece4df7c654b30b6720044b35a83694d7e5bb3Brian else { 35137ece4df7c654b30b6720044b35a83694d7e5bb3Brian /* not using a VBO */ 35237ece4df7c654b30b6720044b35a83694d7e5bb3Brian if (!indices) 35337ece4df7c654b30b6720044b35a83694d7e5bb3Brian return GL_FALSE; 35437ece4df7c654b30b6720044b35a83694d7e5bb3Brian } 35503e29a5f77c13b7b888bd8443cb2752850e47d6aBrian Paul 35692d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt if (!check_index_bounds(ctx, count, type, indices, basevertex)) 35792d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt return GL_FALSE; 358cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 359cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_TRUE; 360cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell} 361cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 36288af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul 36388af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul/** 364fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák * Error checking for glMultiDrawElements(). Includes parameter checking 365fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák * and VBO bounds checking. 366fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák * \return GL_TRUE if OK to render, GL_FALSE if error found 367fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák */ 368fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek OlšákGLboolean 369fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák_mesa_validate_MultiDrawElements(struct gl_context *ctx, 370fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák GLenum mode, const GLsizei *count, 371fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák GLenum type, const GLvoid * const *indices, 372fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák GLuint primcount, const GLint *basevertex) 373fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák{ 374fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák unsigned i; 375fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 3769f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 3779f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák FLUSH_CURRENT(ctx, 0); 378fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 379fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák for (i = 0; i < primcount; i++) { 380fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák if (count[i] <= 0) { 381fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák if (count[i] < 0) 382fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák _mesa_error(ctx, GL_INVALID_VALUE, 383fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák "glMultiDrawElements(count)" ); 384fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák return GL_FALSE; 385fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 386fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 387fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 388fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák if (!_mesa_valid_prim_mode(ctx, mode, "glMultiDrawElements")) { 389fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák return GL_FALSE; 390fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 391fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 392a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick if (!valid_elements_type(ctx, type, "glMultiDrawElements")) 393fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák return GL_FALSE; 394fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 395fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák if (!check_valid_to_render(ctx, "glMultiDrawElements")) 396fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák return GL_FALSE; 397fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 398fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák /* Vertex buffer object tests */ 399fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) { 400fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák /* use indices in the buffer object */ 401fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák /* make sure count doesn't go outside buffer bounds */ 402fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák for (i = 0; i < primcount; i++) { 403fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák if (index_bytes(type, count[i]) > 404fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák ctx->Array.ArrayObj->ElementArrayBufferObj->Size) { 405fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák _mesa_warning(ctx, 406fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák "glMultiDrawElements index out of buffer bounds"); 407fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák return GL_FALSE; 408fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 409fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 410fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 411fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák else { 412fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák /* not using a VBO */ 413fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák for (i = 0; i < primcount; i++) { 414fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák if (!indices[i]) 415fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák return GL_FALSE; 416fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 417fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 418fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 419fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák for (i = 0; i < primcount; i++) { 420fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák if (!check_index_bounds(ctx, count[i], type, indices[i], 421fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák basevertex ? basevertex[i] : 0)) 422fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák return GL_FALSE; 423fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák } 424fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 425fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák return GL_TRUE; 426fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák} 427fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 428fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák 429fcebb157f0eb6c2f374dee609a01b0b14856e7fcMarek Olšák/** 43088af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul * Error checking for glDrawRangeElements(). Includes parameter checking 43188af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul * and VBO bounds checking. 43288af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul * \return GL_TRUE if OK to render, GL_FALSE if error found 43388af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul */ 434cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith WhitwellGLboolean 435f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, 43622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes GLuint start, GLuint end, 43722144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes GLsizei count, GLenum type, 43892d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt const GLvoid *indices, GLint basevertex) 439cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{ 4409f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 4419f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák FLUSH_CURRENT(ctx, 0); 442cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 443cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell if (count <= 0) { 444cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell if (count < 0) 445a2b9bad251b058f6255fa037b842c5465c0609a2Brian Paul _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(count)" ); 446cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 447cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } 448cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 4497ca4f07b5b77ccac0a9b60dc5ac9082906b5947eEric Anholt if (!_mesa_valid_prim_mode(ctx, mode, "glDrawRangeElements")) { 450cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 451cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } 452cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 453cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell if (end < start) { 45408836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(end<start)"); 455cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 456cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } 457cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 458a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick if (!valid_elements_type(ctx, type, "glDrawRangeElements")) 459cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 460cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 461a48b0a5ce7fc17eab4daa375fb95768fa2f50825Brian Paul if (!check_valid_to_render(ctx, "glDrawRangeElements")) 462a2b9bad251b058f6255fa037b842c5465c0609a2Brian Paul return GL_FALSE; 463a2b9bad251b058f6255fa037b842c5465c0609a2Brian Paul 46437ece4df7c654b30b6720044b35a83694d7e5bb3Brian /* Vertex buffer object tests */ 465a0a5bd4bb30a73c10b02c3c3b914940a03f9b790Yuanhan Liu if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) { 466d8c6719f95b1543296ac954f95d13b048ae48634Brian /* use indices in the buffer object */ 467d8c6719f95b1543296ac954f95d13b048ae48634Brian /* make sure count doesn't go outside buffer bounds */ 468a0a5bd4bb30a73c10b02c3c3b914940a03f9b790Yuanhan Liu if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) { 469ef5935bc94a1439eb8f1731732a3eabd0e360407Brian _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds"); 470d8c6719f95b1543296ac954f95d13b048ae48634Brian return GL_FALSE; 471d8c6719f95b1543296ac954f95d13b048ae48634Brian } 47237ece4df7c654b30b6720044b35a83694d7e5bb3Brian } 47337ece4df7c654b30b6720044b35a83694d7e5bb3Brian else { 474d8c6719f95b1543296ac954f95d13b048ae48634Brian /* not using a VBO */ 47537ece4df7c654b30b6720044b35a83694d7e5bb3Brian if (!indices) 47637ece4df7c654b30b6720044b35a83694d7e5bb3Brian return GL_FALSE; 47737ece4df7c654b30b6720044b35a83694d7e5bb3Brian } 47837ece4df7c654b30b6720044b35a83694d7e5bb3Brian 47992d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt if (!check_index_bounds(ctx, count, type, indices, basevertex)) 48092d7ed8a20d4a018ce5324e6537ae7b478b9e5bfEric Anholt return GL_FALSE; 481a2b9bad251b058f6255fa037b842c5465c0609a2Brian Paul 482c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul return GL_TRUE; 483c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul} 484c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul 485cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 486c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul/** 487c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul * Called from the tnl module to error check the function parameters and 488c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul * verify that we really can draw something. 48988af3f8783452dcf50a9e2e82076f52b2044f643Brian Paul * \return GL_TRUE if OK to render, GL_FALSE if error found 490c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul */ 491cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith WhitwellGLboolean 492f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_validate_DrawArrays(struct gl_context *ctx, 493cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell GLenum mode, GLint start, GLsizei count) 494cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{ 4959f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 4969f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák FLUSH_CURRENT(ctx, 0); 497cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 4985cb203433ab5c4e54a7386a816263a237c716aa2Brian if (count <= 0) { 4995cb203433ab5c4e54a7386a816263a237c716aa2Brian if (count < 0) 5005cb203433ab5c4e54a7386a816263a237c716aa2Brian _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" ); 501cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 502cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } 503cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 5047ca4f07b5b77ccac0a9b60dc5ac9082906b5947eEric Anholt if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArrays")) { 505cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell return GL_FALSE; 506cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } 507cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 508a48b0a5ce7fc17eab4daa375fb95768fa2f50825Brian Paul if (!check_valid_to_render(ctx, "glDrawArrays")) 509c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul return GL_FALSE; 510c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul 511a2b9bad251b058f6255fa037b842c5465c0609a2Brian Paul if (ctx->Const.CheckArrayBounds) { 512a185bcbdec856cc98c26098e4e447a683eed14d1Brian Paul if (start + count > (GLint) ctx->Array.ArrayObj->_MaxElement) 513c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul return GL_FALSE; 514a2b9bad251b058f6255fa037b842c5465c0609a2Brian Paul } 515c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul 516c5b1e81de48de5d8830bf5d92ff767ad1985e46eBrian Paul return GL_TRUE; 517cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell} 518cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 519cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 520cf3193ad1cd75b847c5d626def701a4bb012d080Brian PaulGLboolean 521f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint first, 52272f2551017e03f888d63fa9040120740c6d40620Brian Paul GLsizei count, GLsizei numInstances) 523cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul{ 5249f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 5259f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák FLUSH_CURRENT(ctx, 0); 526cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 527cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (count <= 0) { 528cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (count < 0) 529cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul _mesa_error(ctx, GL_INVALID_VALUE, 530cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul "glDrawArraysInstanced(count=%d)", count); 531cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 532cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 533cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 534767ba60831657a684e3852c398a0d13d1201158fEric Anholt if (first < 0) { 535767ba60831657a684e3852c398a0d13d1201158fEric Anholt _mesa_error(ctx, GL_INVALID_VALUE, 536767ba60831657a684e3852c398a0d13d1201158fEric Anholt "glDrawArraysInstanced(start=%d)", first); 537767ba60831657a684e3852c398a0d13d1201158fEric Anholt return GL_FALSE; 538767ba60831657a684e3852c398a0d13d1201158fEric Anholt } 539767ba60831657a684e3852c398a0d13d1201158fEric Anholt 5407ca4f07b5b77ccac0a9b60dc5ac9082906b5947eEric Anholt if (!_mesa_valid_prim_mode(ctx, mode, "glDrawArraysInstanced")) { 541cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 542cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 543cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 54472f2551017e03f888d63fa9040120740c6d40620Brian Paul if (numInstances <= 0) { 54572f2551017e03f888d63fa9040120740c6d40620Brian Paul if (numInstances < 0) 546cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul _mesa_error(ctx, GL_INVALID_VALUE, 54772f2551017e03f888d63fa9040120740c6d40620Brian Paul "glDrawArraysInstanced(numInstances=%d)", numInstances); 548cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 549cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 550cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 551cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)")) 552cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 553cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 554cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (ctx->Const.CheckArrayBounds) { 555cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (first + count > (GLint) ctx->Array.ArrayObj->_MaxElement) 556cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 557cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 558cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 559cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_TRUE; 560cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul} 561cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 562cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 563cf3193ad1cd75b847c5d626def701a4bb012d080Brian PaulGLboolean 564f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_validate_DrawElementsInstanced(struct gl_context *ctx, 565cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul GLenum mode, GLsizei count, GLenum type, 56609201cc7a0c4c50871bb8aa5d00ac70aa4e9e670Pierre-Eric Pelloux-Prayer const GLvoid *indices, GLsizei numInstances, 56709201cc7a0c4c50871bb8aa5d00ac70aa4e9e670Pierre-Eric Pelloux-Prayer GLint basevertex) 568cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul{ 5699f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 5709f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák FLUSH_CURRENT(ctx, 0); 571cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 572cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (count <= 0) { 573cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (count < 0) 574cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul _mesa_error(ctx, GL_INVALID_VALUE, 575cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul "glDrawElementsInstanced(count=%d)", count); 576cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 577cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 578cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 5797ca4f07b5b77ccac0a9b60dc5ac9082906b5947eEric Anholt if (!_mesa_valid_prim_mode(ctx, mode, "glDrawElementsInstanced")) { 580cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 581cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 582cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 583a33f360e8f8138c5b37b5e33324283e764d0750cIan Romanick if (!valid_elements_type(ctx, type, "glDrawElementsInstanced")) 584cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 585cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 58672f2551017e03f888d63fa9040120740c6d40620Brian Paul if (numInstances <= 0) { 58772f2551017e03f888d63fa9040120740c6d40620Brian Paul if (numInstances < 0) 588cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul _mesa_error(ctx, GL_INVALID_VALUE, 58972f2551017e03f888d63fa9040120740c6d40620Brian Paul "glDrawElementsInstanced(numInstances=%d)", numInstances); 590cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 591cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 592cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 593cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (!check_valid_to_render(ctx, "glDrawElementsInstanced")) 594cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 595cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 596cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul /* Vertex buffer object tests */ 597a0a5bd4bb30a73c10b02c3c3b914940a03f9b790Yuanhan Liu if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) { 598cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul /* use indices in the buffer object */ 599cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul /* make sure count doesn't go outside buffer bounds */ 600a0a5bd4bb30a73c10b02c3c3b914940a03f9b790Yuanhan Liu if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) { 601cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul _mesa_warning(ctx, 602cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul "glDrawElementsInstanced index out of buffer bounds"); 603cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 604cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 605cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 606cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul else { 607cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul /* not using a VBO */ 608cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul if (!indices) 609cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 610cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul } 611cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 61209201cc7a0c4c50871bb8aa5d00ac70aa4e9e670Pierre-Eric Pelloux-Prayer if (!check_index_bounds(ctx, count, type, indices, basevertex)) 613cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_FALSE; 614cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul 615cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul return GL_TRUE; 616cf3193ad1cd75b847c5d626def701a4bb012d080Brian Paul} 61714bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 61814bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 61914bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák#if FEATURE_EXT_transform_feedback 62014bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 62114bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek OlšákGLboolean 62214bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák_mesa_validate_DrawTransformFeedback(struct gl_context *ctx, 62314bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák GLenum mode, 624db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák struct gl_transform_feedback_object *obj, 625db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák GLuint stream, 626db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák GLsizei numInstances) 62714bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák{ 6289f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 6299f0f2f9512c3c9dcf875efa490b587f010b260c1Marek Olšák FLUSH_CURRENT(ctx, 0); 63014bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 631db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák if (!_mesa_valid_prim_mode(ctx, mode, "glDrawTransformFeedback*(mode)")) { 63214bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák return GL_FALSE; 63314bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák } 63414bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 63514bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák if (!obj) { 636db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTransformFeedback*(name)"); 63714bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák return GL_FALSE; 63814bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák } 63914bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 64014bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák if (!obj->EndedAnytime) { 641db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*"); 64214bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák return GL_FALSE; 64314bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák } 64414bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 645db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák if (stream >= ctx->Const.MaxVertexStreams) { 646db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák _mesa_error(ctx, GL_INVALID_VALUE, 647db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák "glDrawTransformFeedbackStream*(index>=MaxVertexStream)"); 648db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák return GL_FALSE; 649db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák } 650db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák 651db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák if (numInstances <= 0) { 652db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák if (numInstances < 0) 653db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák _mesa_error(ctx, GL_INVALID_VALUE, 654db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák "glDrawTransformFeedback*Instanced(numInstances=%d)", 655db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák numInstances); 656db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák return GL_FALSE; 657db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák } 658db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák 659db7404defd47aa22082b52a6a31a08fb39fab626Marek Olšák if (!check_valid_to_render(ctx, "glDrawTransformFeedback*")) { 66014bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák return GL_FALSE; 66114bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák } 66214bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 66314bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák return GL_TRUE; 66414bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák} 66514bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák 66614bb957b996dcc5392b8fa589bd3ffa5c55cb6b4Marek Olšák#endif 667