Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
device.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2024 Rahul Satish Vadhyar
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22
23#pragma once
29#include "vulkanHeaders.hpp"
30namespace Chronos {
31namespace Engine {
36 const std::vector<const char*> deviceExtensions
37 = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
38
47 class Device {
48 public:
52 VkDevice device;
53
60 VkPhysicalDevice physicalDevice;
61
66
71 VkQueue presentQueue;
72
80 VkSampleCountFlagBits msaaSamples = VK_SAMPLE_COUNT_1_BIT;
81
82 VkSampleCountFlagBits maxMsaaSamples = VK_SAMPLE_COUNT_1_BIT;
83
95 void init(VkInstance instance, VkSurfaceKHR surface);
96
105 void destroy();
106
107 private:
122 void pickPhysicalDevice(VkInstance instance, VkSurfaceKHR surface);
123
134 void createLogicalDevice(VkSurfaceKHR surface);
135 };
136};
137};
This initializes, manages and destroys the logical and physical devices(GPU).
Definition device.hpp:47
VkSampleCountFlagBits maxMsaaSamples
Definition device.hpp:82
VkDevice device
This is the logical device that is used by Vulkan.
Definition device.hpp:52
void destroy()
This is the function that destroys the device.
Definition device.cpp:36
void pickPhysicalDevice(VkInstance instance, VkSurfaceKHR surface)
This is the function that picks the best device based on the requirements and features that we requir...
Definition device.cpp:142
void init(VkInstance instance, VkSurfaceKHR surface)
This is the function that initializes the devices and queues.
Definition device.cpp:28
VkQueue presentQueue
This is the queue that is used for presentation of the rendered frames.
Definition device.hpp:71
VkPhysicalDevice physicalDevice
This is the physical device that is used by Vulkan.
Definition device.hpp:60
VkSampleCountFlagBits msaaSamples
This sets the MSAA samples count.
Definition device.hpp:80
VkQueue graphicsQueue
This is the queue that is used for graphics rendering.
Definition device.hpp:65
void createLogicalDevice(VkSurfaceKHR surface)
This creates the logical device.
Definition device.cpp:182
const std::vector< const char * > deviceExtensions
THis contain the device extensions that are needed to be enabled in vulkan.
Definition device.hpp:37
Contains the common headers for the vulkan API.