shaderProgram.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 #ifndef PXR_IMAGING_HGI_SHADERPROGRAM_H
8 #define PXR_IMAGING_HGI_SHADERPROGRAM_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hgi/api.h"
12 #include "pxr/imaging/hgi/enums.h"
13 #include "pxr/imaging/hgi/handle.h"
14 #include "pxr/imaging/hgi/shaderFunction.h"
15 #include "pxr/imaging/hgi/types.h"
16 
17 #include <vector>
18 
19 
20 PXR_NAMESPACE_OPEN_SCOPE
21 
22 
35 {
36  HGI_API
38 
39  std::string debugName;
40  HgiShaderFunctionHandleVector shaderFunctions;
41 };
42 
43 HGI_API
44 bool operator==(
45  const HgiShaderProgramDesc& lhs,
46  const HgiShaderProgramDesc& rhs);
47 
48 HGI_API
49 bool operator!=(
50  const HgiShaderProgramDesc& lhs,
51  const HgiShaderProgramDesc& rhs);
52 
53 
64 {
65 public:
66  HGI_API
67  virtual ~HgiShaderProgram();
68 
70  HGI_API
71  HgiShaderProgramDesc const& GetDescriptor() const;
72 
74  HGI_API
75  virtual bool IsValid() const = 0;
76 
78  HGI_API
79  virtual std::string const& GetCompileErrors() = 0;
80 
82  HGI_API
83  virtual HgiShaderFunctionHandleVector const& GetShaderFunctions() const = 0;
84 
89  HGI_API
90  virtual size_t GetByteSizeOfResource() const = 0;
91 
101  HGI_API
102  virtual uint64_t GetRawResource() const = 0;
103 
104 protected:
105  HGI_API
107 
108  HgiShaderProgramDesc _descriptor;
109 
110 private:
111  HgiShaderProgram() = delete;
112  HgiShaderProgram & operator=(const HgiShaderProgram&) = delete;
113  HgiShaderProgram(const HgiShaderProgram&) = delete;
114 };
115 
117 using HgiShaderProgramHandleVector = std::vector<HgiShaderProgramHandle>;
118 
119 
120 PXR_NAMESPACE_CLOSE_SCOPE
121 
122 #endif
virtual HGI_API size_t GetByteSizeOfResource() const =0
Returns the byte size of the GPU shader program.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
virtual HGI_API HgiShaderFunctionHandleVector const & GetShaderFunctions() const =0
Returns the shader functions that are part of this program.
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
virtual HGI_API uint64_t GetRawResource() const =0
This function returns the handle to the Hgi backend's gpu resource, cast to a uint64_t.
virtual HGI_API std::string const & GetCompileErrors()=0
Returns shader compile errors.
Describes the properties needed to create a GPU shader program.
Definition: shaderProgram.h:34
Represents a collection of shader functions.
Definition: shaderProgram.h:63
virtual HGI_API bool IsValid() const =0
Returns false if any shader compile errors occured.
HGI_API HgiShaderProgramDesc const & GetDescriptor() const
The descriptor describes the object.