2023-10-26 18:37:29 +02:00
|
|
|
#include "Descriptor.h"
|
|
|
|
|
|
|
|
|
|
using namespace Seele;
|
|
|
|
|
using namespace Seele::Gfx;
|
|
|
|
|
|
2024-04-19 18:23:36 +02:00
|
|
|
DescriptorLayout::DescriptorLayout(const std::string& name) : name(name) {}
|
2024-04-13 23:51:38 +02:00
|
|
|
|
|
|
|
|
DescriptorLayout::DescriptorLayout(const DescriptorLayout& other) {
|
2024-06-09 12:20:04 +02:00
|
|
|
descriptorBindings.resize(other.descriptorBindings.size());
|
|
|
|
|
for (uint32 i = 0; i < descriptorBindings.size(); ++i) {
|
|
|
|
|
descriptorBindings[i] = other.descriptorBindings[i];
|
|
|
|
|
}
|
2023-11-15 00:06:00 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-13 23:51:38 +02:00
|
|
|
DescriptorLayout& DescriptorLayout::operator=(const DescriptorLayout& other) {
|
2024-06-09 12:20:04 +02:00
|
|
|
if (this != &other) {
|
|
|
|
|
descriptorBindings.resize(other.descriptorBindings.size());
|
|
|
|
|
for (uint32 i = 0; i < descriptorBindings.size(); ++i) {
|
|
|
|
|
descriptorBindings[i] = other.descriptorBindings[i];
|
|
|
|
|
}
|
2024-04-13 23:51:38 +02:00
|
|
|
}
|
2024-06-09 12:20:04 +02:00
|
|
|
return *this;
|
2023-11-15 00:06:00 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-13 23:51:38 +02:00
|
|
|
DescriptorLayout::~DescriptorLayout() {}
|
|
|
|
|
|
2024-04-19 22:44:00 +02:00
|
|
|
void DescriptorLayout::addDescriptorBinding(DescriptorBinding binding) {
|
2024-06-09 12:20:04 +02:00
|
|
|
if (descriptorBindings.size() <= binding.binding) {
|
|
|
|
|
descriptorBindings.resize(binding.binding + 1);
|
|
|
|
|
}
|
2024-04-19 22:44:00 +02:00
|
|
|
descriptorBindings[binding.binding] = binding;
|
2023-11-15 00:06:00 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-13 23:51:38 +02:00
|
|
|
PDescriptorSet DescriptorLayout::allocateDescriptorSet() { return pool->allocateDescriptorSet(); }
|
|
|
|
|
|
|
|
|
|
void DescriptorLayout::reset() { pool->reset(); }
|
|
|
|
|
|
|
|
|
|
DescriptorPool::DescriptorPool() {}
|
|
|
|
|
|
|
|
|
|
DescriptorPool::~DescriptorPool() {}
|
|
|
|
|
|
|
|
|
|
DescriptorSet::DescriptorSet(PDescriptorLayout layout) : layout(layout) {}
|
|
|
|
|
|
|
|
|
|
DescriptorSet::~DescriptorSet() {}
|
|
|
|
|
|
2024-04-20 21:35:43 +02:00
|
|
|
PipelineLayout::PipelineLayout(const std::string& name) : name(name) {}
|
2024-04-13 23:51:38 +02:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
PipelineLayout::PipelineLayout(const std::string& name, PPipelineLayout baseLayout) : name(name) {
|
|
|
|
|
if (baseLayout != nullptr) {
|
|
|
|
|
descriptorSetLayouts = baseLayout->descriptorSetLayouts;
|
|
|
|
|
pushConstants = baseLayout->pushConstants;
|
|
|
|
|
}
|
2023-11-15 00:06:00 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-13 23:51:38 +02:00
|
|
|
PipelineLayout::~PipelineLayout() {}
|
|
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
void PipelineLayout::addDescriptorLayout(PDescriptorLayout layout) { descriptorSetLayouts[layout->getName()] = layout; }
|
2023-11-15 00:06:00 +01:00
|
|
|
|
2024-04-13 23:51:38 +02:00
|
|
|
void PipelineLayout::addPushConstants(const SePushConstantRange& pushConstant) { pushConstants.add(pushConstant); }
|
2024-04-19 18:23:36 +02:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
void PipelineLayout::addMapping(Map<std::string, uint32> mapping) {
|
|
|
|
|
for (const auto& [name, index] : mapping) {
|
|
|
|
|
if (parameterMapping.contains(name)) {
|
2024-04-19 18:23:36 +02:00
|
|
|
assert(parameterMapping[name] == index);
|
|
|
|
|
}
|
|
|
|
|
parameterMapping[name] = index;
|
|
|
|
|
}
|
|
|
|
|
}
|