Blender
V5.0
source
blender
compositor
COM_shader_node.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#pragma once
6
7
#include "
BLI_string_ref.hh
"
8
#include "
BLI_vector.hh
"
9
10
#include "
DNA_node_types.h
"
11
12
#include "
GPU_material.hh
"
13
14
#include "
NOD_derived_node_tree.hh
"
15
16
namespace
blender::compositor
{
17
18
using namespace
nodes::derived_node_tree_types;
19
20
/* ------------------------------------------------------------------------------------------------
21
* Shader Node
22
*
23
* A shader node encapsulates a compositor node tree that is capable of being used together with
24
* other shader nodes to construct a Shader Operation using the GPU material compiler. A GPU node
25
* stack for each of the node inputs and outputs is stored and populated during construction in
26
* order to represent the node as a GPU node inside the GPU material graph, see GPU_material.hh for
27
* more information. The compiler is expected to initialize the input links of the node inputs
28
* before invoking the compile method. See the discussion in COM_shader_operation.hh for more
29
* information. */
30
class
ShaderNode
{
31
private
:
32
/* The node that this operation represents. */
33
DNode
node_;
34
/* The GPU node stacks of the inputs of the node. Those are populated during construction in the
35
* populate_inputs method. The links of the inputs are initialized by the GPU material compiler
36
* prior to calling the compile method. There is an extra stack at the end to mark the end of the
37
* array, as this is what the GPU module functions expect. */
38
Vector<GPUNodeStack>
inputs_;
39
/* The GPU node stacks of the outputs of the node. Those are populated during construction in the
40
* populate_outputs method. There is an extra stack at the end to mark the end of the array, as
41
* this is what the GPU module functions expect. */
42
Vector<GPUNodeStack>
outputs_;
43
44
public
:
45
/* Construct the node by populating both its inputs and outputs. */
46
ShaderNode
(
DNode
node);
47
48
/* Compile the node by adding the appropriate GPU material graph nodes and linking the
49
* appropriate resources. */
50
void
compile
(
GPUMaterial
*material);
51
52
/* Returns the GPU node stack of the input with the given identifier. */
53
GPUNodeStack
&
get_input
(
StringRef
identifier);
54
55
/* Returns the GPU node stack of the output with the given identifier. */
56
GPUNodeStack
&
get_output
(
StringRef
identifier);
57
58
private
:
59
/* Populate the inputs of the node. The input link is set to nullptr and is expected to be
60
* initialized by the GPU material compiler before calling the compile method. */
61
void
populate_inputs();
62
/* Populate the outputs of the node. The output link is set to nullptr and is expected to be
63
* initialized by the compile method. */
64
void
populate_outputs();
65
};
66
67
}
// namespace blender::compositor
BLI_string_ref.hh
BLI_vector.hh
DNA_node_types.h
GPU_material.hh
NOD_derived_node_tree.hh
blender::StringRef
Definition
BLI_string_ref.hh:150
blender::Vector
Definition
BLI_vector.hh:76
blender::compositor::ShaderNode::ShaderNode
ShaderNode(DNode node)
Definition
shader_node.cc:22
blender::compositor::ShaderNode::get_input
GPUNodeStack & get_input(StringRef identifier)
Definition
shader_node.cc:34
blender::compositor::ShaderNode::compile
void compile(GPUMaterial *material)
Definition
shader_node.cc:28
blender::compositor::ShaderNode::get_output
GPUNodeStack & get_output(StringRef identifier)
Definition
shader_node.cc:39
blender::nodes::DNode
Definition
NOD_derived_node_tree.hh:71
blender::compositor
Definition
BKE_node.hh:77
GPUMaterial
Definition
gpu/intern/gpu_material.cc:63
GPUNodeStack
Definition
GPU_material.hh:295
Generated on
for Blender by
doxygen
1.16.1