FastEngine 0.9.4
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
vulkanGlobal.hpp
1/*
2 * Copyright 2025 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_VULKANGLOBAL_HPP_INCLUDED
18#define _FGE_VULKAN_VULKANGLOBAL_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "volk.h"
22
23#define WIN32_LEAN_AND_MEAN
24#ifndef NOMINMAX
25 #define NOMINMAX
26#endif
27#define VMA_NULLABLE
28#define VMA_NOT_NULL
29#define VMA_NULLABLE_NON_DISPATCHABLE
30#include "vk_mem_alloc.h"
31
32#include <vector>
33
34//TODO: In order to have more than 1 frames in flight :
35// Avoid simultaneous buffers access by having multiple ones
36#define FGE_MAX_FRAMES_IN_FLIGHT 1
37
38namespace fge::vulkan
39{
40
41class Context;
42
44{
45 VkBuffer _buffer{VK_NULL_HANDLE};
46 VmaAllocation _allocation{VK_NULL_HANDLE};
47
48 [[nodiscard]] inline constexpr bool valid() const
49 {
50 return this->_buffer != VK_NULL_HANDLE && this->_allocation != VK_NULL_HANDLE;
51 }
52 inline constexpr void clear()
53 {
54 this->_buffer = VK_NULL_HANDLE;
55 this->_allocation = VK_NULL_HANDLE;
56 }
57};
58
60{
61 VkImage _image{VK_NULL_HANDLE};
62 VmaAllocation _allocation{VK_NULL_HANDLE};
63
64 [[nodiscard]] inline constexpr bool valid() const
65 {
66 return this->_image != VK_NULL_HANDLE && this->_allocation != VK_NULL_HANDLE;
67 }
68 inline constexpr void clear()
69 {
70 this->_image = VK_NULL_HANDLE;
71 this->_allocation = VK_NULL_HANDLE;
72 }
73};
74
75FGE_API extern std::vector<char const*> InstanceLayers;
76FGE_API extern std::vector<char const*> DeviceExtensions;
77FGE_API extern std::vector<char const*> InstanceExtensions;
78
79FGE_API extern Context& GetActiveContext();
80FGE_API extern void SetActiveContext(Context& context);
81
82FGE_API bool CheckInstanceLayerSupport(char const* layerName);
83
84} // namespace fge::vulkan
85
86#endif //_FGE_VULKAN_VULKANGLOBAL_HPP_INCLUDED
Vulkan context.
Definition C_context.hpp:70
Definition vulkanGlobal.hpp:44
Definition vulkanGlobal.hpp:60