HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShaderStage Class Reference

#include <ShaderStage.h>

Classes

struct  Scope
 

Public Types

using FunctionCallId = const ShaderNode *
 

Public Member Functions

 ShaderStage (const string &name, ConstSyntaxPtr syntax)
 Constructor. More...
 
const string & getName () const
 Return the stage name. More...
 
const string & getFunctionName () const
 Return the stage function name. More...
 
void setSourceCode (const string &code)
 Set the stage source code. More...
 
const string & getSourceCode () const
 Return the stage source code. More...
 
VariableBlockPtr createUniformBlock (const string &name, const string &instance=EMPTY_STRING)
 Create a new uniform variable block. More...
 
VariableBlockPtr createInputBlock (const string &name, const string &instance=EMPTY_STRING)
 Create a new input variable block. More...
 
VariableBlockPtr createOutputBlock (const string &name, const string &instance=EMPTY_STRING)
 Create a new output variable block. More...
 
VariableBlock & getUniformBlock (const string &name)
 Return the uniform variable block with given name. More...
 
const VariableBlock & getUniformBlock (const string &name) const
 Return the uniform variable block with given name. More...
 
VariableBlock & getInputBlock (const string &name)
 Return the input variable block with given name. More...
 
const VariableBlock & getInputBlock (const string &name) const
 Return the input variable block with given name. More...
 
VariableBlock & getOutputBlock (const string &name)
 Return the output variable block with given name. More...
 
const VariableBlock & getOutputBlock (const string &name) const
 Return the output variable block with given name. More...
 
VariableBlock & getConstantBlock ()
 Return the constant variable block. More...
 
const VariableBlock & getConstantBlock () const
 Return the constant variable block. More...
 
const VariableBlockMap & getUniformBlocks () const
 Return a map of all uniform blocks. More...
 
const VariableBlockMap & getInputBlocks () const
 Return a map of all input blocks. More...
 
const VariableBlockMap & getOutputBlocks () const
 Return a map of all output blocks. More...
 
const StringSet & getIncludes () const
 Return a set of all include files. More...
 
const StringSet & getSourceDependencies () const
 Return a set of all source dependencies. More...
 
void beginScope (Syntax::Punctuation punc=Syntax::CURLY_BRACKETS)
 Start a new scope using the given bracket type. More...
 
void endScope (bool semicolon=false, bool newline=true)
 End the current scope. More...
 
void beginLine ()
 Start a new line. More...
 
void endLine (bool semicolon=true)
 End the current line. More...
 
void newLine ()
 Add a newline character. More...
 
void addString (const string &str)
 Add a string. More...
 
void addLine (const string &str, bool semicolon=true)
 Add a single line of code, optionally appending a semicolon. More...
 
void addComment (const string &str)
 Add a single line code comment. More...
 
void addBlock (const string &str, const FilePath &sourceFilename, GenContext &context)
 Add a block of code. More...
 
void addInclude (const FilePath &includeFilename, const FilePath &sourceFilename, GenContext &context)
 Add the contents of an include file if not already present. More...
 
bool hasSourceDependency (const FilePath &file)
 Return true if this stage depends on the given source file. More...
 
void addSourceDependency (const FilePath &file)
 Mark the given source file as a dependency of this stage. More...
 
template<typename T >
void addValue (const T &value)
 Add a value. More...
 
void addFunctionDefinition (const ShaderNode &node, GenContext &context)
 Add the function definition for a node's implementation. More...
 
void addFunctionCall (const ShaderNode &node, GenContext &context, bool emitCode=true)
 
bool isEmitted (const ShaderNode &node, GenContext &context) const
 Return true if the function for the given node has been emitted in the current scope. More...
 
void setFunctionName (const string &functionName)
 Set stage function name. More...
 

Friends

class ShaderGenerator
 

Detailed Description

A shader stage, containing the state and resulting source code for the stage.

Definition at line 144 of file ShaderStage.h.

Member Typedef Documentation

Definition at line 147 of file ShaderStage.h.

Constructor & Destructor Documentation

ShaderStage::ShaderStage ( const string &  name,
ConstSyntaxPtr  syntax 
)

Constructor.

Member Function Documentation

void ShaderStage::addBlock ( const string &  str,
const FilePath &  sourceFilename,
GenContext &  context 
)

Add a block of code.

void ShaderStage::addComment ( const string &  str)

Add a single line code comment.

void ShaderStage::addFunctionCall ( const ShaderNode &  node,
GenContext &  context,
bool  emitCode = true 
)

