Skip to content

Commit

Permalink
merian: Pipeline: Add more syntactic sugar to push descriptor methods
Browse files Browse the repository at this point in the history
  • Loading branch information
LDAP committed Nov 13, 2024
1 parent 4cca177 commit 49a93ef
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions include/merian/vk/pipeline/pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,41 @@ class Pipeline : public std::enable_shared_from_this<Pipeline> {

public:
template <typename... T>
void
std::enable_if_t<(std::disjunction_v<std::is_same<vk::DescriptorBufferInfo, T>,
std::is_same<vk::DescriptorImageInfo, T>> &&
...)>
push_descriptor_set(const vk::CommandBuffer& cmd, const uint32_t set, const T&... resources) {
push_descriptor_set(cmd, set, std::index_sequence_for<T...>{}, resources...);
}

template <typename... T>
std::enable_if_t<(std::negation_v<std::is_same<int32_t, T>> && ...)>
std::enable_if_t<(std::disjunction_v<std::is_same<vk::DescriptorBufferInfo, T>,
std::is_same<vk::DescriptorImageInfo, T>> &&
...)>
push_descriptor_set(const vk::CommandBuffer& cmd, const T&... resources) {
push_descriptor_set(cmd, 0, std::index_sequence_for<T...>{}, resources...);
}

template <typename... T>
std::enable_if_t<
(std::disjunction_v<std::is_same<BufferHandle, T>, std::is_same<TextureHandle, T>> && ...)>
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<T...>{},
resources->get_descriptor_info()...);
}

template <typename... T>
std::enable_if_t<
(std::disjunction_v<std::is_same<BufferHandle, T>, std::is_same<TextureHandle, T>> && ...)>
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<T...>{},
resources->get_descriptor_info()...);
}

// ---------------------------------------------------------------------------

virtual vk::PipelineBindPoint get_pipeline_bind_point() const = 0;
Expand Down

0 comments on commit 49a93ef

Please sign in to comment.