HDK
|
#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. More... | |
const string & | getName () const |
Return the stage name. More... | |
const string & | getFunctionName () const |
Return the stage function name. More... | |
void | setSourceCode (const string &code) |
Set the stage source code. More... | |
const string & | getSourceCode () const |
Return the stage source code. More... | |
VariableBlockPtr | createUniformBlock (const string &name, const string &instance=EMPTY_STRING) |
Create a new uniform variable block. More... | |
VariableBlockPtr | createInputBlock (const string &name, const string &instance=EMPTY_STRING) |
Create a new input variable block. More... | |
VariableBlockPtr | createOutputBlock (const string &name, const string &instance=EMPTY_STRING) |
Create a new output variable block. More... | |
VariableBlock & | getUniformBlock (const string &name) |
Return the uniform variable block with given name. More... | |
const VariableBlock & | getUniformBlock (const string &name) const |
Return the uniform variable block with given name. More... | |
VariableBlock & | getInputBlock (const string &name) |
Return the input variable block with given name. More... | |
const VariableBlock & | getInputBlock (const string &name) const |
Return the input variable block with given name. More... | |
VariableBlock & | getOutputBlock (const string &name) |
Return the output variable block with given name. More... | |
const VariableBlock & | getOutputBlock (const string &name) const |
Return the output variable block with given name. More... | |
VariableBlock & | getConstantBlock () |
Return the constant variable block. More... | |
const VariableBlock & | getConstantBlock () const |
Return the constant variable block. More... | |
const VariableBlockMap & | getUniformBlocks () const |
Return a map of all uniform blocks. More... | |
const VariableBlockMap & | getInputBlocks () const |
Return a map of all input blocks. More... | |
const VariableBlockMap & | getOutputBlocks () const |
Return a map of all output blocks. More... | |
const StringSet & | getIncludes () const |
Return a set of all include files. More... | |
const StringSet & | getSourceDependencies () const |
Return a set of all source dependencies. More... | |
void | beginScope (Syntax::Punctuation punc=Syntax::CURLY_BRACKETS) |
Start a new scope using the given bracket type. More... | |
void | endScope (bool semicolon=false, bool newline=true) |
End the current scope. More... | |
void | beginLine () |
Start a new line. More... | |
void | endLine (bool semicolon=true) |
End the current line. More... | |
void | newLine () |
Add a newline character. More... | |
void | addString (const string &str) |
Add a string. More... | |
void | addLine (const string &str, bool semicolon=true) |
Add a single line of code, optionally appending a semicolon. More... | |
void | addComment (const string &str) |
Add a single line code comment. More... | |
void | addBlock (const string &str, const FilePath &sourceFilename, GenContext &context) |
Add a block of code. More... | |
void | addInclude (const FilePath &includeFilename, const FilePath &sourceFilename, GenContext &context) |
Add the contents of an include file if not already present. More... | |
void | addSourceDependency (const FilePath &file) |
Add a source file dependency for dependency tracking purposes. More... | |
template<typename T > | |
void | addValue (const T &value) |
Add a value. More... | |
void | addFunctionDefinition (const ShaderNode &node, GenContext &context) |
Add the function definition for a node's implementation. More... | |
void | addFunctionCall (const ShaderNode &node, GenContext &context, bool emitCode=true) |
bool | isEmitted (const ShaderNode &node, GenContext &context) const |
Return true if the function for the given node has been emitted in the current scope. More... | |
void | setFunctionName (const string &functionName) |
Set stage function name. More... | |
Friends | |
class | ShaderGenerator |
A shader stage, containing the state and resulting source code for the stage.
Definition at line 138 of file ShaderStage.h.
using ShaderStage::FunctionCallId = std::pair<const ShaderNode*, int> |
Definition at line 141 of file ShaderStage.h.
ShaderStage::ShaderStage | ( | const string & | name, |
ConstSyntaxPtr | syntax | ||
) |
Contructor.
void ShaderStage::addBlock | ( | const string & | str, |
const FilePath & | sourceFilename, | ||
GenContext & | context | ||
) |
Add a block of code.
void ShaderStage::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.
void ShaderStage::addFunctionDefinition | ( | const ShaderNode & | node, |
GenContext & | context | ||
) |
Add the function definition for a node's implementation.
void ShaderStage::addInclude | ( | const FilePath & | includeFilename, |
const FilePath & | sourceFilename, | ||
GenContext & | context | ||
) |
Add the contents of an include file if not already present.
Add a single line of code, optionally appending a semicolon.
Add a source file dependency for dependency tracking purposes.
Add a value.
Definition at line 264 of file ShaderStage.h.
void ShaderStage::beginLine | ( | ) |
Start a new line.
void ShaderStage::beginScope | ( | Syntax::Punctuation | punc = Syntax::CURLY_BRACKETS | ) |
Start a new scope using the given bracket type.
VariableBlockPtr ShaderStage::createInputBlock | ( | const string & | name, |
const string & | instance = EMPTY_STRING |
||
) |
Create a new input variable block.
VariableBlockPtr ShaderStage::createOutputBlock | ( | const string & | name, |
const string & | instance = EMPTY_STRING |
||
) |
Create a new output variable block.
VariableBlockPtr ShaderStage::createUniformBlock | ( | const string & | name, |
const string & | instance = EMPTY_STRING |
||
) |
Create a new uniform variable block.
void ShaderStage::endLine | ( | bool | semicolon = true | ) |
End the current line.
void ShaderStage::endScope | ( | bool | semicolon = false , |
bool | newline = true |
||
) |
End the current scope.
VariableBlock& ShaderStage::getConstantBlock | ( | ) |
Return the constant variable block.
const VariableBlock& ShaderStage::getConstantBlock | ( | ) | const |
Return the constant variable block.
|
inline |
Return the stage function name.
Definition at line 158 of file ShaderStage.h.
|
inline |
Return a set of all include files.
Definition at line 218 of file ShaderStage.h.
VariableBlock& ShaderStage::getInputBlock | ( | const string & | name | ) |
Return the input variable block with given name.
const VariableBlock& ShaderStage::getInputBlock | ( | const string & | name | ) | const |
Return the input variable block with given name.
|
inline |
Return a map of all input blocks.
Definition at line 206 of file ShaderStage.h.
|
inline |
Return the stage name.
Definition at line 155 of file ShaderStage.h.
VariableBlock& ShaderStage::getOutputBlock | ( | const string & | name | ) |
Return the output variable block with given name.
const VariableBlock& ShaderStage::getOutputBlock | ( | const string & | name | ) | const |
Return the output variable block with given name.
|
inline |
Return a map of all output blocks.
Definition at line 212 of file ShaderStage.h.
|
inline |
Return the stage source code.
Definition at line 164 of file ShaderStage.h.
|
inline |
Return a set of all source dependencies.
Definition at line 224 of file ShaderStage.h.
VariableBlock& ShaderStage::getUniformBlock | ( | const string & | name | ) |
Return the uniform variable block with given name.
const VariableBlock& ShaderStage::getUniformBlock | ( | const string & | name | ) | const |
Return the uniform variable block with given name.
|
inline |
Return a map of all uniform blocks.
Definition at line 200 of file ShaderStage.h.
bool ShaderStage::isEmitted | ( | const ShaderNode & | node, |
GenContext & | context | ||
) | const |
Return true if the function for the given node has been emitted in the current scope.
void ShaderStage::newLine | ( | ) |
Add a newline character.
Set stage function name.
Definition at line 284 of file ShaderStage.h.
Set the stage source code.
Definition at line 161 of file ShaderStage.h.
|
friend |
Definition at line 329 of file ShaderStage.h.