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 = std::pair< const ShaderNode *, int >
 

Public Member Functions

 ShaderStage (const string &name, ConstSyntaxPtr syntax)
 Contructor. More...
 
const stringgetName () const
 Return the stage name. More...
 
const stringgetFunctionName () const
 Return the stage function name. More...
 
void setSourceCode (const string &code)
 Set the stage source code. More...
 
const stringgetSourceCode () 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...
 
VariableBlockgetUniformBlock (const string &name)
 Return the uniform variable block with given name. More...
 
const VariableBlockgetUniformBlock (const string &name) const
 Return the uniform variable block with given name. More...
 
VariableBlockgetInputBlock (const string &name)
 Return the input variable block with given name. More...
 
const VariableBlockgetInputBlock (const string &name) const
 Return the input variable block with given name. More...
 
VariableBlockgetOutputBlock (const string &name)
 Return the output variable block with given name. More...
 
const VariableBlockgetOutputBlock (const string &name) const
 Return the output variable block with given name. More...
 
VariableBlockgetConstantBlock ()
 Return the constant variable block. More...
 
const VariableBlockgetConstantBlock () const
 Return the constant variable block. More...
 
const VariableBlockMapgetUniformBlocks () const
 Return a map of all uniform blocks. More...
 
const VariableBlockMapgetInputBlocks () const
 Return a map of all input blocks. More...
 
const VariableBlockMapgetOutputBlocks () const
 Return a map of all output blocks. More...
 
const StringSetgetIncludes () const
 Return a set of all include files. More...
 
const StringSetgetSourceDependencies () 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...
 
void addSourceDependency (const FilePath &file)
 Add a source file dependency for dependency tracking purposes. 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 138 of file ShaderStage.h.

Member Typedef Documentation

using ShaderStage::FunctionCallId = std::pair<const ShaderNode*, int>

Definition at line 141 of file ShaderStage.h.

Constructor & Destructor Documentation

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

Contructor.

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)

Add a source file dependency for dependency tracking purposes.

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 264 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 158 of file ShaderStage.h.

const StringSet& ShaderStage::getIncludes ( ) const
inline

Return a set of all include files.

Definition at line 218 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 206 of file ShaderStage.h.

const string& ShaderStage::getName ( ) const
inline

Return the stage name.

Definition at line 155 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 212 of file ShaderStage.h.

const string& ShaderStage::getSourceCode ( ) const
inline

Return the stage source code.

Definition at line 164 of file ShaderStage.h.

const StringSet& ShaderStage::getSourceDependencies ( ) const
inline

Return a set of all source dependencies.

Definition at line 224 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 200 of file ShaderStage.h.

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 284 of file ShaderStage.h.

void ShaderStage::setSourceCode ( const string code)
inline

Set the stage source code.

Definition at line 161 of file ShaderStage.h.

Friends And Related Function Documentation

friend class ShaderGenerator
friend

Definition at line 329 of file ShaderStage.h.


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