mirror of
https://github.com/openharmony/third_party_meshoptimizer.git
synced 2026-07-19 12:03:07 -04:00
pretransformanalyzer: Add bytes_fetched stat
All other analyzers expose absolute metrics and compute relative metrics based on that; do the same for pretransform analyzer and expose the number of bytes fetched from memory.
This commit is contained in:
@@ -73,7 +73,8 @@ OverdrawStatistics analyzeOverdraw(const unsigned int* indices, size_t index_cou
|
||||
|
||||
struct PreTransformCacheStatistics
|
||||
{
|
||||
float overfetch;
|
||||
unsigned int bytes_fetched;
|
||||
float overfetch; // fetched bytes / vertex buffer size; best case 1.0 (each byte is fetched once)
|
||||
};
|
||||
|
||||
// Vertex fetch cache analyzer
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace
|
||||
|
||||
// simple direct mapped cache; on typical mesh data this is close to 4-way cache, and this model is a gross approximation anyway
|
||||
size_t cache[kCacheSize / kCacheLine] = {};
|
||||
size_t fetched = 0;
|
||||
|
||||
for (size_t i = 0; i < index_count; ++i)
|
||||
{
|
||||
@@ -34,12 +33,12 @@ namespace
|
||||
size_t line = tag % (sizeof(cache) / sizeof(cache[0]));
|
||||
|
||||
// we store +1 since cache is filled with 0 by default
|
||||
fetched += cache[line] != tag + 1;
|
||||
result.bytes_fetched += (cache[line] != tag + 1) * kCacheLine;
|
||||
cache[line] = tag + 1;
|
||||
}
|
||||
}
|
||||
|
||||
result.overfetch = static_cast<float>(fetched * kCacheLine) / static_cast<float>(vertex_count * vertex_size);
|
||||
result.overfetch = static_cast<float>(result.bytes_fetched) / static_cast<float>(vertex_count * vertex_size);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user