From 7545e49284d9e08e027102ba46722bb2f424fc2d Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 14 Mar 2024 17:30:28 +0100 Subject: [PATCH] Add manual chunks loading before Binary Asset load in case content streaming flushed them out --- Source/Engine/Content/BinaryAsset.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/Engine/Content/BinaryAsset.cpp b/Source/Engine/Content/BinaryAsset.cpp index 85ffd66ec..7735d8b28 100644 --- a/Source/Engine/Content/BinaryAsset.cpp +++ b/Source/Engine/Content/BinaryAsset.cpp @@ -584,6 +584,17 @@ Asset::LoadResult BinaryAsset::loadAsset() ASSERT(Storage && _header.ID.IsValid() && _header.TypeName.HasChars()); auto lock = Storage->Lock(); + auto chunksToPreload = getChunksToPreload(); + if (chunksToPreload != 0) + { + // Ensure that any chunks that were requested before are loaded in memory (in case streaming flushed them out after timeout) + for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++) + { + const auto chunk = _header.Chunks[i]; + if (GET_CHUNK_FLAG(i) & chunksToPreload && chunk && chunk->IsMissing()) + Storage->LoadAssetChunk(chunk); + } + } const LoadResult result = load(); #if !BUILD_RELEASE if (result == LoadResult::MissingDataChunk)