6 #ifndef MATERIALX_SHADERSTAGE_H 
    7 #define MATERIALX_SHADERSTAGE_H 
   27 #define DEFINE_SHADER_STAGE(stage, name) if (stage.getName() == name) 
   30 #define BEGIN_SHADER_STAGE(stage, name) \ 
   31     if (stage.getName() == name)        \ 
   33 #define END_SHADER_STAGE(stage, name) } 
   70     const string& 
getName()
 const { 
return _name; }
 
   79     void setInstance(
const string& instance) { _instance = instance; }
 
   82     bool empty()
 const { 
return _variableOrder.empty(); }
 
   85     size_t size()
 const { 
return _variableOrder.size(); }
 
  131     std::unordered_map<string, ShaderPortPtr> _variableMap;
 
  132     vector<ShaderPort*> _variableOrder;
 
  155     const string& 
getName()
 const { 
return _name; }
 
  226         return _sourceDependencies;
 
  233     void endScope(
bool semicolon = 
false, 
bool newline = 
true);
 
  239     void endLine(
bool semicolon = 
true);
 
  245     void addString(
const string& str);
 
  248     void addLine(
const string& str, 
bool semicolon = 
true);
 
  251     void addComment(
const string& str);
 
  254     void addBlock(
const string& str, 
const FilePath& sourceFilename, 
GenContext& context);
 
  260     bool hasSourceDependency(
const FilePath& file);
 
  263     void addSourceDependency(
const FilePath& file);
 
  266     template <
typename T>
 
  289         _functionName = functionName;
 
  297     string _functionName;
 
  306     vector<Scope> _scopes;
 
  315     std::set<size_t> _definedFunctions;
 
  345     return uniforms.
add(type, name);
 
  360                                  bool shouldWiden = 
false)
 
  363     return inputs.
add(type, name, {}, shouldWiden);
 
  369                                                 bool shouldWiden = 
false)
 
  371     return addStageInput(block, *type, name, stage, shouldWiden);
 
  379                                   bool shouldWiden = 
false)
 
  382     return outputs.
add(type, name, {}, shouldWiden);
 
  388                                                  bool shouldWiden = 
false)
 
  395                                    const string& instance,
 
  409                               bool shouldWiden = 
false)
 
  419                                              bool shouldWiden = 
false)
 
ShaderPort * addStageOutput(const string &block, TypeDesc type, const string &name, ShaderStage &stage, bool shouldWiden=false)
Utility function for adding a new shader port to an output block. 
 
void addStageConnectorBlock(const string &block, const string &instance, ShaderStage &from, ShaderStage &to)
Utility function for adding a connector block between stages. 
 
void addValue(const T &value)
Add a value. 
 
#define MATERIALX_NAMESPACE_BEGIN
 
GLsizei const GLfloat * value
 
bool empty() const 
Return true if the block has no variables. 
 
ShaderPort * add(TypeDesc type, const string &name, ValuePtr value=nullptr, bool shouldWiden=false)
 
Uses the stage's time code range. 
 
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
 
VariableBlockPtr createOutputBlock(const string &name, const string &instance=EMPTY_STRING)
Create a new output variable block. 
 
shared_ptr< const Syntax > ConstSyntaxPtr
Shared pointer to a constant Syntax. 
 
const VariableBlockMap & getOutputBlocks() const 
Return a map of all output blocks. 
 
const VariableBlockMap & getInputBlocks() const 
Return a map of all input blocks. 
 
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
 
const string & getName() const 
Return the stage name. 
 
void setSourceCode(const string &code)
Set the stage source code. 
 
std::shared_ptr< VariableBlock > VariableBlockPtr
Shared pointer to a VariableBlock. 
 
void addStageConnector(const string &block, TypeDesc type, const string &name, ShaderStage &from, ShaderStage &to, bool shouldWiden=false)
Utility function for adding a variable to a stage connector block. 
 
GLint GLint GLsizei GLint GLenum GLenum type
 
const string & getName() const 
Get the name of this block. 
 
std::function< bool(ShaderPort *)> ShaderPortPredicate
A standard function predicate taking an ShaderPort pointer and returning a boolean. 
 
Scope(Syntax::Punctuation p)
 
std::unordered_map< string, VariableBlockPtr > VariableBlockMap
Shared pointer to a map between string identifiers and VariableBlocks. 
 
VariableBlock & getInputBlock(const string &name)
Return the input variable block with given name. 
 
ShaderPort * operator[](size_t index)
Return a variable by index. 
 
const StringSet & getIncludes() const 
Return a set of all include files. 
 
GLuint const GLchar * name
 
void setFunctionName(const string &functionName)
Set stage function name. 
 
ShaderPort * addStageInput(const string &block, TypeDesc type, const string &name, ShaderStage &stage, bool shouldWiden=false)
Utility function for adding a new shader port to an input block. 
 
MX_GENSHADER_API const string PIXEL
 
Syntax::Punctuation punctuation
 
const vector< ShaderPort * > & getVariableOrder() const 
Return a const reference to our variable order vector. 
 
std::set< FunctionCallId > functions
 
size_t size() const 
Return the number of variables in this block. 
 
void setInstance(const string &instance)
Set the instance name of this block. 
 
shared_ptr< ShaderStage > ShaderStagePtr
Shared pointer to a ShaderStage. 
 
Punctuation
Punctuation types. 
 
const VariableBlockMap & getUniformBlocks() const 
Return a map of all uniform blocks. 
 
void setName(const string &name)
Set the name of this block. 
 
shared_ptr< class ShaderPort > ShaderPortPtr
Shared pointer to a ShaderPort. 
 
VariableBlock & getUniformBlock(const string &name)
Return the uniform variable block with given name. 
 
const ShaderPort * operator[](size_t index) const 
Return a variable by index. 
 
std::set< string > StringSet
A set of strings. 
 
#define MATERIALX_NAMESPACE_END
 
ShaderPort * addStageUniform(const string &block, TypeDesc type, const string &name, ShaderStage &stage)
Utility function for adding a new shader port to a uniform block. 
 
VariableBlock & getOutputBlock(const string &name)
Return the output variable block with given name. 
 
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
 
const string & getFunctionName() const 
Return the stage function name. 
 
std::stringstream StringStream
A string stream. 
 
const string & getInstance() const 
Get the instance name of this block. 
 
shared_ptr< Value > ValuePtr
A shared pointer to a Value. 
 
const StringSet & getSourceDependencies() const 
Return a set of all source dependencies. 
 
VariableBlockPtr createInputBlock(const string &name, const string &instance=EMPTY_STRING)
Create a new input variable block. 
 
const string & getSourceCode() const 
Return the stage source code. 
 
VariableBlock(const string &name, const string &instance)