Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
device.cpp File Reference
#include <set>
#include "logging.hpp"
#include "helper.hpp"
#include "swapchain.hpp"
Include dependency graph for device.cpp:

Go to the source code of this file.

Functions

static bool checkDeviceExtensionSupport (VkPhysicalDevice device)
 Checks if the physical device that we provide it supports the extestions we need. This is used to check if the physical device that we provide it supports the extensions that we need.
 
static bool isDeviceSuitable (VkPhysicalDevice device, VkSurfaceKHR surface)
 Checks if the physical device that we provide it is suitable for our needs.
 
VkSampleCountFlagBits getMaxUsableSampleCount (VkPhysicalDevice physicalDevice)
 Gets the maxmimum supported MSAA sample count.
 

Function Documentation

◆ checkDeviceExtensionSupport()

static bool checkDeviceExtensionSupport ( VkPhysicalDevice  device)
inlinestatic

Checks if the physical device that we provide it supports the extestions we need. This is used to check if the physical device that we provide it supports the extensions that we need.

Parameters
deviceThe physical device to check.
Returns
Whether the physical device supports the extensions that we need.

Definition at line 47 of file device.cpp.

48{
49 uint32_t extensionCount;
50 vkEnumerateDeviceExtensionProperties(
51 device, nullptr, &extensionCount, nullptr);
52
53 std::vector<VkExtensionProperties> availableExtensions(extensionCount);
54 vkEnumerateDeviceExtensionProperties(
55 device, nullptr, &extensionCount, availableExtensions.data());
56
57 std::set<std::string> requiredExtensions(
60
61 for (const auto& extension : availableExtensions) {
62 requiredExtensions.erase(extension.extensionName);
63 }
64
65 return requiredExtensions.empty();
66}
const std::vector< const char * > deviceExtensions
THis contain the device extensions that are needed to be enabled in vulkan.
Definition device.hpp:37

References Chronos::Engine::deviceExtensions.

Here is the caller graph for this function:

◆ getMaxUsableSampleCount()

VkSampleCountFlagBits getMaxUsableSampleCount ( VkPhysicalDevice  physicalDevice)

Gets the maxmimum supported MSAA sample count.

This gets the maximum supported MSAA sample count for the physical device that we provide it.

Parameters
physicalDeviceThe physical device to get the maxium supported MSAA sample count for.
Returns
The maxium supported MSAA sample count.

Definition at line 113 of file device.cpp.

114{
115 // used to get max MSAA count
116 VkPhysicalDeviceProperties physicalDeviceProperties;
117 vkGetPhysicalDeviceProperties(physicalDevice, &physicalDeviceProperties);
118
119 VkSampleCountFlags counts
120 = physicalDeviceProperties.limits.framebufferColorSampleCounts;
121 if (counts & VK_SAMPLE_COUNT_64_BIT) {
122 return VK_SAMPLE_COUNT_64_BIT;
123 }
124 if (counts & VK_SAMPLE_COUNT_32_BIT) {
125 return VK_SAMPLE_COUNT_32_BIT;
126 }
127 if (counts & VK_SAMPLE_COUNT_16_BIT) {
128 return VK_SAMPLE_COUNT_16_BIT;
129 }
130 if (counts & VK_SAMPLE_COUNT_8_BIT) {
131 return VK_SAMPLE_COUNT_8_BIT;
132 }
133 if (counts & VK_SAMPLE_COUNT_4_BIT) {
134 return VK_SAMPLE_COUNT_4_BIT;
135 }
136 if (counts & VK_SAMPLE_COUNT_2_BIT) {
137 return VK_SAMPLE_COUNT_2_BIT;
138 }
139 return VK_SAMPLE_COUNT_1_BIT;
140}
Here is the caller graph for this function:

◆ isDeviceSuitable()

static bool isDeviceSuitable ( VkPhysicalDevice  device,
VkSurfaceKHR  surface 
)
inlinestatic

Checks if the physical device that we provide it is suitable for our needs.

For a physical device to be suitable, it must support the extensions that we need, and it must be capable of rendering to the surface that we provide it along with rendering the frames.

Parameters
physicalDeviceThe physical device to check.
surfaceThe surface to which we are rendering.
Returns
Whether the physical device is suitable for our needs.

Definition at line 81 of file device.cpp.

83{
84 // check if the device has the required queue families
86 = Chronos::Engine::findQueueFamilies(device, surface);
87 bool extensionsSupported = checkDeviceExtensionSupport(device);
88
89 bool swapChainAdequate = false;
90 if (extensionsSupported) {
93 swapChainAdequate = !swapChainSupport.formats.empty()
94 && !swapChainSupport.presentModes.empty();
95 }
96
97 VkPhysicalDeviceFeatures supportedFeatures;
98 vkGetPhysicalDeviceFeatures(device, &supportedFeatures);
99 return indices.isComplete() && extensionsSupported && swapChainAdequate
100 && supportedFeatures.samplerAnisotropy;
101}
static bool checkDeviceExtensionSupport(VkPhysicalDevice device)
Checks if the physical device that we provide it supports the extestions we need. This is used to che...
Definition device.cpp:47
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device, VkSurfaceKHR surface)
For a given swapchain mode, it gets the capabilites, formats and present modes.
Definition swapchain.cpp:65
QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface)
Gets the indices of the needed queue families.
Definition helper.cpp:126
This is used to check if a given familty supports graphics and presentation.
Definition helper.hpp:44
Contains the fields to the support details of a physical device.
Definition swapchain.hpp:36
std::vector< VkSurfaceFormatKHR > formats
Definition swapchain.hpp:38
std::vector< VkPresentModeKHR > presentModes
Definition swapchain.hpp:39

References checkDeviceExtensionSupport(), Chronos::Engine::findQueueFamilies(), Chronos::Engine::SwapChainSupportDetails::formats, Chronos::Engine::QueueFamilyIndices::isComplete(), Chronos::Engine::SwapChainSupportDetails::presentModes, and Chronos::Engine::querySwapChainSupport().

Here is the call graph for this function:
Here is the caller graph for this function: