Cogs.Core
Public Member Functions | Public Attributes | List of all members
Cogs::EffectsCommon Struct Referenceabstract
Inheritance diagram for Cogs::EffectsCommon:
Cogs::IEffects Cogs::EffectsD3D11 Cogs::EffectsD3D12 Cogs::EffectsGL20 Cogs::EffectsGLES30 Cogs::EffectsNull Cogs::EffectsVK Cogs::EffectsWebGPU

Public Member Functions

EffectHandle loadEffect (const EffectDescription &description) final
 Load an effect from the given description.
 
EffectHandle loadEffectSource (const EffectDescription &description)
 
EffectHandle loadEffectContents (const EffectDescription &description, const EffectContents &contents)
 
EffectHandle loadEffect (const StringView &fileName, EffectFlags::EEffectFlags effectFlags=EffectFlags::None) final
 Load the given single file effect.
 
EffectHandle loadEffect (const StringView &fileName, const PreprocessorDefinitions &defines, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)
 
EffectHandle loadEffect (const StringView &vsFileName, const StringView &psFileName, EffectFlags::EEffectFlags effectFlags=EffectFlags::None) final
 Load an effect created from the vertex and pixel shader files given.
 
EffectHandle loadEffect (const StringView &vsFileName, const StringView &psFileName, const PreprocessorDefinitions &defines, EffectFlags::EEffectFlags effectFlags=EffectFlags::None) final
 Load an effect created from the vertex and pixel shader files given, applying the given preprocessor definitions to the shaders.
 
EffectHandle loadEffectSource (const StringView &vsSource, const StringView &psSource, EffectFlags::EEffectFlags effectFlags=EffectFlags::None) final
 Load an effect created from the vertex and pixel shader sources given.
 
EffectHandle loadEffectSource (const StringView &vsSource, const StringView &psSource, const PreprocessorDefinitions &defines, EffectFlags::EEffectFlags effectFlags=EffectFlags::None) final
 Load an effect created from the vertex and pixel shader sources given, applying the given preprocessor definitions to the shaders.
 
EffectHandle loadEffectSource (const StringView &vsSource, const StringView &gsSource, const StringView &psSource, EffectFlags::EEffectFlags effectFlags=EffectFlags::None) final
 Load an effect created from the vertex, geometry, and pixel shader sources given.
 
EffectHandle loadEffectSource (const StringView &vsSource, const StringView &gsSource, const StringView &psSource, const PreprocessorDefinitions &defines, EffectFlags::EEffectFlags effectFlags=EffectFlags::None) final
 Load an effect created from the vertex, geometry, and pixel shader sources given, applying the given preprocessor definitions to the shaders.
 
EffectVariableHandle getEffectVariable (EffectHandle effectHandle, const StringView &name) override
 Get a handle to the variable with the given name in the effect with the given effectHandle.
 
ConstantBufferBindingHandle getConstantBufferBinding (EffectHandle effectHandle, const StringView &name) override
 Get a handle to a constant buffer binding, mapping how to bind a constant buffer to the given effect.
 
TextureBindingHandle getTextureBinding (EffectHandle effectHandle, const StringView &name, const unsigned int slot) override
 Get a handle to a texture object binding, mapping how to bind textures to the given effect.
 
SamplerStateBindingHandle getSamplerStateBinding (EffectHandle effectHandle, const StringView &name, const unsigned int slot) override
 Get a handle to a sampler state object binding, mapping how to bind the sampler state to the given effect.
 
BufferBindingHandle getBufferBinding (EffectHandle effectHandle, const StringView &name) override
 Get a handle to a buffer binding.
 
void releaseBufferBinding (BufferBindingHandle bufferBindingHandle) override
 Release a handle to a buffer binding.
 
void setIOHandler (IIOHandler *handler) override
 Sets an external I/O handler to use for I/O operations.
 
IIOHandlergetIOHandler () override
 Gets the external I/O handler.
 
EffectHandle load (const ProcessedContent &vsSource, const ProcessedContent &psSource, const StringView &vsEntryPoint, const StringView &psEntryPoint, const EffectDescription &desc)
 
