Add more insights on potentially missing asset file data chunks
This commit is contained in:
@@ -584,7 +584,32 @@ Asset::LoadResult BinaryAsset::loadAsset()
|
||||
ASSERT(Storage && _header.ID.IsValid() && _header.TypeName.HasChars());
|
||||
|
||||
auto lock = Storage->Lock();
|
||||
return load();
|
||||
const LoadResult result = load();
|
||||
#if !BUILD_RELEASE
|
||||
if (result == LoadResult::MissingDataChunk)
|
||||
{
|
||||
// Provide more insights on potentially missing asset data chunk
|
||||
Char chunksBitMask[ASSET_FILE_DATA_CHUNKS + 1];
|
||||
Char chunksExistBitMask[ASSET_FILE_DATA_CHUNKS + 1];
|
||||
Char chunksLoadBitMask[ASSET_FILE_DATA_CHUNKS + 1];
|
||||
for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
|
||||
{
|
||||
if (const FlaxChunk* chunk = _header.Chunks[i])
|
||||
{
|
||||
chunksBitMask[i] = '1';
|
||||
chunksExistBitMask[i] = chunk->ExistsInFile() ? '1' : '0';
|
||||
chunksLoadBitMask[i] = chunk->IsLoaded() ? '1' : '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
chunksBitMask[i] = chunksExistBitMask[i] = chunksLoadBitMask[i] = '0';
|
||||
}
|
||||
}
|
||||
chunksBitMask[ASSET_FILE_DATA_CHUNKS] = chunksExistBitMask[ASSET_FILE_DATA_CHUNKS] = chunksLoadBitMask[ASSET_FILE_DATA_CHUNKS] = 0;
|
||||
LOG(Warning, "Asset reports missing data chunk. Chunks bitmask: {}, existing chunks: {} loaded chunks: {}. '{}'", chunksBitMask, chunksExistBitMask, chunksLoadBitMask, ToString());
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
void BinaryAsset::releaseStorage()
|
||||
|
||||
@@ -81,36 +81,17 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the amount of created asset chunks.
|
||||
/// </summary>
|
||||
/// <returns>Created asset chunks</returns>
|
||||
int32 GetChunksCount() const
|
||||
{
|
||||
int32 result = 0;
|
||||
for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
|
||||
{
|
||||
if (Chunks[i] != nullptr)
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int32 GetChunksCount() const;
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all chunks. Warning! Chunks are managed internally, use with caution!
|
||||
/// </summary>
|
||||
void DeleteChunks()
|
||||
{
|
||||
for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
|
||||
{
|
||||
SAFE_DELETE(Chunks[i]);
|
||||
}
|
||||
}
|
||||
void DeleteChunks();
|
||||
|
||||
/// <summary>
|
||||
/// Unlinks all chunks.
|
||||
/// </summary>
|
||||
void UnlinkChunks()
|
||||
{
|
||||
Platform::MemoryClear(Chunks, sizeof(Chunks));
|
||||
}
|
||||
void UnlinkChunks();
|
||||
|
||||
/// <summary>
|
||||
/// Gets string with a human-readable info about that header
|
||||
|
||||
@@ -20,6 +20,30 @@
|
||||
#endif
|
||||
#include <ThirdParty/LZ4/lz4.h>
|
||||
|
||||
int32 AssetHeader::GetChunksCount() const
|
||||
{
|
||||
int32 result = 0;
|
||||
for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
|
||||
{
|
||||
if (Chunks[i] != nullptr)
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AssetHeader::DeleteChunks()
|
||||
{
|
||||
for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
|
||||
{
|
||||
SAFE_DELETE(Chunks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void AssetHeader::UnlinkChunks()
|
||||
{
|
||||
Platform::MemoryClear(Chunks, sizeof(Chunks));
|
||||
}
|
||||
|
||||
String AssetHeader::ToString() const
|
||||
{
|
||||
return String::Format(TEXT("ID: {0}, TypeName: {1}, Chunks Count: {2}"), ID, TypeName, GetChunksCount());
|
||||
|
||||
Reference in New Issue
Block a user