SPARK
0.1.0
A general purpose game engine written in C++.
|
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 | |
DeviceState & | operator= (const DeviceState &other)=delete |
DeviceState & | operator= (DeviceState &&other) noexcept=delete |
IRenderPass & | renderPass (const std::string &id) const |
Gets a IRenderPass from the device state. | |
IPipeline & | pipeline (const std::string &id) const |
Gets a IPipeline from the device state. | |
IBuffer & | buffer (const std::string &id) const |
Gets a IBuffer from the device state. | |
IVertexBuffer & | vertexBuffer (const std::string &id) const |
Gets a IVertexBuffer from the device state. | |
IIndexBuffer & | indexBuffer (const std::string &id) const |
Gets a IIndexBuffer from the device state. | |
IImage & | image (const std::string &id) const |
Gets a IImage from the device state. | |
ISampler & | sampler (const std::string &id) const |
Gets a ISampler from the device state. | |
IDescriptorSet & | descriptorSet (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. | |
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.
void spark::render::DeviceState::add | ( | const std::string & | id, |
std::unique_ptr< IBuffer > && | buffer ) |
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.
id | The identifier of the descriptor set in the device state. |
descriptor_set | A std::unique_ptr to the IDescriptorSet to add. |
void spark::render::DeviceState::add | ( | const std::string & | id, |
std::unique_ptr< IImage > && | image ) |
void spark::render::DeviceState::add | ( | const std::string & | id, |
std::unique_ptr< IIndexBuffer > && | index_buffer ) |
Adds a new IIndexBuffer to the device state.
id | The identifier of the index buffer in the device state. |
index_buffer | A std::unique_ptr to the IIndexBuffer to add. |
void spark::render::DeviceState::add | ( | const std::string & | id, |
std::unique_ptr< IPipeline > && | pipeline ) |
void spark::render::DeviceState::add | ( | const std::string & | id, |
std::unique_ptr< IRenderPass > && | render_pass ) |
Adds a new IRenderPass to the device state.
id | The identifier of the render pass in the device state. |
render_pass | A std::unique_ptr to the IRenderPass to add. |
void spark::render::DeviceState::add | ( | const std::string & | id, |
std::unique_ptr< ISampler > && | sampler ) |
void spark::render::DeviceState::add | ( | const std::string & | id, |
std::unique_ptr< IVertexBuffer > && | vertex_buffer ) |
Adds a new IVertexBuffer to the device state.
id | The identifier of the vertex buffer in the device state. |
vertex_buffer | A std::unique_ptr to the IVertexBuffer to add. |
void spark::render::DeviceState::add | ( | std::unique_ptr< IBuffer > && | buffer | ) |
void spark::render::DeviceState::add | ( | std::unique_ptr< IImage > && | image | ) |
void spark::render::DeviceState::add | ( | std::unique_ptr< IIndexBuffer > && | index_buffer | ) |
Adds a IIndexBuffer to the device state and uses its name as identifier.
index_buffer | A std::unique_ptr to the IIndexBuffer to add. |
void spark::render::DeviceState::add | ( | std::unique_ptr< IPipeline > && | pipeline | ) |
void spark::render::DeviceState::add | ( | std::unique_ptr< IRenderPass > && | render_pass | ) |
Adds a IRenderPass to the device state and uses its name as identifier.
render_pass | A std::unique_ptr to the IRenderPass to add. |
void spark::render::DeviceState::add | ( | std::unique_ptr< ISampler > && | sampler | ) |
void spark::render::DeviceState::add | ( | std::unique_ptr< IVertexBuffer > && | vertex_buffer | ) |
Adds a IVertexBuffer to the device state and uses its name as identifier.
vertex_buffer | A std::unique_ptr to the IVertexBuffer to add. |
|
nodiscard |
|
nodiscard |
Gets a IDescriptorSet from the device state.
id | The identifier of the descriptor set. |
|
nodiscard |
|
nodiscard |
Gets a IIndexBuffer from the device state.
id | The identifier of the index buffer. |
|
nodiscard |
bool spark::render::DeviceState::release | ( | const IBuffer & | buffer | ) |
bool spark::render::DeviceState::release | ( | const IDescriptorSet & | descriptor_set | ) |
Releases a IDescriptorSet.
descriptor_set | The IDescriptorSet to release. |
true
if the descriptor set was successfully released, false
otherwise. bool spark::render::DeviceState::release | ( | const IImage & | image | ) |
bool spark::render::DeviceState::release | ( | const IIndexBuffer & | index_buffer | ) |
Releases a IIndexBuffer.
index_buffer | The IIndexBuffer to release. |
true
if the index buffer was successfully released, false
otherwise. bool spark::render::DeviceState::release | ( | const IPipeline & | pipeline | ) |
bool spark::render::DeviceState::release | ( | const IRenderPass & | render_pass | ) |
Releases a IRenderPass.
render_pass | The IRenderPass to release. |
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
.
bool spark::render::DeviceState::release | ( | const ISampler & | sampler | ) |
bool spark::render::DeviceState::release | ( | const IVertexBuffer & | vertex_buffer | ) |
Releases a IVertexBuffer.
vertex_buffer | The IVertexBuffer to release. |
true
if the vertex buffer was successfully released, false
otherwise.
|
nodiscard |
Gets a IRenderPass from the device state.
id | The identifier of the render pass. |
|
nodiscard |
|
nodiscard |
Gets a IVertexBuffer from the device state.
id | The identifier of the vertex buffer. |