MaterialX 1.39.2
Loading...
Searching...
No Matches
SourceCodeNode.h
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_SOURCECODENODE_H
7#define MATERIALX_SOURCECODENODE_H
8
10
12
13MATERIALX_NAMESPACE_BEGIN
14
19class MX_GENSHADER_API SourceCodeNode : public ShaderNodeImpl
20{
21 public:
22 static ShaderNodeImplPtr create();
23
24 void initialize(const InterfaceElement& element, GenContext& context) override;
25 void emitFunctionDefinition(const ShaderNode& node, GenContext& context, ShaderStage& stage) const override;
26 void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const override;
27
28 protected:
30 virtual void resolveSourceCode(const InterfaceElement& element, GenContext& context);
31
32 bool _inlined;
33 string _functionName;
34 string _functionSource;
35 FilePath _sourceFilename;
36};
37
38MATERIALX_NAMESPACE_END
39
40#endif
Cross-platform support for file and search paths.
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition Library.h:40
Base class for shader node implementations.
A generic file path, supporting both syntactic and file system operations.
Definition File.h:27
A context class for shader generation.
Definition GenContext.h:31
The base class for interface elements such as Node, NodeDef, and NodeGraph.
Definition Interface.h:312
Class representing a node in the shader generation DAG.
Definition ShaderNode.h:320
ShaderNodeImpl()
Protected constructor.
A shader stage, containing the state and resulting source code for the stage.
Definition ShaderStage.h:139
Implementation for a node using data-driven static source code.
Definition SourceCodeNode.h:20
void emitFunctionDefinition(const ShaderNode &node, GenContext &context, ShaderStage &stage) const override
Emit function definition for the given node instance.
void emitFunctionCall(const ShaderNode &node, GenContext &context, ShaderStage &stage) const override
Emit the function call or inline source code for given node instance in the given context.
void initialize(const InterfaceElement &element, GenContext &context) override
Initialize with the given implementation element.
virtual void resolveSourceCode(const InterfaceElement &element, GenContext &context)
Resolve the source file and read the source code during the initialization of the node.