summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-11-24 09:25:05 -0700
committerBrian Paul <brianp@vmware.com>2009-01-06 08:53:35 -0700
commit674d7181f80750e171f278b41ff98fb0c755a095 (patch)
tree5fca5591e099a41da0a24fcda84afc207fe069aa /src/mesa/shader/slang
parent19111c5efc990df7f972c97f53bf6335ac43ad27 (diff)
mesa: check that varying variable qualifiers agree
(cherry picked from commit dc1107c08d0ccbeeb063f2e46be598f16cbe9f21)
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_link.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index aaa8859a63..6b895013af 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -76,6 +76,16 @@ link_error(struct gl_shader_program *shProg, const char *msg)
/**
+ * Check if the given bit is either set or clear in both bitfields.
+ */
+static GLboolean
+bits_agree(GLbitfield flags1, GLbitfield flags2, GLbitfield bit)
+{
+ return (flags1 & bit) == (flags2 & bit);
+}
+
+
+/**
* Linking varying vars involves rearranging varying vars so that the
* vertex program's output varyings matches the order of the fragment
* program's input varyings.
@@ -94,12 +104,27 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
const struct gl_program_parameter *var = prog->Varying->Parameters + i;
GLint j = _mesa_lookup_parameter_index(shProg->Varying, -1, var->Name);
if (j >= 0) {
- /* already in list, check size */
- if (var->Size != shProg->Varying->Parameters[j].Size) {
- /* error */
+ /* varying is already in list, do some error checking */
+ const struct gl_program_parameter *v =
+ &shProg->Varying->Parameters[j];
+ if (var->Size != v->Size) {
link_error(shProg, "mismatched varying variable types");
return GL_FALSE;
}
+ if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) {
+ char msg[100];
+ snprintf(msg, sizeof(msg),
+ "centroid modifier mismatch for '%s'", var->Name);
+ link_error(shProg, msg);
+ return GL_FALSE;
+ }
+ if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) {
+ char msg[100];
+ snprintf(msg, sizeof(msg),
+ "invariant modifier mismatch for '%s'", var->Name);
+ link_error(shProg, msg);
+ return GL_FALSE;
+ }
}
else {
/* not already in linked list */