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

#include <VkShaderGenerator.h>

+ Inheritance diagram for VkShaderGenerator:

Public Member Functions

 VkShaderGenerator ()
 
const stringgetTarget () const override
 Return a unique identifier for the target this generator is for. More...
 
const stringgetVersion () const override
 Return the version string for the GLSL version this generator is for. More...
 
string getVertexDataPrefix (const VariableBlock &vertexData) const override
 Determine the prefix of vertex data variables. More...
 
void emitDirectives (GenContext &context, ShaderStage &stage) const override
 
void emitInputs (GenContext &context, ShaderStage &stage) const override
 
void emitOutputs (GenContext &context, ShaderStage &stage) const override
 
- Public Member Functions inherited from GlslShaderGenerator
 GlslShaderGenerator ()
 
ShaderPtr generate (const string &name, ElementPtr element, GenContext &context) const override
 
void emitVariableDeclaration (const ShaderPort *variable, const string &qualifier, GenContext &context, ShaderStage &stage, bool assignValue=true) const override
 Emit a shader variable. More...
 
ShaderNodeImplPtr getImplementation (const NodeDef &nodedef, GenContext &context) const override
 
- Public Member Functions inherited from HwShaderGenerator
void emitFunctionCall (const ShaderNode &node, GenContext &context, ShaderStage &stage) const override
 Add the function call for a single node. More...
 
virtual void addStageLightingUniforms (GenContext &context, ShaderStage &stage) const
 Emit code for active light count definitions and uniforms. More...
 
void getClosureContexts (const ShaderNode &node, vector< ClosureContext * > &cct) const override
 Return the closure contexts defined for the given node. More...
 
- Public Member Functions inherited from ShaderGenerator
virtual ~ShaderGenerator ()
 Destructor. More...
 
virtual void emitScopeBegin (ShaderStage &stage, Syntax::Punctuation punc=Syntax::CURLY_BRACKETS) const
 Start a new scope using the given bracket type. More...
 
virtual void emitScopeEnd (ShaderStage &stage, bool semicolon=false, bool newline=true) const
 End the current scope. More...
 
virtual void emitLineBegin (ShaderStage &stage) const
 Start a new line. More...
 
virtual void emitLineEnd (ShaderStage &stage, bool semicolon=true) const
 End the current line. More...
 
virtual void emitLineBreak (ShaderStage &stage) const
 Add a line break. More...
 
virtual void emitString (const string &str, ShaderStage &stage) const
 Add a string. More...
 
virtual void emitLine (const string &str, ShaderStage &stage, bool semicolon=true) const
 Add a single line of code, optionally appending a semicolon. More...
 
virtual void emitComment (const string &str, ShaderStage &stage) const
 Add a single line code comment. More...
 
virtual void emitBlock (const string &str, const FilePath &sourceFilename, GenContext &context, ShaderStage &stage) const
 Add a block of code. More...
 
virtual void emitLibraryInclude (const FilePath &filename, GenContext &context, ShaderStage &stage) const
 
template<typename T >
void emitValue (const T &value, ShaderStage &stage) const
 Add a value. More...
 
virtual void emitFunctionDefinition (const ShaderNode &node, GenContext &context, ShaderStage &stage) const
 Add the function definition for a single node. More...
 
