shaderGenerator.h
1 //
2 // Copyright 2020 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
8 #ifndef PXR_IMAGING_HGI_SHADERGENERATOR_H
9 #define PXR_IMAGING_HGI_SHADERGENERATOR_H
10 
11 #include "pxr/pxr.h"
12 #include "pxr/imaging/hgi/api.h"
13 #include "pxr/imaging/hgi/enums.h"
14 
15 #include <iosfwd>
16 #include <string>
17 
18 PXR_NAMESPACE_OPEN_SCOPE
19 
21 
31 {
32 public:
33  HGI_API
34  virtual ~HgiShaderGenerator();
35 
36  // Execute shader generation.
37  HGI_API
38  void Execute();
39 
40  // Return generated shader source.
41  HGI_API
42  const char *GetGeneratedShaderCode() const;
43 
44 protected:
45  HGI_API
46  explicit HgiShaderGenerator(const HgiShaderFunctionDesc &descriptor);
47 
48  HGI_API
49  virtual void _Execute(std::ostream &ss) = 0;
50 
51  HGI_API
52  const char *_GetShaderCodeDeclarations() const;
53 
54  HGI_API
55  const char *_GetShaderCode() const;
56 
57  HGI_API
58  HgiShaderStage _GetShaderStage() const;
59 
60 private:
61  const HgiShaderFunctionDesc &_descriptor;
62 
63  // This is used if the descriptor does not specify a string
64  // to be used as the destination for generated output.
65  std::string _localGeneratedShaderCode;
66 
67  HgiShaderGenerator() = delete;
68  HgiShaderGenerator & operator=(const HgiShaderGenerator&) = delete;
69  HgiShaderGenerator(const HgiShaderGenerator&) = delete;
70 };
71 
72 PXR_NAMESPACE_CLOSE_SCOPE
73 
74 #endif
Base class for shader function generation Given a descriptor, converts glslfx domain language to conc...
Describes the properties needed to create a GPU shader function.