SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::render::DeviceState Class Referencefinal

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

#include <DeviceState.h>

Classes

struct  Impl
 

Public Member Functions

 DeviceState ()
 Creates a new DeviceState instance.
 
 DeviceState (const DeviceState &other)=delete
 
 DeviceState (DeviceState &&other) noexcept=delete
 
DeviceStateoperator= (const DeviceState &other)=delete
 
DeviceStateoperator= (DeviceState &&other) noexcept=delete
 
IRenderPassrenderPass (const std::string &id) const
 Gets a IRenderPass from the device state.
 
IPipelinepipeline (const std::string &id) const
 Gets a IPipeline from the device state.
 
IBufferbuffer (const std::string &id) const
 Gets a IBuffer from the device state.
 
IVertexBuffervertexBuffer (const std::string &id) const
 Gets a IVertexBuffer from the device state.
 
IIndexBufferindexBuffer (const std::string &id) const
 Gets a IIndexBuffer from the device state.
 
IImageimage (const std::string &id) const
 Gets a IImage from the device state.
 
ISamplersampler (const std::string &id) const
 Gets a ISampler from the device state.
 
IDescriptorSetdescriptorSet (const std::string &id) const
 Gets a IDescriptorSet from the device state.
 
void add (std::unique_ptr< IRenderPass > &&render_pass)
 Adds a IRenderPass to the device state and uses its name as identifier.
 
void add (const std::string &id, std::unique_ptr< IRenderPass > &&render_pass)
 Adds a new IRenderPass to the device state.
 
void add (std::unique_ptr< IPipeline > &&pipeline)
 Adds a IPipeline to the device state and uses its name as identifier.
 
void add (const std::string &id, std::unique_ptr< IPipeline > &&pipeline)
 Adds a new IPipeline to the device state.
 
void add (std::unique_ptr< IBuffer > &&buffer)
 Adds a IBuffer to the device state and uses its name as identifier.
 
void add (const std::string &id, std::unique_ptr< IBuffer > &&buffer)
 Adds a new IBuffer to the device state.
 
void add (std::unique_ptr< IVertexBuffer > &&vertex_buffer)
 Adds a IVertexBuffer to the device state and uses its name as identifier.
 
void add (const std::string &id, std::unique_ptr< IVertexBuffer > &&vertex_buffer)
 Adds a new IVertexBuffer to the device state.
 
void add (std::unique_ptr< IIndexBuffer > &&index_buffer)
 Adds a IIndexBuffer to the device state and uses its name as identifier.
 
void add (const std::string &id, std::unique_ptr< IIndexBuffer > &&index_buffer)
 Adds a new IIndexBuffer to the device state.
 
void add (std::unique_ptr< IImage > &&image)
 Adds a IImage to the device state and uses its name as identifier.
 
void add (const std::string &id, std::unique_ptr< IImage > &&image)
 Adds a new IImage to the device state.
 
void add (std::unique_ptr< ISampler > &&sampler)
 Adds a ISampler to the device state and uses its name as identifier.
 
void add (const std::string &id, std::unique_ptr< ISampler > &&sampler)
 Adds a new ISampler to the device state.
 
void add (const std::string &id, std::unique_ptr< IDescriptorSet > &&descriptor_set)
 Adds a IDescriptorSet to the device state and uses its name as identifier.
 
bool release (const IRenderPass &render_pass)
 Releases a IRenderPass.
 
bool release (const IPipeline &pipeline)
 Releases a IPipeline.
 
bool release (const IBuffer &buffer)
 Releases a IBuffer.
 
bool release (const IVertexBuffer &vertex_buffer)
 Releases a IVertexBuffer.
 
bool release (const IIndexBuffer &index_buffer)
 Releases a IIndexBuffer.
 
bool release (const IImage &image)
 Releases a IImage.
 
bool release (const ISampler &sampler)
 Releases a ISampler.
 
