6#ifndef MATERIALX_SHADER_H
7#define MATERIALX_SHADER_H
18MATERIALX_NAMESPACE_BEGIN
42 const string&
getName()
const {
return _name; }
65 return _attributeMap.count(attrib) != 0;
72 auto it = _attributeMap.find(attrib);
73 return it != _attributeMap.end() ? it->second :
nullptr;
79 _attributeMap[attrib] = value;
85 _attributeMap[attrib] = Value::createValue<bool>(
true);
98 void setSourceCode(
const string& code,
const string& stage = Stage::PIXEL) { getStage(stage).setSourceCode(code); }
101 const string&
getSourceCode(
const string& stage = Stage::PIXEL)
const {
return getStage(stage).getSourceCode(); }
109 std::unordered_map<string, ShaderStagePtr> _stagesMap;
110 vector<ShaderStage*> _stages;
111 std::unordered_map<string, ValuePtr> _attributeMap;
116MATERIALX_NAMESPACE_END
Shader generation options class.
Macros for declaring imported and exported symbols.
shared_ptr< ShaderStage > ShaderStagePtr
Shared pointer to a ShaderStage.
Definition: Library.h:36
shared_ptr< class ShaderGraph > ShaderGraphPtr
A shared pointer to a shader graph.
Definition: ShaderGraph.h:39
Class related to holding information for shader stages.
shared_ptr< const Syntax > ConstSyntaxPtr
Shared pointer to a constant Syntax.
Definition: Syntax.h:29
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:29
Base class for shader generators All third-party shader generators should derive from this class.
Definition: ShaderGenerator.h:31
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:44
Class containing all data needed during shader generation.
Definition: Shader.h:33
void setAttribute(const string &attrib)
Set a flag attribute on the shader.
Definition: Shader.h:83
const ShaderGraph & getGraph() const
Return the shader graph.
Definition: Shader.h:89
const ShaderStage & getStage(size_t index) const
Return a stage by index.
void setSourceCode(const string &code, const string &stage=Stage::PIXEL)
Set the shader source code for a given shader stage.
Definition: Shader.h:98
bool hasStage(const string &name)
Return if stage exists.
size_t numStages() const
Return the number of shader stages for this shader.
Definition: Shader.h:45
bool hasClassification(unsigned int c) const
Return true if this shader matches the given classification.
Definition: Shader.h:95
const string & getName() const
Return the shader name.
Definition: Shader.h:42
ShaderStagePtr createStage(const string &name, ConstSyntaxPtr syntax)
Create a new stage in the shader.
virtual ~Shader()
Destructor.
Definition: Shader.h:39
ShaderStage & getStage(const string &name)
Return a stage by name.
void setAttribute(const string &attrib, ValuePtr value)
Set a value attribute on the shader.
Definition: Shader.h:77
const string & getSourceCode(const string &stage=Stage::PIXEL) const
Return the shader source code for a given shader stage.
Definition: Shader.h:101
const ShaderStage & getStage(const string &name) const
Return a stage by name.
ShaderStage & getStage(size_t index)
Return a stage by index.
Shader(const string &name, ShaderGraphPtr graph)
Constructor.
ShaderGraph & getGraph()
Return the shader graph.
Definition: Shader.h:92
ValuePtr getAttribute(const string &attrib) const
Return the value for a named attribute, or nullptr if no such attribute is found.
Definition: Shader.h:70
bool hasAttribute(const string &attrib) const
Return true if the shader has a given named attribute.
Definition: Shader.h:63
A shader stage, containing the state and resulting source code for the stage.
Definition: ShaderStage.h:139