MaterialX 1.39.1
|
A shader stage, containing the state and resulting source code for the stage. More...
#include <ShaderStage.h>
Classes | |
struct | Scope |
Public Types | |
using | FunctionCallId = std::pair< const ShaderNode *, int > |
Public Member Functions | |
ShaderStage (const string &name, ConstSyntaxPtr syntax) | |
Contructor. | |
const string & | getName () const |
Return the stage name. | |
const string & | getFunctionName () const |
Return the stage function name. | |
void | setSourceCode (const string &code) |
Set the stage source code. | |
const string & | getSourceCode () const |
Return the stage source code. | |
VariableBlockPtr | createUniformBlock (const string &name, const string &instance=EMPTY_STRING) |
Create a new uniform variable block. | |
VariableBlockPtr | createInputBlock (const string &name, const string &instance=EMPTY_STRING) |
Create a new input variable block. | |
VariableBlockPtr | createOutputBlock (const string &name, const string &instance=EMPTY_STRING) |
Create a new output variable block. | |
VariableBlock & | getUniformBlock (const string &name) |
Return the uniform variable block with given name. | |
const VariableBlock & | getUniformBlock (const string &name) const |
Return the uniform variable block with given name. | |
VariableBlock & | getInputBlock (const string &name) |
Return the input variable block with given name. | |
const VariableBlock & | getInputBlock (const string &name) const |
Return the input variable block with given name. | |
VariableBlock & | getOutputBlock (const string &name) |
Return the output variable block with given name. | |
const VariableBlock & | getOutputBlock (const string &name) const |
Return the output variable block with given name. | |
VariableBlock & | getConstantBlock () |
Return the constant variable block. | |
const VariableBlock & | getConstantBlock () const |
Return the constant variable block. | |
const VariableBlockMap & | getUniformBlocks () const |
Return a map of all uniform blocks. | |
const VariableBlockMap & | getInputBlocks () const |
Return a map of all input blocks. | |
const VariableBlockMap & | getOutputBlocks () const |
Return a map of all output blocks. | |
const StringSet & | getIncludes () const |
Return a set of all include files. | |
const StringSet & | getSourceDependencies () const |
Return a set of all source dependencies. | |
void | beginScope (Syntax::Punctuation punc=Syntax::CURLY_BRACKETS) |
Start a new scope using the given bracket type. | |
void | endScope (bool semicolon=false, bool newline=true) |
End the current scope. | |
void | beginLine () |
Start a new line. | |
void | endLine (bool semicolon=true) |
End the current line. | |
void | newLine () |
Add a newline character. | |
void | addString (const string &str) |
Add a string. | |
void | addLine (const string &str, bool semicolon=true) |
Add a single line of code, optionally appending a semicolon. | |
void | addComment (const string &str) |
Add a single line code comment. | |
void | addBlock (const string &str, const FilePath &sourceFilename, GenContext &context) |
Add a block of code. | |
void | addInclude (const FilePath &includeFilename, const FilePath &sourceFilename, GenContext &context) |
Add the contents of an include file if not already present. | |
bool | hasSourceDependency (const FilePath &file) |
Return true if this stage depends on the given source file. | |
void | addSourceDependency (const FilePath &file) |
Mark the given source file as a dependency of this stage. | |
template<typename T > | |
void | addValue (const T &value) |
Add a value. | |
void | addFunctionDefinition (const ShaderNode &node, GenContext &context) |
Add the function definition for a node's implementation. | |
void | addFunctionCall (const ShaderNode &node, GenContext &context, bool emitCode=true) |
Add the function call for the given node. More... | |
bool | isEmitted (const ShaderNode &node, GenContext &context) const |
Return true if the function for the given node has been emitted in the current scope. | |
void | setFunctionName (const string &functionName) |
Set stage function name. | |
Friends | |
class | ShaderGenerator |
A shader stage, containing the state and resulting source code for the stage.
void addFunctionCall | ( | const ShaderNode & | node, |
GenContext & | context, | ||
bool | emitCode = true |
||
) |
Add the function call for the given node.
This will register the function as being called in the current scope, and code for the function call will be added to the stage. If emitCode is set to false the code for the function call will be omitted.