MaterialX 1.38.10
Loading...
Searching...
No Matches
GenContext Class Reference

A context class for shader generation. More...

#include <GenContext.h>

Public Member Functions

 GenContext (ShaderGeneratorPtr sg)
 Constructor.
 
ShaderGeneratorgetShaderGenerator ()
 Return shader generatior.
 
GenOptionsgetOptions ()
 Return shader generation options.
 
const GenOptionsgetOptions () const
 Return shader generation options.
 
void registerSourceCodeSearchPath (const FilePath &path)
 Register a user search path for finding source code during code generation.
 
void registerSourceCodeSearchPath (const FileSearchPath &path)
 Register a user search path for finding source code during code generation.
 
FilePath resolveSourceFile (const FilePath &filename, const FilePath &localPath) const
 Resolve a source code filename, first checking the given local path then checking any file paths registered by the user.
 
void addReservedWords (const StringSet &names)
 Add reserved words that should not be used as identifiers during code generation.
 
const StringSetgetReservedWords () const
 Return the set of reserved words that should not be used as identifiers during code generation.
 
void addNodeImplementation (const string &name, ShaderNodeImplPtr impl)
 Cache a shader node implementation.
 
ShaderNodeImplPtr findNodeImplementation (const string &name) const
 Find and return a cached shader node implementation, or return nullptr if no implementation is found.
 
void getNodeImplementationNames (StringSet &names)
 Get the names of all cached node implementations.
 
void clearNodeImplementations ()
 Clear all cached shader node implementation.
 
void pushClosureContext (ClosureContext *cct)
 Push a new closure context to use for closure evaluation.
 
void popClosureContext ()
 Pop the current closure context.
 
ClosureContextgetClosureContext ()
 Return the current closure context.
 
void pushParentNode (ConstNodePtr node)
 Push a parent node onto the stack.
 
void popParentNode ()
 Pop the current parent node from the stack.
 
const vector< ConstNodePtr > & getParentNodes ()
 Return the current stack of parent nodes.
 
void pushUserData (const string &name, GenUserDataPtr data)
 Add user data to the context to make it available during shader generator.
 
void popUserData (const string &name)
 Remove user data from the context.
 
void clearUserData ()
 Clear all user data from the context.
 
template<class T >
std::shared_ptr< T > getUserData (const string &name)
 Return user data with given name, or nullptr if no data is found.
 
void addInputSuffix (const ShaderInput *input, const string &suffix)
 Add an input suffix to be used for the input in this context. More...
 
void removeInputSuffix (const ShaderInput *input)
 Remove an input suffix to be used for the input in this context. More...
 
void getInputSuffix (const ShaderInput *input, string &suffix) const
 Get an input suffix to be used for the input in this context. More...
 
void addOutputSuffix (const ShaderOutput *output, const string &suffix)
 Add an output suffix to be used for the output in this context. More...
 
void removeOutputSuffix (const ShaderOutput *output)
 Remove an output suffix to be used for the output in this context. More...
 
void getOutputSuffix (const ShaderOutput *output, string &suffix) const
 Get an output suffix to be used for the output in this context. More...
 
void setApplicationVariableHandler (ApplicationVariableHandler handler)
 Set handler for application variables.
 
ApplicationVariableHandler getApplicationVariableHandler () const
 Get handler for application variables.
 

Protected Attributes

ShaderGeneratorPtr _sg
 
GenOptions _options
 
FileSearchPath _sourceCodeSearchPath
 
StringSet _reservedWords
 
std::unordered_map< string, ShaderNodeImplPtr_nodeImpls
 
std::unordered_map< string, vector< GenUserDataPtr > > _userData
 
std::unordered_map< const ShaderInput *, string > _inputSuffix
 
std::unordered_map< const ShaderOutput *, string > _outputSuffix
 
vector< ClosureContext * > _closureContexts
 
vector< ConstNodePtr_parentNodes
 
ApplicationVariableHandler _applicationVariableHandler
 

Detailed Description

A context class for shader generation.

Used for thread local storage of data needed during shader generation.

Member Function Documentation

◆ addInputSuffix()

void addInputSuffix ( const ShaderInput input,
const string &  suffix 
)

Add an input suffix to be used for the input in this context.

Parameters
inputNode input
suffixSuffix string

◆ addOutputSuffix()

void addOutputSuffix ( const ShaderOutput output,
const string &  suffix 
)

Add an output suffix to be used for the output in this context.

Parameters
outputNode output
suffixSuffix string

◆ getInputSuffix()

void getInputSuffix ( const ShaderInput input,
string &  suffix 
) const

Get an input suffix to be used for the input in this context.

Parameters
inputNode input
suffixSuffix string returned. Is empty if not found.

◆ getOutputSuffix()

void getOutputSuffix ( const ShaderOutput output,
string &  suffix 
) const

Get an output suffix to be used for the output in this context.

Parameters
outputNode output
suffixSuffix string returned. Is empty if not found.

◆ removeInputSuffix()

void removeInputSuffix ( const ShaderInput input)

Remove an input suffix to be used for the input in this context.

Parameters
inputNode input

◆ removeOutputSuffix()

void removeOutputSuffix ( const ShaderOutput output)

Remove an output suffix to be used for the output in this context.

Parameters
outputNode output

The documentation for this class was generated from the following files: