FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_instance.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_INSTANCE_HPP_INCLUDED
18#define _FGE_VULKAN_C_INSTANCE_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "volk.h"
22#include "C_physicalDevice.hpp"
23#include "tinyutf8.h"
24#include <optional>
25#include <string>
26#include <vector>
27
28namespace fge::vulkan
29{
30
38class FGE_API Instance
39{
40public:
41 Instance();
45 explicit Instance(std::string_view applicationName,
46 uint16_t versionMajor = 1,
47 uint16_t versionMinor = 0,
48 uint16_t versionPatch = 0);
49 Instance(Instance const& r) = delete;
50 Instance(Instance&& r) noexcept;
51 ~Instance();
52
53 Instance& operator=(Instance const& r) = delete;
54 Instance& operator=(Instance&& r) noexcept = delete;
55
64 void create(std::string_view applicationName,
65 uint16_t versionMajor = 1,
66 uint16_t versionMinor = 0,
67 uint16_t versionPatch = 0);
68 void destroy();
69
70 [[nodiscard]] tiny_utf8::string const& getApplicationName() const;
71
72 [[nodiscard]] VkInstance get() const;
73
81 [[nodiscard]] std::vector<PhysicalDevice> const& getPhysicalDevices() const;
91 [[nodiscard]] std::optional<PhysicalDevice> pickPhysicalDevice(VkSurfaceKHR surface) const;
92
93private:
94 void enumeratePhysicalDevices();
95
96 VkInstance g_instance;
97 tiny_utf8::string g_applicationName;
98
99 std::vector<PhysicalDevice> g_physicalDevices;
100};
101
102} // namespace fge::vulkan
103
104#endif //_FGE_VULKAN_C_INSTANCE_HPP_INCLUDED
Vulkan instance abstraction.
Definition C_instance.hpp:39
std::optional< PhysicalDevice > pickPhysicalDevice(VkSurfaceKHR surface) const
Pick a physical device.
void create(std::string_view applicationName, uint16_t versionMajor=1, uint16_t versionMinor=0, uint16_t versionPatch=0)
Create the instance.
std::vector< PhysicalDevice > const & getPhysicalDevices() const
Get a list of physical devices.
Instance(std::string_view applicationName, uint16_t versionMajor=1, uint16_t versionMinor=0, uint16_t versionPatch=0)