Skip to content

Commit edd7e62

Browse files
Merge pull request #740 from Devsh-Graphics-Programming/tad_external_assets_hashes
Content hashes for loader-external assets
2 parents c92a34c + 9bc4e13 commit edd7e62

22 files changed

+46
-2
lines changed

include/nbl/asset/IAssetManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class NBL_API2 IAssetManager : public core::IReferenceCounted
127127
m_compilerSet(std::move(compilerSet)),
128128
m_defaultLoaderOverride(this)
129129
{
130+
assert(IPreHashed::INVALID_HASH == static_cast<core::blake3_hash_t>(core::blake3_hasher{}));
130131
initializeMeshTools();
131132

132133
for (size_t i = 0u; i < m_assetCache.size(); ++i)

include/nbl/asset/ICPUBuffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ICPUBuffer : public asset::IBuffer, public IPreHashed
4545
{
4646
auto cp = core::make_smart_refctd_ptr<ICPUBuffer>(m_creationParams.size);
4747
memcpy(cp->getPointer(), data, m_creationParams.size);
48+
cp->setContentHash(getContentHash());
4849
return cp;
4950
}
5051

include/nbl/asset/ICPUImage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
3838
else
3939
cp->buffer = buffer;
4040

41+
cp->setContentHash(getContentHash());
4142
return cp;
4243
}
4344

include/nbl/asset/IPreHashed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace nbl::asset
1414
class IPreHashed : public IAsset
1515
{
1616
public:
17+
constexpr static inline core::blake3_hash_t INVALID_HASH = { 0xaf,0x13,0x49,0xb9,0xf5,0xf9,0xa1,0xa6,0xa0,0x40,0x4d,0xea,0x36,0xdc,0xc9,0x49,0x9b,0xcb,0x25,0xc9,0xad,0xc1,0x12,0xb7,0xcc,0x9a,0x93,0xca,0xe4,0x1f,0x32,0x62 };
1718
//
1819
inline const core::blake3_hash_t& getContentHash() const {return m_contentHash;}
1920
//

include/nbl/asset/filters/CBlitImageFilter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ class CBlitImageFilter :
448448
CBasicImageFilterCommon::executePerRegion(policy,outImg,scaleCoverage,outRegions, clip);
449449
};
450450

451+
outImg->setContentHash(IPreHashed::INVALID_HASH);
452+
451453
// process
452454
state->normalization.template initialize<double>();
453455
const core::vectorSIMDf fInExtent(inExtentLayerCount);

include/nbl/asset/filters/CCopyImageFilter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class CCopyImageFilter : public CImageFilter<CCopyImageFilter>, public CMatchedS
7373
return true;
7474
};
7575

76+
state->outImage->setContentHash(IPreHashed::INVALID_HASH);
77+
7678
return commonExecute(state,perOutputRegion);
7779
}
7880
static inline bool execute(state_type* state)

include/nbl/asset/filters/CFillImageFilter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class CFillImageFilter : public CImageFilter<CFillImageFilter>
5454
auto regions = img->getRegions(state->subresource.mipLevel);
5555
CBasicImageFilterCommon::executePerRegion(std::forward<ExecutionPolicy>(policy),img,fill,regions,clip);
5656

57+
state->outImage->setContentHash(IPreHashed::INVALID_HASH);
58+
5759
return true;
5860
}
5961
static inline bool execute(state_type* state)

include/nbl/asset/filters/CFlattenRegionsImageFilter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ class CFlattenRegionsImageFilter : public CImageFilter<CFlattenRegionsImageFilte
165165
if (!CCopyImageFilter::execute(policy,&copy))
166166
return false;
167167
}
168+
169+
outImg->setContentHash(inImg->getContentHash());
170+
168171
return true;
169172
}
170173
static inline bool execute(state_type* state)

include/nbl/asset/filters/CMipMapGenerationImageFilter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ class CMipMapGenerationImageFilter : public CImageFilter<CMipMapGenerationImageF
9595
if (!pseudo_base_t::template execute<ExecutionPolicy>(std::forward<ExecutionPolicy>(policy),&blit))
9696
return false;
9797
}
98+
99+
state->inOutImage->setContentHash(IPreHashed::INVALID_HASH);
100+
98101
return true;
99102
}
100103
static inline bool execute(state_type* state)

include/nbl/asset/filters/CPaddedCopyImageFilter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ class CPaddedCopyImageFilter : public CImageFilter<CPaddedCopyImageFilter>, publ
211211
}
212212
}
213213

214+
state->outImage->setContentHash(IPreHashed::INVALID_HASH);
215+
214216
return true;
215217
}
216218
static inline bool execute(state_type* state)

0 commit comments

Comments
 (0)