Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-04-17 08:19:28 +0300
committerMike Erwin <significant.bit@gmail.com>2017-04-17 08:19:28 +0300
commitb3e38cfc6b6320c702b93fe179323ed79583abd9 (patch)
tree263345d5a19223b84844f7a2be791889a20f609d /intern
parent47e0d2b23528f280eaaf6adbbda7863c9e972dc2 (diff)
Gawain: look up uniforms by name quicker
ShaderInterface_uniform searches custom uniforms first, then builtin uniforms if needed. This reduces the amount of string matching since you're almost certainly looking for one of those custom uniforms. Otherwise you would've called ShaderInterface_**builtin**_uniform.
Diffstat (limited to 'intern')
-rw-r--r--intern/gawain/src/shader_interface.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/intern/gawain/src/shader_interface.c b/intern/gawain/src/shader_interface.c
index 7af26a2585e..b7a30f24c38 100644
--- a/intern/gawain/src/shader_interface.c
+++ b/intern/gawain/src/shader_interface.c
@@ -211,17 +211,34 @@ void ShaderInterface_discard(ShaderInterface* shaderface)
const ShaderInput* ShaderInterface_uniform(const ShaderInterface* shaderface, const char* name)
{
+ // search through custom uniforms first
for (uint32_t i = 0; i < shaderface->uniform_ct; ++i)
{
const ShaderInput* uniform = shaderface->inputs + i;
+ if (uniform->builtin_type == UNIFORM_CUSTOM)
+ {
#if SUPPORT_LEGACY_GLSL
- if (uniform->name == NULL) continue;
+ if (uniform->name == NULL) continue;
#endif
- if (match(uniform->name, name))
- return uniform;
+ if (match(uniform->name, name))
+ return uniform;
+ }
}
+
+ // search through builtin uniforms next
+ for (uint32_t i = 0; i < shaderface->uniform_ct; ++i)
+ {
+ const ShaderInput* uniform = shaderface->inputs + i;
+
+ if (uniform->builtin_type != UNIFORM_CUSTOM)
+ if (match(uniform->name, name))
+ return uniform;
+
+ // TODO: warn if we find a matching builtin, since these can be looked up much quicker --v
+ }
+
return NULL; // not found
}