SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
GraphicsDevice.h
1#pragma once
2
3#include "spark/render/CommandQueue.h"
4#include "spark/render/DeviceState.h"
5#include "spark/render/Export.h"
6#include "spark/render/GraphicsAdapter.h"
7#include "spark/render/GraphicsFactory.h"
8#include "spark/render/Surface.h"
9#include "spark/render/SwapChain.h"
10#include "spark/render/Format.h"
11
12namespace spark::render
13{
17 class SPARK_RENDER_EXPORT IGraphicsDevice
18 {
19 public:
20 virtual ~IGraphicsDevice() noexcept = default;
21
26 [[nodiscard]] virtual DeviceState& state() noexcept = 0;
27
32 [[nodiscard]] virtual const ISurface& surface() const noexcept = 0;
33
38 [[nodiscard]] virtual const IGraphicsFactory& factory() const noexcept = 0;
39
44 [[nodiscard]] virtual const IGraphicsAdapter& graphicsAdapter() const noexcept = 0;
45
50 [[nodiscard]] virtual const ISwapChain& swapChain() const noexcept = 0;
51
56 [[nodiscard]] virtual ISwapChain& swapChain() noexcept = 0;
57
62 [[nodiscard]] virtual const ICommandQueue& graphicsQueue() const noexcept = 0;
63
69 [[nodiscard]] virtual const ICommandQueue& transferQueue() const noexcept = 0;
70
76 [[nodiscard]] virtual const ICommandQueue& bufferQueue() const noexcept = 0;
77
83 [[nodiscard]] virtual const ICommandQueue& computeQueue() const noexcept = 0;
84
90 [[nodiscard]] virtual MultiSamplingLevel maximumMultiSamplingLevel(Format format) const noexcept = 0;
91
96 [[nodiscard]] virtual double ticksPerMillisecond() const noexcept = 0;
97
104 virtual void wait() const = 0;
105 };
106
119 template <typename FactoryType, typename SurfaceType, typename GraphicsAdapterType, typename SwapChainType, typename CommandQueueType, typename RenderPassType>
121 {
122 public:
123 using surface_type = SurfaceType;
124 using adapter_type = GraphicsAdapterType;
125 using swap_chain_type = SwapChainType;
126 using command_queue_type = CommandQueueType;
127 using command_buffer_type = typename command_queue_type::command_buffer_type;
128 using factory_type = FactoryType;
129 using descriptor_layout_type = typename factory_type::descriptor_layout_type;
130 using vertex_buffer_type = typename factory_type::vertex_buffer_type;
131 using index_buffer_type = typename factory_type::index_buffer_type;
132 using buffer_type = typename factory_type::buffer_type;
133 using image_type = typename factory_type::image_type;
134 using sampler_type = typename factory_type::sampler_type;
135 using render_pass_type = RenderPassType;
136 using frame_buffer_type = typename render_pass_type::frame_buffer_type;
137 using render_pipeline_type = typename render_pass_type::render_pipeline_type;
138 using pipeline_layout_type = typename render_pipeline_type::pipeline_layout_type;
139 using shader_program_type = typename render_pipeline_type::shader_program_type;
140 using input_assembler_type = typename render_pipeline_type::input_assembler_type;
141 using rasterizer_type = typename render_pipeline_type::rasterizer_type;
142
143 public:
145 [[nodiscard]] DeviceState& state() noexcept override = 0;
146
148 [[nodiscard]] const surface_type& surface() const noexcept override = 0;
149
151 [[nodiscard]] const adapter_type& graphicsAdapter() const noexcept override = 0;
152
154 [[nodiscard]] const swap_chain_type& swapChain() const noexcept override = 0;
155
157 [[nodiscard]] swap_chain_type& swapChain() noexcept override = 0;
158
160 [[nodiscard]] const factory_type& factory() const noexcept override = 0;
161
163 [[nodiscard]] const command_queue_type& graphicsQueue() const noexcept override = 0;
164
166 [[nodiscard]] const command_queue_type& transferQueue() const noexcept override = 0;
167
169 [[nodiscard]] const command_queue_type& bufferQueue() const noexcept override = 0;
170
172 [[nodiscard]] const command_queue_type& computeQueue() const noexcept override = 0;
173 };
174}
A class used to manage the state of a IGraphicsDevice.
Definition DeviceState.h:27
Represents the graphics device that a rendering back-end is doing work on.
Definition GraphicsDevice.h:121
DeviceState & state() noexcept override=0
Gets the device state used to manage the device resources.
Interface for a command queue.
Definition CommandQueue.h:69
Represents a physical graphics adapter.
Definition GraphicsAdapter.h:37
Interface for a graphics device.
Definition GraphicsDevice.h:18
virtual DeviceState & state() noexcept=0
Gets the device state used to manage the device resources.
Definition GraphicsFactory.h:16
Represents a surface to render to. A surface can be seen as a window or area on the screen where the ...
Definition Surface.h:14
Interface for a swap chain, a chain of multiple IImage instances that can be presented using a ISurfa...
Definition SwapChain.h:16