bool release (const IDescriptorSet &descriptor_set)
 Releases a IDescriptorSet.
 
void clear ()
 Releases all resources managed by the device state.
 

Detailed Description

A class 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. 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.

Member Function Documentation

◆ add() [1/15]

void spark::render::DeviceState::add ( const std::string & id,
std::unique_ptr< IBuffer > && buffer )

Adds a new IBuffer to the device state.

Parameters
idThe identifier of the buffer in the device state.
bufferA std::unique_ptr to the IBuffer to add.

◆ add() [2/15]

void spark::render::DeviceState::add ( const std::string & id,
std::unique_ptr< IDescriptorSet > && descriptor_set )

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

Parameters
idThe identifier of the descriptor set in the device state.
descriptor_setA std::unique_ptr to the IDescriptorSet to add.

◆ add() [3/15]

void spark::render::DeviceState::add ( const std::string & id,
std::unique_ptr< IImage > && image )

Adds a new IImage to the device state.

Parameters
idThe identifier of the image in the device state.
imageA std::unique_ptr to the IImage to add.

◆ add() [4/15]

void spark::render::DeviceState::add ( const std::string & id,
std::unique_ptr< IIndexBuffer > && index_buffer )

Adds a new IIndexBuffer to the device state.

Parameters
idThe identifier of the index buffer in the device state.
index_bufferA std::unique_ptr to the IIndexBuffer to add.

◆ add() [5/15]

void spark::render::DeviceState::add ( const std::string & id,
std::unique_ptr< IPipeline > && pipeline )

Adds a new IPipeline to the device state.

Parameters
idThe identifier of the pipeline in the device state.
pipelineA std::unique_ptr to the IPipeline to add.

◆ add() [6/15]

void spark::render::DeviceState::add ( const std::string & id,
std::unique_ptr< IRenderPass > && render_pass )

Adds a new IRenderPass to the device state.

Parameters
idThe identifier of the render pass in the device state.
render_passA std::unique_ptr to the IRenderPass to add.

◆ add() [7/15]

void spark::render::DeviceState::add ( const std::string & id,
std::unique_ptr< ISampler > && sampler )

Adds a new ISampler to the device state.

Parameters
idThe identifier of the sampler in the device state.
samplerA std::unique_ptr to the ISampler to add.

◆ add() [8/15]

void spark::render::DeviceState::add ( const std::string & id,
std::unique_ptr< IVertexBuffer > && vertex_buffer )

Adds a new IVertexBuffer to the device state.

Parameters
idThe identifier of the vertex buffer in the device state.
vertex_bufferA std::unique_ptr to the IVertexBuffer to add.

◆ add() [9/15]

void spark::render::DeviceState::add ( std::unique_ptr< IBuffer > && buffer)

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

Parameters
bufferA std::unique_ptr to the IBuffer to add.

◆ add() [10/15]

void spark::render::DeviceState::add ( std::unique_ptr< IImage > && image)

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

Parameters
imageA std::unique_ptr to the IImage to add.

◆ add() [11/15]

void spark::render::DeviceState::add ( std::unique_ptr< IIndexBuffer > && index_buffer)

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

Parameters
index_bufferA std::unique_ptr to the IIndexBuffer to add.

◆ add() [12/15]

void spark::render::DeviceState::add ( std::unique_ptr< IPipeline > && pipeline)

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

Parameters
pipelineA std::unique_ptr to the IPipeline to add.

◆ add() [13/15]

void spark::render::DeviceState::add ( std::unique_ptr< IRenderPass > && render_pass)

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

Parameters
render_passA std::unique_ptr to the IRenderPass to add.

◆ add() [14/15]

void spark::render::DeviceState::add ( std::unique_ptr< ISampler > && sampler)

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

Parameters
samplerA std::unique_ptr to the ISampler to add.

◆ add() [15/15]

void spark::render::DeviceState::add ( std::unique_ptr< IVertexBuffer > && vertex_buffer)

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

Parameters
vertex_bufferA std::unique_ptr to the IVertexBuffer to add.

◆ buffer()

IBuffer & spark::render::DeviceState::buffer ( const std::string & id) const
nodiscard

Gets a IBuffer from the device state.

Parameters
idThe identifier of the buffer.
Returns
A reference to the IBuffer associated with the given identifier.

◆ descriptorSet()

IDescriptorSet & spark::render::DeviceState::descriptorSet ( const std::string & id) const
nodiscard

Gets a IDescriptorSet from the device state.

Parameters
idThe identifier of the descriptor set.
Returns
A reference to the IDescriptorSet associated with the given identifier.

◆ image()

IImage & spark::render::DeviceState::image ( const std::string & id) const
nodiscard

Gets a IImage from the device state.

Parameters
idThe identifier of the image.
Returns
Gets a reference to the IImage associated with the given identifier.

◆ indexBuffer()

IIndexBuffer & spark::render::DeviceState::indexBuffer ( const std::string & id) const
nodiscard

Gets a IIndexBuffer from the device state.

Parameters
idThe identifier of the index buffer.
Returns
A reference to the IIndexBuffer associated with the given identifier.

◆ pipeline()

IPipeline & spark::render::DeviceState::pipeline ( const std::string & id) const
nodiscard

Gets a IPipeline from the device state.

Parameters
idThe identifier of the pipeline.
Returns
A reference to the IPipeline associated with the given identifier.

◆ release() [1/8]

bool spark::render::DeviceState::release ( const IBuffer & buffer)

Releases a IBuffer.

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

◆ release() [2/8]

bool spark::render::DeviceState::release ( const IDescriptorSet & descriptor_set)

Releases a IDescriptorSet.

Parameters
descriptor_setThe IDescriptorSet to release.
Returns
true if the descriptor set was successfully released, false otherwise.

◆ release() [3/8]

bool spark::render::DeviceState::release ( const IImage & image)

Releases a IImage.

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

◆ release() [4/8]

bool spark::render::DeviceState::release ( const IIndexBuffer & index_buffer)

Releases a IIndexBuffer.

Parameters
index_bufferThe IIndexBuffer to release.
Returns
true if the index buffer was successfully released, false otherwise.

◆ release() [5/8]

bool spark::render::DeviceState::release ( const IPipeline & pipeline)

Releases a IPipeline.

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

◆ release() [6/8]

bool spark::render::DeviceState::release ( const IRenderPass & render_pass)

Releases a IRenderPass.

Parameters
render_passThe IRenderPass to release.
Returns
true if the render pass was successfully released, false otherwise.

Calling this method will destroy the render pass. Before calling it, the render pass must be requested using DeviceState::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.

◆ release() [7/8]

bool spark::render::DeviceState::release ( const ISampler & sampler)

Releases a ISampler.

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

◆ release() [8/8]

bool spark::render::DeviceState::release ( const IVertexBuffer & vertex_buffer)

Releases a IVertexBuffer.

Parameters
vertex_bufferThe IVertexBuffer to release.
Returns
true if the vertex buffer was successfully released, false otherwise.

◆ renderPass()

IRenderPass & spark::render::DeviceState::renderPass ( const std::string & id) const
nodiscard

Gets a IRenderPass from the device state.

Parameters
idThe identifier of the render pass.
Returns
A reference to the RenderPass associated with the given identifier.

◆ sampler()

ISampler & spark::render::DeviceState::sampler ( const std::string & id) const
nodiscard

Gets a ISampler from the device state.

Parameters
idThe identifier of the sampler.
Returns
A reference to the ISampler associated with the given identifier.

◆ vertexBuffer()

IVertexBuffer & spark::render::DeviceState::vertexBuffer ( const std::string & id) const
nodiscard

Gets a IVertexBuffer from the device state.

Parameters
idThe identifier of the vertex buffer.
Returns
A reference to the IVertexBuffer associated with the given identifier.