HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderPassShader.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_HD_ST_RENDER_PASS_SHADER_H
8 #define PXR_IMAGING_HD_ST_RENDER_PASS_SHADER_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
14 #include "pxr/imaging/hd/enums.h"
15 #include "pxr/imaging/hio/glslfx.h"
16 
18 #include "pxr/base/tf/token.h"
19 
20 #include <memory>
21 
23 
25  std::shared_ptr<class HdStRenderPassShader>;
27 class HdRenderIndex;
29  std::vector<struct HdRenderPassAovBinding>;
30 
31 /// \class HdStRenderPassShader
32 ///
33 /// A shader that supports common renderPass functionality.
34 ///
36 public:
37  HDST_API
39  HDST_API
40  HdStRenderPassShader(TfToken const &glslfxFile);
41  HDST_API
43  HDST_API
44  ~HdStRenderPassShader() override;
45 
46  /// HdShader overrides
47  HDST_API
48  ID ComputeHash() const override;
49  HDST_API
50  std::string GetSource(TfToken const &shaderStageKey) const override;
51  HDST_API
52  void BindResources(int program,
53  HdSt_ResourceBinder const &binder) override;
54  HDST_API
55  void UnbindResources(int program,
56  HdSt_ResourceBinder const &binder) override;
57  HDST_API
58  void AddBindings(HdStBindingRequestVector *customBindings) override;
59  HDST_API
60  HdSt_MaterialParamVector const& GetParams() const override;
61 
62  HDST_API
63  NamedTextureHandleVector const & GetNamedTextureHandles() const override;
64 
65  /// Add a custom binding request for use when this shader executes.
66  HDST_API
67  void AddBufferBinding(HdStBindingRequest const& req);
68 
69  /// Remove \p name from custom binding.
70  HDST_API
71  void RemoveBufferBinding(TfToken const &name);
72 
73  /// Clear all custom bindings associated with this shader.
74  HDST_API
75  void ClearBufferBindings();
76 
77  // Sets the textures and params such that the shader can access
78  // the requested aovs with HdGet_AOVNAMEReadback().
79  //
80  // Needs to be called in task prepare or sync since it is
81  // allocating texture handles.
82  //
83  HDST_API
85  HdRenderPassAovBindingVector const &aovInputBindings,
86  HdRenderIndex * const renderIndex);
87 
88  HDST_API
89  static
92  HdStRenderPassState *renderPassState,
93  HdStResourceRegistrySharedPtr const &resourceRegistry,
94  HdRenderPassAovBindingVector const &aovBindings);
95 
96 private:
97  HioGlslfxSharedPtr _glslfx;
98  mutable size_t _hash;
99  mutable bool _hashValid;
100 
101  // Lexicographic ordering for stable output between runs.
102  std::map<TfToken, HdStBindingRequest> _customBuffers;
103 
104  NamedTextureHandleVector _namedTextureHandles;
105 
106  HdSt_MaterialParamVector _params;
107 
108  // No copying
109  HdStRenderPassShader(const HdStRenderPassShader &) = delete;
110  HdStRenderPassShader &operator =(const HdStRenderPassShader &) = delete;
111 
112  HioGlslfx const * _GetGlslfx() const override;
113 };
114 
115 
117 
118 #endif // PXR_IMAGING_HD_ST_RENDER_PASS_SHADER_H
HDST_API std::string GetSource(TfToken const &shaderStageKey) const override
HDST_API ~HdStRenderPassShader() override
HDST_API void AddBindings(HdStBindingRequestVector *customBindings) override
Add custom bindings (used by codegen)
std::vector< class HdStBindingRequest > HdStBindingRequestVector
Definition: binding.h:23
HDST_API HdStRenderPassShader()
HDST_API void AddBufferBinding(HdStBindingRequest const &req)
Add a custom binding request for use when this shader executes.
HDST_API void UnbindResources(int program, HdSt_ResourceBinder const &binder) override
Unbinds shader-specific resources.
HDST_API void BindResources(int program, HdSt_ResourceBinder const &binder) override
Definition: token.h:70
static HDST_API HdStRenderPassShaderSharedPtr CreateRenderPassShaderFromAovs(HdStRenderPassState *renderPassState, HdStResourceRegistrySharedPtr const &resourceRegistry, HdRenderPassAovBindingVector const &aovBindings)
GLuint const GLchar * name
Definition: glcorearb.h:786
HDST_API NamedTextureHandleVector const & GetNamedTextureHandles() const override
std::shared_ptr< class HdStRenderPassShader > HdStRenderPassShaderSharedPtr
HDST_API void ClearBufferBindings()
Clear all custom bindings associated with this shader.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
std::vector< NamedTextureHandle > NamedTextureHandleVector
Definition: shaderCode.h:144
#define HDST_API
Definition: api.h:23
std::shared_ptr< class HioGlslfx > HioGlslfxSharedPtr
Definition: glslfxShader.h:17
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDST_API ID ComputeHash() const override
HdShader overrides.
HDST_API void RemoveBufferBinding(TfToken const &name)
Remove name from custom binding.
std::vector< HdRenderPassAovBinding > HdRenderPassAovBindingVector
Definition: aov.h:137
std::shared_ptr< class HdStResourceRegistry > HdStResourceRegistrySharedPtr
Definition: commandBuffer.h:30
HDST_API void UpdateAovInputTextures(HdRenderPassAovBindingVector const &aovInputBindings, HdRenderIndex *const renderIndex)
HDST_API HdSt_MaterialParamVector const & GetParams() const override
Returns the shader parameters for this shader.
GLbitfield GLuint program
Definition: glcorearb.h:1931
std::vector< class HdSt_MaterialParam > HdSt_MaterialParamVector