virtual void emitFunctionDefinitions (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const
 Add all function definitions for a graph. More...
 
virtual void emitFunctionCall (const ShaderNode &node, GenContext &context, ShaderStage &stage, bool checkScope) const
 
virtual void emitFunctionCalls (const ShaderGraph &graph, GenContext &context, ShaderStage &stage, uint32_t classification=0u) const
 
virtual void emitDependentFunctionCalls (const ShaderNode &node, GenContext &context, ShaderStage &stage, uint32_t classification=0u) const
 
virtual void emitFunctionBodyBegin (const ShaderNode &node, GenContext &context, ShaderStage &stage, Syntax::Punctuation punc=Syntax::CURLY_BRACKETS) const
 Emit code for starting a new function body. More...
 
virtual void emitFunctionBodyEnd (const ShaderNode &node, GenContext &context, ShaderStage &stage) const
 Emit code for ending a function body. More...
 
virtual void emitTypeDefinitions (GenContext &context, ShaderStage &stage) const
 Emit type definitions for all data types that needs it. More...
 
virtual void emitInput (const ShaderInput *input, GenContext &context, ShaderStage &stage) const
 
virtual void emitOutput (const ShaderOutput *output, bool includeType, bool assignValue, GenContext &context, ShaderStage &stage) const
 
virtual void emitVariableDeclarations (const VariableBlock &block, const string &qualifier, const string &separator, GenContext &context, ShaderStage &stage, bool assignValue=true) const
 
virtual string getUpstreamResult (const ShaderInput *input, GenContext &context) const
 Return the result of an upstream connection or value for an input. More...
 
const SyntaxgetSyntax () const
 Return the syntax object for the language used by the code generator. More...
 
void registerImplementation (const string &name, CreatorFunction< ShaderNodeImpl > creator)
 Register a shader node implementation for a given implementation element name. More...
 
void registerImplementation (const StringVec &nameVec, CreatorFunction< ShaderNodeImpl > creator)
 Register a shader node implementation for a given set of implementation element names. More...
 
bool implementationRegistered (const string &name) const
 Determine if a shader node implementation has been registered for a given implementation element name. More...
 
void setColorManagementSystem (ColorManagementSystemPtr colorManagementSystem)
 Sets the color management system. More...
 
ColorManagementSystemPtr getColorManagementSystem () const
 Returns the color management system. More...
 
void setUnitSystem (UnitSystemPtr unitSystem)
 Sets the unit system. More...
 
UnitSystemPtr getUnitSystem () const
 Returns the unit system. More...
 
const StringMapgetTokenSubstitutions () const
 Return the map of token substitutions used by the generator. More...
 
virtual void registerShaderMetadata (const DocumentPtr &doc, GenContext &context) const
 

Static Public Member Functions

static ShaderGeneratorPtr create ()
 
- Static Public Member Functions inherited from GlslShaderGenerator
static ShaderGeneratorPtr create ()
 
- Static Public Member Functions inherited from HwShaderGenerator
static void bindLightShader (const NodeDef &nodeDef, unsigned int lightTypeId, GenContext &context)
 
static void unbindLightShader (unsigned int lightTypeId, GenContext &context)
 Unbind a light shader previously bound to the given light type id. More...
 
static void unbindLightShaders (GenContext &context)
 Unbind all light shaders previously bound. More...
 

Static Public Attributes

static const string TARGET
 Unique identifier for this generator target. More...
 
static const string VERSION
 
- Static Public Attributes inherited from GlslShaderGenerator
static const string TARGET
 Unique identifier for this generator target. More...
 
static const string VERSION
 Version string for the generator target. More...
 
- Static Public Attributes inherited from HwShaderGenerator
static const string CLOSURE_CONTEXT_SUFFIX_REFLECTION
 String constants for closure context suffixes. More...
 
static const string CLOSURE_CONTEXT_SUFFIX_TRANSMISSION
 
static const string CLOSURE_CONTEXT_SUFFIX_INDIRECT
 

Protected Member Functions

HwResourceBindingContextPtr getResourceBindingContext (GenContext &) const override
 
- Protected Member Functions inherited from GlslShaderGenerator
virtual void emitVertexStage (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const
 
virtual void emitPixelStage (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const
 
virtual void emitConstants (GenContext &context, ShaderStage &stage) const
 
virtual void emitUniforms (GenContext &context, ShaderStage &stage) const
 
virtual void emitLightData (GenContext &context, ShaderStage &stage) const
 
virtual bool requiresLighting (const ShaderGraph &graph) const
 
virtual void emitSpecularEnvironment (GenContext &context, ShaderStage &stage) const
 Emit specular environment lookup code. More...
 
virtual void emitTransmissionRender (GenContext &context, ShaderStage &stage) const
 Emit transmission rendering code. More...
 
virtual void emitLightFunctionDefinitions (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const
 Emit function definitions for lighting code. More...
 
- Protected Member Functions inherited from HwShaderGenerator
 HwShaderGenerator (SyntaxPtr syntax)
 
virtual ShaderPtr createShader (const string &name, ElementPtr element, GenContext &context) const
 Create and initialize a new HW shader for shader generation. More...
 
- Protected Member Functions inherited from ShaderGenerator
 ShaderGenerator (SyntaxPtr syntax)
 Protected constructor. More...
 
virtual ShaderStagePtr createStage (const string &name, Shader &shader) const
 Create a new stage in a shader. More...
 
void setFunctionName (const string &functionName, ShaderStage &stage) const
 Set function name for a stage. More...
 
void replaceTokens (const StringMap &substitutions, ShaderStage &stage) const
 Replace tokens with identifiers according to the given substitutions map. More...
 
void createVariables (ShaderGraphPtr graph, GenContext &context, Shader &shader) const
 

Protected Attributes

VkResourceBindingContextPtr _resourceBindingCtx = nullptr
 
- Protected Attributes inherited from GlslShaderGenerator
vector< ShaderNodePtr_lightSamplingNodes
 Nodes used internally for light sampling. More...
 
- Protected Attributes inherited from HwShaderGenerator
ClosureContext _defDefault
 Closure contexts for defining closure functions. More...
 
ClosureContext _defReflection
 
ClosureContext _defTransmission
 
ClosureContext _defIndirect
 
ClosureContext _defEmission
 
- Protected Attributes inherited from ShaderGenerator
SyntaxPtr _syntax
 
Factory< ShaderNodeImpl_implFactory
 
ColorManagementSystemPtr _colorManagementSystem
 
UnitSystemPtr _unitSystem
 
StringMap _tokenSubstitutions
 
friend ShaderGraph
 

Additional Inherited Members

- Public Types inherited from HwShaderGenerator
enum  ClosureContextType {
  DEFAULT, REFLECTION, TRANSMISSION, INDIRECT,
  EMISSION
}
 Types of closure contexts for HW. More...
 
- Static Protected Member Functions inherited from GlslShaderGenerator
static void toVec4 (const TypeDesc *type, string &variable)
 
- Static Protected Attributes inherited from ShaderGenerator
static const string T_FILE_TRANSFORM_UV
 

Detailed Description

A Vulkan GLSL shader generator

Definition at line 21 of file VkShaderGenerator.h.

Constructor & Destructor Documentation

VkShaderGenerator::VkShaderGenerator ( )

Member Function Documentation

static ShaderGeneratorPtr VkShaderGenerator::create ( )
inlinestatic

Definition at line 26 of file VkShaderGenerator.h.

void VkShaderGenerator::emitDirectives ( GenContext context,
ShaderStage stage 
) const
overridevirtual

Reimplemented from GlslShaderGenerator.

void VkShaderGenerator::emitInputs ( GenContext context,
ShaderStage stage 
) const
overridevirtual

Reimplemented from GlslShaderGenerator.

void VkShaderGenerator::emitOutputs ( GenContext context,
ShaderStage stage 
) const
overridevirtual

Reimplemented from GlslShaderGenerator.

HwResourceBindingContextPtr VkShaderGenerator::getResourceBindingContext ( GenContext ) const
overrideprotectedvirtual

Reimplemented from GlslShaderGenerator.

const string& VkShaderGenerator::getTarget ( ) const
inlineoverridevirtual

Return a unique identifier for the target this generator is for.

Reimplemented from GlslShaderGenerator.

Definition at line 29 of file VkShaderGenerator.h.

const string& VkShaderGenerator::getVersion ( ) const
inlineoverridevirtual

Return the version string for the GLSL version this generator is for.

Reimplemented from GlslShaderGenerator.

Definition at line 32 of file VkShaderGenerator.h.

string VkShaderGenerator::getVertexDataPrefix ( const VariableBlock vertexData) const
overridevirtual

Determine the prefix of vertex data variables.

Reimplemented from GlslShaderGenerator.

Member Data Documentation

VkResourceBindingContextPtr VkShaderGenerator::_resourceBindingCtx = nullptr
protected

Definition at line 50 of file VkShaderGenerator.h.

const string VkShaderGenerator::TARGET
static

Unique identifier for this generator target.

Definition at line 37 of file VkShaderGenerator.h.

const string VkShaderGenerator::VERSION
static

Definition at line 38 of file VkShaderGenerator.h.


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