Skip to content

Commit 6aadeeb

Browse files
committed
Merge branch 'master' into nahim_complex_fft_workgroup
2 parents ea7b5ee + fcb891a commit 6aadeeb

26 files changed

+481
-285
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Below are some tasks that are open for contribution. If you start working on a t
5656
- [GPU flip fluid simulation task idea](https://www.youtube.com/watch?v=okQzAJM7LcE) -> discord [thread](https://discord.com/channels/318590007881236480/374061825454768129/1257988553112027186) for more info
5757
- [Exact Distance Transform on a GPU](https://docs.google.com/document/d/1iUF0ilFbWVWr5JfPtR8D8z7OdmbhUJXK-eoR_7u4-50/edit)
5858
- [Light Scattering Effects Using Epipolar Sampling and 1D Min/Max Binary Trees](https://ubm-twvideo01.s3.amazonaws.com/o1/vault/gdc2013/slides/822368Yusov_Egor_Practical_Implementation_of_Light.pdf)
59+
- [Cone Map Generation](https://github.com/Bundas102/falcor-conemap/)
5960

6061
**[Issues](https://github.com/Devsh-Graphics-Programming/Nabla/issues) also count as free tasks.** We also have old issues from previous generation **[here](https://github.com/buildaworldnet/IrrlichtBAW/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)**.
6162

include/nbl/asset/ICPUDescriptorSet.h

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class NBL_API2 ICPUDescriptorSet final : public IDescriptorSet<ICPUDescriptorSet
6767
return 0xdeadbeefull;
6868
}
6969

70-
inline core::SRange<SDescriptorInfo> getDescriptorInfoStorage(const IDescriptor::E_TYPE type) const
70+
inline std::span<SDescriptorInfo> getDescriptorInfoStorage(const IDescriptor::E_TYPE type) const
7171
{
7272
// TODO: @Hazardu
7373
// Cannot do the mutability check here because it requires the function to be non-const, but the function cannot be non-const because it's called
@@ -78,14 +78,14 @@ class NBL_API2 ICPUDescriptorSet final : public IDescriptorSet<ICPUDescriptorSet
7878
//
7979
// assert(!isImmutable_debug());
8080
if (!m_descriptorInfos[static_cast<uint32_t>(type)])
81-
return { nullptr, nullptr };
81+
return { };
8282
else
8383
return { m_descriptorInfos[static_cast<uint32_t>(type)]->begin(), m_descriptorInfos[static_cast<uint32_t>(type)]->end() };
8484
}
8585

86-
core::SRange<SDescriptorInfo> getDescriptorInfos(const ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t binding, IDescriptor::E_TYPE type = IDescriptor::E_TYPE::ET_COUNT);
86+
std::span<SDescriptorInfo> getDescriptorInfos(const ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t binding, IDescriptor::E_TYPE type = IDescriptor::E_TYPE::ET_COUNT);
8787

88-
core::SRange<const SDescriptorInfo> getDescriptorInfos(const ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t binding, IDescriptor::E_TYPE type = IDescriptor::E_TYPE::ET_COUNT) const;
88+
std::span<const SDescriptorInfo> getDescriptorInfos(const ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t binding, IDescriptor::E_TYPE type = IDescriptor::E_TYPE::ET_COUNT) const;
8989

9090
core::smart_refctd_ptr<IAsset> clone(uint32_t _depth = ~0u) const override;
9191

@@ -99,38 +99,6 @@ class NBL_API2 ICPUDescriptorSet final : public IDescriptorSet<ICPUDescriptorSet
9999
virtual ~ICPUDescriptorSet() = default;
100100

101101
private:
102-
static inline IDescriptor::E_CATEGORY getCategoryFromType(const IDescriptor::E_TYPE type)
103-
{
104-
auto category = IDescriptor::E_CATEGORY::EC_COUNT;
105-
switch (type)
106-
{
107-
case IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER: [[fallthrough]];
108-
case IDescriptor::E_TYPE::ET_STORAGE_IMAGE: [[fallthrough]];
109-
case IDescriptor::E_TYPE::ET_INPUT_ATTACHMENT:
110-
category = IDescriptor::E_CATEGORY::EC_IMAGE;
111-
break;
112-
113-
case IDescriptor::E_TYPE::ET_UNIFORM_BUFFER: [[fallthrough]];
114-
case IDescriptor::E_TYPE::ET_UNIFORM_BUFFER_DYNAMIC: [[fallthrough]];
115-
case IDescriptor::E_TYPE::ET_STORAGE_BUFFER: [[fallthrough]];
116-
case IDescriptor::E_TYPE::ET_STORAGE_BUFFER_DYNAMIC:
117-
category = IDescriptor::E_CATEGORY::EC_BUFFER;
118-
break;
119-
120-
case IDescriptor::E_TYPE::ET_UNIFORM_TEXEL_BUFFER:
121-
case IDescriptor::E_TYPE::ET_STORAGE_TEXEL_BUFFER:
122-
category = IDescriptor::E_CATEGORY::EC_BUFFER_VIEW;
123-
break;
124-
125-
case IDescriptor::E_TYPE::ET_ACCELERATION_STRUCTURE:
126-
category = IDescriptor::E_CATEGORY::EC_ACCELERATION_STRUCTURE;
127-
break;
128-
129-
default:
130-
assert(!"Invalid code path.");
131-
}
132-
return category;
133-
}
134102

135103
core::smart_refctd_dynamic_array<ICPUDescriptorSet::SDescriptorInfo> m_descriptorInfos[static_cast<uint32_t>(IDescriptor::E_TYPE::ET_COUNT)];
136104
};

include/nbl/asset/ICPUDescriptorSetLayout.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ class ICPUDescriptorSetLayout : public IDescriptorSetLayout<ICPUSampler>, public
3434
for (uint32_t t = 0; t < static_cast<uint32_t>(asset::IDescriptor::E_TYPE::ET_COUNT); ++t)
3535
cp->m_descriptorRedirects[t] = m_descriptorRedirects[t].clone();
3636
cp->m_immutableSamplerRedirect = m_immutableSamplerRedirect.clone();
37-
cp->m_mutableSamplerRedirect = m_mutableSamplerRedirect.clone();
37+
cp->m_mutableCombinedSamplerRedirect = m_mutableCombinedSamplerRedirect.clone();
3838

39-
if (m_samplers)
39+
if (m_immutableSamplers)
4040
{
41-
cp->m_samplers = core::make_refctd_dynamic_array<decltype(m_samplers)>(m_samplers->size());
41+
cp->m_immutableSamplers = core::make_refctd_dynamic_array<decltype(m_immutableSamplers)>(m_immutableSamplers->size());
4242

4343
if (_depth > 0u)
4444
{
45-
for (size_t i = 0ull; i < m_samplers->size(); ++i)
46-
(*cp->m_samplers)[i] = core::smart_refctd_ptr_static_cast<ICPUSampler>((*m_samplers)[i]->clone(_depth - 1u));
45+
for (size_t i = 0ull; i < m_immutableSamplers->size(); ++i)
46+
(*cp->m_immutableSamplers)[i] = core::smart_refctd_ptr_static_cast<ICPUSampler>((*m_immutableSamplers)[i]->clone(_depth - 1u));
4747
}
4848
else
4949
{
50-
std::copy(m_samplers->begin(), m_samplers->end(), cp->m_samplers->begin());
50+
std::copy(m_immutableSamplers->begin(), m_immutableSamplers->end(), cp->m_immutableSamplers->begin());
5151
}
5252
}
5353

@@ -60,9 +60,9 @@ class ICPUDescriptorSetLayout : public IDescriptorSetLayout<ICPUSampler>, public
6060
for (uint32_t t = 0; t < static_cast<uint32_t>(asset::IDescriptor::E_TYPE::ET_COUNT); ++t)
6161
result += m_descriptorRedirects[t].conservativeSizeEstimate();
6262
result += m_immutableSamplerRedirect.conservativeSizeEstimate();
63-
result += m_mutableSamplerRedirect.conservativeSizeEstimate();
63+
result += m_mutableCombinedSamplerRedirect.conservativeSizeEstimate();
6464

65-
result += m_samplers->size() * sizeof(void*);
65+
result += m_immutableSamplers->size() * sizeof(void*);
6666

6767
return result;
6868
}
@@ -74,9 +74,9 @@ class ICPUDescriptorSetLayout : public IDescriptorSetLayout<ICPUSampler>, public
7474
if (referenceLevelsBelowToConvert)
7575
{
7676
--referenceLevelsBelowToConvert;
77-
if (m_samplers)
77+
if (m_immutableSamplers)
7878
{
79-
for (auto it=m_samplers->begin(); it!=m_samplers->end(); it++)
79+
for (auto it=m_immutableSamplers->begin(); it!=m_immutableSamplers->end(); it++)
8080
it->get()->convertToDummyObject(referenceLevelsBelowToConvert);
8181
}
8282
}
@@ -90,15 +90,15 @@ class ICPUDescriptorSetLayout : public IDescriptorSetLayout<ICPUSampler>, public
9090
auto* other = static_cast<const ICPUDescriptorSetLayout*>(_other);
9191
if (getTotalBindingCount() != other->getTotalBindingCount())
9292
return false;
93-
if ((!m_samplers) != (!other->m_samplers))
93+
if ((!m_immutableSamplers) != (!other->m_immutableSamplers))
9494
return false;
95-
if (m_samplers && m_samplers->size() != other->m_samplers->size())
95+
if (m_immutableSamplers && m_immutableSamplers->size() != other->m_immutableSamplers->size())
9696
return false;
97-
if (m_samplers)
97+
if (m_immutableSamplers)
9898
{
99-
for (uint32_t i = 0u; i < m_samplers->size(); ++i)
99+
for (uint32_t i = 0u; i < m_immutableSamplers->size(); ++i)
100100
{
101-
if (!(*m_samplers)[i]->canBeRestoredFrom((*other->m_samplers)[i].get()))
101+
if (!(*m_immutableSamplers)[i]->canBeRestoredFrom((*other->m_immutableSamplers)[i].get()))
102102
return false;
103103
}
104104
}
@@ -115,21 +115,21 @@ class ICPUDescriptorSetLayout : public IDescriptorSetLayout<ICPUSampler>, public
115115
return;
116116

117117
--_levelsBelow;
118-
if (m_samplers)
118+
if (m_immutableSamplers)
119119
{
120-
for (uint32_t i = 0u; i < m_samplers->size(); ++i)
121-
restoreFromDummy_impl_call((*m_samplers)[i].get(), (*other->m_samplers)[i].get(), _levelsBelow);
120+
for (uint32_t i = 0u; i < m_immutableSamplers->size(); ++i)
121+
restoreFromDummy_impl_call((*m_immutableSamplers)[i].get(), (*other->m_immutableSamplers)[i].get(), _levelsBelow);
122122
}
123123
}
124124

125125
bool isAnyDependencyDummy_impl(uint32_t _levelsBelow) const override
126126
{
127127
--_levelsBelow;
128-
if (m_samplers)
128+
if (m_immutableSamplers)
129129
{
130-
for (uint32_t i = 0u; i < m_samplers->size(); ++i)
130+
for (uint32_t i = 0u; i < m_immutableSamplers->size(); ++i)
131131
{
132-
if ((*m_samplers)[i]->isAnyDependencyDummy(_levelsBelow))
132+
if ((*m_immutableSamplers)[i]->isAnyDependencyDummy(_levelsBelow))
133133
return true;
134134
}
135135
}

include/nbl/asset/ICPUSampler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ICPUSampler : public ISampler, public IAsset
7777

7878

7979
_NBL_STATIC_INLINE_CONSTEXPR auto AssetType = ET_SAMPLER;
80-
inline E_TYPE getAssetType() const override { return AssetType; }
80+
inline IAsset::E_TYPE getAssetType() const override { return AssetType; }
8181

8282
bool canBeRestoredFrom(const IAsset* _other) const override
8383
{

include/nbl/asset/IDescriptor.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class IDescriptor : public virtual core::IReferenceCounted
1414
public:
1515
enum class E_TYPE : uint8_t
1616
{
17-
ET_COMBINED_IMAGE_SAMPLER = 0,
17+
ET_SAMPLER = 0,
18+
ET_COMBINED_IMAGE_SAMPLER,
19+
ET_SAMPLED_IMAGE,
1820
ET_STORAGE_IMAGE,
1921
ET_UNIFORM_TEXEL_BUFFER,
2022
ET_STORAGE_TEXEL_BUFFER,
@@ -39,6 +41,7 @@ class IDescriptor : public virtual core::IReferenceCounted
3941
enum E_CATEGORY : uint8_t
4042
{
4143
EC_BUFFER = 0,
44+
EC_SAMPLER,
4245
EC_IMAGE,
4346
EC_BUFFER_VIEW,
4447
EC_ACCELERATION_STRUCTURE,
@@ -48,24 +51,23 @@ class IDescriptor : public virtual core::IReferenceCounted
4851
{
4952
switch (type)
5053
{
54+
case E_TYPE::ET_SAMPLER:
55+
return EC_SAMPLER;
5156
case E_TYPE::ET_COMBINED_IMAGE_SAMPLER:
57+
case E_TYPE::ET_SAMPLED_IMAGE:
5258
case E_TYPE::ET_STORAGE_IMAGE:
5359
case E_TYPE::ET_INPUT_ATTACHMENT:
5460
return EC_IMAGE;
55-
break;
5661
case E_TYPE::ET_UNIFORM_TEXEL_BUFFER:
5762
case E_TYPE::ET_STORAGE_TEXEL_BUFFER:
5863
return EC_BUFFER_VIEW;
59-
break;
6064
case E_TYPE::ET_UNIFORM_BUFFER:
6165
case E_TYPE::ET_STORAGE_BUFFER:
6266
case E_TYPE::ET_UNIFORM_BUFFER_DYNAMIC:
6367
case E_TYPE::ET_STORAGE_BUFFER_DYNAMIC:
6468
return EC_BUFFER;
65-
break;
6669
case E_TYPE::ET_ACCELERATION_STRUCTURE:
6770
return EC_ACCELERATION_STRUCTURE;
68-
break;
6971
default:
7072
break;
7173
}

include/nbl/asset/IDescriptorSet.h

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,28 @@ class IDescriptorSet : public virtual core::IReferenceCounted // TODO: try to re
4545

4646
auto operator<=>(const SBufferInfo&) const = default;
4747
};
48-
struct SImageInfo
49-
{
50-
// This will be ignored if the DS layout already has an immutable sampler specified for the binding.
51-
core::smart_refctd_ptr<typename layout_t::sampler_type> sampler;
52-
IImage::LAYOUT imageLayout;
53-
};
48+
struct SImageInfo
49+
{
50+
IImage::LAYOUT imageLayout;
51+
};
52+
struct SCombinedImageSamplerInfo : SImageInfo
53+
{
54+
core::smart_refctd_ptr<typename layout_t::sampler_type> sampler;
55+
};
5456

5557
core::smart_refctd_ptr<IDescriptor> desc;
5658
union SBufferImageInfo
5759
{
5860
SBufferImageInfo()
5961
{
60-
memset(&buffer, 0, core::max<size_t>(sizeof(buffer), sizeof(image)));
62+
memset(&buffer, 0, core::max<size_t>(sizeof(buffer), sizeof(combinedImageSampler)));
6163
};
6264

6365
~SBufferImageInfo() {};
6466

6567
SBufferInfo buffer;
6668
SImageInfo image;
69+
SCombinedImageSamplerInfo combinedImageSampler;
6770
} info;
6871

6972
SDescriptorInfo() {}
@@ -92,41 +95,44 @@ class IDescriptorSet : public virtual core::IReferenceCounted // TODO: try to re
9295
}
9396
~SDescriptorInfo()
9497
{
95-
if (desc && desc->getTypeCategory()==IDescriptor::EC_IMAGE)
96-
info.image.sampler = nullptr;
98+
if (desc && desc->getTypeCategory() == IDescriptor::EC_IMAGE)
99+
info.combinedImageSampler.sampler = nullptr;
97100
}
98101

99102
inline SDescriptorInfo& operator=(const SDescriptorInfo& other)
100103
{
101-
if (desc && desc->getTypeCategory()==IDescriptor::EC_IMAGE)
102-
info.image.sampler = nullptr;
104+
if (desc and desc->getTypeCategory()==IDescriptor::EC_IMAGE)
105+
info.combinedImageSampler.sampler = nullptr;
103106
desc = other.desc;
104-
const auto type = desc->getTypeCategory();
105-
if (type!=IDescriptor::EC_IMAGE)
106-
info.buffer = other.info.buffer;
107-
else
108-
info.image = other.info.image;
107+
if (desc)
108+
{
109+
const auto type = desc->getTypeCategory();
110+
if (type != IDescriptor::EC_IMAGE)
111+
info.buffer = other.info.buffer;
112+
else
113+
info.combinedImageSampler = other.info.combinedImageSampler;
114+
}
109115
return *this;
110116
}
111117
inline SDescriptorInfo& operator=(SDescriptorInfo&& other)
112118
{
113-
if (desc && desc->getTypeCategory()==IDescriptor::EC_IMAGE)
114-
info.image = {nullptr,IImage::LAYOUT::UNDEFINED};
119+
if (desc and desc->getTypeCategory() == IDescriptor::EC_IMAGE)
120+
info.combinedImageSampler = {IImage::LAYOUT::UNDEFINED, nullptr};
115121
desc = std::move(other.desc);
116122
if (desc)
117123
{
118124
const auto type = desc->getTypeCategory();
119125
if (type!=IDescriptor::EC_IMAGE)
120126
info.buffer = other.info.buffer;
121127
else
122-
info.image = other.info.image;
128+
info.combinedImageSampler = other.info.combinedImageSampler;
123129
}
124130
return *this;
125131
}
126132

127133
inline bool operator!=(const SDescriptorInfo& other) const
128134
{
129-
if (desc != desc)
135+
if (desc != other.desc)
130136
return true;
131137
return info.buffer != other.info.buffer;
132138
}

0 commit comments

Comments
 (0)