Cg tries to bind NV fragment programs to the GL_FRAGMENT_PROGRAM_ARB target
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 24 Aug 2006 23:11:39 +0000 (23:11 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 24 Aug 2006 23:11:39 +0000 (23:11 +0000)
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

index 27eb5c2..f6877bd 100644 (file)
@@ -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;