evan 2026.1.4
Evan
Loading...
Searching...
No Matches
DesktopBackend.hpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** DesktopBackend
6*/
7
8#pragma once
9
10#include "evan/EvanPlatform.hpp"
11
12#include "evan/ADeviceBackend.hpp"
13#include "IDesktopPlatform.hpp"
14#include "evan/ASwapchainImage.hpp"
15
16#include "evan/Version.hpp"
17
18#include <utility/event/keyboard_event.hpp>
19#include <utility/event/mouse_button_event.hpp>
20
30const std::vector<const char *> deviceExtensions = {
31 VK_KHR_SWAPCHAIN_EXTENSION_NAME
32};
33
34namespace evan
35{
51 VkSurfaceCapabilitiesKHR capabilities;
52
57 std::vector<VkSurfaceFormatKHR> formats;
58
63 std::vector<VkPresentModeKHR> presentModes;
64 };
65
74 {
75 public:
82 DesktopBackend(const IPlatform &platform);
83
90
105 Error preprocessFrame(ASwapchainContext &swapchainContext) override
106 {
107 // No specific preprocessing needed for Desktop backend
108 return Error::Ok;
109 }
110
131 Error processFrame(VkPresentInfoKHR presentInfo,
132 ASwapchainImage &swapchainImage) override;
133
151 Error postprocessFrame(ASwapchainContext &swapchainContext) override
152 {
153 // No specific postprocessing needed for Desktop backend
154 return Error::Ok;
155 }
156
170 uint32_t countSwapchainFormats() const override;
171
190 std::vector<int64_t> enumerateSwapchainFormats(
191 uint32_t swapchainFormatCount) const override;
192
214
227
236 void createPresentQueue();
237
245 VkSurfaceKHR getSurface() const
246 {
247 return _surface;
248 }
249
250 protected:
274 void createInstance(const IPlatform &platform,
275 const std::string &appName,
276 Version &appVersion) override;
277
294 void createLogicalDevice() override;
295
313 void pickPhysicalDevice() override;
314
315 private:
323 VkSurfaceKHR _surface = VK_NULL_HANDLE;
324
333 VkQueue _presentQueue = VK_NULL_HANDLE;
334
339 const IPlatform *_platform = nullptr;
340
357 bool isDeviceSuitable(VkPhysicalDevice physicalDevice,
358 std::vector<const char *> deviceExtensions);
359
372 bool checkDeviceExtensionSupport(
373 VkPhysicalDevice device,
374 std::vector<const char *> deviceExtensions);
375
382 bool checkValidationLayerSupport();
383
392 void populateDebugMessengerCreateInfo(
393 VkDebugUtilsMessengerCreateInfoEXT &createInfo,
394 debugCallback_t debugCallback);
395
408 void setupCallbackEvent(const IPlatform &platform);
409 };
410} // namespace evan
Abstract base class for Vulkan device backends.
Represents the context for managing the swapchain in the rendering system.
ASwapchainImage is a class that represents an image in the swapchain of the Evan engine....
Desktop backend implementation.
VkSurfaceKHR getSurface() const
Retrieves the Vulkan surface associated with the Desktop backend.
Error preprocessFrame(ASwapchainContext &swapchainContext) override
Preprocesses a frame before rendering.
evan::SwapChainSupportDetails querySwapChainSupport()
Queries the swap chain support details for a given Vulkan physical device and surface....
uint32_t countSwapchainFormats() const override
Counts the number of supported swapchain formats for the Vulkan surface.
void createPresentQueue()
Creates the presentation queue for the device context.
~DesktopBackend()
Destructor for DesktopBackend.
QueueFamilyIndices findQueueFamilies() override
Finds the queue family indices for the Vulkan physical device.
std::vector< int64_t > enumerateSwapchainFormats(uint32_t swapchainFormatCount) const override
Enumerates the supported swapchain formats for the Vulkan surface.
Error postprocessFrame(ASwapchainContext &swapchainContext) override
Postprocesses a frame after rendering.
void createLogicalDevice() override
Creates a Vulkan logical device and retrieves the necessary queues for the Desktop platform.
Error processFrame(VkPresentInfoKHR presentInfo, ASwapchainImage &swapchainImage) override
Processes a frame for rendering.
void createInstance(const IPlatform &platform, const std::string &appName, Version &appVersion) override
Creates a Vulkan instance and initializes the device backend for the Desktop platform.
void pickPhysicalDevice() override
Picks a suitable Vulkan physical device for the Desktop platform.
Abstract interface for platform-specific functionality.
Definition IPlatform.hpp:36
Represents a software version using major, minor, and patch numbers.
Definition Version.hpp:35
A structure to represent Vulkan queue family indices.
Struct to encapsulate details about swap chain support.
std::vector< VkPresentModeKHR > presentModes
A list of supported presentation modes (e.g., FIFO, Mailbox, etc.).
std::vector< VkSurfaceFormatKHR > formats
A list of supported surface formats (color space and pixel format).
VkSurfaceCapabilitiesKHR capabilities
Vulkan surface capabilities, such as the minimum and maximum image count, extent, and supported trans...