Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface > Struct Template Reference

Base implementation of a shader variable. More...

#include <ShaderResourceVariableBase.hpp>

Inheritance diagram for Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >:
Diligent.IShaderResourceVariable Diligent.IObject

Public Member Functions

virtual void DILIGENT_CALL_TYPE QueryInterface (const INTERFACE_ID &IID, IObject **ppInterface) override
 Queries the specific interface.
 
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE AddRef () override final
 Increments the number of strong references by 1.
 
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE Release () override final
 
virtual IReferenceCounters *DILIGENT_CALL_TYPE GetReferenceCounters () const override final
 
virtual void DILIGENT_CALL_TYPE Set (IDeviceObject *pObject, SET_SHADER_RESOURCE_FLAGS Flags) override final
 Binds resource to the variable.
 
virtual void DILIGENT_CALL_TYPE SetArray (IDeviceObject *const *ppObjects, Uint32 FirstElement, Uint32 NumElements, SET_SHADER_RESOURCE_FLAGS Flags) override final
 Binds resource array to the variable.
 
virtual void DILIGENT_CALL_TYPE SetBufferRange (IDeviceObject *pObject, Uint64 Offset, Uint64 Size, Uint32 ArrayIndex, SET_SHADER_RESOURCE_FLAGS Flags) override
 Binds the specified constant buffer range to the variable.
 
virtual void DILIGENT_CALL_TYPE SetBufferOffset (Uint32 Offset, Uint32 ArrayIndex) override final
 Sets the constant or structured buffer dynamic offset.
 
virtual SHADER_RESOURCE_VARIABLE_TYPE DILIGENT_CALL_TYPE GetType () const override final
 Returns the shader resource variable type.
 
virtual void DILIGENT_CALL_TYPE GetResourceDesc (ShaderResourceDesc &ResourceDesc) const override final
 Returns shader resource description. See Diligent::ShaderResourceDesc.
 
virtual Uint32 DILIGENT_CALL_TYPE GetIndex () const override final
 Returns the variable index that can be used to access the variable.
 
- Public Member Functions inherited from Diligent.IShaderResourceVariable
virtual IDeviceObject *DILIGENT_CALL_TYPE Get (Uint32 ArrayIndex=0) const =0
 Returns a pointer to the resource that is bound to this variable.
 

Detailed Description

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
struct Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >

Base implementation of a shader variable.

Member Function Documentation

◆ AddRef()

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >::AddRef ( )
inlinefinaloverridevirtual

Increments the number of strong references by 1.

Remarks
This method is equivalent to GetReferenceCounters()->AddStrongRef().
The method is thread-safe and does not require explicit synchronization.
Returns
The number of strong references after incrementing the counter.
Note
In a multithreaded environment, the returned number may not be reliable as other threads may simultaneously change the actual value of the counter.

Implements Diligent.IObject.

◆ GetReferenceCounters()

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
virtual IReferenceCounters *DILIGENT_CALL_TYPE Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >::GetReferenceCounters ( ) const
inlinefinaloverridevirtual

Returns the pointer to IReferenceCounters interface of the associated reference counters object. The method does NOT increment the number of strong references to the returned object.

Implements Diligent.IObject.

◆ QueryInterface()

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
virtual void DILIGENT_CALL_TYPE Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >::QueryInterface ( const INTERFACE_ID & IID,
IObject ** ppInterface )
inlineoverridevirtual

Queries the specific interface.

Parameters
[in]IID- Unique identifier of the requested interface.
[out]ppInterface- Memory address where the pointer to the requested interface will be written. If the interface is not supported, null pointer will be returned.
Remarks
The method increments the number of strong references by 1. The interface must be released by a call to Release() method when it is no longer needed.

Implements Diligent.IObject.

◆ Release()

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >::Release ( )
inlinefinaloverridevirtual

Decrements the number of strong references by 1 and destroys the object when the counter reaches zero.

