HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VkShaderGenerator.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_VKSHADERGENERATOR_H
7 #define MATERIALX_VKSHADERGENERATOR_H
8 
9 /// @file
10 /// Vulkan GLSL shader generator
11 
14 
16 
17 using VkShaderGeneratorPtr = shared_ptr<class VkShaderGenerator>;
18 
19 /// @class VkShaderGenerator
20 /// A Vulkan GLSL shader generator
22 {
23  public:
24  /// Constructor.
25  VkShaderGenerator(TypeSystemPtr typeSystem);
26 
27  /// Creator function.
28  /// If a TypeSystem is not provided it will be created internally.
29  /// Optionally pass in an externally created TypeSystem here,
30  /// if you want to keep type descriptions alive after the lifetime
31  /// of the shader generator.
32  static ShaderGeneratorPtr create(TypeSystemPtr typeSystem = nullptr)
33  {
34  return std::make_shared<VkShaderGenerator>(typeSystem ? typeSystem : TypeSystem::create());
35  }
36 
37  /// Return a unique identifier for the target this generator is for
38  const string& getTarget() const override { return TARGET; }
39 
40  /// Return the version string for the GLSL version this generator is for
41  const string& getVersion() const override { return VERSION; }
42 
43  string getVertexDataPrefix(const VariableBlock& vertexData) const override;
44 
45  /// Unique identifier for this generator target
46  static const string TARGET;
47  static const string VERSION;
48 
49  // Emit directives for stage
50  void emitDirectives(GenContext& context, ShaderStage& stage) const override;
51 
52  void emitInputs(GenContext& context, ShaderStage& stage) const override;
53 
54  void emitOutputs(GenContext& context, ShaderStage& stage) const override;
55 
56  protected:
58 
59  VkResourceBindingContextPtr _resourceBindingCtx = nullptr;
60 };
61 
63 
64 #endif
virtual HwResourceBindingContextPtr getResourceBindingContext(GenContext &context) const
shared_ptr< class VkShaderGenerator > VkShaderGeneratorPtr
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
static const string TARGET
Unique identifier for this generator target.
static TypeSystemPtr create()
Create a new type system.
shared_ptr< class TypeSystem > TypeSystemPtr
Definition: TypeDesc.h:219
static const string VERSION
static const string VERSION
Version string for the generator target.
shared_ptr< class HwResourceBindingContext > HwResourceBindingContextPtr
Shared pointer to a HwResourceBindingContext.
virtual void emitDirectives(GenContext &context, ShaderStage &stage) const
virtual void emitInputs(GenContext &context, ShaderStage &stage) const
const string & getVersion() const override
Return the version string for the GLSL version this generator is for.
const string & getTarget() const override
Return a unique identifier for the target this generator is for.
shared_ptr< class VkResourceBindingContext > VkResourceBindingContextPtr
Shared pointer to a VkResourceBindingContext.
virtual void emitOutputs(GenContext &context, ShaderStage &stage) const
static ShaderGeneratorPtr create(TypeSystemPtr typeSystem=nullptr)
string getVertexDataPrefix(const VariableBlock &vertexData) const override
Determine the prefix of vertex data variables.
static const string TARGET
Unique identifier for this generator target.
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
shared_ptr< ShaderGenerator > ShaderGeneratorPtr
Shared pointer to a ShaderGenerator.
Definition: Library.h:37
#define MX_GENGLSL_API
Definition: Export.h:18