class Shader

Contains definitions of GPU programs used for rendering, as well as a set of global parameters to control those programs.

Public

Methods

GetShaderName

String GetShaderName() const

Returns the name of the shader.

SetIncludeFiles

void SetIncludeFiles(const Vector<String> &includes)

Sets a list include file paths that are referenced by this shader.

staticIsSampler

static bool IsSampler(GpuParameterObjectType type)

Checks is the provided object type a sampler.

staticIsTexture

static bool IsTexture(GpuParameterObjectType type)

Checks is the provided object type a texture.

staticIsLoadStoreTexture

static bool IsLoadStoreTexture(GpuParameterObjectType type)

Checks is the provided object type a load/store (unordered read/write) texture.

staticIsBuffer

static bool IsBuffer(GpuParameterObjectType type)

Checks is the provided object type a buffer.

staticGetDataParameterSize

static u32 GetDataParameterSize(GpuDataParameterType type)

Returns the size in bytes for a specific data type.

staticCreate

static HShader Create(const String &name, const ShaderCreateInformation &createInformation)

Creates a new shader resource using the provided descriptor and variations.

staticCreateEmpty

static SPtr<Shader> CreateEmpty()

Returns a shader object but doesn't initialize it.

staticComputeHash

static Array<u64, 2> ComputeHash(const String &string)

Computes a hash from shader source code.

staticComputeIncludeHash

static Array<u64, 2> ComputeIncludeHash(const String &path)

Computes a hash for a shader include at the provided path.

path
Relative path to the include, as provided in the shader source.

Returns: Computed hash value.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

~TShader<IsRenderProxy>

virtual ~TShader<IsRenderProxy>()

GetVariationCount

u32 GetVariationCount() const

Returns the total number of variations in this shader.

GetCompatibleVariations

Vector<SPtr<VariationType>> GetCompatibleVariations() const

Returns the list of all supported variations based on current render API and renderer.

GetVariations

const Vector<SPtr<VariationType>> &GetVariations() const

Returns a list of all variations in this shader.

GetVariationParameters

const Vector<ShaderVariationParameterInformation> &GetVariationParameters() const

Returns the list of all variation parameters supported by this shader, possible values of each parameter and other meta-data.

GetQueueSortType

QueueSortType GetQueueSortType() const

Returns currently active queue sort type.

GetQueuePriority

i32 GetQueuePriority() const

Returns currently active queue priority.

GetAllowSeparablePasses

bool GetAllowSeparablePasses() const

Returns if separable passes are allowed.

GetFlags

ShaderFlags GetFlags() const

Returns flags that control how the renderer interprets the shader.

Actual interpretation of the flags depends on the active renderer.

GetDataParameterDescription

const ShaderDataParameterInformation *GetDataParameterDescription(const String &name) const

Returns description for a data parameter with the specified name.

Returns null if it doesn't exist.

GetTextureParameterDescription

const ShaderObjectParameterInformation *GetTextureParameterDescription(const String &name) const

Returns description for a texture parameter with the specified name.

Returns null if it doesn't exist.

GetSamplerParameterDescription

const ShaderObjectParameterInformation *GetSamplerParameterDescription(const String &name) const

Returns description for a sampler parameter with the specified name.

Returns null if it doesn't exist.

GetBufferParameterInformation

const ShaderObjectParameterInformation *GetBufferParameterInformation(const String &name) const

Returns description for a buffer parameter with the specified name.

Returns null if it doesn't exist.

HasDataParameter

bool HasDataParameter(const String &name) const

Checks if the parameter with the specified name exists, and is a data parameter.

HasTextureParameter

bool HasTextureParameter(const String &name) const

Checks if the parameter with the specified name exists, and is a texture parameter.

HasSamplerParameter

bool HasSamplerParameter(const String &name) const

Checks if the parameter with the specified name exists, and is a sampler parameter.

HasBufferParameter

bool HasBufferParameter(const String &name) const

Checks if the parameter with the specified name exists, and is a buffer parameter.

HasUniformBuffer

bool HasUniformBuffer(const String &name) const

Checks if the uniform buffer with the specified name exists.

GetDataParameters

const Map<String, ShaderDataParameterInformation> &GetDataParameters() const

Returns a map of all data parameters in the shader.

GetTextureParameters

const Map<String, ShaderObjectParameterInformation> &GetTextureParameters() const

Returns a map of all texture parameters in the shader.

GetBufferParameters

const Map<String, ShaderObjectParameterInformation> &GetBufferParameters() const

Returns a map of all buffer parameters in the shader.

GetSamplerParameters

const Map<String, ShaderObjectParameterInformation> &GetSamplerParameters() const

Returns a map of all sampler parameters in the shader.

GetUniformBuffers

const Map<String, ShaderUniformBufferInformation> &GetUniformBuffers() const

Returns a map of all uniform buffers.

GetParameterAttributes

const Vector<ShaderParameterAttribute> &GetParameterAttributes() const

Returns a list of all parameter attributes, as referenced by individual parameters.

GetDefault2DTexture

TextureType GetDefault2DTexture(u32 index) const

Returns a default 2D texture for a parameter that has the specified default value index (retrieved from the parameters descriptor).

GetDefault3DTexture

TextureType GetDefault3DTexture(u32 index) const

Returns a default 3D texture for a parameter that has the specified default value index (retrieved from the parameters descriptor).

GetDefaultSampler

SPtr<SamplerState> GetDefaultSampler(u32 index) const

Returns a default sampler state for a parameter that has the specified default value index (retrieved from the parameters descriptor).

GetDefaultValue

u8 *GetDefaultValue(u32 index) const

Returns a pointer to the internal buffer containing the default value for a data parameter that has the specified default value index (retrieved from the parameters descriptor).

GetShaderId

u32 GetShaderId() const

Returns the unique shader ID.

Internal

Methods

staticCreateShared

static SPtr<Shader> CreateShared(const String &name, const ShaderCreateInformation &createInformation)

Creates a new shader object using the provided descriptor and variations.

GetCompilerMetaData

const SPtr<ShaderCompilerMetaData> &GetCompilerMetaData() const

Returns the meta-data required by the shader compiler to compile individual shader variations.

Protected

Fields

mInformation

ShaderInformationType mInformation

mShaderId

u32 mShaderId

Private

Constructors

Shader

Shader(const String &name, const ShaderCreateInformation &createInformation, u32 id)

Shader

Shader(u32 id)

*********************************************************************

Methods

GetCoreDependencies

void GetCoreDependencies(Vector<CoreObject *> &dependencies) override

Populates the provided array with all core objects that this core object depends upon.

Dependencies are required for syncing to the render thread, so the system can be aware to update the dependant objects if a dependency is marked as dirty (for example updating a camera's viewport should also trigger an update on camera so it has a chance to potentially update its data).

CreateRenderProxy

SPtr<render::RenderProxy> CreateRenderProxy() const override

Creates an object that contains render thread specific data and methods for this object.

Can be null if such object is not required.