From 77427a1e52ec8fc7547fe22af31a4480be90938a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 24 Aug 2006 23:11:39 +0000 Subject: Cg tries to bind NV fragment programs to the GL_FRAGMENT_PROGRAM_ARB target with glBindProgramARB(). I guess the GL_ARB_fragment_program specification allows that, but Mesa didn't. Relaxed the check with a new predicate function: compatible_program_targets(). --- src/mesa/shader/program.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/mesa/shader/program.c') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 27eb5c2f432..f6877bd1426 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -1722,6 +1722,27 @@ _mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) } +/** + * Mixing ARB and NV vertex/fragment programs can be tricky. + * Note: GL_VERTEX_PROGRAM_ARB == GL_VERTEX_PROGRAM_NV + * but, GL_FRAGMENT_PROGRAM_ARB != GL_FRAGMENT_PROGRAM_NV + * The two different fragment program targets are supposed to be compatible + * to some extent (see GL_ARB_fragment_program spec). + * This function does the compatibility check. + */ +static GLboolean +compatible_program_targets(GLenum t1, GLenum t2) +{ + if (t1 == t2) + return GL_TRUE; + if (t1 == GL_FRAGMENT_PROGRAM_ARB && t2 == GL_FRAGMENT_PROGRAM_NV) + return GL_TRUE; + if (t1 == GL_FRAGMENT_PROGRAM_NV && t2 == GL_FRAGMENT_PROGRAM_ARB) + return GL_TRUE; + return GL_FALSE; +} + + /**********************************************************************/ /* API functions */ @@ -1809,7 +1830,7 @@ _mesa_BindProgram(GLenum target, GLuint id) } _mesa_HashInsert(ctx->Shared->Programs, id, prog); } - else if (prog->Target != target) { + else if (!compatible_program_targets(prog->Target, target)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBindProgramNV/ARB(target mismatch)"); return; -- cgit v1.2.3