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.
26 // Swapchain buffer sizes.
28 // Min number of buffers in the swap chain. i.e. double buffering = 2, triple buffering = 3, etc.
29 // Driver may create more buffers than requested.
31 // Present mode for the swap chain.
35 RHISwapchain(RHIDevice const& device, SwapchainDesc const& desc) : mDevice(device), mDesc(desc) {}
44 ) = 0;
45 [[nodiscard]] virtual RHIExtent2D GetExtents() const = 0;
46 [[nodiscard]] inline float GetAspectRatio() const {
47 auto xy = GetExtents();
48 return static_cast<float>(xy.x) / static_cast<float>(xy.y);
49 }
50
51 virtual void DebugSetObjectName(const char* name) = 0;
52 };
58}
#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:84
#define ENUM_NAME(E)
Definition Enums.hpp:95
Definition Device.hpp:131
Base class for all RHI objects.
Definition Details.hpp:16
Definition Swapchain.hpp:19
const RHIDevice & mDevice
Definition Swapchain.hpp:21
virtual uint32_t GetNextImage(uint64_t timeout_ns, RHIDeviceObjectHandle< RHIDeviceSemaphore > semaphore, RHIDeviceObjectHandle< RHIDeviceFence > fence)=0
Gets the next image in the swapchain. Raises RHISwapchainResizeException if the swapchain needs to be...
RHISwapchain(RHIDevice const &device, SwapchainDesc const &desc)
Definition Swapchain.hpp:35
virtual Core::Span< RHITexture *const > GetImages() const =0
struct Foundation::RHI::RHISwapchain::SwapchainDesc mDesc
virtual void DebugSetObjectName(const char *name)=0
virtual RHIExtent2D GetExtents() const =0
float GetAspectRatio() const
Definition Swapchain.hpp:46
std::unique_ptr< T, StlDeleter< T > > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:161
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:5
RHISwapchainPresentMode
Definition Swapchain.hpp:11
RHIResourceFormat
Definition Common.hpp:20
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
uint32_t minBufferCount
Definition Swapchain.hpp:30
RHIResourceFormat format
Definition Swapchain.hpp:25
RHISwapchainPresentMode presentMode
Definition Swapchain.hpp:32
RHIExtent2D extents
Definition Swapchain.hpp:27