Skip to content

Commit 773690d

Browse files
author
devsh
committed
finally able to tell apart ICPUImage without any region upload from one that has missing content
1 parent 44f2fd4 commit 773690d

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

examples_tests

include/nbl/asset/ICPUBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ICPUBuffer : public asset::IBuffer, public IPreHashed
6262
return static_cast<core::blake3_hash_t>(hasher);
6363
}
6464

65-
inline bool missingContent() const {return !data;}
65+
inline bool missingContent() const override {return !data;}
6666

6767
//! Returns pointer to data.
6868
const void* getPointer() const {return data;}

include/nbl/asset/ICPUImage.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
4444
constexpr static inline auto AssetType = ET_IMAGE;
4545
inline IAsset::E_TYPE getAssetType() const override { return AssetType; }
4646

47-
// Having regions specififed to upload is optional!
48-
inline size_t getDependantCount() const override {return !missingContent()&&buffer ? 1:0;}
47+
// Do not report buffer as dependant, as we will simply drop it instead of discarding its contents!
48+
inline size_t getDependantCount() const override {return 0;}
4949

5050
core::blake3_hash_t computeContentHash() const override;
5151

52+
// Having regions specififed to upload is optional! So to have content missing we must have regions but no buffer content
5253
inline bool missingContent() const override
5354
{
54-
return !regions || regions->empty() || !buffer;
55+
return regions && !regions->empty() && (!buffer || buffer->missingContent());
5556
}
5657

5758
virtual bool validateCopies(const SImageCopy* pRegionsBegin, const SImageCopy* pRegionsEnd, const ICPUImage* src) const
@@ -205,7 +206,6 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed
205206
inline void discardContent_impl() override
206207
{
207208
buffer = nullptr;
208-
regions = nullptr;
209209
}
210210

211211
// TODO: maybe we shouldn't make a single buffer back all regions?

include/nbl/asset/IPreHashed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class IPreHashed : public IAsset
3030
// One can free up RAM by discarding content, but keep the pointers and content hash around.
3131
// This is a good alternative to simply ejecting assets from the <path,asset> cache as it prevents repeated loads.
3232
// And you can still hash the asset DAG and find your already converted GPU objects.
33+
// NOTE: `missingContent` is only about this DAG node!
3334
virtual bool missingContent() const = 0;
3435
inline void discardContent()
3536
{

0 commit comments

Comments
 (0)