evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::DesktopBackend Class Reference

Desktop backend implementation. More...

#include <headers/evan/glfw/DesktopBackend.hpp>

Inheritance diagram for evan::DesktopBackend:
Collaboration diagram for evan::DesktopBackend:

Public Member Functions

 DesktopBackend (const IPlatform &platform)
 Constructor for DesktopBackend.
 
 ~DesktopBackend ()
 Destructor for DesktopBackend.
 
Error preprocessFrame (ASwapchainContext &swapchainContext) override
 Preprocesses a frame before rendering.
 
Error processFrame (VkPresentInfoKHR presentInfo, ASwapchainImage &swapchainImage) override
 Processes a frame for rendering.
 
Error postprocessFrame (ASwapchainContext &swapchainContext) override
 Postprocesses a frame after rendering.
 
uint32_t countSwapchainFormats () const override
 Counts the number of supported swapchain formats for the Vulkan surface.
 
std::vector< int64_t > enumerateSwapchainFormats (uint32_t swapchainFormatCount) const override
 Enumerates the supported swapchain formats for the Vulkan surface.
 
QueueFamilyIndices findQueueFamilies () override
 Finds the queue family indices for the Vulkan physical device.
 
evan::SwapChainSupportDetails querySwapChainSupport ()
 Queries the swap chain support details for a given Vulkan physical device and surface. This function retrieves information about the swap chain capabilities, available surface formats, and present modes for the specified Vulkan physical device and surface. It populates a SwapChainSupportDetails structure with the retrieved information.
 
void createPresentQueue ()
 Creates the presentation queue for the device context.
 
VkSurfaceKHR getSurface () const
 Retrieves the Vulkan surface associated with the Desktop backend.
 
- Public Member Functions inherited from evan::ADeviceBackend
virtual ~ADeviceBackend ()
 Virtual destructor for the ADeviceBackend class.
 
Error createBuffer (const CreateBufferProperties &properties) const
 Creates a Vulkan buffer and allocates memory for it.
 
Error transitionImageLayout (const TransitionImageLayoutProperties &properties) const
 Transitions the layout of a Vulkan image.
 
VkCommandBuffer beginSingleTimeCommands (VkCommandPool commandPool) const
 Begins recording a single-use command buffer for one-time operations.
 
void endSingleTimeCommands (VkCommandPool commandPool, VkQueue graphicsQueue, VkCommandBuffer commandBuffer) const
 Ends recording of a single-use command buffer and submits it for execution.
 
Error createImage (const CreateImageProperties &properties) const
 Creates a Vulkan image and allocates memory for it.
 
Error copyBufferToImage (const CopyBufferToImageProperties &properties) const
 Copies data from a Vulkan buffer to a Vulkan image.
 
Error copyBuffer (const CopyBufferProperties &properties) const
 Copies data from one Vulkan buffer to another.
 
Result< VkImageView > createImageView (VkImage image, VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels, uint32_t layerCount=1) const
 Creates a Vulkan image view for a given image.
 
virtual VkDevice getDevice () const
 Retrieves the Vulkan logical device handle.
 
virtual VkInstance getInstance () const
 Retrieves the Vulkan instance handle.
 
virtual VkPhysicalDevice getPhysicalDevice () const
 Retrieves the Vulkan physical device handle.
 
bool supportsMultiview () const
 Indicates whether multiview rendering is available.
 
bool supportsTimestampQueries ()
 Indicates whether GPU timestamp queries can be used.
 
float getTimestampPeriod () const
 Nanoseconds per timestamp tick.
 
uint32_t getTimestampValidBits ()
 Number of valid bits in a timestamp value.
 

Protected Member Functions

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 createLogicalDevice () override
 Creates a Vulkan logical device and retrieves the necessary queues for the Desktop platform.
 
void pickPhysicalDevice () override
 Picks a suitable Vulkan physical device for the Desktop platform.
 
- Protected Member Functions inherited from evan::ADeviceBackend
std::vector< VkLayerProperties > getAvailableLayers ()
 Retrieves the available Vulkan layers on the system.
 

Additional Inherited Members

- Static Protected Member Functions inherited from evan::ADeviceBackend
static bool queryMultiviewSupport (VkPhysicalDevice physicalDevice, uint32_t apiVersion)
 Queries whether a physical device can run multiview passes.
 
- Protected Attributes inherited from evan::ADeviceBackend
VkPhysicalDevice _physicalDevice = VK_NULL_HANDLE
 
VkDevice _device = VK_NULL_HANDLE
 
VkInstance _VkInstance = VK_NULL_HANDLE
 
bool _multiviewSupported = false
 Whether the multiview feature was enabled on the logical device created by this backend.
 

Detailed Description

Desktop backend implementation.

This class provides an implementation of the backend for Desktop. It handles platform-specific functionality related to Desktop, such as creating a Vulkan surface for rendering or later handling input events.

Definition at line 73 of file DesktopBackend.hpp.

Constructor & Destructor Documentation

◆ DesktopBackend()

evan::DesktopBackend::DesktopBackend ( const IPlatform &  platform)

Constructor for DesktopBackend.

Parameters
platformThe platform instance to be used for Desktop initialization.

Definition at line 85 of file DesktopBackend.cpp.

Here is the call graph for this function:

◆ ~DesktopBackend()

evan::DesktopBackend::~DesktopBackend ( )

Destructor for DesktopBackend.

Ensures proper cleanup of Desktop resources.

Definition at line 109 of file DesktopBackend.cpp.

Member Function Documentation

◆ countSwapchainFormats()

uint32_t evan::DesktopBackend::countSwapchainFormats ( ) const
overridevirtual

Counts the number of supported swapchain formats for the Vulkan surface.

This function queries the Vulkan API to determine the number of supported swapchain formats for the surface associated with the Desktop backend. It retrieves the list of supported surface formats and returns the count, which can be used to determine how many different formats are available for use when creating a swapchain.

Returns
The number of supported swapchain formats for the Vulkan surface.

Implements evan::ADeviceBackend.

Definition at line 143 of file DesktopBackend.cpp.

◆ createInstance()

void evan::DesktopBackend::createInstance ( const IPlatform &  platform,
const std::string &  appName,
evan::Version &  appVersion 
)
overrideprotectedvirtual

Creates a Vulkan instance and initializes the device backend for the Desktop platform.

This function is responsible for creating a Vulkan instance and performing any necessary initialization for the device backend specific to the Desktop platform. It takes the platform information, application name, and application version as parameters to set up the Vulkan instance with the appropriate application info and extensions required for the Desktop backend.

Parameters
platformThe platform instance containing information about the Desktop environment.
appNameThe name of the application, used for Vulkan instance creation.
appVersionThe version of the application, used for Vulkan instance creation.
Note
This function is an override of the pure virtual function defined in the ADeviceBackend class, and it provides the specific implementation for creating a Vulkan instance and initializing the device backend in the context of the Desktop platform.

Implements evan::ADeviceBackend.

Definition at line 312 of file DesktopBackend.cpp.

Here is the caller graph for this function:

◆ createLogicalDevice()

void evan::DesktopBackend::createLogicalDevice ( )
overrideprotectedvirtual

Creates a Vulkan logical device and retrieves the necessary queues for the Desktop platform.

This function is responsible for creating a Vulkan logical device based on the selected physical device and retrieving the necessary queues (such as graphics and presentation queues) for the Desktop platform. It uses the queue family indices determined during device selection to ensure that the created logical device has access to the required queues for rendering and presentation operations.

Note
This function is an override of the pure virtual function defined in the ADeviceBackend class, and it provides the specific implementation for creating a Vulkan logical device and retrieving queues in the context of the Desktop platform.

Implements evan::ADeviceBackend.

Definition at line 411 of file DesktopBackend.cpp.

Here is the caller graph for this function:

◆ createPresentQueue()

void evan::DesktopBackend::createPresentQueue ( )

Creates the presentation queue for the device context.

This function retrieves the presentation queue from the logical device and stores it in a member variable (not shown in this snippet). It assumes that the logical device has already been created and that the presentation queue family index has been determined.

Definition at line 291 of file DesktopBackend.cpp.

Here is the caller graph for this function:

◆ enumerateSwapchainFormats()

std::vector< int64_t > evan::DesktopBackend::enumerateSwapchainFormats ( uint32_t  swapchainFormatCount) const
overridevirtual

Enumerates the supported swapchain formats for the Vulkan surface.

This function retrieves the list of supported swapchain formats for the surface associated with the Desktop backend and returns them as a vector of integers. Each integer in the vector represents a specific Vulkan format that is supported for use in the swapchain. This information can be used when creating a swapchain to select an appropriate format for rendering.

Parameters
swapchainFormatCountThe number of swapchain formats to enumerate, which should match the count returned by countSwapchainFormats().
Returns
A vector of integers representing the supported swapchain formats for the Vulkan surface.

Implements evan::ADeviceBackend.

Definition at line 157 of file DesktopBackend.cpp.

◆ findQueueFamilies()

evan::QueueFamilyIndices evan::DesktopBackend::findQueueFamilies ( )
overridevirtual

Finds the queue family indices for the Vulkan physical device.

This function queries the Vulkan API to find the indices of the queue families that support graphics and presentation operations for the physical device associated with the Desktop backend. It returns a QueueFamilyIndices structure containing the indices of the graphics and presentation queue families, which can be used during device creation to ensure that the necessary queues are available for rendering and presentation.

Returns
A QueueFamilyIndices structure containing the indices of the graphics and presentation queue families for the Vulkan physical device.
Note
This function is an override of the pure virtual function defined in the ADeviceBackend class, and it provides the specific implementation for finding queue family indices in the context of the Desktop backend.

Implements evan::ADeviceBackend.

Definition at line 178 of file DesktopBackend.cpp.

◆ getSurface()

VkSurfaceKHR evan::DesktopBackend::getSurface ( ) const
inline

Retrieves the Vulkan surface associated with the Desktop backend.

Returns
VkSurfaceKHR The Vulkan surface used for rendering and presentation.

Definition at line 245 of file DesktopBackend.hpp.

◆ pickPhysicalDevice()

void evan::DesktopBackend::pickPhysicalDevice ( )
overrideprotectedvirtual

Picks a suitable Vulkan physical device for the Desktop platform.

This function is responsible for selecting a Vulkan physical device that is suitable for use with the Desktop platform. It evaluates the available physical devices and checks their capabilities, features, and support for required extensions to determine which device is best suited for the application's needs. The selected physical device will be used for creating the logical device and performing rendering operations.

Note
This function is an override of the pure virtual function defined in the ADeviceBackend class, and it provides the specific implementation for picking a Vulkan physical device in the context of the Desktop platform.

Implements evan::ADeviceBackend.

Definition at line 530 of file DesktopBackend.cpp.

Here is the caller graph for this function:

◆ postprocessFrame()

Error evan::DesktopBackend::postprocessFrame ( ASwapchainContext &  swapchainContext)
inlineoverridevirtual

Postprocesses a frame after rendering.

This function can be used to perform any necessary postprocessing steps after rendering a frame, such as presenting the rendered image to the screen, handling synchronization, or performing any other operations that need to occur after rendering. In the case of the Desktop backend, no specific postprocessing is needed, so this function simply returns true.

Parameters
swapchainContextThe swap chain context for the current frame, which may include information about the swap chain and presentation details.
Returns
Always returns evan::Error::Ok, because no specific postprocessing is needed for the Desktop backend.

Implements evan::ADeviceBackend.

Definition at line 151 of file DesktopBackend.hpp.

◆ preprocessFrame()

Error evan::DesktopBackend::preprocessFrame ( ASwapchainContext &  swapchainContext)
inlineoverridevirtual

Preprocesses a frame before rendering.

This function can be used to perform any necessary preprocessing steps before rendering a frame, such as updating uniform buffers, handling input events, or performing any other per-frame updates. In the case of the Desktop backend, no specific preprocessing is needed, so this function simply returns true.

Parameters
swapchainContextThe swap chain context for the current frame.
Returns
Always returns evan::Error::Ok, because no specific preprocessing is needed for the Desktop backend.

Implements evan::ADeviceBackend.

Definition at line 105 of file DesktopBackend.hpp.

◆ processFrame()

evan::Error evan::DesktopBackend::processFrame ( VkPresentInfoKHR  presentInfo,
ASwapchainImage &  swapchainImage 
)
overridevirtual

Processes a frame for rendering.

This function is responsible for processing a frame before it is rendered. In the context of the Desktop backend, this function can be used to perform any necessary operations on the frame, such as updating uniform buffers, handling input events, or performing any other per-frame updates. However, in the current implementation, no specific processing is needed for the Desktop backend, so this function simply returns true.

Parameters
presentInfoThe presentation information for the current frame, which may include details about the swap chain and presentation mode.
swapchainImageThe swap chain image that will be rendered to for the current frame. This parameter can be used to access the image and perform any necessary operations on it before rendering.
Returns
evan::Error::Ok on success, or a mapped error otherwise.

Implements evan::ADeviceBackend.

Definition at line 126 of file DesktopBackend.cpp.

◆ querySwapChainSupport()

evan::SwapChainSupportDetails evan::DesktopBackend::querySwapChainSupport ( )

Queries the swap chain support details for a given Vulkan physical device and surface. This function retrieves information about the swap chain capabilities, available surface formats, and present modes for the specified Vulkan physical device and surface. It populates a SwapChainSupportDetails structure with the retrieved information.

Returns
A SwapChainSupportDetails structure containing the swap chain support details for the specified device and surface.

Definition at line 236 of file DesktopBackend.cpp.


The documentation for this class was generated from the following files: