Base class for shader generators All third-party shader generators should derive from this class.
More...
|
virtual | ~ShaderGenerator () |
| Destructor.
|
|
virtual const string & | getTarget () const |
| Return the name of the target this generator is for. More...
|
|
virtual ShaderPtr | generate (const string &, ElementPtr, GenContext &) const |
| Generate a shader starting from the given element, translating the element and all dependencies upstream into shader code. More...
|
|
virtual void | emitScopeBegin (ShaderStage &stage, Syntax::Punctuation punc=Syntax::CURLY_BRACKETS) const |
| Start a new scope using the given bracket type.
|
|
virtual void | emitScopeEnd (ShaderStage &stage, bool semicolon=false, bool newline=true) const |
| End the current scope.
|
|
virtual void | emitLineBegin (ShaderStage &stage) const |
| Start a new line.
|
|
virtual void | emitLineEnd (ShaderStage &stage, bool semicolon=true) const |
| End the current line.
|
|
virtual void | emitLineBreak (ShaderStage &stage) const |
| Add a line break.
|
|
virtual void | emitString (const string &str, ShaderStage &stage) const |
| Add a string.
|
|
virtual void | emitLine (const string &str, ShaderStage &stage, bool semicolon=true) const |
| Add a single line of code, optionally appending a semicolon.
|
|
virtual void | emitComment (const string &str, ShaderStage &stage) const |
| Add a single line code comment.
|
|
virtual void | emitBlock (const string &str, const FilePath &sourceFilename, GenContext &context, ShaderStage &stage) const |
| Add a block of code.
|
|
virtual void | emitLibraryInclude (const FilePath &filename, GenContext &context, ShaderStage &stage) const |
| Add the contents of a standard library include file if not already present. More...
|
|
template<typename T > |
void | emitValue (const T &value, ShaderStage &stage) const |
| Add a value.
|
|
virtual void | emitFunctionDefinition (const ShaderNode &node, GenContext &context, ShaderStage &stage) const |
| Add the function definition for a single node.
|
|
virtual void | emitFunctionDefinitions (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const |
| Add all function definitions for a graph.
|
|
virtual void | emitFunctionCall (const ShaderNode &node, GenContext &context, ShaderStage &stage) const |
| Add the function call for a single node. More...
|
|
virtual void | emitFunctionCall (const ShaderNode &node, GenContext &context, ShaderStage &stage, bool checkScope) const |
|
virtual void | emitFunctionCalls (const ShaderGraph &graph, GenContext &context, ShaderStage &stage, uint32_t classification=0u) const |
| Add all function calls for a graph. More...
|
|
virtual void | emitDependentFunctionCalls (const ShaderNode &node, GenContext &context, ShaderStage &stage, uint32_t classification=0u) const |
| Add function calls for nodes connected directly upstream from the given node. More...
|
|
virtual void | emitFunctionBodyBegin (const ShaderNode &node, GenContext &context, ShaderStage &stage, Syntax::Punctuation punc=Syntax::CURLY_BRACKETS) const |
| Emit code for starting a new function body. More...
|
|
virtual void | emitFunctionBodyEnd (const ShaderNode &node, GenContext &context, ShaderStage &stage) const |
| Emit code for ending a function body.
|
|
virtual void | emitTypeDefinitions (GenContext &context, ShaderStage &stage) const |
| Emit type definitions for all data types that needs it.
|
|
virtual void | emitInput (const ShaderInput *input, GenContext &context, ShaderStage &stage) const |
| Emit the connected variable name for an input, or constant value if the port is not connected.
|
|
virtual void | emitOutput (const ShaderOutput *output, bool includeType, bool assignValue, GenContext &context, ShaderStage &stage) const |
| Emit the output variable name for an output, optionally including it's type and default value assignment.
|
|
virtual void | emitVariableDeclarations (const VariableBlock &block, const string &qualifier, const string &separator, GenContext &context, ShaderStage &stage, bool assignValue=true) const |
| Emit definitions for all shader variables in a block. More...
|
|
virtual void | emitVariableDeclaration (const ShaderPort *variable, const string &qualifier, GenContext &context, ShaderStage &stage, bool assignValue=true) const |
| Emit definition of a single shader variable. More...
|
|
virtual void | getClosureContexts (const ShaderNode &node, vector< ClosureContext * > &cct) const |
| Return the closure contexts defined for the given node. More...
|
|
virtual string | getUpstreamResult (const ShaderInput *input, GenContext &context) const |
| Return the result of an upstream connection or value for an input. More...
|
|
const Syntax & | getSyntax () const |
| Return the syntax object for the language used by the code generator.
|
|
void | registerImplementation (const string &name, CreatorFunction< ShaderNodeImpl > creator) |
| Register a shader node implementation for a given implementation element name.
|
|
void | registerImplementation (const StringVec &nameVec, CreatorFunction< ShaderNodeImpl > creator) |
| Register a shader node implementation for a given set of implementation element names.
|
|
bool | implementationRegistered (const string &name) const |
| Determine if a shader node implementation has been registered for a given implementation element name.
|
|
virtual ShaderNodeImplPtr | getImplementation (const NodeDef &nodedef, GenContext &context) const |
| Return a registered shader node implementation for the given nodedef. More...
|
|
void | setColorManagementSystem (ColorManagementSystemPtr colorManagementSystem) |
| Sets the color management system.
|
|
ColorManagementSystemPtr | getColorManagementSystem () const |
| Returns the color management system.
|
|
void | setUnitSystem (UnitSystemPtr unitSystem) |
| Sets the unit system.
|
|
UnitSystemPtr | getUnitSystem () const |
| Returns the unit system.
|
|
const StringMap & | getTokenSubstitutions () const |
| Return the map of token substitutions used by the generator.
|
|
virtual void | registerShaderMetadata (const DocumentPtr &doc, GenContext &context) const |
| Register metadata that should be exported to the generated shaders. More...
|
|
Base class for shader generators All third-party shader generators should derive from this class.
Derived classes should use DECLARE_SHADER_GENERATOR / DEFINE_SHADER_GENERATOR in their declaration / definition, and register with the Registry class.