Skip to content

Commit f356185

Browse files
author
devsh
committed
Make the staging cache reference counted and make failures propagate properly
1 parent 4d5097b commit f356185

File tree

2 files changed

+182
-184
lines changed

2 files changed

+182
-184
lines changed

include/nbl/video/utilities/CAssetConverter.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,14 @@ class CAssetConverter : public core::IReferenceCounted
973973

974974
public:
975975
template<asset::Asset AssetType>
976-
using staging_cache_t = core::unordered_map<typename asset_traits<AssetType>::video_t*,typename CCache<AssetType>::key_t>;
976+
struct staging_cache_key
977+
{
978+
core::smart_refctd_ptr<typename asset_traits<AssetType>::video_t> gpuRef;
979+
typename CCache<AssetType>::key_t cacheKey;
980+
};
981+
// it may seem weird storing both a smart pointer and a raw pointer, but the reason is to be able to drop a refcount while not loosing the key for lookup
982+
template<asset::Asset AssetType>
983+
using staging_cache_t = core::unordered_map<const typename asset_traits<AssetType>::video_t*,staging_cache_key<AssetType>>;
977984

978985
inline SReserveResult(SReserveResult&&) = default;
979986
inline SReserveResult(const SReserveResult&) = delete;

0 commit comments

Comments
 (0)