EffectHandle load (const ProcessedContent &vsSource, const ProcessedContent &gsSource, const ProcessedContent &psSource, const StringView &vsEntryPoint, const StringView &gsEntryPoint, const StringView &psEntryPoint, const EffectDescription &desc)
 
virtual EffectHandle load (const ProcessedContent &vsSource, const ProcessedContent &hsSource, const ProcessedContent &dsSource, const ProcessedContent &gsSource, const ProcessedContent &psSource, const StringView &vsEntryPoint, const StringView &hsEntryPoint, const StringView &dsEntryPoint, const StringView &gsEntryPoint, const StringView &psEntryPoint, const EffectDescription &desc)=0
 
void initialize (struct IBuffers *buffers)
 
- Public Member Functions inherited from Cogs::IEffects
virtual EffectHandle loadEffect (const EffectDescription &description)=0
 Load an effect from the given description.
 
virtual EffectHandle loadEffect (const StringView &fileName, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load the given single file effect.
 
virtual EffectHandle loadComputeEffect (const StringView &fileName, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load the compute shader with the given file name and create an effect.
 
virtual EffectHandle loadComputeEffect (const StringView &fileName, const PreprocessorDefinitions &definitions, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load the compute shader with the given file name and create an effect.
 
virtual EffectHandle loadEffect (const StringView &vsFileName, const StringView &psFileName, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load an effect created from the vertex and pixel shader files given.
 
virtual EffectHandle loadEffect (const StringView &vsFileName, const StringView &psFileName, const PreprocessorDefinitions &definitions, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load an effect created from the vertex and pixel shader files given, applying the given preprocessor definitions to the shaders.
 
virtual EffectHandle loadEffectSource (const StringView &vsSource, const StringView &psSource, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load an effect created from the vertex and pixel shader sources given.
 
virtual EffectHandle loadEffectSource (const StringView &vsSource, const StringView &gsSource, const StringView &psSource, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load an effect created from the vertex, geometry, and pixel shader sources given.
 
virtual EffectHandle loadEffectSource (const StringView &vsSource, const StringView &psSource, const PreprocessorDefinitions &definitions, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load an effect created from the vertex and pixel shader sources given, applying the given preprocessor definitions to the shaders.
 
virtual EffectHandle loadEffectSource (const StringView &vsSource, const StringView &gsSource, const StringView &psSource, const PreprocessorDefinitions &definitions, EffectFlags::EEffectFlags effectFlags=EffectFlags::None)=0
 Load an effect created from the vertex, geometry, and pixel shader sources given, applying the given preprocessor definitions to the shaders.
 
virtual void releaseEffect (EffectHandle effectHandle)=0
 Release the effect with the given handle, freeing all resources generated during program loading.
 
virtual EffectVariableHandle getEffectVariable (EffectHandle effectHandle, const StringView &name)=0
 Get a handle to the variable with the given name in the effect with the given effectHandle.
 
virtual ConstantBufferBindingHandle getConstantBufferBinding (EffectHandle effectHandle, const StringView &name)=0
 Get a handle to a constant buffer binding, mapping how to bind a constant buffer to the given effect.
 
virtual TextureBindingHandle getTextureBinding (EffectHandle effectHandle, const StringView &name, const unsigned int slot)=0
 Get a handle to a texture object binding, mapping how to bind textures to the given effect.
 
virtual BufferBindingHandle getBufferBinding (EffectHandle effectHandle, const StringView &name)=0
 Get a handle to a buffer binding.
 
virtual void releaseBufferBinding (BufferBindingHandle bufferBindingHandle)=0
 Release a handle to a buffer binding.
 
virtual SamplerStateBindingHandle getSamplerStateBinding (EffectHandle effectHandle, const StringView &name, const unsigned int slot)=0
 Get a handle to a sampler state object binding, mapping how to bind the sampler state to the given effect.
 
virtual void releaseResources ()=0
 Release all allocated effect resources.
 
virtual void annotate (EffectHandle handle, const StringView &name)
 Associate a name with an object for use in graphics debugging.
 
virtual void annotateVS (EffectHandle handle, const StringView &name)
 Associate a name with an object for use in graphics debugging.
 
virtual void annotateGS (EffectHandle handle, const StringView &name)
 Associate a name with an object for use in graphics debugging.
 
virtual void annotatePS (EffectHandle handle, const StringView &name)
 Associate a name with an object for use in graphics debugging.
 
virtual void annotateCS (EffectHandle handle, const StringView &name)
 Associate a name with an object for use in graphics debugging.
 
virtual void setIOHandler (IIOHandler *handler)=0
 Sets an external I/O handler to use for I/O operations.
 
virtual IIOHandlergetIOHandler ()
 Gets the external I/O handler.
 

Public Attributes

SafeResourceMap< EffectHandle, Effecteffects
 
ResourceMap< BufferBindingHandle, BufferBindingbufferBindings
 
IIOHandlerhandler = nullptr
 
std::unique_ptr< IIOHandlerdefaultHandler
 
struct IBuffersbuffers = nullptr
 

Detailed Description

Definition at line 236 of file EffectsCommon.h.

Member Function Documentation

◆ getBufferBinding()

Cogs::BufferBindingHandle Cogs::EffectsCommon::getBufferBinding ( EffectHandle  effectHandle,
const StringView name 
)
overridevirtual

Get a handle to a buffer binding.

Implements Cogs::IEffects.

Reimplemented in Cogs::EffectsGL20, and Cogs::EffectsWebGPU.

Definition at line 443 of file EffectsCommon.cpp.

◆ getConstantBufferBinding()

Cogs::ConstantBufferBindingHandle Cogs::EffectsCommon::getConstantBufferBinding ( EffectHandle  effectHandle,
const StringView name 
)
overridevirtual

Get a handle to a constant buffer binding, mapping how to bind a constant buffer to the given effect.

The binding object can then be used to effectively bind the constant buffer before drawing, and avoid having to do name based lookups at runtime.

Parameters
effectHandleValid handle to an effect.
nameName of the constant buffer as used in shaders.
Returns
Handle to the constant buffer binding, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Reimplemented in Cogs::EffectsGL20, Cogs::EffectsGLES30, and Cogs::EffectsWebGPU.

Definition at line 410 of file EffectsCommon.cpp.

◆ getEffectVariable()

Cogs::EffectVariableHandle Cogs::EffectsCommon::getEffectVariable ( EffectHandle  effectHandle,
const StringView name 
)
overridevirtual

Get a handle to the variable with the given name in the effect with the given effectHandle.

Parameters
effectHandleValid handle to an effect.
nameName of the variable get a handle to.
Returns
Handle to the effect variable, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Reimplemented in Cogs::EffectsGLES30.

Definition at line 366 of file EffectsCommon.cpp.

References Cogs::BindFlags::ConstantBuffer, Cogs::Usage::Dynamic, Cogs::hash(), Cogs::Handle_t< VariableBindingTag >::InvalidHandle, and Cogs::AccessMode::Write.

◆ getIOHandler()

IIOHandler * Cogs::EffectsCommon::getIOHandler ( )
inlineoverridevirtual

Gets the external I/O handler.

Reimplemented from Cogs::IEffects.

Definition at line 262 of file EffectsCommon.h.

◆ getSamplerStateBinding()

Cogs::SamplerStateBindingHandle Cogs::EffectsCommon::getSamplerStateBinding ( EffectHandle  effectHandle,
const StringView name,
const unsigned int  slot 
)
overridevirtual

Get a handle to a sampler state object binding, mapping how to bind the sampler state to the given effect.

The name is used to lookup a shader-defined sampler state object if supported. If named sampler states are not supported, the given slot is used to bind the sampler state.

In scenarios where no sampler state usage is defined in the shader, the sampler state object should be bound to a slot with the same number as the texture slot the sampler should be applied to.

Parameters
effectHandleValid handle to an effect.
nameName of the sampler state object as used in shaders in the effect. If not supported by the graphics device, this field is ignored.
slotSlot number to bind the sampler state object to. The slot number is by default used to apply the sampler state when sampling from textures bound with the same slot index. On supported systems this may be remapped in the shaders.
Returns
Handle to the sampler state object binding, InvalidHandle if the operation failed.s

Implements Cogs::IEffects.

Reimplemented in Cogs::EffectsWebGPU, Cogs::EffectsGL20, and Cogs::EffectsGLES30.

Definition at line 432 of file EffectsCommon.cpp.

◆ getTextureBinding()

Cogs::TextureBindingHandle Cogs::EffectsCommon::getTextureBinding ( EffectHandle  effectHandle,
const StringView name,
const unsigned int  slot 
)
overridevirtual

Get a handle to a texture object binding, mapping how to bind textures to the given effect.

The name is used to lookup how to make textures set using this binding be bound to the shader variable of the same name. The slot number is used to bind the texture if no direct slot is given by the shader.

Parameters
effectHandleValid handle to an effect.
nameName of the texture object as used in shaders in the effect.
slotSlot number to bind the texture object to. If multiple textures are bound to the same effect, the slot numbers must be unique and ranging from zero to the maximum number of texture slots for the graphics device.
Returns
Handle to the texture object binding, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Reimplemented in Cogs::EffectsGL20, Cogs::EffectsGLES30, and Cogs::EffectsWebGPU.

Definition at line 421 of file EffectsCommon.cpp.

◆ initialize()

void Cogs::EffectsCommon::initialize ( struct IBuffers buffers)

Definition at line 39 of file EffectsCommon.cpp.

◆ load() [1/2]

Cogs::EffectHandle Cogs::EffectsCommon::load ( const ProcessedContent vsSource,
const ProcessedContent gsSource,
const ProcessedContent psSource,
const StringView vsEntryPoint,
const StringView gsEntryPoint,
const StringView psEntryPoint,
const EffectDescription desc 
)

Definition at line 247 of file EffectsCommon.cpp.

◆ load() [2/2]

Cogs::EffectHandle Cogs::EffectsCommon::load ( const ProcessedContent vsSource,
const ProcessedContent psSource,
const StringView vsEntryPoint,
const StringView psEntryPoint,
const EffectDescription desc 
)

Definition at line 238 of file EffectsCommon.cpp.

◆ loadEffect() [1/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffect ( const EffectDescription description)
finalvirtual

◆ loadEffect() [2/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffect ( const StringView fileName,
const PreprocessorDefinitions defines,
EffectFlags::EEffectFlags  effectFlags = EffectFlags::None 
)

Definition at line 225 of file EffectsCommon.cpp.

◆ loadEffect() [3/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffect ( const StringView fileName,
EffectFlags::EEffectFlags  effectFlags = EffectFlags::None 
)
finalvirtual

Load the given single file effect.

Parameters
fileNameFile name of an effect to load. Must be a valid single file effect (for D3D11 typically .fx file).
Returns
Handle to the loaded effect, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Definition at line 148 of file EffectsCommon.cpp.

◆ loadEffect() [4/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffect ( const StringView vsFileName,
const StringView psFileName,
const PreprocessorDefinitions definitions,
EffectFlags::EEffectFlags  effectFlags = EffectFlags::None 
)
finalvirtual

Load an effect created from the vertex and pixel shader files given, applying the given preprocessor definitions to the shaders.

Parameters
vsFileNameFile name for the vertex shader.
psFileNameFile name for the pixel shader.
definitionsA list of preprocessor definitions (key, value pairs) to apply to the shaders before compilation.
Returns
Handle to the loaded effect, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Definition at line 171 of file EffectsCommon.cpp.

References Cogs::File.

◆ loadEffect() [5/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffect ( const StringView vsFileName,
const StringView psFileName,
EffectFlags::EEffectFlags  effectFlags = EffectFlags::None 
)
finalvirtual

Load an effect created from the vertex and pixel shader files given.

Parameters
vsFileNameFile name for the vertex shader.
psFileNameFile name for the pixel shader.
Returns
Handle to the loaded effect, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Definition at line 159 of file EffectsCommon.cpp.

◆ loadEffectContents()

Cogs::EffectHandle Cogs::EffectsCommon::loadEffectContents ( const EffectDescription description,
const EffectContents contents 
)

Definition at line 123 of file EffectsCommon.cpp.

◆ loadEffectSource() [1/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffectSource ( const EffectDescription description)

Definition at line 94 of file EffectsCommon.cpp.

◆ loadEffectSource() [2/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffectSource ( const StringView vsSource,
const StringView gsSource,
const StringView psSource,
const PreprocessorDefinitions definitions,
EffectFlags::EEffectFlags  effectFlags = EffectFlags::None 
)
finalvirtual

Load an effect created from the vertex, geometry, and pixel shader sources given, applying the given preprocessor definitions to the shaders.

Parameters
vsSourceSource code for the vertex shader.
gsSourceSource code for the geometry shader.
psSourceSource code for the pixel shader.
definitionsA list of preprocessor definitions (key, value pairs) to apply to the shaders before compilation.
effectFlagsFlags to describe effect source.
Returns
Handle to the loaded effect, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Definition at line 212 of file EffectsCommon.cpp.

References Cogs::Source.

◆ loadEffectSource() [3/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffectSource ( const StringView vsSource,
const StringView gsSource,
const StringView psSource,
EffectFlags::EEffectFlags  effectFlags = EffectFlags::None 
)
finalvirtual

Load an effect created from the vertex, geometry, and pixel shader sources given.

Parameters
vsSourceSource code for the vertex shader.
gsSourceSource code for the geometry shader.
psSourceSource code for the pixel shader.
effectFlagsFlags to describe effect source.
Returns
Handle to the loaded effect, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Definition at line 207 of file EffectsCommon.cpp.

◆ loadEffectSource() [4/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffectSource ( const StringView vsSource,
const StringView psSource,
const PreprocessorDefinitions definitions,
EffectFlags::EEffectFlags  effectFlags = EffectFlags::None 
)
finalvirtual

Load an effect created from the vertex and pixel shader sources given, applying the given preprocessor definitions to the shaders.

Parameters
vsSourceSource code for the vertex shader.
psSourceSource code for the pixel shader.
definitionsA list of preprocessor definitions (key, value pairs) to apply to the shaders before compilation.
effectFlagsFlags to describe effect source.
Returns
Handle to the loaded effect, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Definition at line 195 of file EffectsCommon.cpp.

References Cogs::Source.

◆ loadEffectSource() [5/5]

Cogs::EffectHandle Cogs::EffectsCommon::loadEffectSource ( const StringView vsSource,
const StringView psSource,
EffectFlags::EEffectFlags  effectFlags = EffectFlags::None 
)
finalvirtual

Load an effect created from the vertex and pixel shader sources given.

Parameters
vsSourceSource code for the vertex shader.
psSourceSource code for the pixel shader.
effectFlagsFlags to describe effect source.
Returns
Handle to the loaded effect, InvalidHandle if the operation failed.

Implements Cogs::IEffects.

Definition at line 190 of file EffectsCommon.cpp.

◆ releaseBufferBinding()

void Cogs::EffectsCommon::releaseBufferBinding ( BufferBindingHandle  bufferBindingHandle)
overridevirtual

Release a handle to a buffer binding.

Implements Cogs::IEffects.

Reimplemented in Cogs::EffectsGL20, and Cogs::EffectsWebGPU.

Definition at line 458 of file EffectsCommon.cpp.

◆ setIOHandler()

void Cogs::EffectsCommon::setIOHandler ( IIOHandler handler)
inlineoverridevirtual

Sets an external I/O handler to use for I/O operations.

Parameters
handlerPointer to user implemented I/O handler.

Implements Cogs::IEffects.

Definition at line 261 of file EffectsCommon.h.

Referenced by Cogs::GraphicsDeviceNull::initialize(), and Cogs::GraphicsDeviceWebGPU::initialize().

Member Data Documentation

◆ bufferBindings

ResourceMap<BufferBindingHandle, BufferBinding> Cogs::EffectsCommon::bufferBindings

Definition at line 294 of file EffectsCommon.h.

◆ buffers

struct IBuffers* Cogs::EffectsCommon::buffers = nullptr

Definition at line 298 of file EffectsCommon.h.

◆ defaultHandler

std::unique_ptr<IIOHandler> Cogs::EffectsCommon::defaultHandler

Definition at line 297 of file EffectsCommon.h.

◆ effects

SafeResourceMap<EffectHandle, Effect> Cogs::EffectsCommon::effects

Definition at line 292 of file EffectsCommon.h.

◆ handler

IIOHandler* Cogs::EffectsCommon::handler = nullptr

Definition at line 296 of file EffectsCommon.h.


The documentation for this struct was generated from the following files: