-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathICPUPipelineLayout.h
More file actions
94 lines (76 loc) · 3.66 KB
/
ICPUPipelineLayout.h
File metadata and controls
94 lines (76 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (C) 2018-2024 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_ASSET_I_CPU_PIPELINE_LAYOUT_H_INCLUDED_
#define _NBL_ASSET_I_CPU_PIPELINE_LAYOUT_H_INCLUDED_
#include "nbl/asset/IAsset.h"
#include "nbl/asset/ICPUDescriptorSetLayout.h"
#include "nbl/asset/IPipelineLayout.h"
namespace nbl::asset
{
//! CPU Version of Pipeline Layout
/*
@see IPipelineLayout
*/
class ICPUPipelineLayout : public IAsset, public IPipelineLayout<ICPUDescriptorSetLayout>
{
public:
static inline constexpr uint32_t DESC_SET_LAYOUT_HIERARCHYLEVELS_BELOW = 1u;
static inline constexpr uint32_t IMMUTABLE_SAMPLER_HIERARCHYLEVELS_BELOW = 1u+ICPUDescriptorSetLayout::IMMUTABLE_SAMPLER_HIERARCHYLEVELS_BELOW;
inline ICPUPipelineLayout(
const std::span<const asset::SPushConstantRange> _pcRanges,
core::smart_refctd_ptr<ICPUDescriptorSetLayout>&& _layout0, core::smart_refctd_ptr<ICPUDescriptorSetLayout>&& _layout1,
core::smart_refctd_ptr<ICPUDescriptorSetLayout>&& _layout2, core::smart_refctd_ptr<ICPUDescriptorSetLayout>&& _layout3
) : IPipelineLayout<ICPUDescriptorSetLayout>(_pcRanges,std::move(_layout0),std::move(_layout1),std::move(_layout2),std::move(_layout3)) {}
//
ICPUDescriptorSetLayout* getDescriptorSetLayout(uint32_t _set)
{
assert(isMutable());
return m_descSetLayouts[_set].get();
}
const ICPUDescriptorSetLayout* getDescriptorSetLayout(uint32_t _set) const { return m_descSetLayouts[_set].get(); }
void setDescriptorSetLayout(uint32_t _set, core::smart_refctd_ptr<ICPUDescriptorSetLayout>&& _dslayout)
{
assert(isMutable());
assert(_set < DESCRIPTOR_SET_COUNT);
m_descSetLayouts[_set] = std::move(_dslayout);
}
void setPushConstantRanges(core::smart_refctd_dynamic_array<SPushConstantRange>&& _ranges)
{
assert(isMutable());
m_pushConstantRanges = std::move(_ranges);
}
core::smart_refctd_ptr<IAsset> clone(uint32_t _depth = ~0u) const override
{
std::array<core::smart_refctd_ptr<ICPUDescriptorSetLayout>,DESCRIPTOR_SET_COUNT> dsLayouts;
for (size_t i = 0ull; i < dsLayouts.size(); ++i)
dsLayouts[i] = (m_descSetLayouts[i] && _depth > 0u) ? core::smart_refctd_ptr_static_cast<ICPUDescriptorSetLayout>(m_descSetLayouts[i]->clone(_depth-1u)) : m_descSetLayouts[i];
return core::make_smart_refctd_ptr<ICPUPipelineLayout>(
std::span<const asset::SPushConstantRange>{m_pushConstantRanges->begin(),m_pushConstantRanges->end()},
std::move(dsLayouts[0]),std::move(dsLayouts[1]),std::move(dsLayouts[2]),std::move(dsLayouts[3])
);
}
static inline constexpr auto AssetType = ET_PIPELINE_LAYOUT;
inline E_TYPE getAssetType() const override { return AssetType; }
inline bool valid() const override
{
for (size_t i = 0; i < m_descSetLayouts.size(); i++)
{
if (!m_descSetLayouts[i]) continue;
if (!m_descSetLayouts[i]->valid()) return false;
}
return true;
}
protected:
virtual ~ICPUPipelineLayout() = default;
inline void visitDependents_impl(std::function<bool(const IAsset*)> visit) const override
{
for (size_t i = 0; i < m_descSetLayouts.size(); i++)
{
if (!m_descSetLayouts[i]) continue;
if (!visit(m_descSetLayouts[i].get())) return;
}
}
};
}
#endif