From 49a93efe9352846450d169197f79acd85dc5fc87 Mon Sep 17 00:00:00 2001 From: Lucas Alber Date: Wed, 13 Nov 2024 09:33:21 +0100 Subject: [PATCH] merian: Pipeline: Add more syntactic sugar to push descriptor methods --- include/merian/vk/pipeline/pipeline.hpp | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/include/merian/vk/pipeline/pipeline.hpp b/include/merian/vk/pipeline/pipeline.hpp index 5e3fa6b..d97bdec 100644 --- a/include/merian/vk/pipeline/pipeline.hpp +++ b/include/merian/vk/pipeline/pipeline.hpp @@ -96,17 +96,41 @@ class Pipeline : public std::enable_shared_from_this { public: template - void + std::enable_if_t<(std::disjunction_v, + std::is_same> && + ...)> push_descriptor_set(const vk::CommandBuffer& cmd, const uint32_t set, const T&... resources) { push_descriptor_set(cmd, set, std::index_sequence_for{}, resources...); } template - std::enable_if_t<(std::negation_v> && ...)> + std::enable_if_t<(std::disjunction_v, + std::is_same> && + ...)> push_descriptor_set(const vk::CommandBuffer& cmd, const T&... resources) { push_descriptor_set(cmd, 0, std::index_sequence_for{}, resources...); } + template + std::enable_if_t< + (std::disjunction_v, std::is_same> && ...)> + push_descriptor_set(const vk::CommandBuffer& cmd, const uint32_t set, const T&... resources) { + // need this recursive call else the Image and Buffer descriptor info is deallocated from + // stack and we need the addresses. + push_descriptor_set(cmd, set, std::index_sequence_for{}, + resources->get_descriptor_info()...); + } + + template + std::enable_if_t< + (std::disjunction_v, std::is_same> && ...)> + push_descriptor_set(const vk::CommandBuffer& cmd, const T&... resources) { + // need this recursive call else the Image and Buffer descriptor info is deallocated from + // stack and we need the addresses. + push_descriptor_set(cmd, 0, std::index_sequence_for{}, + resources->get_descriptor_info()...); + } + // --------------------------------------------------------------------------- virtual vk::PipelineBindPoint get_pipeline_bind_point() const = 0;