Skip to content

Commit db9c4b2

Browse files
Merge pull request #547 from Crisspl/3rdparty-upgrade
Partial Asset Mutability Fix
2 parents 85a8163 + e4ce3bb commit db9c4b2

File tree

8 files changed

+23
-7
lines changed

8 files changed

+23
-7
lines changed

include/irr/asset/IAsset.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ class IAsset : virtual public core::IReferenceCounted
208208

209209
void convertToDummyObject_common(uint32_t referenceLevelsBelowToConvert)
210210
{
211-
isDummyObjectForCacheAliasing = true;
211+
if (m_mutable)
212+
isDummyObjectForCacheAliasing = true;
212213
}
213214

214215
//! Checks if the object is either not dummy or dummy but in some cache for a purpose

include/irr/asset/ICPUBuffer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class ICPUBuffer : public asset::IBuffer, public asset::IAsset
6565
if (isDummyObjectForCacheAliasing)
6666
return;
6767
convertToDummyObject_common(referenceLevelsBelowToConvert);
68+
if (!m_mutable)
69+
return;
6870

6971
if (data)
7072
_IRR_ALIGNED_FREE(data);
@@ -135,6 +137,8 @@ class CCustomAllocatorCPUBuffer<Allocator, true> : public ICPUBuffer
135137
if (isDummyObjectForCacheAliasing)
136138
return;
137139
convertToDummyObject_common(referenceLevelsBelowToConvert);
140+
if (!m_mutable)
141+
return;
138142

139143
if (ICPUBuffer::data)
140144
m_allocator.deallocate(reinterpret_cast<typename Allocator::pointer>(ICPUBuffer::data), ICPUBuffer::size);

include/irr/asset/ICPUDescriptorSetLayout.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ class ICPUDescriptorSetLayout : public IDescriptorSetLayout<ICPUSampler>, public
5959
return;
6060
convertToDummyObject_common(referenceLevelsBelowToConvert);
6161

62-
m_bindings = nullptr;
62+
if (m_mutable)
63+
m_bindings = nullptr;
64+
6365
if (referenceLevelsBelowToConvert)
6466
{
6567
--referenceLevelsBelowToConvert;
6668
if (m_samplers)
6769
for (auto it=m_samplers->begin(); it!=m_samplers->end(); it++)
6870
it->get()->convertToDummyObject(referenceLevelsBelowToConvert);
6971
}
70-
m_samplers = nullptr;
72+
73+
if (m_mutable)
74+
m_samplers = nullptr;
7175
}
7276

7377
_IRR_STATIC_INLINE_CONSTEXPR auto AssetType = ET_DESCRIPTOR_SET_LAYOUT;

include/irr/asset/ICPUImage.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class ICPUImage final : public IImage, public IAsset
4949
if (referenceLevelsBelowToConvert)
5050
if (buffer)
5151
buffer->convertToDummyObject(referenceLevelsBelowToConvert-1u);
52-
regions = nullptr;
52+
53+
if (m_mutable)
54+
regions = nullptr;
5355
}
5456

5557
_IRR_STATIC_INLINE_CONSTEXPR auto AssetType = ET_IMAGE;

include/irr/asset/ICPUPipelineCache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ class ICPUPipelineCache final : public IAsset
110110
size_t conservativeSizeEstimate() const override { return 0ull; /*TODO*/ }
111111
void convertToDummyObject(uint32_t referenceLevelsBelowToConvert = 0u) override
112112
{
113-
m_cache.clear();
113+
if (m_mutable)
114+
m_cache.clear();
114115
}
115116

116117
_IRR_STATIC_INLINE_CONSTEXPR auto AssetType = ET_PIPELINE_CACHE;

include/irr/asset/ICPUPipelineLayout.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class ICPUPipelineLayout : public IAsset, public IPipelineLayout<ICPUDescriptorS
5252
for (auto it=m_descSetLayouts.begin(); it!=m_descSetLayouts.end(); it++)
5353
if (it->get())
5454
it->get()->convertToDummyObject(referenceLevelsBelowToConvert-1u);
55-
m_pushConstantRanges = nullptr;
55+
56+
if (m_mutable)
57+
m_pushConstantRanges = nullptr;
5658
}
5759

5860
_IRR_STATIC_INLINE_CONSTEXPR auto AssetType = ET_PIPELINE_LAYOUT;

include/irr/asset/ICPUSpecializedShader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class ICPUSpecializedShader : public IAsset, public ISpecializedShader
6969
//m_specInfo.getBackingBuffer()->convertToDummyObject(referenceLevelsBelowToConvert-1u);
7070
m_unspecialized->convertToDummyObject(referenceLevelsBelowToConvert-1u);
7171
}
72-
m_specInfo.setEntries(nullptr,core::smart_refctd_ptr<ICPUBuffer>(m_specInfo.getBackingBuffer()));
72+
if (m_mutable)
73+
m_specInfo.setEntries(nullptr,core::smart_refctd_ptr<ICPUBuffer>(m_specInfo.getBackingBuffer()));
7374
}
7475

7576
inline E_SHADER_STAGE getStage() const { return m_specInfo.shaderStage; }

src/irr/asset/CGraphicsPipelineLoaderMTL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ core::smart_refctd_ptr<ICPUPipelineLayout> CGraphicsPipelineLoaderMTL::makePipel
234234
}
235235

236236
auto ds1layout = getDefaultAsset<ICPUDescriptorSetLayout, IAsset::ET_DESCRIPTOR_SET_LAYOUT>("irr/builtin/descriptor_set_layout/basic_view_parameters", m_assetMgr);
237+
237238
core::smart_refctd_ptr<ICPUDescriptorSetLayout> ds3Layout = _noDS3 ? nullptr : core::make_smart_refctd_ptr<ICPUDescriptorSetLayout>(bindings->begin(), bindings->end());
238239
SPushConstantRange pcRng;
239240
pcRng.stageFlags = ICPUSpecializedShader::ESS_FRAGMENT;

0 commit comments

Comments
 (0)