GPUMaterial: Make uniform attrib precompute hash and attribute safe name

This avoids redundant operation at draw time.
The per attrib hash is to be used with the future implementation.
This commit is contained in:
2022-09-01 13:35:04 +02:00
parent 06005b0870
commit ba1bf87bd8
4 changed files with 20 additions and 15 deletions

View File

@@ -321,10 +321,18 @@ void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph)
LISTBASE_FOREACH (GPUUniformAttr *, attr, &attrs->list) {
attr->id = next_id++;
attrs->hash_code ^= BLI_ghashutil_strhash_p(attr->name);
attr->hash_code = BLI_ghashutil_strhash_p(attr->name);
if (attr->use_dupli) {
attrs->hash_code ^= BLI_ghashutil_uinthash(attr->id);
attr->hash_code ^= BLI_ghashutil_uinthash(attr->id);
}
attrs->hash_code ^= attr->hash_code;
{
char attr_name_esc[sizeof(attr->name) * 2];
BLI_str_escape(attr_name_esc, attr->name, sizeof(attr_name_esc));
SNPRINTF(attr->name_id_prop, "[\"%s\"]", attr_name_esc);
}
}
}