MaterialX 1.38.2
Public Member Functions | Protected Attributes | List of all members
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)
 Add to the search path used for finding source code.
 
void registerSourceCodeSearchPath (const FileSearchPath &path)
 Add to the search path used for finding source code.
 
FilePath resolveSourceFile (const FilePath &filename) const
 Resolve a file using the registered search paths.
 
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 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...
 

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
 

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: