Chronos 0.0
A advanced 2D rendering and animation system
|
This initializes, manages and destroys the logical and physical devices(GPU). More...
#include <device.hpp>
Public Member Functions | |
void | init (VkInstance instance, VkSurfaceKHR surface) |
This is the function that initializes the devices and queues. | |
void | destroy () |
This is the function that destroys the device. | |
Public Attributes | |
VkDevice | device |
This is the logical device that is used by Vulkan. | |
VkPhysicalDevice | physicalDevice |
This is the physical device that is used by Vulkan. | |
VkQueue | graphicsQueue |
This is the queue that is used for graphics rendering. | |
VkQueue | presentQueue |
This is the queue that is used for presentation of the rendered frames. | |
VkSampleCountFlagBits | msaaSamples = VK_SAMPLE_COUNT_1_BIT |
This sets the MSAA samples count. | |
VkSampleCountFlagBits | maxMsaaSamples = VK_SAMPLE_COUNT_1_BIT |
Private Member Functions | |
void | pickPhysicalDevice (VkInstance instance, VkSurfaceKHR surface) |
This is the function that picks the best device based on the requirements and features that we require. | |
void | createLogicalDevice (VkSurfaceKHR surface) |
This creates the logical device. | |
This initializes, manages and destroys the logical and physical devices(GPU).
It also manages the various queues that are used for rendering and presentation. MSAA is also handled here due to the fact that it is a device managed property.
Definition at line 47 of file device.hpp.
|
private |
This creates the logical device.
Along with creating the logical device, it creates the queues that are used for rendering and presentation. anisotropy and other features are also enabled here.
surface | The surface that is used by the application for presenting the rendered images. |
Definition at line 182 of file device.cpp.
References Chronos::Engine::deviceExtensions, Chronos::Engine::findQueueFamilies(), Chronos::Engine::QueueFamilyIndices::graphicsFamily, LOG, and Chronos::Engine::QueueFamilyIndices::presentFamily.
void Chronos::Engine::Device::destroy | ( | ) |
This is the function that destroys the device.
We need to make sure that all the objects that are created using the device are destroyed before this is called. Else Vulkan Valiation layers will become angry at us.
Definition at line 36 of file device.cpp.
void Chronos::Engine::Device::init | ( | VkInstance | instance, |
VkSurfaceKHR | surface | ||
) |
This is the function that initializes the devices and queues.
It picks the best device(GPU) based on the requirements and features that we require.
instance | The Vulkan instance that is used by the application. |
surface | The surface that is used by the application for presenting the rendered images. |
Definition at line 28 of file device.cpp.
References createLogicalDevice(), LOG, and pickPhysicalDevice().
|
private |
This is the function that picks the best device based on the requirements and features that we require.
It finds all the physical devices(GPUs) that are available and then checks if they are suitable for our application. If none of the devices are suitable then it throws an error. If there are multiple suitable devices, then it gets the first usable device. the maximum number of MSAA samples is also set here.
instance | The Vulkan instance that is used by the application. |
surface | The surface that is used by the application for presenting the rendered images. |
Definition at line 142 of file device.cpp.
References getMaxUsableSampleCount(), isDeviceSuitable(), and LOG.
VkDevice Chronos::Engine::Device::device |
This is the logical device that is used by Vulkan.
Definition at line 52 of file device.hpp.
VkQueue Chronos::Engine::Device::graphicsQueue |
This is the queue that is used for graphics rendering.
Definition at line 65 of file device.hpp.
VkSampleCountFlagBits Chronos::Engine::Device::maxMsaaSamples = VK_SAMPLE_COUNT_1_BIT |
Definition at line 82 of file device.hpp.
VkSampleCountFlagBits Chronos::Engine::Device::msaaSamples = VK_SAMPLE_COUNT_1_BIT |
This sets the MSAA samples count.
During initialization it is set to maximium number possible. This can be changed on the fly. However it requires the swapchain to be recreated along with textures and any other assosicated buffers and objects.
Definition at line 80 of file device.hpp.
VkPhysicalDevice Chronos::Engine::Device::physicalDevice |
This is the physical device that is used by Vulkan.
Generally used for allocating memory and buffers.
Definition at line 60 of file device.hpp.
VkQueue Chronos::Engine::Device::presentQueue |
This is the queue that is used for presentation of the rendered frames.
Definition at line 71 of file device.hpp.