LiteFX 0.3.1.2022
Computer Graphics Engine
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 () noexcept
 Creates a new device state instance. More...
 
 DeviceState (DeviceState &&)=delete
 
 DeviceState (const DeviceState &)=delete
 
virtual ~DeviceState () noexcept
 
void clear ()
 Release all resources managed by the device state. More...
 
void add (UniquePtr< IRenderPass > &&renderPass)
 Adds a new render pass to the device state and uses its name as identifier. More...
 
void add (const String &id, UniquePtr< IRenderPass > &&renderPass)
 Adds a new render pass to the device state. More...
 
void add (UniquePtr< IPipeline > &&pipeline)
 Adds a new pipeline to the device state and uses its name as identifier. More...
 
void add (const String &id, UniquePtr< IPipeline > &&pipeline)
 Adds a new pipeline to the device state. More...
 
void add (UniquePtr< IBuffer > &&buffer)
 Adds a new buffer to the device state and uses its name as identifier. More...
 
void add (const String &id, UniquePtr< IBuffer > &&buffer)
 Adds a new buffer to the device state. More...
 
void add (UniquePtr< IVertexBuffer > &&vertexBuffer)
 Adds a new vertex buffer to the device state and uses its name as identifier. More...
 
void add (const String &id, UniquePtr< IVertexBuffer > &&vertexBuffer)
 Adds a new vertex buffer to the device state. More...
 
void add (UniquePtr< IIndexBuffer > &&indexBuffer)
 Adds a new index buffer to the device state and uses its name as identifier. More...
 
void add (const String &id, UniquePtr< IIndexBuffer > &&indexBuffer)
 Adds a new index buffer to the device state. More...
 
void add (UniquePtr< IImage > &&image)
 Adds a new image to the device state and uses its name as identifier. More...
 
void add (const String &id, UniquePtr< IImage > &&image)
 Adds a new image to the device state. More...
 
void add (UniquePtr< ISampler > &&sampler)
 Adds a new sampler to the device state and uses its name as identifier. More...
 
void add (const String &id, UniquePtr< ISampler > &&sampler)
 Adds a new sampler to the device state. More...
 
void add (const String &id, UniquePtr< IDescriptorSet > &&descriptorSet)
 Adds a new descriptor set to the device state. More...
 
IRenderPassrenderPass (const String &id) const
 Returns a render pass from the device state. More...
 
IPipelinepipeline (const String &id) const
 Returns a pipeline from the device state. More...
 
IBufferbuffer (const String &id) const
 Returns a buffer from the device state. More...
 
IVertexBuffervertexBuffer (const String &id) const
 Returns a vertex buffer from the device state. More...
 
IIndexBufferindexBuffer (const String &id) const
 Returns an index buffer from the device state. More...
 
IImageimage (const String &id) const
 Returns an image from the device state. More...
 
ISamplersampler (const String &id) const
 Returns an sampler from the device state. More...
 
IDescriptorSetdescriptorSet (const String &id) const
 Returns an descriptor set from the device state. More...
 
bool release (const IRenderPass &renderPass)
 Releases a render pass. More...
 
bool release (const IPipeline &pipeline)
 Releases a pipeline. More...
 
bool release (const IBuffer &buffer)
 Releases a buffer. More...
 
bool release (const IVertexBuffer &buffer)
 Releases a vertex buffer. More...
 
bool release (const IIndexBuffer &buffer)
 Releases a index buffer. More...
 
bool release (const IImage &image)
 Releases an image. More...
 
bool release (const ISampler &sampler)
 Releases a sampler. More...
 
bool release (const IDescriptorSet &descriptorSet)
 Releases a descriptor set. More...
 

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 ( )
explicitnoexcept

Creates a new device state instance.

◆ DeviceState() [2/3]

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

◆ DeviceState() [3/3]

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

◆ ~DeviceState()

DeviceState::~DeviceState ( )
virtualnoexcept

Member Function Documentation

◆ add() [1/15]

void DeviceState::add ( const String id,
UniquePtr< 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/15]

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() [3/15]

void DeviceState::add ( const String id,
UniquePtr< 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/15]

void DeviceState::add ( const String id,
UniquePtr< 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/15]

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() [6/15]

void DeviceState::add ( const String id,
UniquePtr< 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() [7/15]

void DeviceState::add ( const String id,
UniquePtr< 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() [8/15]

void DeviceState::add ( const String id,
UniquePtr< 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() [9/15]

void DeviceState::add ( UniquePtr< 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() [10/15]

void DeviceState::add ( UniquePtr< 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() [11/15]

void DeviceState::add ( UniquePtr< 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() [12/15]

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.

◆ add() [13/15]

void DeviceState::add ( UniquePtr< 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() [14/15]

void DeviceState::add ( UniquePtr< 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() [15/15]

void DeviceState::add ( UniquePtr< 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.

◆ 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 an 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 .

◆ 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 .

◆ 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/8]

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/8]

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/8]

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() [4/8]

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() [5/8]

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() [6/8]

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() [7/8]

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() [8/8]

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 an 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 Function Documentation

◆ IGraphicsDevice

friend class IGraphicsDevice
friend