FastEngine 0.9.5
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_physicalDevice.hpp
1/*
2 * Copyright 2026 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 bool _isPresentFamilyDifferent{false};
43 };
45 {
46 VkSurfaceCapabilitiesKHR _capabilities;
47
48 std::vector<VkSurfaceFormatKHR> _formats;
49 std::vector<VkFormatProperties> _formatProperties;
50
51 std::vector<VkPresentModeKHR> _presentModes;
52 };
53
54 explicit PhysicalDevice(VkPhysicalDevice device = VK_NULL_HANDLE);
55 PhysicalDevice(PhysicalDevice const& r) = default;
56 PhysicalDevice(PhysicalDevice&& r) noexcept;
57 ~PhysicalDevice() = default;
58
59 PhysicalDevice& operator=(PhysicalDevice const& r) = default;
60 PhysicalDevice& operator=(PhysicalDevice&& r) noexcept;
61
62 [[nodiscard]] VkPhysicalDevice getDevice() const;
63
71 [[nodiscard]] bool checkDeviceExtensionSupport() const;
72
84 [[nodiscard]] uint32_t rateDeviceSuitability(VkSurfaceKHR surface) const;
94 [[nodiscard]] QueueFamilyIndices findQueueFamilies(VkSurfaceKHR surface) const;
95 [[nodiscard]] SwapChainSupportDetails querySwapChainSupport(VkSurfaceKHR surface) const;
96
97 [[nodiscard]] uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) const;
98
99 [[nodiscard]] uint32_t getMaxImageDimension2D() const;
100 [[nodiscard]] uint32_t getMinUniformBufferOffsetAlignment() const;
101 [[nodiscard]] VkDeviceSize getMaxMemoryAllocationSize() const;
102 [[nodiscard]] uint32_t getMaxMemoryAllocationCount() const;
103 [[nodiscard]] VkPhysicalDeviceFeatures getFeatures() const;
104 [[nodiscard]] VkPhysicalDeviceFeatures2 getFeatures2() const;
105 [[nodiscard]] VkPhysicalDeviceRobustness2FeaturesEXT getRobustness2Features() const;
106
107private:
108 void updateDeviceExtensionSupport();
109
110 VkPhysicalDevice g_device;
111 bool g_extensionSupport;
112};
113
114} // namespace fge::vulkan
115
116#endif //_FGE_VULKAN_C_PHYSICALDEVICE_HPP_INCLUDED
bool checkDeviceExtensionSupport() const
Check if the device support the required extensions.
QueueFamilyIndices findQueueFamilies(VkSurfaceKHR surface) const
Retrieve the QueueFamilyIndices.
uint32_t rateDeviceSuitability(VkSurfaceKHR surface) const
Give a score to the device.
Definition C_physicalDevice.hpp:37