Add the function call for the given node. This will register the function as being called in the current scope, and code for the function call will be added to the stage. If emitCode is set to false the code for the function call will be omitted.

void ShaderStage::addFunctionDefinition ( const ShaderNode &  node,
GenContext &  context 
)

Add the function definition for a node's implementation.

void ShaderStage::addInclude ( const FilePath &  includeFilename,
const FilePath &  sourceFilename,
GenContext &  context 
)

Add the contents of an include file if not already present.

void ShaderStage::addLine ( const string &  str,
bool  semicolon = true 
)

Add a single line of code, optionally appending a semicolon.

void ShaderStage::addSourceDependency ( const FilePath &  file)

Mark the given source file as a dependency of this stage.

void ShaderStage::addString ( const string &  str)

Add a string.

template<typename T >
void ShaderStage::addValue ( const T &  value)
inline

Add a value.

Definition at line 273 of file ShaderStage.h.

void ShaderStage::beginLine ( )

Start a new line.

void ShaderStage::beginScope ( Syntax::Punctuation  punc = Syntax::CURLY_BRACKETS)

Start a new scope using the given bracket type.

VariableBlockPtr ShaderStage::createInputBlock ( const string &  name,
const string &  instance = EMPTY_STRING 
)

Create a new input variable block.

VariableBlockPtr ShaderStage::createOutputBlock ( const string &  name,
const string &  instance = EMPTY_STRING 
)

Create a new output variable block.

VariableBlockPtr ShaderStage::createUniformBlock ( const string &  name,
const string &  instance = EMPTY_STRING 
)

Create a new uniform variable block.

void ShaderStage::endLine ( bool  semicolon = true)

End the current line.

void ShaderStage::endScope ( bool  semicolon = false,
bool  newline = true 
)

End the current scope.

VariableBlock& ShaderStage::getConstantBlock ( )

Return the constant variable block.

const VariableBlock& ShaderStage::getConstantBlock ( ) const

Return the constant variable block.

const string& ShaderStage::getFunctionName ( ) const
inline

Return the stage function name.

Definition at line 164 of file ShaderStage.h.

const StringSet& ShaderStage::getIncludes ( ) const
inline

Return a set of all include files.

Definition at line 224 of file ShaderStage.h.

VariableBlock& ShaderStage::getInputBlock ( const string &  name)

Return the input variable block with given name.

const VariableBlock& ShaderStage::getInputBlock ( const string &  name) const

Return the input variable block with given name.

const VariableBlockMap& ShaderStage::getInputBlocks ( ) const
inline

Return a map of all input blocks.

Definition at line 212 of file ShaderStage.h.

const string& ShaderStage::getName ( ) const
inline

Return the stage name.

Definition at line 161 of file ShaderStage.h.

VariableBlock& ShaderStage::getOutputBlock ( const string &  name)

Return the output variable block with given name.

const VariableBlock& ShaderStage::getOutputBlock ( const string &  name) const

Return the output variable block with given name.

const VariableBlockMap& ShaderStage::getOutputBlocks ( ) const
inline

Return a map of all output blocks.

Definition at line 218 of file ShaderStage.h.

const string& ShaderStage::getSourceCode ( ) const
inline

Return the stage source code.

Definition at line 170 of file ShaderStage.h.

const StringSet& ShaderStage::getSourceDependencies ( ) const
inline

Return a set of all source dependencies.

Definition at line 230 of file ShaderStage.h.

VariableBlock& ShaderStage::getUniformBlock ( const string &  name)

Return the uniform variable block with given name.

const VariableBlock& ShaderStage::getUniformBlock ( const string &  name) const

Return the uniform variable block with given name.

const VariableBlockMap& ShaderStage::getUniformBlocks ( ) const
inline

Return a map of all uniform blocks.

Definition at line 206 of file ShaderStage.h.

bool ShaderStage::hasSourceDependency ( const FilePath &  file)

Return true if this stage depends on the given source file.

bool ShaderStage::isEmitted ( const ShaderNode &  node,
GenContext &  context 
) const

Return true if the function for the given node has been emitted in the current scope.

void ShaderStage::newLine ( )

Add a newline character.

void ShaderStage::setFunctionName ( const string &  functionName)
inline

Set stage function name.

Definition at line 293 of file ShaderStage.h.

void ShaderStage::setSourceCode ( const string &  code)
inline

Set the stage source code.

Definition at line 167 of file ShaderStage.h.

Friends And Related Function Documentation

friend class ShaderGenerator
friend

Definition at line 338 of file ShaderStage.h.


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