mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-22 21:35:51 +12:00
Draft Vulkan DescriptorHeap
A utility class from a personal project for managing a heap of descriptors of a particular layout. Allows the display graphics pipeline to be successfully created, satisfying its descriptor layout issues.
This commit is contained in:
parent
6ebbd80286
commit
72c77e41b4
5 changed files with 189 additions and 5 deletions
49
include/renderer_vk/vk_descriptor_heap.hpp
Normal file
49
include/renderer_vk/vk_descriptor_heap.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <span>
|
||||
|
||||
#include "helpers.hpp"
|
||||
#include "vk_api.hpp"
|
||||
|
||||
namespace Vulkan {
|
||||
// Implements a basic heap of descriptor sets given a layout of particular
|
||||
// bindings. Create a descriptor set by providing a list of bindings and it will
|
||||
// automatically create both the pool, layout, and maintail a heap of descriptor
|
||||
// sets. Descriptor sets will be reused and recycled. Assume that newly
|
||||
// allocated descriptor sets are in an undefined state.
|
||||
class DescriptorHeap {
|
||||
private:
|
||||
const vk::Device device;
|
||||
|
||||
vk::UniqueDescriptorPool descriptorPool;
|
||||
vk::UniqueDescriptorSetLayout descriptorSetLayout;
|
||||
std::vector<vk::UniqueDescriptorSet> descriptorSets;
|
||||
|
||||
std::vector<vk::DescriptorSetLayoutBinding> bindings;
|
||||
|
||||
std::vector<bool> allocationMap;
|
||||
|
||||
explicit DescriptorHeap(vk::Device device);
|
||||
|
||||
public:
|
||||
~DescriptorHeap() = default;
|
||||
|
||||
DescriptorHeap(DescriptorHeap&&) = default;
|
||||
|
||||
const vk::DescriptorPool& getDescriptorPool() const { return descriptorPool.get(); };
|
||||
|
||||
const vk::DescriptorSetLayout& getDescriptorSetLayout() const { return descriptorSetLayout.get(); };
|
||||
|
||||
const std::span<const vk::UniqueDescriptorSet> getDescriptorSets() const { return descriptorSets; };
|
||||
|
||||
std::span<const vk::DescriptorSetLayoutBinding> getBindings() const { return bindings; };
|
||||
|
||||
std::optional<vk::DescriptorSet> allocateDescriptorSet();
|
||||
bool freeDescriptorSet(vk::DescriptorSet set);
|
||||
|
||||
static std::optional<DescriptorHeap> create(
|
||||
vk::Device device, std::span<const vk::DescriptorSetLayoutBinding> bindings, u16 descriptorHeapCount = 1024
|
||||
);
|
||||
};
|
||||
} // namespace Vulkan
|
Loading…
Add table
Add a link
Reference in a new issue