vk: imagecompare: highlight total difference > 1%

This commit is contained in:
Ivan Avdeev 2023-11-21 10:43:39 -05:00
parent 27ed4b157a
commit 1ac00a8792
2 changed files with 15 additions and 2 deletions

View File

@ -3,6 +3,11 @@
- [ ] dump all components
- [ ] script
- [ ] try also dumping in native code
- [ ] script for running and comparing results
- [ ] command for random seed fixation
- [ ] difference heatmap
- [ ] difference gif
- [ ] difference summary table
- [ ] make sure it's reproducible
- [ ] contemplate infrastructure: scripts, repo, etc.
- [ ] spec for profiler dumper

View File

@ -87,10 +87,18 @@ int main(int argc, char *argv[]) {
const uint32_t total = a.w * a.h * a.comp * 256;
fprintf(stderr, "Total difference \"%s\" vs \"%s\": %d (%.03f%%)\n", argv[1], argv[2], diff_sum, (diff_sum * 100. / total));
const float diff_pct_threshold = 1.f;
const float diff_pct = diff_sum * 100.f / total;
const int over = diff_pct_threshold < diff_pct;
fprintf(stderr, "%sTotal difference \"%s\" vs \"%s\": %d (%.03f%%)%s\n",
over ? "\033[31mFAIL " : "",
argv[1], argv[2], diff_sum, diff_pct,
over ? "\033[0m" : ""
);
if (!imageSave(&diff, argv[3]))
return 1;
return diff_sum == 0;
return over;
}