Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_node_graph.c
| Show First 20 Lines • Show All 908 Lines • ▼ Show 20 Lines | void gpu_node_graph_prune_unused(GPUNodeGraph *graph) | ||||
| LISTBASE_FOREACH_MUTABLE (GPUUniformAttr *, attr, &uattrs->list) { | LISTBASE_FOREACH_MUTABLE (GPUUniformAttr *, attr, &uattrs->list) { | ||||
| if (attr->users == 0) { | if (attr->users == 0) { | ||||
| BLI_freelinkN(&uattrs->list, attr); | BLI_freelinkN(&uattrs->list, attr); | ||||
| uattrs->count--; | uattrs->count--; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void gpu_node_graph_optimize(GPUNodeGraph *graph) | |||||
| { | |||||
| /* Replace all uniform node links with constant. */ | |||||
| LISTBASE_FOREACH (GPUNode *, node, &graph->nodes) { | |||||
| LISTBASE_FOREACH (GPUInput *, input, &node->inputs) { | |||||
| if (input->link) { | |||||
| if (input->link->link_type == GPU_NODE_LINK_UNIFORM) { | |||||
| input->link->link_type = GPU_NODE_LINK_CONSTANT; | |||||
| } | |||||
| } | |||||
| if (input->source == GPU_SOURCE_UNIFORM) { | |||||
| input->source = (input->type == GPU_CLOSURE) ? GPU_SOURCE_STRUCT : GPU_SOURCE_CONSTANT; | |||||
| } | |||||
| } | |||||
| } | |||||
| /* TODO: Consider performing other node graph optimizations here. */ | |||||
| } | |||||