HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderProgram.h
Go to the documentation of this file.
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_HGIGL_SHADERPROGRAM_H
8 #define PXR_IMAGING_HGIGL_SHADERPROGRAM_H
9 
11 
12 #include "pxr/imaging/hgiGL/api.h"
14 
15 #include <vector>
16 
18 
19 
20 ///
21 /// \class HgiGLShaderProgram
22 ///
23 /// OpenGL implementation of HgiShaderProgram
24 ///
26 {
27 public:
28  HGIGL_API
29  ~HgiGLShaderProgram() override;
30 
31  HGIGL_API
32  bool IsValid() const override;
33 
34  HGIGL_API
35  std::string const& GetCompileErrors() override;
36 
37  HGIGL_API
38  HgiShaderFunctionHandleVector const& GetShaderFunctions() const override;
39 
40  HGIGL_API
41  size_t GetByteSizeOfResource() const override;
42 
43  HGIGL_API
44  uint64_t GetRawResource() const override;
45 
46  /// Returns the gl resource id of the program.
47  HGIGL_API
48  uint32_t GetProgramId() const;
49 
50  /// Returns the gl resource for the uniform block of this shader program.
51  /// This uniform block is used to store some per-shader values, such as
52  /// indices or offsets into other buffers.
53  /// See also Hgi::SetConstantValues.
54  /// 'sizeHint' is used to store the byte size of the uniform buffer, but
55  /// this fn does not actually allocate the data storage for the buffer.
56  HGIGL_API
57  uint32_t GetUniformBuffer(size_t sizeHint);
58 
59 protected:
60  friend class HgiGL;
61 
62  HGIGL_API
64 
65 private:
66  HgiGLShaderProgram() = delete;
67  HgiGLShaderProgram & operator=(const HgiGLShaderProgram&) = delete;
68  HgiGLShaderProgram(const HgiGLShaderProgram&) = delete;
69 
70 private:
71  std::string _errors;
72  uint32_t _programId;
73  size_t _programByteSize;
74  uint32_t _uniformBuffer;
75  size_t _uboByteSize;
76 };
77 
78 
80 
81 #endif
HGIGL_API std::string const & GetCompileErrors() override
Returns shader compile errors.
HGIGL_API size_t GetByteSizeOfResource() const override
std::vector< HgiShaderFunctionHandle > HgiShaderFunctionHandleVector
Definition: hgi.h:54
#define HGIGL_API
Definition: api.h:23
HGIGL_API uint64_t GetRawResource() const override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HGIGL_API uint32_t GetProgramId() const
Returns the gl resource id of the program.
HGIGL_API ~HgiGLShaderProgram() override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HGIGL_API bool IsValid() const override
Returns false if any shader compile errors occured.
HGIGL_API uint32_t GetUniformBuffer(size_t sizeHint)
HGIGL_API HgiShaderFunctionHandleVector const & GetShaderFunctions() const override
Returns the shader functions that are part of this program.