Skip to content

Commit

Permalink
DescriptorSetLayouts structure changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe2933 committed May 23, 2024
1 parent 2fcc676 commit a99033c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions examples/00-compute-device/pipelines/MultiplyComputer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class MultiplyComputer {
explicit DescriptorSetLayouts(
const vk::raii::Device &device
) : vku::DescriptorSetLayouts<1> { device, LayoutBindings {
{},
vk::DescriptorSetLayoutBinding { 0, vk::DescriptorType::eStorageBuffer, 1, vk::ShaderStageFlagBits::eCompute },
} } { }
};
Expand Down
21 changes: 10 additions & 11 deletions include/vku/DescriptorSetLayouts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
#include <vulkan/vulkan_raii.hpp>

#include "details/concepts.hpp"
#include "details/nofield.hpp"

namespace vku {
template <std::size_t... BindingCounts>
class DescriptorSetLayouts : public std::array<vk::DescriptorSetLayout, sizeof...(BindingCounts)> {
public:
template <std::size_t BindingCount, bool HasBindingFlags = false>
struct LayoutBindings {
std::array<vk::DescriptorSetLayoutBinding, BindingCount> bindings;
vk::DescriptorSetLayoutCreateFlags flags = {};
};

template <std::size_t BindingCount>
struct LayoutBindings<BindingCount, true> {
std::array<vk::DescriptorSetLayoutBinding, BindingCount> bindings;
vk::DescriptorSetLayoutCreateFlags flags = {};
std::array<vk::DescriptorBindingFlags, BindingCount> bindingFlags;
#ifndef _MSC_VER
[[no_unique_address]]
#endif
std::conditional_t<HasBindingFlags, std::array<vk::DescriptorBindingFlags, BindingCount>, details::nofield> bindingFlags;
};

// Type deductions.
// TODO: tricky deduction, might be ill-formed...
template <typename... Ts>
LayoutBindings(Ts...) -> LayoutBindings<
LayoutBindings(vk::DescriptorSetLayoutCreateFlags, Ts...) -> LayoutBindings<
details::leading_n<vk::DescriptorSetLayoutBinding, Ts...>,
std::convertible_to<details::last_type<Ts...>, std::array<vk::DescriptorBindingFlags, details::leading_n<vk::DescriptorSetLayoutBinding, Ts...>>>>;
std::convertible_to<
details::last_type<Ts...>,
std::array<vk::DescriptorBindingFlags, details::leading_n<vk::DescriptorSetLayoutBinding, Ts...>>>>;

/// Number of descriptor sets in the descriptor set layouts.
static constexpr std::size_t setCount = sizeof...(BindingCounts);
Expand All @@ -37,10 +37,9 @@ namespace vku {

std::tuple<std::array<vk::DescriptorSetLayoutBinding, BindingCounts>...> setLayouts;

template <bool... HasBindingFlags>
explicit DescriptorSetLayouts(
const vk::raii::Device &device,
const LayoutBindings<BindingCounts, HasBindingFlags> &...layoutBindings
const auto &...layoutBindings
) : setLayouts { layoutBindings.bindings... },
raiiLayouts { vk::raii::DescriptorSetLayout { device, getDescriptorSetLayoutCreateInfo(layoutBindings).get() }... } {
static_cast<std::array<vk::DescriptorSetLayout, setCount>&>(*this)
Expand Down
5 changes: 1 addition & 4 deletions include/vku/Gpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
#include <vulkan/vulkan_raii.hpp>

#include "details/concepts.hpp"
#include "details/nofield.hpp"
#include "details/ranges.hpp"

namespace vku {
namespace details {
struct nofield{};
}

template <typename QueueFamilyIndices, typename Queues> requires
std::constructible_from<Queues, vk::Device, const QueueFamilyIndices&>
&& requires(const QueueFamilyIndices &queueFamilyIndices) {
Expand Down
5 changes: 5 additions & 0 deletions include/vku/details/nofield.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

namespace vku::details {
struct nofield{};
};

0 comments on commit a99033c

Please sign in to comment.