Blender V5.3
gpu_node_graph.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#pragma once
12
13#include <variant>
14
15#include "DNA_listBase.h"
16
17#include "BLI_enum_flags.hh"
20#include "BLI_span.hh"
21
22#include "GPU_material.hh"
23
24namespace blender {
25
26struct GPUNode;
27struct GPUOutput;
28struct GPUInput;
29
46
64
75
77
78struct GPUNode {
80
81 const char *name;
82
83 /* Internal flag to mark nodes during pruning */
85
86 ListBaseT<GPUInput> inputs;
87 ListBaseT<GPUOutput> outputs;
88
89 /* Zones. */
92};
93
94using GPUNodeLinkData = std::variant<const float *, const int *, const bool *>;
95
97 GPUNodeStack *socket = nullptr;
98
100 int users = 0; /* Refcount */
101
102 union {
103 /* GPU_NODE_LINK_CONSTANT | GPU_NODE_LINK_UNIFORM */
104 GPUNodeLinkData data = static_cast<const float *>(nullptr);
105 /* GPU_NODE_LINK_COLORBAND */
107 /* GPU_NODE_LINK_OUTPUT */
109 /* GPU_NODE_LINK_ATTR */
111 /* GPU_NODE_LINK_UNIFORM_ATTR */
113 /* GPU_NODE_LINK_LAYER_ATTR */
115 /* GPU_NODE_LINK_IMAGE_BLENDER */
117 /* GPU_NODE_LINK_DIFFERENTIATE_FLOAT_FN */
118 struct {
119 const char *function_name;
120 float filter_width;
122 };
123};
124
125struct GPUOutput {
127
129 GPUType type; /* data type = length of vector/matrix */
130 GPUNodeLink *link; /* output link */
131 int id; /* unique id as created by code generator */
132
133 /* True for Zone Items. */
135 /* This variable is shared with other socket/s and doesn't need to be declared. */
137};
138
140 std::variant<float, float2, float3, float4, float3x3, float4x4, int, int2, int3, int4, bool>;
141
145
146struct GPUInput {
147 GPUInput *next = nullptr;
148 GPUInput *prev = nullptr;
149
150 GPUNode *node = nullptr;
151 GPUType type = GPU_NONE; /* data-type. */
152 GPUNodeLink *link = nullptr;
153 int id = 0; /* unique id as created by code generator */
154
156
157 /* Content based on GPUDataSource */
158 union {
159 /* GPU_SOURCE_CONSTANT | GPU_SOURCE_UNIFORM */
161 /* GPU_SOURCE_TEX | GPU_SOURCE_TEX_TILED_MAPPING */
163 /* GPU_SOURCE_ATTR */
165 /* GPU_SOURCE_UNIFORM_ATTR */
167 /* GPU_SOURCE_LAYER_ATTR */
169 /* GPU_SOURCE_FUNCTION_CALL */
170 char function_call[64];
171 };
172
173 /* True for Zone Items. */
174 bool is_zone_io = false;
175 /* This variable is shared with other socket/s and doesn't need to be declared. */
176 bool is_duplicate = false;
177};
178
184
190
192 /* Nodes */
193 ListBaseT<GPUNode> nodes;
194
195 /* Main Outputs. */
200 /* List of GPUNodeGraphOutputLink */
201 ListBaseT<GPUNodeGraphOutputLink> outlink_aovs;
202 /* List of GPUNodeGraphFunctionLink */
203 ListBaseT<GPUNodeGraphFunctionLink> material_functions;
204 /* List of GPUNodeGraphOutputLink */
205 ListBaseT<GPUNodeGraphOutputLink> outlink_compositor;
206
207 /* Requested attributes and textures. */
208 ListBaseT<GPUMaterialAttribute> attributes;
209 ListBaseT<GPUMaterialTexture> textures;
210
211 /* The list of uniform attributes. */
213
214 /* The list of layer attributes. */
215 ListBaseT<GPULayerAttr> layer_attrs;
216};
217
218/* Node Graph */
219
220void gpu_nodes_tag(GPUNodeGraph *graph, GPUNodeLink *link_start, GPUNodeTag tag);
223
237
246
247/* Material calls */
248
254 int size,
255 const float *pixels,
256 float *r_row);
261 GPUMaterial *mat, int width, int height, const float *pixels, float *row);
262
263} // namespace blender
#define ENUM_OPERATORS(_enum_type)
These structs are the foundation for all linked lists in the library system.
BMesh Iterators.
std::variant< const float *, const int *, const bool * > GPUNodeLinkData
GPUNodeGraph * gpu_material_node_graph(GPUMaterial *material)
Span< float > gpu_constant_to_float_span(const GPUInputConstantData &data, const GPUType type)
Span< int > gpu_constant_to_int_span(const GPUInputConstantData &data, const GPUType type)
void gpu_nodes_tag(GPUNodeGraph *graph, GPUNodeLink *link_start, GPUNodeTag tag)
gpu::Texture ** gpu_material_ramp_texture_row_set(GPUMaterial *mat, int size, const float *pixels, float *r_row)
gpu::Texture ** gpu_material_sky_texture_layer_set(GPUMaterial *mat, int width, int height, const float *pixels, float *row)
BMesh const char void * data
bool gpu_constant_to_bool(const GPUInputConstantData &data)
@ GPU_NODE_TAG_SURFACE
@ GPU_NODE_TAG_THICKNESS
@ GPU_NODE_TAG_VOLUME
@ GPU_NODE_TAG_FUNCTION
@ GPU_NODE_TAG_COMPOSITOR
@ GPU_NODE_TAG_DISPLACEMENT
void gpu_node_graph_free(GPUNodeGraph *graph)
void gpu_node_graph_free_nodes(GPUNodeGraph *graph)
@ GPU_NODE_LINK_CONSTANT
@ GPU_NODE_LINK_IMAGE_SKY
@ GPU_NODE_LINK_IMAGE
@ GPU_NODE_LINK_LAYER_ATTR
@ GPU_NODE_LINK_KERNEL_GLOBALS
@ GPU_NODE_LINK_IMAGE_TILED
@ GPU_NODE_LINK_SHADING_DATA
@ GPU_NODE_LINK_DIFFERENTIATE_FLOAT_FN
@ GPU_NODE_LINK_IMAGE_TILED_MAPPING
@ GPU_NODE_LINK_COLORBAND
@ GPU_NODE_LINK_OUTPUT
@ GPU_NODE_LINK_UNIFORM
@ GPU_NODE_LINK_UNIFORM_ATTR
@ GPU_SOURCE_TEX_TILED_MAPPING
@ GPU_SOURCE_SHADING_DATA
@ GPU_SOURCE_FUNCTION_CALL
@ GPU_SOURCE_LAYER_ATTR
@ GPU_SOURCE_CONSTANT
@ GPU_SOURCE_THICKNESS_MODE
@ GPU_SOURCE_CRYPTOMATTE
@ GPU_SOURCE_UNIFORM_ATTR
@ GPU_SOURCE_KERNEL_GLOBALS
void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph)
void gpu_node_graph_prune_unused(GPUNodeGraph *graph)
void gpu_node_graph_optimize(GPUNodeGraph *graph)
std::variant< float, float2, float3, float4, float3x3, float4x4, int, int2, int3, int4, bool > GPUInputConstantData
GPUDataSource source
ListBaseT< GPUMaterialAttribute > attributes
ListBaseT< GPUNodeGraphFunctionLink > material_functions
GPUNodeLink * outlink_surface
ListBaseT< GPULayerAttr > layer_attrs
GPUNodeLink * outlink_displacement
ListBaseT< GPUNodeGraphOutputLink > outlink_aovs
GPUNodeLink * outlink_thickness
ListBaseT< GPUNode > nodes
ListBaseT< GPUNodeGraphOutputLink > outlink_compositor
GPUNodeLink * outlink_volume
ListBaseT< GPUMaterialTexture > textures
GPUUniformAttrList uniform_attrs
ListBaseT< GPUOutput > outputs
const char * name
ListBaseT< GPUInput > inputs