SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
PushConstantsLayout.h
1#pragma once
2
3#include "spark/render/Export.h"
4#include "spark/render/PushConstantsRange.h"
5
6#include <algorithm>
7#include <vector>
8
9namespace spark::render
10{
14 class SPARK_RENDER_EXPORT IPushConstantsLayout
15 {
16 public:
17 virtual ~IPushConstantsLayout() noexcept = default;
18
23 [[nodiscard]] virtual unsigned int size() const noexcept = 0;
24
32 [[nodiscard]] virtual const IPushConstantsRange& range(ShaderStage stage) const = 0;
33
38 [[nodiscard]] std::vector<const IPushConstantsRange*> ranges() const noexcept { return genericRanges(); }
39
40 private:
42 [[nodiscard]] virtual std::vector<const IPushConstantsRange*> genericRanges() const noexcept = 0;
43 };
44
63 template <typename PushConstantsRangeType>
65 {
66 public:
67 using PushConstantsRange = PushConstantsRangeType;
68
69 public:
71 [[nodiscard]] const PushConstantsRangeType& range(ShaderStage stage) const override = 0;
72
74 [[nodiscard]] virtual std::vector<const PushConstantsRangeType*> ranges() const noexcept = 0;
75
76 private:
77 [[nodiscard]] virtual std::vector<const IPushConstantsRange*> genericRanges() const noexcept final
78 {
79 std::vector<const IPushConstantsRange*> ranges_vector;
80 ranges_vector.reserve(ranges().size());
81 std::ranges::transform(ranges(), std::back_inserter(ranges_vector), [](const auto& range) { return static_cast<const IPushConstantsRange*>(range); });
82 return ranges_vector;
83 }
84 };
85}
Interface for a push constants layout.
Definition PushConstantsLayout.h:15
virtual unsigned int size() const noexcept=0
Get the size (in bytes) of the push constants backing memory.
Interface for a push constants range in a push constants layout .
Definition PushConstantsRange.h:12
Describes the layout of the pipelines push constant ranges.
Definition PushConstantsLayout.h:65
virtual std::vector< const PushConstantsRangeType * > ranges() const noexcept=0
Get all push constants ranges .
const PushConstantsRangeType & range(ShaderStage stage) const override=0
Get the push constants range associated with the shader stage provided.