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) {
|
|
|
|
|
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) {
|
|
|
|
|
if (this != &other) {
|
|
|
|
|
descriptorBindings.resize(other.descriptorBindings.size());
|
|
|
|
|
for (uint32 i = 0; i < descriptorBindings.size(); ++i) {
|
|
|
|
|
descriptorBindings[i] = other.descriptorBindings[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return *this;
|
2023-11-15 00:06:00 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-13 23:51:38 +02:00
|
|
|
DescriptorLayout::~DescriptorLayout() {}
|
|
|
|
|
|
2024-04-15 13:48:34 +02:00
|
|
|
void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, SeImageViewType textureType, uint32 arrayCount,
|
2024-04-13 23:51:38 +02:00
|
|
|
SeDescriptorBindingFlags bindingFlags, SeShaderStageFlags shaderStages) {
|
|
|
|
|
if (descriptorBindings.size() <= bindingIndex) {
|
|
|
|
|
descriptorBindings.resize(bindingIndex + 1);
|
|
|
|
|
}
|
|
|
|
|
descriptorBindings[bindingIndex] = DescriptorBinding{
|
|
|
|
|
.binding = bindingIndex,
|
|
|
|
|
.descriptorType = type,
|
2024-04-15 13:48:34 +02:00
|
|
|
.textureType = textureType,
|
2024-04-13 23:51:38 +02:00
|
|
|
.descriptorCount = arrayCount,
|
|
|
|
|
.bindingFlags = bindingFlags,
|
|
|
|
|
.shaderStages = shaderStages,
|
|
|
|
|
};
|
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() {}
|
|
|
|
|
|
|
|
|
|
PipelineLayout::PipelineLayout() {}
|
|
|
|
|
|
|
|
|
|
PipelineLayout::PipelineLayout(PPipelineLayout baseLayout) {
|
|
|
|
|
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-04-19 18:23:36 +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
|
|
|
|
|
|
|
|
void PipelineLayout::addMapping(Map<std::string, uint32> mapping)
|
|
|
|
|
{
|
|
|
|
|
for(const auto& [name, index] : mapping)
|
|
|
|
|
{
|
|
|
|
|
if(parameterMapping.contains(name))
|
|
|
|
|
{
|
|
|
|
|
assert(parameterMapping[name] == index);
|
|
|
|
|
}
|
|
|
|
|
parameterMapping[name] = index;
|
|
|
|
|
}
|
|
|
|
|
}
|