24 #ifndef PXR_IMAGING_HD_ST_SURFACE_SHADER_H
25 #define PXR_IMAGING_HD_ST_SURFACE_SHADER_H
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hdSt/shaderCode.h"
32 #include "pxr/usd/sdf/path.h"
34 #include "pxr/base/vt/value.h"
40 PXR_NAMESPACE_OPEN_SCOPE
45 using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
47 using HdStSurfaceShaderSharedPtr = std::shared_ptr<class HdStSurfaceShader>;
49 using HdBufferSpecVector = std::vector<struct HdBufferSpec>;
50 using HdStResourceRegistrySharedPtr =
51 std::shared_ptr<class HdStResourceRegistry>;
66 ~HdStSurfaceShader()
override;
75 HdSt_MaterialParamVector
const&
GetParams()
const override;
77 void SetEnabledPrimvarFiltering(
bool enabled);
83 HdBufferArrayRangeSharedPtr
const&
GetShaderData()
const override;
88 HdSt_ResourceBinder
const &binder,
92 HdSt_ResourceBinder
const &binder,
95 void AddBindings(HdBindingRequestVector *customBindings)
override;
109 void SetGeometrySource(
const std::string &source);
111 void SetParams(
const HdSt_MaterialParamVector ¶ms);
113 void SetNamedTextureHandles(
const NamedTextureHandleVector &);
115 void SetBufferSources(
116 HdBufferSpecVector
const &bufferSpecs,
117 HdBufferSourceSharedPtrVector &&bufferSources,
118 HdStResourceRegistrySharedPtr
const &resourceRegistry);
131 void SetMaterialTag(
TfToken const &materialTag);
139 static bool CanAggregate(HdStShaderCodeSharedPtr
const &shaderA,
140 HdStShaderCodeSharedPtr
const &shaderB);
147 const HdSt_MaterialParam ¶m,
148 HdBufferSpecVector *
const specs,
149 HdBufferSourceSharedPtrVector *
const sources);
153 void _SetSource(
TfToken const &shaderStageKey, std::string
const &source);
156 ID _ComputeHash()
const;
159 ID _ComputeTextureSourceHash()
const;
162 std::string _fragmentSource;
163 std::string _geometrySource;
166 HdSt_MaterialParamVector _params;
167 HdBufferSpecVector _paramSpec;
168 HdBufferArrayRangeSharedPtr _paramArray;
170 bool _isEnabledPrimvarFiltering;
172 mutable size_t _computedHash;
173 mutable bool _isValidComputedHash;
175 mutable size_t _computedTextureSourceHash;
176 mutable bool _isValidComputedTextureSourceHash;
178 NamedTextureHandleVector _namedTextureHandles;
183 HdStSurfaceShader(
const HdStSurfaceShader &) =
delete;
184 HdStSurfaceShader &operator =(
const HdStSurfaceShader &) =
delete;
188 PXR_NAMESPACE_CLOSE_SCOPE
190 #endif //PXR_IMAGING_HD_ST_SURFACE_SHADER_H
HDST_API HdSt_MaterialParamVector const & GetParams() const override
Returns the shader parameters for this shader.
HDST_API ID ComputeTextureSourceHash() const override
Returns the hash value of the paths of the texture prims consumed by this shader. ...
virtual HDST_API void Reload()
If the prim is based on asset, reload that asset.
HDST_API HdBufferArrayRangeSharedPtr const & GetShaderData() const override
Returns a buffer which stores parameter fallback values and texture handles.
HDST_API void AddBindings(HdBindingRequestVector *customBindings) override
Add custom bindings (used by codegen)
HDST_API bool IsEnabledPrimvarFiltering() const override
Returns whether primvar filtering is enabled for this shader.
HDST_API void UnbindResources(int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state) override
Unbinds shader-specific resources.
A set of rendering parameters used among render passes.
Token for efficient comparison, assignment, and hashing of known strings.
static HDST_API void AddFallbackValueToSpecsAndSources(const HdSt_MaterialParam ¶m, HdBufferSpecVector *const specs, HdBufferSourceSharedPtrVector *const sources)
Adds the fallback value of the given material param to buffer specs and sources using the param's nam...
Adapter class providing data exchange with the client scene graph.
HDST_API ID ComputeHash() const override
Returns the hash value of the shader code and configuration.
std::vector< TfToken > TfTokenVector
Convenience types.
HDST_API std::string GetSource(TfToken const &shaderStageKey) const override
Returns the shader source provided by this shader for shaderStageKey.
A scene-based SurfaceShader object.
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPas...
HDST_API void AddResourcesFromTextures(ResourceContext &ctx) const override
Called after textures have been committed.
HDST_API NamedTextureHandleVector const & GetNamedTextureHandles() const override
Textures that need to be bound for this shader.
HDST_API void SetFragmentSource(const std::string &source)
Setter method for prim.
The context available in implementations of AddResourcesFromTextures.
HDST_API void BindResources(int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state) override
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...
HDST_API TfToken GetMaterialTag() const override
Material tags can be set in the meta-data of a glslfx file to control what rprim collection that prim...
static HDST_API bool CanAggregate(HdStShaderCodeSharedPtr const &shaderA, HdStShaderCodeSharedPtr const &shaderB)
Returns if the two shaders can be aggregated into the same draw batch.
HDST_API TfTokenVector const & GetPrimvarNames() const override
Returns the names of primvar that are used by this shader.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...