FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
vulkanGlobal.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_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 LogicalDevice;
42class PhysicalDevice;
43class Context;
44
45FGE_API extern std::vector<char const*> InstanceLayers;
46FGE_API extern std::vector<char const*> DeviceExtensions;
47FGE_API extern std::vector<char const*> InstanceExtensions;
48
49FGE_API extern Context& GetActiveContext();
50FGE_API extern void SetActiveContext(Context& context);
51
52FGE_API bool CheckInstanceLayerSupport(char const* layerName);
53
54FGE_API void CreateBuffer(Context const& context,
55 VkDeviceSize size,
56 VkBufferUsageFlags usage,
57 VkMemoryPropertyFlags properties,
58 VkBuffer& buffer,
59 VmaAllocation& allocation);
60
61FGE_API void CreateImage(Context const& context,
62 uint32_t width,
63 uint32_t height,
64 VkFormat format,
65 VkImageTiling tiling,
66 VkImageUsageFlags usage,
67 VkMemoryPropertyFlags properties,
68 uint32_t mipLevels,
69 VkImage& image,
70 VmaAllocation& allocation);
71
72FGE_API VkImageView CreateImageView(LogicalDevice const& logicalDevice,
73 VkImage image,
74 VkFormat format,
75 uint32_t mipLevels);
76
77} // namespace fge::vulkan
78
79#endif //_FGE_VULKAN_VULKANGLOBAL_HPP_INCLUDED