mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-05-10 19:21:42 +00:00
feat(bindless): Build stages for pipelines
This commit is contained in:
parent
8ba32ddca6
commit
5c32cb2173
2 changed files with 60 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include "modules/pipeline/signature.hpp"
|
||||
#include "modules/pipeline/signature/helpers.hpp"
|
||||
#include "modules/pipeline/signature/image.hpp"
|
||||
#include "modules/pipeline/signature/pass.hpp"
|
||||
#include "utility/logger.hpp"
|
||||
#include "utility/vkhelper.hpp"
|
||||
|
||||
|
|
@ -17,6 +18,7 @@
|
|||
#include <numeric>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
|
@ -532,5 +534,42 @@ Pipeline::Pipeline(
|
|||
|
||||
LOG_DEBUG(" Created " << this->m_pipelines.size() << " pipelines")
|
||||
|
||||
// Build pipeline stages
|
||||
std::unordered_map<std::string_view, uint32_t> indices;
|
||||
for (const auto& stageSignature : signature.stages) {
|
||||
auto& stage{this->m_stages.emplace_back()};
|
||||
stage.substages.emplace_back();
|
||||
|
||||
for (const auto& passIdx : stageSignature.passes) { // (Sorted by shader)
|
||||
const auto& pass{signature.passes.at(passIdx)};
|
||||
|
||||
for (const auto& resource : pass.inputs) {
|
||||
if (!resource.idx())
|
||||
continue;
|
||||
stage.sampledImages.push_back(*resource.idx());
|
||||
}
|
||||
for (const auto& resource : pass.outputs) {
|
||||
if (!resource.idx())
|
||||
continue;
|
||||
stage.storageImages.push_back(*resource.idx());
|
||||
}
|
||||
|
||||
auto& lastPipeline{stage.substages.back().pipeline};
|
||||
if (!lastPipeline.empty() && lastPipeline != pass.shader) {
|
||||
stage.substages.emplace_back();
|
||||
}
|
||||
|
||||
auto& substage{stage.substages.back()};
|
||||
substage.pipeline = pass.shader;
|
||||
substage.subiterations.push_back({
|
||||
.iterationIndex = indices[substage.pipeline]++,
|
||||
.dispatch = apply(extent, flowExtent, pass.dispatchOp),
|
||||
.isSpecial = pass.flags & PassFlag::Special
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG(" Built " << this->m_stages.size() << " pipeline stages")
|
||||
|
||||
LOG_DEBUG("Finished building pipeline")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,6 +170,27 @@ namespace lsfgvk::pipeline {
|
|||
|
||||
vk::UniquePipelineCache m_cache;
|
||||
std::unordered_map<std::string_view, vk::UniquePipeline> m_pipelines;
|
||||
|
||||
/// Single iteration of a sub-stage
|
||||
struct SubIteration {
|
||||
uint32_t iterationIndex{};
|
||||
vk::Extent2D dispatch;
|
||||
bool isSpecial{};
|
||||
};
|
||||
|
||||
/// Sub-stage of an execution stage
|
||||
struct SubStage {
|
||||
std::string_view pipeline;
|
||||
std::vector<SubIteration> subiterations;
|
||||
};
|
||||
|
||||
/// Execution stage
|
||||
struct Stage {
|
||||
std::vector<SubStage> substages;
|
||||
std::vector<size_t> sampledImages;
|
||||
std::vector<size_t> storageImages;
|
||||
};
|
||||
std::vector<Stage> m_stages;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue