[Bf-blender-cvs] [56e9629d96f] blender2.8: Gawain: look up array uniforms correctly
Mike Erwin
noreply at git.blender.org
Thu Apr 13 07:18:00 CEST 2017
Commit: 56e9629d96f1cc42b0ba47af562b14ed79b9ae2e
Author: Mike Erwin
Date: Thu Apr 13 00:51:18 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB56e9629d96f1cc42b0ba47af562b14ed79b9ae2e
Gawain: look up array uniforms correctly
Look up "name[0]" when asked for "name", since that marks the beginning of the array.
We're comparing to the name stored in ShaderInterface which comes from glGetActiveUniform.
===================================================================
M intern/gawain/src/immediate.c
===================================================================
diff --git a/intern/gawain/src/immediate.c b/intern/gawain/src/immediate.c
index f384887a2ad..f3fc046d2c5 100644
--- a/intern/gawain/src/immediate.c
+++ b/intern/gawain/src/immediate.c
@@ -754,8 +754,23 @@ void immUniform3fv(const char* name, const float data[3])
glUniform3fv(uniform->location, 1, data);
}
-void immUniformArray3fv(const char* name, const float *data, int count)
+// can increase this limit or move to another file
+#define MAX_UNIFORM_NAME_LEN 60
+
+void immUniformArray3fv(const char* bare_name, const float *data, int count)
{
+ // look up "name[0]" when given "name"
+ const size_t len = strlen(bare_name);
+#if TRUST_NO_ONE
+ assert(len <= MAX_UNIFORM_NAME_LEN);
+#endif
+ char name[MAX_UNIFORM_NAME_LEN];
+ strcpy(name, bare_name);
+ name[len + 0] = '[';
+ name[len + 1] = '0';
+ name[len + 2] = ']';
+ name[len + 3] = '\0';
+
GET_UNIFORM
glUniform3fv(uniform->location, count, data);
}
More information about the Bf-blender-cvs
mailing list