diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-09-01 14:35:04 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-09-01 15:41:00 +0300 |
commit | ba1bf87bd8f13fa2c67c435eb4a31a0c898d65ac (patch) | |
tree | 09281e081767384b2b3f6ad0d3f72c38f8a96daa /source/blender/draw | |
parent | 06005b0870be9a0a3b73b4c388c26988f1f991d2 (diff) |
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.
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/intern/draw_instance_data.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index 88cc71fa0dd..8754a75d346 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -642,23 +642,16 @@ static void drw_uniform_attribute_lookup(GPUUniformAttr *attr, { copy_v4_fl(r_data, 0); - char idprop_name[(sizeof(attr->name) * 2) + 4]; - { - char attr_name_esc[sizeof(attr->name) * 2]; - BLI_str_escape(attr_name_esc, attr->name, sizeof(attr_name_esc)); - SNPRINTF(idprop_name, "[\"%s\"]", attr_name_esc); - } - /* If requesting instance data, check the parent particle system and object. */ if (attr->use_dupli) { if (dupli_source && dupli_source->particle_system) { ParticleSettings *settings = dupli_source->particle_system->part; - if (drw_uniform_property_lookup((ID *)settings, idprop_name, r_data) || + if (drw_uniform_property_lookup((ID *)settings, attr->name_id_prop, r_data) || drw_uniform_property_lookup((ID *)settings, attr->name, r_data)) { return; } } - if (drw_uniform_property_lookup((ID *)dupli_parent, idprop_name, r_data) || + if (drw_uniform_property_lookup((ID *)dupli_parent, attr->name_id_prop, r_data) || drw_uniform_property_lookup((ID *)dupli_parent, attr->name, r_data)) { return; } @@ -666,9 +659,9 @@ static void drw_uniform_attribute_lookup(GPUUniformAttr *attr, /* Check the object and mesh. */ if (ob) { - if (drw_uniform_property_lookup((ID *)ob, idprop_name, r_data) || + if (drw_uniform_property_lookup((ID *)ob, attr->name_id_prop, r_data) || drw_uniform_property_lookup((ID *)ob, attr->name, r_data) || - drw_uniform_property_lookup((ID *)ob->data, idprop_name, r_data) || + drw_uniform_property_lookup((ID *)ob->data, attr->name_id_prop, r_data) || drw_uniform_property_lookup((ID *)ob->data, attr->name, r_data)) { return; } |