Signed-off-by: Chris Forbes <chr...@ijw.co.nz> --- src/mesa/main/api_validate.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 51a3d1f..64ed465 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -186,6 +186,8 @@ _mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode) case GL_TRIANGLES_ADJACENCY: case GL_TRIANGLE_STRIP_ADJACENCY: return _mesa_has_geometry_shaders(ctx); + case GL_PATCHES: + return ctx->Extensions.ARB_tessellation_shader; default: return false; } @@ -197,6 +199,7 @@ _mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode) * etc? Also, do additional checking related to transformation feedback. * Note: this function cannot be called during glNewList(GL_COMPILE) because * this code depends on current transform feedback state. + * Also, do additional checking related to tessellation shaders. */ GLboolean _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) @@ -232,7 +235,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) * TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB. * */ - if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) { + if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY] && + !ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]) { const GLenum geom_mode = ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.InputType; switch (mode) { @@ -276,6 +280,35 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) } } + /* From the OpenGL 4.0 (Core Profile) spec (section 2.12): + * + * "Tessellation operates only on patch primitives. If tessellation is + * active, any command that transfers vertices to the GL will + * generate an INVALID_OPERATION error if the primitive mode is not + * PATCHES. + * Patch primitives are not supported by pipeline stages below the + * tessellation evaluation shader. If there is no active program + * object or the active program object does not contain a tessellation + * evaluation shader, the error INVALID_OPERATION is generated by any + * command that transfers vertices to the GL if the primitive mode is + * PATCHES." + * + */ + if (ctx->Shader.CurrentProgram[MESA_SHADER_TESS_EVAL] || + ctx->Shader.CurrentProgram[MESA_SHADER_TESS_CTRL]) { + if (mode != GL_PATCHES) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "only GL_PATCHES valid with tessellation"); + return GL_FALSE; + } + } else { + if (mode == GL_PATCHES) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "GL_PATCHES only valid with tessellation"); + return GL_FALSE; + } + } + /* From the GL_EXT_transform_feedback spec: * * "The error INVALID_OPERATION is generated if Begin, or any command @@ -308,6 +341,14 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) pass = GL_FALSE; } } + else if(ctx->Shader.CurrentProgram[MESA_SHADER_TESS_EVAL]) { + if (ctx->Shader.CurrentProgram[MESA_SHADER_TESS_EVAL]->TessEval.PointMode) + pass = ctx->TransformFeedback.Mode == GL_POINTS; + else if (ctx->Shader.CurrentProgram[MESA_SHADER_TESS_EVAL]->TessEval.PrimitiveMode == GL_ISOLINES) + pass = ctx->TransformFeedback.Mode == GL_LINES; + else + pass = ctx->TransformFeedback.Mode == GL_TRIANGLES; + } else { switch (mode) { case GL_POINTS: -- 2.1.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev