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... | |
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, GenContext &context) |
Add a block of code. More... | |
void | addInclude (const string &file, GenContext &context) |
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) |
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. 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 122 of file ShaderStage.h.
using ShaderStage::FunctionCallId = std::pair<const ShaderNode*, int> |
Definition at line 125 of file ShaderStage.h.
ShaderStage::ShaderStage | ( | const string & | name, |
ConstSyntaxPtr | syntax | ||
) |
Contructor.
void ShaderStage::addBlock | ( | const string & | str, |
GenContext & | context | ||
) |
Add a block of code.
void ShaderStage::addFunctionCall | ( | const ShaderNode & | node, |
GenContext & | context | ||
) |
Add the function call for the given node.
void ShaderStage::addFunctionDefinition | ( | const ShaderNode & | node, |
GenContext & | context | ||
) |
Add the function definition for a node's implementation.
void ShaderStage::addInclude | ( | const string & | file, |
GenContext & | context | ||
) |
Add the contents of an include file. Making sure it is only included once for the shader stage.
Add a single line of code, optionally appending a semicolon.
Add a value.
Definition at line 233 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.
Return the stage function name.
Definition at line 141 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 189 of file ShaderStage.h.
Return the stage name.
Definition at line 138 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 195 of file ShaderStage.h.
Return the stage source code.
Definition at line 147 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 183 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 250 of file ShaderStage.h.
Set the stage source code.
Definition at line 144 of file ShaderStage.h.
|
friend |
Definition at line 292 of file ShaderStage.h.