Foundation
Loading...
Searching...
No Matches
Swapchain.hpp
Go to the documentation of this file.
1#pragma once
2#include "Common.hpp"
3namespace Foundation::RHI {
4 class RHIDevice;
5 class RHITexture;
6 class RHIDeviceSemaphore;
7 class RHIDeviceFence;
8 struct RHISwapchainResizeException : std::exception {
9 using std::exception::exception;
10 };
12 // V-Sync
13 Fifo,
14 // N buffering
15 Mailbox,
16 // No V-Sync (tearing allowed)
18 };
19 class RHISwapchain : public RHIObject {
20 protected:
22 public:
24 // Name for the swap chain, used for debugging purposes.
27 // Swapchain buffer sizes.
29 // Min number of buffers in the swap chain. i.e. double buffering = 2, triple buffering = 3, etc.
30 // Driver may create more buffers than requested.
32 // Present mode for the swap chain.
36 RHISwapchain(RHIDevice const& device, SwapchainDesc const& desc) : mDevice(device), mDesc(desc) {}
45 ) = 0;
46 [[nodiscard]] virtual RHIExtent2D GetExtents() const = 0;
47 [[nodiscard]] float GetAspectRatio() const {
48 auto xy = GetExtents();
49 return static_cast<float>(xy.x) / static_cast<float>(xy.y);
50 }
51
52 virtual void DebugSetObjectName(const char* name) = 0;
53 };
59}
#define ENUM_NAME_CONV_BEGIN(T)
Defines convince to_string() method and format_as() [fmt] for the respective enum class Example usage...
Definition Enums.hpp:82
#define ENUM_NAME(E)
Definition Enums.hpp:93
Definition Device.hpp:245
Handle type for RHI Objects.
Definition Details.hpp:42
Base class for all RHI objects.
Definition Details.hpp:16
Definition Swapchain.hpp:19
const RHIDevice & mDevice
Definition Swapchain.hpp:21
RHISwapchain(RHIDevice const &device, SwapchainDesc const &desc)
Definition Swapchain.hpp:36
virtual Span< RHITexture *const > GetImages() const =0
struct Foundation::RHI::RHISwapchain::SwapchainDesc mDesc
virtual uint32_t GetNextImage(uint64_t timeout_ns, RHIDeviceHandle< RHIDeviceSemaphore > semaphore, RHIDeviceHandle< RHIDeviceFence > fence)=0
Gets the next image in the swapchain. Raises RHISwapchainResizeException if the swapchain needs to be...
virtual void DebugSetObjectName(const char *name)=0
virtual RHIExtent2D GetExtents() const =0
float GetAspectRatio() const
Definition Swapchain.hpp:47
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:153
std::span< T > Span
Alias for std::span
Definition Container.hpp:60
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:4
RHISwapchainPresentMode
Definition Swapchain.hpp:11
RHIColorSpace
Definition Common.hpp:131
RHIResourceFormat
Definition Common.hpp:34
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
uint32_t minBufferCount
Definition Swapchain.hpp:31
RHIResourceFormat format
Definition Swapchain.hpp:25
RHIColorSpace colorSpace
Definition Swapchain.hpp:26
RHISwapchainPresentMode presentMode
Definition Swapchain.hpp:33
RHIExtent2D extents
Definition Swapchain.hpp:28