LiteFX 0.4.1.2025
Computer Graphics Engine
Loading...
Searching...
No Matches
LiteFX::Rendering::DeviceState Class Reference

A class that can be used to manage the state of a IGraphicsDevice. More...

#include <rendering_api.hpp>

Classes

class  DeviceStateImpl
 

Public Member Functions

 DeviceState ()
 Creates a new device state instance.
 
 DeviceState (DeviceState &&_other) noexcept
 Takes over another instance of a device state.
 
DeviceStateoperator= (DeviceState &&_other) noexcept
 Assigns a device state by taking it over.
 
virtual ~DeviceState () noexcept
 Releases the device state instance.
 
 DeviceState (const DeviceState &)=delete
 
DeviceStateoperator= (const DeviceState &)=delete
 
void clear ()
 Release all resources managed by the device state.
 
void add (SharedPtr< IRenderPass > &&renderPass)
 Adds a new render pass to the device state and uses its name as identifier.
 
void add (const String &id, SharedPtr< IRenderPass > &&renderPass)
 Adds a new render pass to the device state.
 
void add (SharedPtr< IFrameBuffer > &&frameBuffer)
 Adds a new frame buffer to the device state and uses its name as identifier.
 
void add (const String &id, SharedPtr< IFrameBuffer > &&frameBuffer)
 Adds a new frame buffer to the device state.
 
void add (UniquePtr< IPipeline > &&pipeline)
 Adds a new pipeline to the device state and uses its name as identifier.
 
void add (const String &id, UniquePtr< IPipeline > &&pipeline)
 Adds a new pipeline to the device state.
 
void add (SharedPtr< IBuffer > &&buffer)
 Adds a new buffer to the device state and uses its name as identifier.
 
void add (const String &id, SharedPtr< IBuffer > &&buffer)
 Adds a new buffer to the device state.
 
void add (SharedPtr< IVertexBuffer > &&vertexBuffer)
 Adds a new vertex buffer to the device state and uses its name as identifier.
 
void add (const String &id, SharedPtr< IVertexBuffer > &&vertexBuffer)
 Adds a new vertex buffer to the device state.
 
void add (SharedPtr< IIndexBuffer > &&indexBuffer)
 Adds a new index buffer to the device state and uses its name as identifier.
 
void add (const String &id, SharedPtr< IIndexBuffer > &&indexBuffer)
 Adds a new index buffer to the device state.
 
void add (SharedPtr< IImage > &&image)
 Adds a new image to the device state and uses its name as identifier.
 
void add (const String &id, SharedPtr< IImage > &&image)
 Adds a new image to the device state.
 
void add (SharedPtr< ISampler > &&sampler)
 Adds a new sampler to the device state and uses its name as identifier.
 
void add (const String &id, SharedPtr< ISampler > &&sampler)
 Adds a new sampler to the device state.
 
void add (UniquePtr< IAccelerationStructure > &&accelerationStructure)
 Adds a new acceleration structure to the device state and uses its name as identifier.
 
void add (const String &id, UniquePtr< IAccelerationStructure > &&accelerationStructure)
 Adds a new acceleration structure to the device state.
 
void add (const String &id, UniquePtr< IDescriptorSet > &&descriptorSet)
 Adds a new descriptor set to the device state.
 
IRenderPassrenderPass (const String &id) const
 Returns a render pass from the device state.
 
IFrameBufferframeBuffer (const String &id) const
 Returns a frame buffer from the device state.
 
IPipelinepipeline (const String &id) const
 Returns a pipeline from the device state.
 
IBufferbuffer (const String &id) const
 Returns a buffer from the device state.
 
IVertexBuffervertexBuffer (const String &id) const
 Returns a vertex buffer from the device state.
 
IIndexBufferindexBuffer (const String &id) const
 Returns an index buffer from the device state.
 
IImageimage (const String &id) const
 Returns an image from the device state.
 
ISamplersampler (const String &id) const
 Returns a sampler from the device state.
 
IAccelerationStructureaccelerationStructure (const String &id) const
 Returns an acceleration structure from the device state.
 
IDescriptorSetdescriptorSet (const String &id) const
 Returns a descriptor set from the device state.
 
bool release (const IRenderPass &renderPass)
 Releases a render pass.
 