Remarks
This method is equivalent to GetReferenceCounters()->ReleaseStrongRef().
The method is thread-safe and does not require explicit synchronization.
Returns
The number of strong references after decrementing the counter.
Note
In a multithreaded environment, the returned number may not be reliable as other threads may simultaneously change the actual value of the counter. The only reliable value is 0 as the object is destroyed when the last strong reference is released.

Implements Diligent.IObject.

◆ Set()

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
virtual void DILIGENT_CALL_TYPE Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >::Set ( IDeviceObject * pObject,
SET_SHADER_RESOURCE_FLAGS Flags )
inlinefinaloverridevirtual

Binds resource to the variable.

The method performs run-time correctness checks. For instance, shader resource view cannot be assigned to a constant buffer variable.

Implements Diligent.IShaderResourceVariable.

◆ SetArray()

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
virtual void DILIGENT_CALL_TYPE Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >::SetArray ( IDeviceObject *const * ppObjects,
Uint32 FirstElement,
Uint32 NumElements,
SET_SHADER_RESOURCE_FLAGS Flags )
inlinefinaloverridevirtual

Binds resource array to the variable.

Parameters
[in]ppObjects- a pointer to the array of objects.
[in]FirstElement- first array element to set.
[in]NumElements- the number of objects in ppObjects array.
[in]Flags- flags, see Diligent::SET_SHADER_RESOURCE_FLAGS.

The method performs run-time correctness checks. For instance, shader resource view cannot be assigned to a constant buffer variable.

Implements Diligent.IShaderResourceVariable.

◆ SetBufferOffset()

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
virtual void DILIGENT_CALL_TYPE Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >::SetBufferOffset ( Uint32 Offset,
Uint32 ArrayIndex )
inlinefinaloverridevirtual

Sets the constant or structured buffer dynamic offset.

Parameters
[in]Offset- additional offset, in bytes, that is added to the base offset (see remarks). Only 32-bit offsets are supported.
[in]ArrayIndex- for array variables, index of the array element.

This method is only allowed for constant or structured buffer variables that were not created with Diligent::SHADER_VARIABLE_FLAG_NO_DYNAMIC_BUFFERS or Diligent::PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS flags. The method is also not allowed for static resource variables.

Note
The Offset must be an integer multiple of ConstantBufferOffsetAlignment member when setting the offset for a constant buffer, or StructuredBufferOffsetAlignment when setting the offset for a structured buffer, as specified by device limits (see Diligent::DeviceLimits).

For constant buffers, the offset is added to the offset that was previously set by SetBufferRange() method (if any). For structured buffers, the offset is added to the base offset specified by the buffer view.

Changing the buffer offset does not require committing the SRB. From the engine point of view, buffers with dynamic offsets are treated similar to dynamic buffers, and thus affected by Diligent::DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT flag.

Implements Diligent.IShaderResourceVariable.

◆ SetBufferRange()

template<typename ThisImplType, typename VarManagerType, typename ResourceVariableBaseInterface = IShaderResourceVariable>
virtual void DILIGENT_CALL_TYPE Diligent::ShaderVariableBase< ThisImplType, VarManagerType, ResourceVariableBaseInterface >::SetBufferRange ( IDeviceObject * pObject,
Uint64 Offset,
Uint64 Size,
Uint32 ArrayIndex,
SET_SHADER_RESOURCE_FLAGS Flags )
inlineoverridevirtual

Binds the specified constant buffer range to the variable.

Parameters
[in]pObject- pointer to the buffer object.
[in]Offset- offset, in bytes, to the start of the buffer range to bind.
[in]Size- size, in bytes, of the buffer range to bind.
[in]ArrayIndex- for array variables, index of the array element.
[in]Flags- flags, see Diligent::SET_SHADER_RESOURCE_FLAGS.

This method is only allowed for constant buffers. If dynamic offset is further set by SetBufferOffset() method, it is added to the base offset set by this method.

The method resets dynamic offset previously set for this variable to zero.

Warning
The Offset must be an integer multiple of ConstantBufferOffsetAlignment member specified by the device limits (see Diligent::DeviceLimits).

Implements Diligent.IShaderResourceVariable.