Skip to content

Commit 0891b58

Browse files
committed
Pull from 'asset-conversion-v3'
1 parent 0857ede commit 0891b58

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

include/nbl/asset/ICPUImage.h

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace nbl::asset
1515
{
1616

17-
class NBL_API2 ICPUImage final : public IImage, public IPreHashed
17+
class ICPUImage final : public IImage, public IPreHashed
1818
{
1919
public:
2020
inline static core::smart_refctd_ptr<ICPUImage> create(const SCreationParams& _params)
@@ -38,16 +38,44 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
3838
return cp;
3939
}
4040

41-
// The buffer used to back the ranges used in the regions are is not a real dependent
42-
constexpr static inline bool HasDependents = false;
43-
4441
constexpr static inline auto AssetType = ET_IMAGE;
4542
inline IAsset::E_TYPE getAssetType() const override { return AssetType; }
4643

4744
// Having regions specififed to upload is optional!
4845
inline size_t getDependantCount() const override {return !missingContent()&&buffer ? 1:0;}
4946

50-
core::blake3_hash_t computeContentHash() const override;
47+
//!
48+
inline core::blake3_hash_t computeContentHash() const override
49+
{
50+
// TODO: Arek turn this into an image filter maybe?
51+
core::blake3_hasher hasher;
52+
for (auto m=0; m<m_creationParams.mipLevels; m++)
53+
{
54+
const auto blockInfo = getTexelBlockInfo();
55+
const auto mipExtentInBlocks = blockInfo.convertTexelsToBlocks(getMipSize(m));
56+
core::blake3_hasher levelHasher;
57+
if (missingContent())
58+
{
59+
const auto zeroLength = blockInfo.getBlockByteSize()*mipExtentInBlocks[0];
60+
auto zeroArray = std::make_unique<uint8_t[]>(zeroLength);
61+
for (auto l=0; l<m_creationParams.arrayLayers; l++)
62+
{
63+
// layers could be run in parallel
64+
core::blake3_hasher layerHasher;
65+
for (auto z=0; z<mipExtentInBlocks[2]; z++)
66+
for (auto y=0; y<mipExtentInBlocks[1]; y++)
67+
layerHasher.update(zeroArray.get(),zeroLength);
68+
levelHasher << static_cast<core::blake3_hash_t>(layerHasher);
69+
}
70+
}
71+
else
72+
{
73+
_NBL_TODO(); // TODO: Arek
74+
}
75+
levelHasher << static_cast<core::blake3_hash_t>(levelHasher);
76+
}
77+
return static_cast<core::blake3_hash_t>(hasher);
78+
}
5179

5280
inline bool missingContent() const override
5381
{
@@ -67,14 +95,14 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
6795
}
6896
inline const auto* getBuffer() const { return buffer.get(); }
6997

70-
inline std::span<const IImage::SBufferCopy> getRegions() const
98+
inline core::SRange<const IImage::SBufferCopy> getRegions() const
7199
{
72100
if (regions)
73101
return {regions->begin(),regions->end()};
74-
return {};
102+
return {nullptr,nullptr};
75103
}
76104

77-
inline std::span<const IImage::SBufferCopy> getRegions(uint32_t mipLevel) const
105+
inline core::SRange<const IImage::SBufferCopy> getRegions(uint32_t mipLevel) const
78106
{
79107
const IImage::SBufferCopy dummy = { 0ull,0u,0u,{static_cast<E_ASPECT_FLAGS>(0u),mipLevel,0u,0u},{},{} };
80108
auto begin = std::lower_bound(regions->begin(),regions->end(),dummy,mip_order_t());

include/nbl/asset/IDescriptorSetLayout.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ class IDescriptorSetLayout : public IDescriptorSetLayoutBase
467467
if ((b.type == IDescriptor::E_TYPE::ET_SAMPLER or b.type == IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER) and b.immutableSamplers)
468468
{
469469
const auto localOffset = m_immutableSamplerRedirect.getStorageOffset(typename CBindingRedirect::binding_number_t(b.binding)).data;
470+
assert(bool(localOffset));
470471

471472
auto* dst = m_immutableSamplers->begin() + localOffset;
472473
std::copy_n(b.immutableSamplers, b.count, dst);

0 commit comments

Comments
 (0)