bool release (const IFrameBuffer &frameBuffer)
 Releases a frame buffer.
 
bool release (const IPipeline &pipeline)
 Releases a pipeline.
 
bool release (const IBuffer &buffer)
 Releases a buffer.
 
bool release (const IVertexBuffer &buffer)
 Releases a vertex buffer.
 
bool release (const IIndexBuffer &buffer)
 Releases a index buffer.
 
bool release (const IImage &image)
 Releases an image.
 
bool release (const ISampler &sampler)
 Releases a sampler.
 
bool release (const IDescriptorSet &descriptorSet)
 Releases a descriptor set.
 

Friends

class IGraphicsDevice
 

Detailed Description

A class that can be used to manage the state of a IGraphicsDevice.

The device state makes managing resources created by a device easier, since you do not have to worry about storage and release order. Note, however, that this is not free. Requesting a resource requires a lookup within a hash-map. Also device states are not specialized for the concrete device, so you can only work with interfaces. This implies potentially inefficient upcasting of the state resource when its passed to another object. You have to decide if or to which degree you want to rely on storing resources in a device state.

See also
StateResource, IGraphicsDevice

Constructor & Destructor Documentation

◆ DeviceState() [1/3]

DeviceState::DeviceState ( )
explicitdefault

Creates a new device state instance.

◆ DeviceState() [2/3]

DeviceState::DeviceState ( DeviceState && _other)
defaultnoexcept

Takes over another instance of a device state.

Parameters
_otherThe device state instance to take over.

◆ ~DeviceState()

DeviceState::~DeviceState ( )
virtualnoexcept

Releases the device state instance.

◆ DeviceState() [3/3]

LiteFX::Rendering::DeviceState::DeviceState ( const DeviceState & )
delete

Member Function Documentation

◆ accelerationStructure()

IAccelerationStructure & DeviceState::accelerationStructure ( const String & id) const

Returns an acceleration structure from the device state.

Parameters
idThe identifier associated with the acceleration structure.
Returns
A reference of the acceleration structure.
Exceptions
InvalidArgumentExceptoinThrown, if no acceleration structure has been added for the provided id .

◆ add() [1/19]

void DeviceState::add ( const String & id,
SharedPtr< IBuffer > && buffer )

Adds a new buffer to the device state.

Parameters
idThe identifier for the buffer.
bufferThe buffer to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another buffer with the same id has already been added.

◆ add() [2/19]

void DeviceState::add ( const String & id,
SharedPtr< IFrameBuffer > && frameBuffer )

Adds a new frame buffer to the device state.

Parameters
idThe identifier for the frame buffer.
renderPassThe frame buffer to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another frame buffer with the same id has already been added.

◆ add() [3/19]

void DeviceState::add ( const String & id,
SharedPtr< IImage > && image )

Adds a new image to the device state.

Parameters
idThe identifier for the image.
imageThe image to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another image with the same id has already been added.

◆ add() [4/19]

void DeviceState::add ( const String & id,
SharedPtr< IIndexBuffer > && indexBuffer )

Adds a new index buffer to the device state.

Parameters
idThe identifier for the index buffer.
indexBufferThe index buffer to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another index buffer with the same id has already been added.

◆ add() [5/19]

void DeviceState::add ( const String & id,
SharedPtr< IRenderPass > && renderPass )

Adds a new render pass to the device state.

Parameters
idThe identifier for the render pass.
renderPassThe render pass to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another render pass with the same id has already been added.

◆ add() [6/19]

void DeviceState::add ( const String & id,
SharedPtr< ISampler > && sampler )

Adds a new sampler to the device state.

Parameters
idThe identifier for the sampler.
samplerThe sampler to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another sampler with the same id has already been added.

◆ add() [7/19]

void DeviceState::add ( const String & id,
SharedPtr< IVertexBuffer > && vertexBuffer )

Adds a new vertex buffer to the device state.

Parameters
idThe identifier for the vertex buffer.
vertexBufferThe vertex buffer to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another vertex buffer with the same id has already been added.

◆ add() [8/19]

void DeviceState::add ( const String & id,
UniquePtr< IAccelerationStructure > && accelerationStructure )

Adds a new acceleration structure to the device state.

Parameters
idThe identifier for the acceleration structure.
accelerationStructureThe acceleration structure to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another acceleration structure with the same id has already been added.

◆ add() [9/19]

void DeviceState::add ( const String & id,
UniquePtr< IDescriptorSet > && descriptorSet )

Adds a new descriptor set to the device state.

Parameters
idThe identifier for the descriptor set.
samplerThe descriptor set to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another descriptor set with the same id has already been added.

◆ add() [10/19]

void DeviceState::add ( const String & id,
UniquePtr< IPipeline > && pipeline )

Adds a new pipeline to the device state.

Parameters
idThe identifier for the pipeline.
pipelineThe pipeline to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another pipeline with the same id has already been added.

◆ add() [11/19]

void DeviceState::add ( SharedPtr< IBuffer > && buffer)

Adds a new buffer to the device state and uses its name as identifier.

Parameters
bufferThe buffer to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another buffer with the same identifier has already been added.

◆ add() [12/19]

void DeviceState::add ( SharedPtr< IFrameBuffer > && frameBuffer)

Adds a new frame buffer to the device state and uses its name as identifier.

Parameters
frameBufferThe render pass to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another frame buffer with the same identifier has already been added.

◆ add() [13/19]

void DeviceState::add ( SharedPtr< IImage > && image)

Adds a new image to the device state and uses its name as identifier.

Parameters
imageThe image to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another image with the same identifier has already been added.

◆ add() [14/19]

void DeviceState::add ( SharedPtr< IIndexBuffer > && indexBuffer)

Adds a new index buffer to the device state and uses its name as identifier.

Parameters
indexBufferThe index buffer to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another index buffer with the same identifier has already been added.

◆ add() [15/19]

void DeviceState::add ( SharedPtr< IRenderPass > && renderPass)

Adds a new render pass to the device state and uses its name as identifier.

Parameters
renderPassThe render pass to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another render pass with the same identifier has already been added.

◆ add() [16/19]

void DeviceState::add ( SharedPtr< ISampler > && sampler)

Adds a new sampler to the device state and uses its name as identifier.

Parameters
samplerThe sampler to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another sampler with the same identifier has already been added.

◆ add() [17/19]

void DeviceState::add ( SharedPtr< IVertexBuffer > && vertexBuffer)

Adds a new vertex buffer to the device state and uses its name as identifier.

Parameters
vertexBufferThe vertex buffer to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another vertex buffer with the same identifier has already been added.

◆ add() [18/19]

void DeviceState::add ( UniquePtr< IAccelerationStructure > && accelerationStructure)

Adds a new acceleration structure to the device state and uses its name as identifier.

Parameters
accelerationStructureThe acceleration structure to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another acceleration structure with the same id has already been added.

◆ add() [19/19]

void DeviceState::add ( UniquePtr< IPipeline > && pipeline)

Adds a new pipeline to the device state and uses its name as identifier.

Parameters
pipelineThe pipeline to add to the device state.
Exceptions
InvalidArgumentExceptionThrown, if another pipeline with the same identifier has already been added.

◆ buffer()

IBuffer & DeviceState::buffer ( const String & id) const

Returns a buffer from the device state.

Parameters
idThe identifier associated with the buffer.
Returns
A reference of the buffer.
Exceptions
InvalidArgumentExceptoinThrown, if no buffer has been added for the provided id .

◆ clear()

void DeviceState::clear ( )

Release all resources managed by the device state.

◆ descriptorSet()

IDescriptorSet & DeviceState::descriptorSet ( const String & id) const

Returns a descriptor set from the device state.

Parameters
idThe identifier associated with the descriptor set.
Returns
A reference of the descriptor set.
Exceptions
InvalidArgumentExceptoinThrown, if no descriptor set has been added for the provided id .

◆ frameBuffer()

IFrameBuffer & DeviceState::frameBuffer ( const String & id) const

Returns a frame buffer from the device state.

Parameters
idThe identifier associated with the frame buffer.
Returns
A reference of the frame buffer.
Exceptions
InvalidArgumentExceptoinThrown, if no frame buffer has been added for the provided id .

◆ image()

IImage & DeviceState::image ( const String & id) const

Returns an image from the device state.

Parameters
idThe identifier associated with the image.
Returns
A reference of the image.
Exceptions
InvalidArgumentExceptoinThrown, if no image has been added for the provided id .

