From 58a6055dec8deb750fc2d68b32e7ce4390e7a249 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 13 Aug 2010 09:06:29 -0600 Subject: [PATCH] mesa: fix glDrawArrays/Elements() validation check When using a vertex shader/program we don't necessarily need to have the traditional GL_VERTEX_ARRAY or user-defined array[0] enabled in order to draw something (we could use the texcoord array data to compute gl_Position, for example). See fd.o bug 29540 for more info. --- src/mesa/main/api_validate.c | 27 ++++++++++++++++++++++----- 1 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index b3b5c6c..518e8d0 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -118,11 +118,28 @@ check_valid_to_render(GLcontext *ctx, const char *function) #if FEATURE_ES1 || FEATURE_GL case API_OPENGLES: case API_OPENGL: - /* For regular OpenGL, only draw if we have vertex positions - * (regardless of whether or not we have a vertex program/shader). */ - if (!ctx->Array.ArrayObj->Vertex.Enabled && - !ctx->Array.ArrayObj->VertexAttrib[0].Enabled) - return GL_FALSE; + /* For regular OpenGL and fixed-function drawing (no vertex + * shader or vertex program) we can only draw arrays if the + * vertex position array is enabled. But when we have a vertex + * shader/program there's no telling which vertex arrays will be + * used to compute position. + */ + { + GLboolean haveVertexShader = + (ctx->Shader.CurrentProgram && + ctx->Shader.CurrentProgram->LinkStatus && + ctx->Shader.CurrentProgram->VertexProgram); + GLboolean haveVertexProgram = ctx->VertexProgram._Enabled; + + if (!haveVertexShader && + !haveVertexProgram && + !ctx->Array.ArrayObj->Vertex.Enabled) { + /* Fixed function drawing without vertex position array + * is not possible. + */ + return GL_FALSE; + } + } break; #endif -- 1.7.1.1