GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
Device.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Ivar Härnqvist
2// SPDX-License-Identifier: MIT
3
4#ifndef GREM_GRAPHICS_DEVICE_HPP
5#define GREM_GRAPHICS_DEVICE_HPP
6
8
11#include <GREM/core/extents.hpp>
16
17namespace grem {
18
19class Filesystem; // Forward declaration, to avoid including Filesystem.hpp.
20
21} // namespace grem
22
23namespace grem::graphics {
24
25class Window; // Forward declaration, to avoid including Window.hpp.
26class Swapchain; // Forward declaration, to avoid a circular include of Swapchain.hpp.
27
28struct DeviceImplementation;
29
33enum class PresentationSubmissionID : uint64_t {};
34
59
68class Device {
69public:
101
115 GREM_API(graphics) explicit Device(Window& window, const DeviceOptions& options = {});
116
137 GREM_API(graphics) Device(Filesystem& filesystem, Window& window, const DeviceOptions& options = {});
138
140 GREM_API(graphics) ~Device();
141
143 Device(const Device&) = delete;
144
146 Device(Device&&) = delete;
147
149 Device& operator=(const Device&) = delete;
150
152 Device& operator=(Device&&) = delete;
153
173 GREM_API(graphics) void blit(TextureRegion2DReference renderTarget, TextureRegion2DConstReference renderSource, TextureFilter filter);
174
202 GREM_API(graphics) void blit(TextureSubresourceReference renderTarget, Offset2D targetOffset, TextureRegion2DConstReference renderSource);
203
229 blit(renderTarget, Offset2D{.x = 0, .y = 0}, renderSource);
230 }
231
242 GREM_API(graphics) void render(const RenderPass& renderPass);
243
248 GREM_API(graphics) void await() noexcept;
249
267 GREM_API(graphics) bool awaitPresentation(const Swapchain& swapchain, PresentationSubmissionID presentationSubmissionID, Duration timeout = {}) noexcept;
268
284
290 [[nodiscard]] GREM_API(graphics) const FeatureSupport& getSupportedFeatures() const noexcept;
291
300 [[nodiscard]] DeviceImplementation* get() noexcept { // NOLINT(readability-make-member-function-const)
301 return implementation.get();
302 }
303
312 [[nodiscard]] const DeviceImplementation* get() const noexcept {
313 return implementation.get();
314 }
315
316private:
318};
319
320} // namespace grem::graphics
321
322#endif
Base interface for a filesystem.
Definition Filesystem.hpp:25
Nullable RAII data pointer with exclusive ownership of an object that is automatically destroyed on p...
Definition UniquePointer.hpp:77
Device & operator=(Device &&)=delete
Moving a device is not allowed.
void blit(TextureSubresourceReference renderTarget, TextureRegion2DConstReference renderSource)
Copy and paste a rectangular region of a texture at its original size onto another texture at its bot...
Definition Device.hpp:228
Device(Window &window, const DeviceOptions &options={})
Construct a device.
void render(const RenderPass &renderPass)
Submit a list of graphics commands to be rendered.
bool awaitPresentation(const Swapchain &swapchain, PresentationSubmissionID presentationSubmissionID, Duration timeout={}) noexcept
Wait for a specific frame to finish being rendered and presented.
Device(const Device &)=delete
Copying a device is not allowed.
Device(Filesystem &filesystem, Window &window, const DeviceOptions &options={})
Construct a device with an associated filesystem, allowing for graphics pipelines to be cached.
const DeviceImplementation * get() const noexcept
Get a pointer to the underlying resource implementation.
Definition Device.hpp:312
Device(Device &&)=delete
Moving a device is not allowed.
DeviceImplementation * get() noexcept
Get a pointer to the underlying resource implementation.
Definition Device.hpp:300
PresentationSubmission present(Swapchain &swapchain)
Submit the current back buffer of a swapchain for display to its associated window,...
void blit(TextureSubresourceReference renderTarget, Offset2D targetOffset, TextureRegion2DConstReference renderSource)
Copy and paste a rectangular region of a texture at its original size onto another texture at a speci...
const FeatureSupport & getSupportedFeatures() const noexcept
Get the features supported by the device.
Device & operator=(const Device &)=delete
Copying a device is not allowed.
void await() noexcept
Wait for all submitted graphics commands to finish being rendered and presented.
void blit(TextureRegion2DReference renderTarget, TextureRegion2DConstReference renderSource, TextureFilter filter)
Copy and paste a rectangular region of a texture onto a region of another texture.
Backend-specific implementation of RenderPass.
Definition RenderPass.hpp:38
Render target texture holding a chain of images leading to a window to be presented to.
Definition Swapchain.hpp:61
Graphical window that can be rendered to.
Definition Window.hpp:131
Definition buffer_layouts.hpp:20
PresentationSubmissionID
Backend-specific implementation of Device.
Definition Device.hpp:33
TextureFilter
Filtering mode for the sampler of a Texture.
Definition Texture.hpp:473
Definition aliases.hpp:9
Clock::duration Duration
Definition Clock.hpp:25
Offset< 2 > Offset2D
Offset in a 2D data region.
Definition extents.hpp:21
StringBase< char, std::char_traits< char >, std::allocator< char > > String
Definition String.hpp:17
Configuration options for a Device.
Definition Device.hpp:38
String shaderCacheOutputFilepath
Virtual output filepath to save the shader cache to when the rendering context is destroyed,...
Definition Device.hpp:57
String shaderCacheInputFilepath
Virtual input filepath to load the shader cache from when the rendering context is created,...
Definition Device.hpp:46
Information about a frame that has been submitted for presentation.
Definition Device.hpp:73
PresentationSubmissionID id
Identifier for the frame.
Definition Device.hpp:77
size_t totalRenderPassCount
Total number of render passes rendered in the frame.
Definition Device.hpp:94
size_t totalBlitCount
Total number of texture blits performed in the frame.
Definition Device.hpp:99
Duration totalWaitTime
Estimation of the total time spent waiting for resources to become available while preparing the fram...
Definition Device.hpp:89
RenderPass::Statistics totalRenderPassStatistics
Total accumulated statistics of all render passes rendered in the frame.
Definition Device.hpp:83
Declarations of special features supported by a Device.
Definition FeatureSupport.hpp:18
Performance-related statistics of a render pass.
Definition RenderPass.hpp:43
Read-only reference to a 2D region of a texture.
Definition Texture.hpp:396
Reference to a 2D region of a texture.
Definition Texture.hpp:388
Reference to a subresource of a texture.
Definition Texture.hpp:372