FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_descriptorSet.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_DESCRIPTORSET_HPP_INCLUDED
18#define _FGE_VULKAN_C_DESCRIPTORSET_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "volk.h"
22#include <variant>
23
24namespace fge::vulkan
25{
26
27class Context;
28class DescriptorSetLayout;
29class DescriptorPool;
30class UniformBuffer;
31class TextureImage;
32
40class FGE_API DescriptorSet
41{
42public:
51 struct FGE_API Descriptor
52 {
53 enum class BufferTypes
54 {
55 STATIC,
56 DYNAMIC,
57 STORAGE
58 };
59
60 Descriptor() = default;
61 Descriptor(UniformBuffer const& uniformBuffer,
62 uint32_t binding,
63 BufferTypes type = BufferTypes::STATIC,
64 VkDeviceSize range = 0);
65 Descriptor(TextureImage const& textureImage, uint32_t binding);
66
67 std::variant<VkDescriptorBufferInfo, VkDescriptorImageInfo> _data;
68 uint32_t _binding{0};
69 BufferTypes _bufferType{};
70 uint32_t _dstArrayElement{0};
71 };
72
74 DescriptorSet(VkDescriptorSet descriptorSet, DescriptorPool const* pool, VkDescriptorPool descriptorPool);
76 DescriptorSet(DescriptorSet&& r) noexcept;
78
79 DescriptorSet& operator=(DescriptorSet const& r);
80 DescriptorSet& operator=(DescriptorSet&& r) noexcept;
81
82 void destroy();
83
84 [[nodiscard]] VkDescriptorSet get() const;
85 [[nodiscard]] DescriptorPool const* getPool() const;
86 [[nodiscard]] Context const* getContext() const;
87
96 void updateDescriptorSet(Descriptor const* descriptors, std::size_t descriptorSize);
97
98private:
99 VkDescriptorSet g_descriptorSet;
100 DescriptorPool const* g_pool;
101 VkDescriptorPool g_poolKey;
102};
103
104} // namespace fge::vulkan
105
106#endif //_FGE_VULKAN_C_DESCRIPTORSET_HPP_INCLUDED
Vulkan context.
Definition C_context.hpp:70
This class abstract the vulkan descriptor pool for easier use.
Definition C_descriptorPool.hpp:41
This class abstract the vulkan descriptor set for easier use.
Definition C_descriptorSet.hpp:41
void updateDescriptorSet(Descriptor const *descriptors, std::size_t descriptorSize)
Update the descriptor set.
Definition C_textureImage.hpp:34
Definition C_uniformBuffer.hpp:32
This struct is used to describe a descriptor.
Definition C_descriptorSet.hpp:52