Skip to content

Commit ad362fc

Browse files
went a bit overboard with previous commit, also fix inifinite recursion bug due to bad const resolution
1 parent 0093d51 commit ad362fc

3 files changed

Lines changed: 58 additions & 56 deletions

File tree

include/nbl/asset/IAsset.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,11 @@ class IAsset : virtual public core::IReferenceCounted
169169
inline void visitDependents(std::function<bool(IAsset*)> visit)
170170
{
171171
assert(isMutable());
172-
visitDependents([&](const IAsset* dependent) -> bool
172+
visitDependents_impl([&](const IAsset* dep) -> bool
173173
{
174-
return visit(const_cast<IAsset*>(dependent));
174+
if (dep)
175+
return visit(const_cast<IAsset*>(dep));
176+
return true;
175177
});
176178
}
177179

include/nbl/asset/IPreHashed.h

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -39,61 +39,61 @@ class IPreHashed : public IAsset
3939
discardContent_impl();
4040
}
4141

42-
static inline void discardDependantsContents(const std::span<IAsset* const> roots)
43-
{
44-
core::vector<IAsset*> stack;
45-
core::unordered_set<IAsset*> alreadyVisited; // whether we have push the node to the stack
46-
auto push = [&stack,&alreadyVisited](IAsset* node) -> bool
47-
{
48-
const auto [dummy,inserted] = alreadyVisited.insert(node);
49-
if (inserted)
50-
stack.push_back(node);
51-
return true;
52-
};
53-
for (const auto& root : roots)
54-
push(root);
55-
while (!stack.empty())
56-
{
57-
auto* entry = stack.back();
58-
stack.pop_back();
59-
entry->visitDependents(push);
60-
// pre order traversal does discard
61-
auto* isPrehashed = dynamic_cast<IPreHashed*>(entry);
62-
if (isPrehashed)
63-
isPrehashed->discardContent();
64-
}
65-
}
66-
static inline bool anyDependantDiscardedContents(const IAsset* root)
67-
{
68-
core::vector<const IAsset*> stack;
69-
core::unordered_set<const IAsset*> alreadyVisited; // whether we have push the node to the stack
70-
bool result = false;
71-
auto push = [&stack,&alreadyVisited,&result](const IAsset* node) -> bool
72-
{
73-
const auto [dummy,inserted] = alreadyVisited.insert(node);
74-
if (inserted)
42+
static inline void discardDependantsContents(const std::span<IAsset* const> roots)
7543
{
76-
auto* isPrehashed = dynamic_cast<const IPreHashed*>(node);
77-
if (isPrehashed && isPrehashed->missingContent())
78-
{
79-
stack.clear();
80-
result = true;
81-
return false;
82-
}
83-
stack.push_back(node);
44+
core::vector<IAsset*> stack;
45+
core::unordered_set<IAsset*> alreadyVisited; // whether we have push the node to the stack
46+
auto push = [&stack,&alreadyVisited](IAsset* node) -> bool
47+
{
48+
const auto [dummy,inserted] = alreadyVisited.insert(node);
49+
if (inserted)
50+
stack.push_back(node);
51+
return true;
52+
};
53+
for (const auto& root : roots)
54+
push(root);
55+
while (!stack.empty())
56+
{
57+
auto* entry = stack.back();
58+
stack.pop_back();
59+
entry->visitDependents(push);
60+
// pre order traversal does discard
61+
auto* isPrehashed = dynamic_cast<IPreHashed*>(entry);
62+
if (isPrehashed)
63+
isPrehashed->discardContent();
64+
}
65+
}
66+
static inline bool anyDependantDiscardedContents(const IAsset* root)
67+
{
68+
core::vector<const IAsset*> stack;
69+
core::unordered_set<const IAsset*> alreadyVisited; // whether we have push the node to the stack
70+
bool result = false;
71+
auto push = [&stack,&alreadyVisited,&result](const IAsset* node) -> bool
72+
{
73+
const auto [dummy,inserted] = alreadyVisited.insert(node);
74+
if (inserted)
75+
{
76+
auto* isPrehashed = dynamic_cast<const IPreHashed*>(node);
77+
if (isPrehashed && isPrehashed->missingContent())
78+
{
79+
stack.clear();
80+
result = true;
81+
return false;
82+
}
83+
stack.push_back(node);
84+
}
85+
return true;
86+
};
87+
if (!push(root))
88+
return true;
89+
while (!stack.empty())
90+
{
91+
auto* entry = stack.back();
92+
stack.pop_back();
93+
entry->visitDependents(push);
94+
}
95+
return result;
8496
}
85-
return true;
86-
};
87-
if (!push(root))
88-
return true;
89-
while (!stack.empty())
90-
{
91-
auto* entry = stack.back();
92-
stack.pop_back();
93-
entry->visitDependents(push);
94-
}
95-
return result;
96-
}
9797

9898
protected:
9999
inline IPreHashed() = default;

src/nbl/video/utilities/CAssetConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4165,7 +4165,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
41654165
struct SMissingDependent
41664166
{
41674167
// This only checks if whether we had to convert and failed, but the dependent might be in readCache of one or more converters, so if in doubt assume its okay
4168-
explicit inline operator bool() const {return wasInStaging && gotWiped;}
4168+
inline operator bool() const {return wasInStaging && gotWiped;}
41694169

41704170
bool wasInStaging;
41714171
bool gotWiped;

0 commit comments

Comments
 (0)