Attribute Node: refactor lookup to remove duplication between engines.

Currently lookup of Object and Instancer attributes is completely
duplicated between Cycles, Eevee and Eevee Next. This is bad design,
so this patch aims to deduplicate it by introducing a common API
in blenkernel.

In case of Cycles this requires certain hacks, but according to
Brecht it is planned to be rewritten later for more direct access
to internal Blender data anyway.

Differential Revision: https://developer.blender.org/D16117
This commit is contained in:
2022-09-30 18:54:26 +03:00
parent 42eda155df
commit 554afabf75
10 changed files with 155 additions and 215 deletions

View File

@@ -335,8 +335,6 @@ typedef struct GPUUniformAttr {
/* Meaningful part of the attribute set key. */
char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
/** Escaped name with [""]. */
char name_id_prop[64 * 2 + 4];
/** Hash of name[64] + use_dupli. */
uint32_t hash_code;
bool use_dupli;

View File

@@ -416,11 +416,6 @@ static GPUUniformAttr *gpu_node_graph_add_uniform_attribute(GPUNodeGraph *graph,
if (attr == NULL && attrs->count < GPU_MAX_UNIFORM_ATTR) {
attr = MEM_callocN(sizeof(*attr), __func__);
STRNCPY(attr->name, name);
{
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);
}
attr->use_dupli = use_dupli;
attr->hash_code = BLI_ghashutil_strhash_p(attr->name) << 1 | (attr->use_dupli ? 0 : 1);
attr->id = -1;