Skip to content

Commit e4ce3bb

Browse files
committed
Another approach to fixing bug from prev commit
Handling immutable assets to the point of fixing this bug -- so basically making immutable assets not being converted into dummy cache handles
1 parent 5c67fd0 commit e4ce3bb

File tree

8 files changed

+23
-10
lines changed

8 files changed

+23
-10
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);
@@ -123,6 +125,8 @@ class CCustomAllocatorCPUBuffer<Allocator, true> : public ICPUBuffer
123125
if (isDummyObjectForCacheAliasing)
124126
return;
125127
convertToDummyObject_common(referenceLevelsBelowToConvert);
128+
if (!m_mutable)
129+
return;
126130

127131
if (ICPUBuffer::data)
128132
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
@@ -53,15 +53,19 @@ class ICPUDescriptorSetLayout : public IDescriptorSetLayout<ICPUSampler>, public
5353
return;
5454
convertToDummyObject_common(referenceLevelsBelowToConvert);
5555

56-
m_bindings = nullptr;
56+
if (m_mutable)
57+
m_bindings = nullptr;
58+
5759
if (referenceLevelsBelowToConvert)
5860
{
5961
--referenceLevelsBelowToConvert;
6062
if (m_samplers)
6163
for (auto it=m_samplers->begin(); it!=m_samplers->end(); it++)
6264
it->get()->convertToDummyObject(referenceLevelsBelowToConvert);
6365
}
64-
m_samplers = nullptr;
66+
67+
if (m_mutable)
68+
m_samplers = nullptr;
6569
}
6670

6771
_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
@@ -47,7 +47,9 @@ class ICPUPipelineLayout : public IAsset, public IPipelineLayout<ICPUDescriptorS
4747
for (auto it=m_descSetLayouts.begin(); it!=m_descSetLayouts.end(); it++)
4848
if (it->get())
4949
it->get()->convertToDummyObject(referenceLevelsBelowToConvert-1u);
50-
m_pushConstantRanges = nullptr;
50+
51+
if (m_mutable)
52+
m_pushConstantRanges = nullptr;
5153
}
5254

5355
_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
@@ -63,7 +63,8 @@ class ICPUSpecializedShader : public IAsset, public ISpecializedShader
6363
//m_specInfo.getBackingBuffer()->convertToDummyObject(referenceLevelsBelowToConvert-1u);
6464
m_unspecialized->convertToDummyObject(referenceLevelsBelowToConvert-1u);
6565
}
66-
m_specInfo.setEntries(nullptr,core::smart_refctd_ptr<ICPUBuffer>(m_specInfo.getBackingBuffer()));
66+
if (m_mutable)
67+
m_specInfo.setEntries(nullptr,core::smart_refctd_ptr<ICPUBuffer>(m_specInfo.getBackingBuffer()));
6768
}
6869

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

src/irr/asset/CGraphicsPipelineLoaderMTL.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +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-
// clone DS layout so that the builtin object is not used used in resulting asset (so that builtin object is not transformed into dummy asset key)
238-
// this rule concerns every asset type and every loader!
239-
ds1layout = core::smart_refctd_ptr_static_cast<ICPUDescriptorSetLayout>(ds1layout->clone(0u));
237+
240238
core::smart_refctd_ptr<ICPUDescriptorSetLayout> ds3Layout = _noDS3 ? nullptr : core::make_smart_refctd_ptr<ICPUDescriptorSetLayout>(bindings->begin(), bindings->end());
241239
SPushConstantRange pcRng;
242240
pcRng.stageFlags = ICPUSpecializedShader::ESS_FRAGMENT;

0 commit comments

Comments
 (0)