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-06-05 05:02:30 +0300
committerMike Erwin <significant.bit@gmail.com>2017-06-07 23:20:37 +0300
commitbb3e669d06ec5aead740affe75ac0375110b4d7a (patch)
tree46baece98940b3607e6433ca992f72451839be73 /intern
parenta5242d08fbe4105dd18e1adbe65d4f17f83fa68f (diff)
Gawain: faster lookup shader attribs by name
Quick hash rejection instead of string comparison. Uniform lookups already work this way. I don't expect a major overall speedup since attributes are looked up less frequently than uniforms.
Diffstat (limited to 'intern')
-rw-r--r--intern/gawain/src/shader_interface.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/intern/gawain/src/shader_interface.c b/intern/gawain/src/shader_interface.c
index f0da342f088..4c9f7fae67f 100644
--- a/intern/gawain/src/shader_interface.c
+++ b/intern/gawain/src/shader_interface.c
@@ -288,6 +288,7 @@ const ShaderInput* ShaderInterface_attrib(const ShaderInterface* shaderface, con
{
// attribs are stored after uniforms
const uint32_t input_ct = shaderface->uniform_ct + shaderface->attrib_ct;
+ const unsigned name_hash = hash_string(name);
for (uint32_t i = shaderface->uniform_ct; i < input_ct; ++i)
{
const ShaderInput* attrib = shaderface->inputs + i;
@@ -296,6 +297,8 @@ const ShaderInput* ShaderInterface_attrib(const ShaderInterface* shaderface, con
if (attrib->name == NULL) continue;
#endif
+ if (attrib->name_hash != name_hash) continue;
+
if (match(attrib->name, name))
return attrib;
}