A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPass.
More...
#include <shaderCode.h>
|
virtual ID | ComputeHash () const =0 |
| Returns the hash value of the shader code and configuration.
|
|
virtual ID | ComputeTextureSourceHash () const |
| Returns the hash value of the paths of the texture prims consumed by this shader.
|
|
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 HdSt_MaterialParamVector const & | GetParams () const |
| Returns the shader parameters for this shader.
|
|
virtual HDST_API bool | IsEnabledPrimvarFiltering () const |
| Returns whether primvar filtering is enabled for this shader.
|
|
virtual HDST_API TfTokenVector const & | GetPrimvarNames () const |
| Returns the names of primvar that are used by this shader.
|
|
virtual HDST_API HdBufferArrayRangeSharedPtr const & | GetShaderData () const |
| Returns a buffer which stores parameter fallback values and texture handles.
|
|
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 GlfSimpleLightingContext mechanism, and not for generic use-cases.
|
|
virtual void | UnbindResources (int program, HdSt_ResourceBinder const &binder)=0 |
| Unbinds shader-specific resources.
|
|
virtual void | AddBindings (HdStBindingRequestVector *customBindings)=0 |
| Add custom bindings (used by codegen)
|
|
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 prims using this shader should go into.
|
|
virtual HDST_API void | AddResourcesFromTextures (ResourceContext &ctx) const |
| This function is called after textures have been allocated and loaded to add buffer sources and computations to the resource registry that require texture meta data not available until the texture is allocated or loaded.
|
|
|
static HDST_API ID | ComputeHash (HdStShaderCodeSharedPtrVector const &shaders) |
| Returns the combined hash values of multiple shaders.
|
|
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPass.
This interface provides a simple way for clients to affect the composition of shading programs used for a render pass.
Definition at line 75 of file shaderCode.h.
◆ HdStShaderCode::NamedTextureHandle
struct HdStShaderCode::NamedTextureHandle |
Information necessary to bind textures and create accessor for the texture.
Definition at line 142 of file shaderCode.h.
Class Members |
HdStTextureHandleSharedPtr |
handle |
The texture. |
size_t |
hash |
A hash unique to the corresponding asset; used to split draw batches when not using bindless textures. |
TfToken |
name |
Name by which the texture will be accessed, i.e., the name of the accesor for thexture will be HdGet_name(...). |
HdTextureType |
type |
Equal to handle->GetTextureObject()->GetTextureType(). Saved here for convenience (note that name and type completely determine the creation of the texture accesor HdGet_name(...)).
|
◆ ID
◆ NamedTextureHandleVector
◆ AddBindings()
virtual void AddBindings |
( |
HdStBindingRequestVector * |
customBindings | ) |
|
|
pure virtual |
◆ AddResourcesFromTextures()
virtual HDST_API void AddResourcesFromTextures |
( |
ResourceContext & |
ctx | ) |
const |
|
virtual |
This function is called after textures have been allocated and loaded to add buffer sources and computations to the resource registry that require texture meta data not available until the texture is allocated or loaded.
For example, the OpenGl texture sampler handle (in the bindless case) is not available until after the texture commit phase.
Reimplemented in HdStSimpleLightingShader.
◆ BindResources()
virtual void BindResources |
( |
int |
program, |
|
|
HdSt_ResourceBinder const & |
binder |
|
) |
| |
|
pure virtual |
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the GlfSimpleLightingContext mechanism, and not for generic use-cases.
Implemented in HdStRenderPassShader, and HdStSimpleLightingShader.
◆ ComputeHash() [1/2]
virtual ID ComputeHash |
( |
| ) |
const |
|
pure virtual |
Returns the hash value of the shader code and configuration.
It is computed from the the GLSL code as well as the resource signature of the shader (as determined from its parameters). If two shaders have the same hash, the GLSL code as expanded by codegen should also be the same.
Implemented in HdStRenderPassShader, and HdStSimpleLightingShader.
◆ ComputeHash() [2/2]
static HDST_API ID ComputeHash |
( |
HdStShaderCodeSharedPtrVector const & |
shaders | ) |
|
|
static |
Returns the combined hash values of multiple shaders.
◆ ComputeTextureSourceHash()
virtual ID ComputeTextureSourceHash |
( |
| ) |
const |
|
virtual |
Returns the hash value of the paths of the texture prims consumed by this shader.
Unless textures are bindless, shaders using different textures cannot be used in the same draw batch. Since textures can be animated, it can happen that two texture prims use the same texture at some time but different textures at other times. To avoid re-computing the draw batches over time, we use the this hash when grouping the draw batches.
◆ GetLayout()
Returns the resource layout for the shader stages specified by shaderStageKeys.
This is initialized using the shader's HioGlslfx configuration.
◆ GetMaterialTag()
virtual HDST_API TfToken GetMaterialTag |
( |
| ) |
const |
|
virtual |
Material tags can be set in the meta-data of a glslfx file to control what rprim collection that prims using this shader should go into.
E.g. We can use it to split opaque and translucent prims into different collections. When no material tags are specified in the shader, a empty token is returned.
◆ GetNamedTextureHandles()
virtual HDST_API NamedTextureHandleVector const & GetNamedTextureHandles |
( |
| ) |
const |
|
virtual |
◆ GetParams()
virtual HDST_API HdSt_MaterialParamVector const & GetParams |
( |
| ) |
const |
|
virtual |
◆ GetPrimvarNames()
Returns the names of primvar that are used by this shader.
◆ GetShaderData()
virtual HDST_API HdBufferArrayRangeSharedPtr const & GetShaderData |
( |
| ) |
const |
|
virtual |
Returns a buffer which stores parameter fallback values and texture handles.
◆ GetSource()
virtual std::string GetSource |
( |
TfToken const & |
shaderStageKey | ) |
const |
|
pure virtual |
◆ IsEnabledPrimvarFiltering()
virtual HDST_API bool IsEnabledPrimvarFiltering |
( |
| ) |
const |
|
virtual |
Returns whether primvar filtering is enabled for this shader.
◆ UnbindResources()
virtual void UnbindResources |
( |
int |
program, |
|
|
HdSt_ResourceBinder const & |
binder |
|
) |
| |
|
pure virtual |
The documentation for this class was generated from the following file: