Skip to content

Commit

Permalink
Merge Add statistics about asset type usage (mr-604)
Browse files Browse the repository at this point in the history
eda0d88 - tweak(streaming): add statistics about asset type usage
  • Loading branch information
prikolium-cfx committed Nov 22, 2024
2 parents a4881fb + eda0d88 commit e451feb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion code/components/gta-streaming-five/src/LoadStreamingFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,8 @@ static hook::cdecl_stub<void(int, const char*)> initGfxTexture([]()
});
#endif

std::unordered_map<std::string, int> g_resourceStats;

static void LoadStreamingFiles(LoadType loadType)
{
auto cstreaming = streaming::Manager::GetInstance();
Expand Down Expand Up @@ -1835,6 +1837,8 @@ static void LoadStreamingFiles(LoadType loadType)
continue;
}

g_resourceStats[ext]++;

// this may get used on unloading
if (baseName == "busy_spinner.gfx")
{
Expand Down Expand Up @@ -2884,6 +2888,8 @@ static void SafelyDrainStreamer()
_unloadTextureLODs();

trace("Shutdown: streamer tasks done\n");

g_resourceStats.clear();
}

#ifdef GTA_FIVE
Expand Down Expand Up @@ -3276,7 +3282,13 @@ void* chunkyArrayAppend(hook::FlexStruct* self)
const int32_t loadedEntriesCount = self->Get<int32_t>(chunkyArrayCountOffset);
if (loadedEntriesCount >= 0xFFFF)
{
FatalError("ERR_STR_FAILURE: trying to add more assets to pgRawStreamer when it's already full (65535).");
std::stringstream ss;
for (auto& [ext, num] : g_resourceStats)
{
ss << ext << ": " << num << ", ";
}
AddCrashometry("asset_stats", ss.str());
FatalError("ERR_STR_FAILURE: trying to add more assets to pgRawStreamer when it's already full (65535).");
}

return g_chunkyArrayAppend(self);
Expand Down

0 comments on commit e451feb

Please sign in to comment.