HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HdStShaderCode Class Referenceabstract

#include <shaderCode.h>

+ Inheritance diagram for HdStShaderCode:

Classes

struct  NamedTextureHandle
 
class  ResourceContext
 
struct  TextureDescriptor
 

Public Types

typedef size_t ID
 

Public Member Functions

HDST_API HdStShaderCode ()
 
virtual HDST_API ~HdStShaderCode ()
 
virtual ID ComputeHash () const =0
 
virtual ID ComputeTextureSourceHash () const
 
virtual std::string GetSource (TfToken const &shaderStageKey) const =0
 
virtual HDST_API
HdSt_MaterialParamVector const
GetParams () const
 Returns the shader parameters for this shader. More...
 
virtual HDST_API bool IsEnabledPrimvarFiltering () const
 Returns whether primvar filtering is enabled for this shader. More...
 
virtual HDST_API TfTokenVector
const
GetPrimvarNames () const
 Returns the names of primvar that are used by this shader. More...
 
virtual HDST_API
HdBufferArrayRangeSharedPtr
const
GetShaderData () const
 
virtual void BindResources (int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state)=0
 
virtual void UnbindResources (int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state)=0
 Unbinds shader-specific resources. More...
 
virtual void AddBindings (HdBindingRequestVector *customBindings)=0
 Add custom bindings (used by codegen) More...
 
virtual HDST_API TfToken GetMaterialTag () const
 
virtual HDST_API void AddResourcesFromTextures (ResourceContext &ctx) const
 

Static Public Member Functions

static HDST_API ID ComputeHash (HdStShaderCodeSharedPtrVector const &shaders)
 Returns the combined hash values of multiple shaders. More...
 

Old texture system

typedef std::vector
< TextureDescriptor
TextureDescriptorVector
 
virtual HDST_API
TextureDescriptorVector 
GetTextures () const
 

New texture system

using NamedTextureHandleVector = std::vector< NamedTextureHandle >
 
virtual HDST_API
NamedTextureHandleVector const
GetNamedTextureHandles () const
 

Detailed Description

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 76 of file shaderCode.h.

Member Typedef Documentation

typedef size_t HdStShaderCode::ID

Definition at line 79 of file shaderCode.h.

Textures that need to be bound for this shader.

Definition at line 186 of file shaderCode.h.

Definition at line 140 of file shaderCode.h.

Constructor & Destructor Documentation

HDST_API HdStShaderCode::HdStShaderCode ( )
virtual HDST_API HdStShaderCode::~HdStShaderCode ( )
virtual

Member Function Documentation

virtual void HdStShaderCode::AddBindings ( HdBindingRequestVector customBindings)
pure virtual
virtual HDST_API void HdStShaderCode::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 HdStSurfaceShader, and HdStSimpleLightingShader.

virtual void HdStShaderCode::BindResources ( int  program,
HdSt_ResourceBinder const binder,
HdRenderPassState const state 
)
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 HdSt_GeometricShader, HdStSurfaceShader, HdStMixinShader, HdStComputeShader, HdStSimpleLightingShader, HdStRenderPassShader, and HdSt_FallbackLightingShader.

virtual ID HdStShaderCode::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 HdSt_GeometricShader, HdStSurfaceShader, HdStComputeShader, HdStSimpleLightingShader, HdStRenderPassShader, HdSt_FallbackLightingShader, and HdStMixinShader.

static HDST_API ID HdStShaderCode::ComputeHash ( HdStShaderCodeSharedPtrVector const shaders)
static

Returns the combined hash values of multiple shaders.

virtual ID HdStShaderCode::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.

Reimplemented in HdStSurfaceShader, and HdStMixinShader.

virtual HDST_API TfToken HdStShaderCode::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.

Reimplemented in HdStSurfaceShader, and HdStMixinShader.

virtual HDST_API NamedTextureHandleVector const& HdStShaderCode::GetNamedTextureHandles ( ) const
virtual

Textures that need to be bound for this shader.

Reimplemented in HdStSimpleLightingShader, and HdStSurfaceShader.

virtual HDST_API HdSt_MaterialParamVector const& HdStShaderCode::GetParams ( ) const
virtual

Returns the shader parameters for this shader.

Reimplemented in HdStSimpleLightingShader, HdStSurfaceShader, HdStRenderPassShader, HdStComputeShader, and HdStMixinShader.

virtual HDST_API TfTokenVector const& HdStShaderCode::GetPrimvarNames ( ) const
virtual

Returns the names of primvar that are used by this shader.

Reimplemented in HdStSurfaceShader, and HdStMixinShader.

virtual HDST_API HdBufferArrayRangeSharedPtr const& HdStShaderCode::GetShaderData ( ) const
virtual

Returns a buffer which stores parameter fallback values and texture handles.

Reimplemented in HdStSurfaceShader, HdStMixinShader, and HdStComputeShader.

virtual std::string HdStShaderCode::GetSource ( TfToken const shaderStageKey) const
pure virtual

Returns the shader source provided by this shader for shaderStageKey

Implemented in HdSt_GeometricShader, HdStSurfaceShader, HdStComputeShader, HdStMixinShader, HdStSimpleLightingShader, HdStRenderPassShader, and HdSt_FallbackLightingShader.

virtual HDST_API TextureDescriptorVector HdStShaderCode::GetTextures ( ) const
virtual
virtual HDST_API bool HdStShaderCode::IsEnabledPrimvarFiltering ( ) const
virtual

Returns whether primvar filtering is enabled for this shader.

Reimplemented in HdStSurfaceShader, and HdStMixinShader.

virtual void HdStShaderCode::UnbindResources ( int  program,
HdSt_ResourceBinder const binder,
HdRenderPassState const state 
)
pure virtual

The documentation for this class was generated from the following file: