|
evan 2026.1.4
Evan
|
Represents the device context for the engine, managing Vulkan-related resources and operations. More...
#include <headers/evan/DeviceContext.hpp>


Public Member Functions | |
| DeviceContext (const IPlatform &platform) | |
| Constructs a DeviceContext instance using the provided platform. | |
| VkSampleCountFlagBits | getMsaaSamples () const |
| Retrieves the number of MSAA samples used by this device context. | |
| void | setMsaaSamples (VkSampleCountFlagBits samples) |
| Overrides the MSAA sample count used by this device context. | |
| VkSampleCountFlagBits | getMaxSupportedMsaaSamples () const |
| Retrieves the highest MSAA sample count this device accepts. | |
| std::shared_ptr< ADeviceBackend > | getDeviceBackend () const |
| Retrieves a shared pointer to the ADeviceBackend instance associated with this device context. | |
| VkCommandPool | getCommandPool () const |
| Retrieves the Vulkan command pool associated with this device context. | |
| VkQueue | getGraphicsQueue () const |
| Retrieves the Vulkan graphics queue associated with this device context. | |
| TransferManager & | getTransferManager () |
| Retrieves the transfer manager used to upload resources asynchronously without draining the graphics queue. | |
| const PipelineCache & | getPipelineCache () const |
| Retrieves the pipeline cache used when creating pipelines. | |
Represents the device context for the engine, managing Vulkan-related resources and operations.
The DeviceContext class encapsulates the Vulkan instance, physical device, logical device, graphics queue, command pool, and MSAA samples. It provides a structured way to manage these resources and perform operations related to Vulkan rendering.
Definition at line 36 of file DeviceContext.hpp.
Constructs a DeviceContext instance using the provided platform.
This constructor initializes the device context by creating a Vulkan instance, selecting a physical device, creating a logical device, and setting up the graphics queue and command pool. It also determines the maximum usable sample count for MSAA and sets up the Vulkan debug messenger for validation layers.
| platform | A reference to an IPlatform instance that provides platform-specific implementations for Vulkan device management operations. The platform is used to create the Vulkan instance, select the physical device, and create the logical device. |
| VkCommandPool evan::DeviceContext::getCommandPool | ( | ) | const |
Retrieves the Vulkan command pool associated with this device context.
| std::shared_ptr< ADeviceBackend > evan::DeviceContext::getDeviceBackend | ( | ) | const |
Retrieves a shared pointer to the ADeviceBackend instance associated with this device context.

| VkQueue evan::DeviceContext::getGraphicsQueue | ( | ) | const |
Retrieves the Vulkan graphics queue associated with this device context.
| VkSampleCountFlagBits evan::DeviceContext::getMaxSupportedMsaaSamples | ( | ) | const |
Retrieves the highest MSAA sample count this device accepts.
Derived from the sample counts supported by both the framebuffer color and depth attachments, capped at VK_SAMPLE_COUNT_4_BIT.
| VkSampleCountFlagBits evan::DeviceContext::getMsaaSamples | ( | ) | const |
Retrieves the number of MSAA samples used by this device context.
Defaults to VK_SAMPLE_COUNT_1_BIT, that is no multisampling.

| const PipelineCache & evan::DeviceContext::getPipelineCache | ( | ) | const |
Retrieves the pipeline cache used when creating pipelines.
The returned cache is passed to vkCreateGraphicsPipelines so the driver can reuse pipelines it already compiled, either earlier in this run or during a previous one when the blob was reloaded from disk.
| TransferManager & evan::DeviceContext::getTransferManager | ( | ) |
Retrieves the transfer manager used to upload resources asynchronously without draining the graphics queue.
| void evan::DeviceContext::setMsaaSamples | ( | VkSampleCountFlagBits | samples | ) |
Overrides the MSAA sample count used by this device context.
Multisampling is disabled by default: every draw pays the multiplied color and depth bandwidth and the resolve pass, whether or not the scene benefits from it. Applications raise the count to 2x or 4x when the extra edge quality is worth that cost.
The requested count is applied only when it is supported by both the framebuffer color and depth attachments of the physical device and stays within the supported cap (see getMaxSupportedMsaaSamples); otherwise the current value is kept and a warning is logged. The EVAN_MSAA environment variable takes precedence over samples, so the cost of multisampling can be measured without a rebuild.
| samples | The MSAA sample count flag bits to use. |
|
protected |
The command pool, which is used to allocate command buffers for recording rendering commands.
Definition at line 182 of file DeviceContext.hpp.
|
protected |
Vulkan debug messenger for validation layers. This member variable holds the handle to the Vulkan debug messenger, which is used to receive debug messages from the Vulkan validation layers. The debug messenger is set up during the initialization of the device context and is configured to capture messages of various severity levels and types, providing valuable information for debugging and development purposes.
vkCreateDebugUtilsMessengerEXT function and requires the VK_EXT_debug_utils extension to be enabled in the Vulkan instance. Ensure that the extension is available and enabled for proper functionality of the debug messenger. Definition at line 230 of file DeviceContext.hpp.
|
protected |
A shared pointer to the ADeviceBackend instance, which provides platform-specific implementations for Vulkan device management operations. This allows the DeviceContext to utilize the backend's methods
Definition at line 213 of file DeviceContext.hpp.
|
protected |
The graphics queue, which is used to submit rendering commands to the GPU.
Definition at line 175 of file DeviceContext.hpp.
|
protected |
The number of samples used for multisampling anti-aliasing (MSAA), which is a technique used to improve the visual quality of rendered images by reducing aliasing artifacts.
Defaults to a single sample, which disables MSAA.
Definition at line 205 of file DeviceContext.hpp.
|
protected |
Pipeline cache shared by every pipeline created for this device.
It is created with the device and persisted on destruction, so the pipelines compiled by a run are available to the next one.
Definition at line 195 of file DeviceContext.hpp.
|
protected |
Owns staging memory and command buffers for asynchronous uploads.
Definition at line 187 of file DeviceContext.hpp.