14
14
namespace nbl ::asset
15
15
{
16
16
17
- class NBL_API2 ICPUImage final : public IImage, public IPreHashed
17
+ class ICPUImage final : public IImage, public IPreHashed
18
18
{
19
19
public:
20
20
inline static core::smart_refctd_ptr<ICPUImage> create (const SCreationParams& _params)
@@ -38,16 +38,44 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
38
38
return cp;
39
39
}
40
40
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
-
44
41
constexpr static inline auto AssetType = ET_IMAGE;
45
42
inline IAsset::E_TYPE getAssetType () const override { return AssetType; }
46
43
47
44
// Having regions specififed to upload is optional!
48
45
inline size_t getDependantCount () const override {return !missingContent ()&&buffer ? 1 :0 ;}
49
46
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
+ }
51
79
52
80
inline bool missingContent () const override
53
81
{
@@ -67,14 +95,14 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
67
95
}
68
96
inline const auto * getBuffer () const { return buffer.get (); }
69
97
70
- inline std::span <const IImage::SBufferCopy> getRegions () const
98
+ inline core::SRange <const IImage::SBufferCopy> getRegions () const
71
99
{
72
100
if (regions)
73
101
return {regions->begin (),regions->end ()};
74
- return {};
102
+ return {nullptr , nullptr };
75
103
}
76
104
77
- inline std::span <const IImage::SBufferCopy> getRegions (uint32_t mipLevel) const
105
+ inline core::SRange <const IImage::SBufferCopy> getRegions (uint32_t mipLevel) const
78
106
{
79
107
const IImage::SBufferCopy dummy = { 0ull ,0u ,0u ,{static_cast <E_ASPECT_FLAGS>(0u ),mipLevel,0u ,0u },{},{} };
80
108
auto begin = std::lower_bound (regions->begin (),regions->end (),dummy,mip_order_t ());
0 commit comments