From a12e61baf08ff66de2aff0eb60e9e31f28a10e6e Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 15 May 2017 20:44:24 -0700 Subject: [PATCH] Add ATVR to vcache analyzer ACMR is a good metric in general but the optimal ACMR number for a given mesh depends on the triangle/vertex ratio - ACMR of 0.5 is impossible to reach for certain meshes. In contrast, if we assume all vertices are required by a given mesh, ATVR (average transform to vertex ratio) has to be at least 1.0 (each vertex is transformed once), and represents the amount of over-transformation due to vertex cache misses. --- demo/main.cpp | 2 +- src/meshoptimizer.hpp | 3 ++- src/vcacheanalyzer.cpp | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/demo/main.cpp b/demo/main.cpp index ea779d2b..121fe3d2 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -139,7 +139,7 @@ void optimize(const Mesh& mesh, const char* name, void (*optf)(Mesh& mesh)) PostTransformCacheStatistics stats = analyzePostTransform(©.indices[0], copy.indices.size(), copy.vertices.size(), kCacheSize); - printf("%-10s: ACMR %f in %f msec\n", name, stats.acmr, double(end - start) / CLOCKS_PER_SEC * 1000); + printf("%-10s: ACMR %f ATVR %f in %f msec\n", name, stats.acmr, stats.atvr, double(end - start) / CLOCKS_PER_SEC * 1000); } int main(int argc, char** argv) diff --git a/src/meshoptimizer.hpp b/src/meshoptimizer.hpp index 8a5776ec..aa0988db 100644 --- a/src/meshoptimizer.hpp +++ b/src/meshoptimizer.hpp @@ -47,7 +47,8 @@ struct PostTransformCacheStatistics { unsigned int hits, misses; float hit_percent, miss_percent; - float acmr; // transformed vertices / triangle count + float acmr; // transformed vertices / triangle count; best case 0.5, worst case 3.0, optimum depends on topology + float atvr; // transformed vertices / vertex count; best case 1.0, worse case 6.0, optimum is 1.0 (each vertex is transformed once) }; // Vertex transform cache analyzer diff --git a/src/vcacheanalyzer.cpp b/src/vcacheanalyzer.cpp index af4b7706..dbbbde18 100644 --- a/src/vcacheanalyzer.cpp +++ b/src/vcacheanalyzer.cpp @@ -29,6 +29,7 @@ namespace result.miss_percent = 100 * static_cast(result.misses) / index_count; result.acmr = static_cast(result.misses) / (index_count / 3); + result.atvr = static_cast(result.misses) / vertex_count; return result; }