[Bf-blender-cvs] [bb3e669d06e] blender2.8: Gawain: faster lookup shader attribs by name
Mike Erwin
noreply at git.blender.org
Wed Jun 7 22:29:03 CEST 2017
Commit: bb3e669d06ec5aead740affe75ac0375110b4d7a
Author: Mike Erwin
Date: Sun Jun 4 22:02:30 2017 -0400
Branches: blender2.8
https://developer.blender.org/rBbb3e669d06ec5aead740affe75ac0375110b4d7a
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.
===================================================================
M intern/gawain/src/shader_interface.c
===================================================================
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;
}
More information about the Bf-blender-cvs
mailing list