FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_physicalDevice.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_VULKAN_C_PHYSICALDEVICE_HPP_INCLUDED
18#define _FGE_VULKAN_C_PHYSICALDEVICE_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "volk.h"
22#include <optional>
23#include <vector>
24
25namespace fge::vulkan
26{
27
33class FGE_API PhysicalDevice
34{
35public:
37 {
38 std::optional<uint32_t> _graphicsFamily;
39 std::optional<uint32_t> _computeFamily;
40 std::optional<uint32_t> _transferFamily;
41 std::optional<uint32_t> _presentFamily;
42 };
44 {
45 VkSurfaceCapabilitiesKHR _capabilities;
46
47 std::vector<VkSurfaceFormatKHR> _formats;
48 std::vector<VkFormatProperties> _formatProperties;
49
50 std::vector<VkPresentModeKHR> _presentModes;
51 };
52
53 explicit PhysicalDevice(VkPhysicalDevice device = VK_NULL_HANDLE);
54 PhysicalDevice(PhysicalDevice const& r) = default;
55 PhysicalDevice(PhysicalDevice&& r) noexcept;
56 ~PhysicalDevice() = default;
57
58 PhysicalDevice& operator=(PhysicalDevice const& r) = default;
59 PhysicalDevice& operator=(PhysicalDevice&& r) noexcept;
60
61 [[nodiscard]] VkPhysicalDevice getDevice() const;
62
70 [[nodiscard]] bool checkDeviceExtensionSupport() const;
71
83 [[nodiscard]] unsigned int rateDeviceSuitability(VkSurfaceKHR surface) const;
93 [[nodiscard]] QueueFamilyIndices findQueueFamilies(VkSurfaceKHR surface) const;
94 [[nodiscard]] SwapChainSupportDetails querySwapChainSupport(VkSurfaceKHR surface) const;
95
96 [[nodiscard]] uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) const;
97
98 [[nodiscard]] uint32_t getMaxImageDimension2D() const;
99 [[nodiscard]] uint32_t getMinUniformBufferOffsetAlignment() const;
100 [[nodiscard]] VkDeviceSize getMaxMemoryAllocationSize() const;
101 [[nodiscard]] uint32_t getMaxMemoryAllocationCount() const;
102 [[nodiscard]] VkPhysicalDeviceFeatures getFeatures() const;
103 [[nodiscard]] VkPhysicalDeviceFeatures2 getFeatures2() const;
104 [[nodiscard]] VkPhysicalDeviceRobustness2FeaturesEXT getRobustness2Features() const;
105
106private:
107 void updateDeviceExtensionSupport();
108
109 VkPhysicalDevice g_device;
110 bool g_extensionSupport;
111};
112
113} // namespace fge::vulkan
114
115#endif //_FGE_VULKAN_C_PHYSICALDEVICE_HPP_INCLUDED
Vulkan physical device abstraction.
Definition C_physicalDevice.hpp:34
bool checkDeviceExtensionSupport() const
Check if the device support the required extensions.
unsigned int rateDeviceSuitability(VkSurfaceKHR surface) const
Give a score to the device.
QueueFamilyIndices findQueueFamilies(VkSurfaceKHR surface) const
Retrieve the QueueFamilyIndices.
Definition C_physicalDevice.hpp:37