Loading...
Searching...
No Matches
renderPassShader.h
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"
12#include "pxr/imaging/hdSt/binding.h"
13#include "pxr/imaging/hdSt/shaderCode.h"
14#include "pxr/imaging/hd/enums.h"
16
18#include "pxr/base/tf/token.h"
19
20#include <memory>
21
22PXR_NAMESPACE_OPEN_SCOPE
23
24using HdStRenderPassShaderSharedPtr =
25 std::shared_ptr<class HdStRenderPassShader>;
26class HdRenderIndex;
27using HdRenderPassAovBindingVector =
28 std::vector<struct HdRenderPassAovBinding>;
29
35public:
36 HDST_API
38 HDST_API
39 HdStRenderPassShader(TfToken const &glslfxFile);
40 HDST_API
41 HdStRenderPassShader(HioGlslfxSharedPtr const &glslfx);
42 HDST_API
43 ~HdStRenderPassShader() override;
44
46 HDST_API
47 ID ComputeHash() const override;
48 HDST_API
49 std::string GetSource(TfToken const &shaderStageKey) const override;
50 HDST_API
51 void BindResources(int program,
52 HdSt_ResourceBinder const &binder) override;
53 HDST_API
54 void UnbindResources(int program,
55 HdSt_ResourceBinder const &binder) override;
56 HDST_API
57 void AddBindings(HdStBindingRequestVector *customBindings) override;
58 HDST_API
59 HdSt_MaterialParamVector const& GetParams() const override;
60
61 HDST_API
62 NamedTextureHandleVector const & GetNamedTextureHandles() const override;
63
65 HDST_API
67
69 HDST_API
70 void RemoveBufferBinding(TfToken const &name);
71
73 HDST_API
75
76 // Sets the textures and params such that the shader can access
77 // the requested aovs with HdGet_AOVNAMEReadback().
78 //
79 // Needs to be called in task prepare or sync since it is
80 // allocating texture handles.
81 //
82 HDST_API
83 void UpdateAovInputTextures(
84 HdRenderPassAovBindingVector const &aovInputBindings,
85 HdRenderIndex * const renderIndex);
86
87private:
88 HioGlslfxSharedPtr _glslfx;
89 mutable size_t _hash;
90 mutable bool _hashValid;
91
92 // Lexicographic ordering for stable output between runs.
93 std::map<TfToken, HdStBindingRequest> _customBuffers;
94
95 NamedTextureHandleVector _namedTextureHandles;
96
97 HdSt_MaterialParamVector _params;
98
99 // No copying
101 HdStRenderPassShader &operator =(const HdStRenderPassShader &) = delete;
102
103 HioGlslfx const * _GetGlslfx() const override;
104};
105
106
107PXR_NAMESPACE_CLOSE_SCOPE
108
109#endif // PXR_IMAGING_HD_ST_RENDER_PASS_SHADER_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:104
BindingRequest allows externally allocated buffers to be bound at render time.
Definition: binding.h:109
A shader that supports common renderPass functionality.
HDST_API void RemoveBufferBinding(TfToken const &name)
Remove name from custom binding.
HDST_API void AddBufferBinding(HdStBindingRequest const &req)
Add a custom binding request for use when this shader executes.
HDST_API void AddBindings(HdStBindingRequestVector *customBindings) override
Add custom bindings (used by codegen)
HDST_API void ClearBufferBindings()
Clear all custom bindings associated with this shader.
HDST_API std::string GetSource(TfToken const &shaderStageKey) const override
Returns the shader source provided by this shader for shaderStageKey.
HDST_API ID ComputeHash() const override
HdShader overrides.
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
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...
HDST_API NamedTextureHandleVector const & GetNamedTextureHandles() const override
Textures that need to be bound for this shader.
HDST_API HdSt_MaterialParamVector const & GetParams() const override
Returns the shader parameters for this shader.
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPas...
Definition: shaderCode.h:59
A class representing the config and shader source of a glslfx file.
Definition: glslfx.h:134
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Standard pointer typedefs.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...