7#ifndef PXR_IMAGING_HD_ST_SHADER_CODE_H
8#define PXR_IMAGING_HD_ST_SHADER_CODE_H
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hdSt/resourceRegistry.h"
13#include "pxr/imaging/hdSt/enums.h"
14#include "pxr/imaging/hd/version.h"
16#include "pxr/usd/sdf/path.h"
24PXR_NAMESPACE_OPEN_SCOPE
27using HdStBindingRequestVector = std::vector<class HdStBindingRequest>;
29using HdStShaderCodeSharedPtr =
30 std::shared_ptr<class HdStShaderCode>;
31using HdStShaderCodeSharedPtrVector =
32 std::vector<HdStShaderCodeSharedPtr>;
34using HdSt_MaterialParamVector =
35 std::vector<class HdSt_MaterialParam>;
36using HdBufferSourceSharedPtr =
37 std::shared_ptr<class HdBufferSource>;
38using HdBufferSourceSharedPtrVector =
39 std::vector<HdBufferSourceSharedPtr>;
40using HdBufferArrayRangeSharedPtr =
41 std::shared_ptr<class HdBufferArrayRange>;
42using HdStTextureHandleSharedPtr =
43 std::shared_ptr<class HdStTextureHandle>;
44using HdStComputationSharedPtr =
45 std::shared_ptr<class HdStComputation>;
48class HdSt_ResourceBinder;
79 static ID
ComputeHash(HdStShaderCodeSharedPtrVector
const &shaders);
107 virtual HdSt_MaterialParamVector
const&
GetParams()
const;
139 std::vector<HdStTextureHandleSharedPtr>
handles;
145 using NamedTextureHandleVector = std::vector<NamedTextureHandle>;
164 HdSt_ResourceBinder
const &binder) = 0;
168 HdSt_ResourceBinder
const &binder) = 0;
171 virtual void AddBindings(HdStBindingRequestVector* customBindings) = 0;
188 void AddSource(HdBufferArrayRangeSharedPtr
const &range,
189 HdBufferSourceSharedPtr
const &source);
192 void AddSources(HdBufferArrayRangeSharedPtr
const &range,
193 HdBufferSourceSharedPtrVector &&sources);
196 void AddComputation(HdBufferArrayRangeSharedPtr
const &range,
197 HdStComputationSharedPtr
const &computation,
198 HdStComputeQueue
const queue);
228 virtual HioGlslfx const * _GetGlslfx()
const;
232PXR_NAMESPACE_CLOSE_SCOPE
A central registry of all GPU resources.
The context available in implementations of AddResourcesFromTextures.
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPas...
static HDST_API ID ComputeHash(HdStShaderCodeSharedPtrVector const &shaders)
Returns the combined hash values of multiple shaders.
virtual void BindResources(int program, HdSt_ResourceBinder const &binder)=0
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...
size_t hash
A hash unique to the corresponding asset; used to split draw batches when not using bindless textures...
virtual HDST_API TfTokenVector const & GetPrimvarNames() const
Returns the names of primvar that are used by this shader.
HdStTextureType type
Equal to handle->GetTextureObject()->GetTextureType().
virtual HDST_API HdSt_MaterialParamVector const & GetParams() const
Returns the shader parameters for this shader.
virtual HDST_API NamedTextureHandleVector const & GetNamedTextureHandles() const
Textures that need to be bound for this shader.
virtual void AddBindings(HdStBindingRequestVector *customBindings)=0
Add custom bindings (used by codegen)
virtual HDST_API void AddResourcesFromTextures(ResourceContext &ctx) const
This function is called after textures have been allocated and loaded to add buffer sources and compu...
virtual std::string GetSource(TfToken const &shaderStageKey) const =0
Returns the shader source provided by this shader for shaderStageKey.
HDST_API VtDictionary GetLayout(TfTokenVector const &shaderStageKeys) const
Returns the resource layout for the shader stages specified by shaderStageKeys.
virtual HDST_API ID ComputeTextureSourceHash() const
Returns the hash value of the paths of the texture prims consumed by this shader.
virtual HDST_API TfToken GetMaterialTag() const
Material tags can be set in the meta-data of a glslfx file to control what rprim collection that prim...
virtual void UnbindResources(int program, HdSt_ResourceBinder const &binder)=0
Unbinds shader-specific resources.
virtual HDST_API bool IsEnabledPrimvarFiltering() const
Returns whether primvar filtering is enabled for this shader.
std::vector< HdStTextureHandleSharedPtr > handles
The texture(s). Multiple handles indicate an array of textures.
virtual HDST_API HdBufferArrayRangeSharedPtr const & GetShaderData() const
Returns a buffer which stores parameter fallback values and texture handles.
virtual ID ComputeHash() const =0
Returns the hash value of the shader code and configuration.
TfToken name
Name by which the texture(s) will be accessed, i.e., the name of the accesor for the texture(s) will ...
Information necessary to bind textures and create accessor for the texture.
A class representing the config and shader source of a glslfx file.
Token for efficient comparison, assignment, and hashing of known strings.
A map with string keys and VtValue values.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.