improved docs

This commit is contained in:
Jorijn van der Graaf 2025-06-14 14:58:02 +02:00
commit dfe9b1abe9
16 changed files with 315 additions and 40 deletions

View file

@ -35,22 +35,31 @@ import :WindowWaylandVulkan;
import :VulkanPipeline;
namespace Crafter {
export struct DescriptorEntry {
struct DescriptorEntry {
VkDescriptorType type;
bool occured = true;
};
/**
* @brief A holder for descriptor sets.
* @brief Holder for VkDescriptorSet.
*
* This class stores 2 VkDescriptorSet one for the first stage and one for the second stage,
* This class has static members to effeciently use a VkDescriptorPool.
* @tparam MeshShader the VulkanShader to use for the first stage.
* @tparam FragmentShader the VulkanShader to use for the second stage.
*/
export template <typename MeshShader, typename FragmentShader>
class DescriptorSet {
public:
/**
* @brief [0] refers to the first stage, [1] refers to the second stage.
*/
VkDescriptorSet set[2];
/**
* @brief This event is triggered when a descriptor is aded to this static set which invalidates all previous descriptors, subscribe to this event to renew them.
*/
inline static Event<void> onDescriptorRefresh;
private:
inline static std::vector<DescriptorSet*> sets;
inline static VkDescriptorPool descriptorPool = VK_NULL_HANDLE;
@ -131,7 +140,11 @@ namespace Crafter {
return types;
}
public:
/**
* @brief Allocates 2 VkDescriptorSet from the pool, all descriptors previously allocated become invalid.
*/
DescriptorSet() {
sets.push_back(this);
@ -153,20 +166,11 @@ namespace Crafter {
onDescriptorRefresh.Invoke();
}
/**
* @brief Deallocates 2 VkDescriptorSet from the pool.
*/
~DescriptorSet() {
sets.erase(find(sets.begin(), sets.end(), this));
}
// void Write(VkWriteDescriptorSet* descriptors, std::uint32_t count) {
// vkUpdateDescriptorSets(VulkanDevice::device, count, descriptors, 0, nullptr);
// }
// void Write(std::uint32_t stage, VkDescriptorType type, std::uint32_t binding, VkDescriptorBufferInfo* buffer) {
// VkWriteDescriptorSet write = vks::initializers::writeDescriptorSet(set[stage], type, binding, buffer);
// vkUpdateDescriptorSets(VulkanDevice::device, 1, &write, 0, nullptr);
// }
// void Write(std::uint32_t stage, VkDescriptorType type, std::uint32_t binding, VkDescriptorImageInfo* buffer) {
// VkWriteDescriptorSet write = vks::initializers::writeDescriptorSet(set[stage], type, binding, buffer);
// vkUpdateDescriptorSets(VulkanDevice::device, 1, &write, 0, nullptr);
// }
};
}