◆ indexBuffer()

IIndexBuffer & DeviceState::indexBuffer ( const String & id) const

Returns an index buffer from the device state.

Parameters
idThe identifier associated with the index buffer.
Returns
A reference of the index buffer.
Exceptions
InvalidArgumentExceptoinThrown, if no index buffer has been added for the provided id .

◆ operator=() [1/2]

DeviceState & LiteFX::Rendering::DeviceState::operator= ( const DeviceState & )
delete

◆ operator=() [2/2]

DeviceState & DeviceState::operator= ( DeviceState && _other)
defaultnoexcept

Assigns a device state by taking it over.

Parameters
_otherThe device state to take over.
Returns
A reference to the current device state instance.

◆ pipeline()

IPipeline & DeviceState::pipeline ( const String & id) const

Returns a pipeline from the device state.

Parameters
idThe identifier associated with the pipeline.
Returns
A reference of the pipeline.
Exceptions
InvalidArgumentExceptoinThrown, if no pipeline has been added for the provided id .

◆ release() [1/9]

bool DeviceState::release ( const IBuffer & buffer)

Releases a buffer.

Parameters
bufferThe buffer to release.
Returns
true, if the buffer was properly released, false otherwise.

◆ release() [2/9]

bool DeviceState::release ( const IDescriptorSet & descriptorSet)

Releases a descriptor set.

Parameters
descriptorSetThe descriptor set to release.
Returns
true, if the descriptor set was properly released, false otherwise.

◆ release() [3/9]

bool DeviceState::release ( const IFrameBuffer & frameBuffer)

Releases a frame buffer.

Parameters
renderPassThe frame buffer to release.
Returns
true, if the frame buffer was properly released, false otherwise.

◆ release() [4/9]

bool DeviceState::release ( const IImage & image)

Releases an image.

Parameters
imageThe image to release.
Returns
true, if the image was properly released, false otherwise.

◆ release() [5/9]

bool DeviceState::release ( const IIndexBuffer & buffer)

Releases a index buffer.

Parameters
bufferThe index buffer to release.
Returns
true, if the index buffer was properly released, false otherwise.

◆ release() [6/9]

bool DeviceState::release ( const IPipeline & pipeline)

Releases a pipeline.

Parameters
pipelineThe pipeline to release.
Returns
true, if the pipeline was properly released, false otherwise.

◆ release() [7/9]

bool DeviceState::release ( const IRenderPass & renderPass)

Releases a render pass.

Calling this method will destroy the render pass. Before calling it, the render pass must be requested using renderPass. After this method has been executed, all references (including the renderPass parameter) will be invalid. If the render pass is not managed by the device state, this method will do nothing and return false.

Parameters
renderPassThe render pass to release.
Returns
true, if the render pass was properly released, false otherwise.

◆ release() [8/9]

bool DeviceState::release ( const ISampler & sampler)

Releases a sampler.

Parameters
samplerThe sampler to release.
Returns
true, if the sampler was properly released, false otherwise.

◆ release() [9/9]

bool DeviceState::release ( const IVertexBuffer & buffer)

Releases a vertex buffer.

Parameters
bufferThe vertex buffer to release.
Returns
true, if the vertex buffer was properly released, false otherwise.

◆ renderPass()

IRenderPass & DeviceState::renderPass ( const String & id) const

Returns a render pass from the device state.

Parameters
idThe identifier associated with the render pass.
Returns
A reference of the render pass.
Exceptions
InvalidArgumentExceptoinThrown, if no render pass has been added for the provided id .

◆ sampler()

ISampler & DeviceState::sampler ( const String & id) const

Returns a sampler from the device state.

Parameters
idThe identifier associated with the sampler.
Returns
A reference of the sampler.
Exceptions
InvalidArgumentExceptoinThrown, if no sampler has been added for the provided id .

◆ vertexBuffer()

IVertexBuffer & DeviceState::vertexBuffer ( const String & id) const

Returns a vertex buffer from the device state.

Parameters
idThe identifier associated with the vertex buffer.
Returns
A reference of the vertex buffer.
Exceptions
InvalidArgumentExceptoinThrown, if no vertex buffer has been added for the provided id .

Friends And Related Symbol Documentation

◆ IGraphicsDevice

friend class IGraphicsDevice
friend