mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
headless: Switch screenshot error to MSE.
This is more useful than 1/0 on whether a pixel doesn't match, when many are close but not exact.
This commit is contained in:
parent
d703c934dd
commit
f32e8e11ab
@ -305,11 +305,18 @@ bool CompareOutput(const Path &bootFilename, const std::string &output, bool ver
|
||||
}
|
||||
}
|
||||
|
||||
inline int ComparePixel(u32 pix1, u32 pix2) {
|
||||
// For now, if they're different at all except alpha, it's an error.
|
||||
if ((pix1 & 0xFFFFFF) != (pix2 & 0xFFFFFF))
|
||||
return 1;
|
||||
return 0;
|
||||
static inline double CompareChannel(int pix1, int pix2) {
|
||||
double diff = pix1 - pix2;
|
||||
return diff * diff;
|
||||
}
|
||||
|
||||
static inline double ComparePixel(u32 pix1, u32 pix2) {
|
||||
// Ignore alpha.
|
||||
double r = CompareChannel(pix1 & 0xFF, pix2 & 0xFF);
|
||||
double g = CompareChannel((pix1 >> 8) & 0xFF, (pix2 >> 8) & 0xFF);
|
||||
double b = CompareChannel((pix1 >> 16) & 0xFF, (pix2 >> 16) & 0xFF);
|
||||
|
||||
return r + g + b;
|
||||
}
|
||||
|
||||
std::vector<u32> TranslateDebugBufferToCompare(const GPUDebugBuffer *buffer, u32 stride, u32 h) {
|
||||
@ -338,7 +345,6 @@ std::vector<u32> TranslateDebugBufferToCompare(const GPUDebugBuffer *buffer, u32
|
||||
dst += (h - safeH) * stride;
|
||||
}
|
||||
|
||||
u32 errors = 0;
|
||||
for (u32 y = 0; y < safeH; ++y) {
|
||||
switch (buffer->GetFormat()) {
|
||||
case GPU_DBG_FORMAT_8888:
|
||||
@ -429,7 +435,7 @@ double ScreenshotComparer::Compare(const Path &screenshotFilename) {
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
u32 errors = 0;
|
||||
double errors = 0;
|
||||
if (asBitmap_) {
|
||||
// The reference is flipped and BGRA by default for the common BMP compare case.
|
||||
for (u32 y = 0; y < h_; ++y) {
|
||||
@ -447,7 +453,8 @@ double ScreenshotComparer::Compare(const Path &screenshotFilename) {
|
||||
}
|
||||
}
|
||||
|
||||
return (double) errors / (double) (w_ * h_);
|
||||
// Convert to MSE, accounting for all three channels (RGB.)
|
||||
return errors / (double)(w_ * h_ * 3);
|
||||
}
|
||||
|
||||
bool ScreenshotComparer::SaveActualBitmap(const Path &resultFilename) {
|
||||
|
@ -55,7 +55,7 @@ void HeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) {
|
||||
SendOrCollectDebugOutput(comparer.GetError() + "\n");
|
||||
|
||||
if (errors > 0)
|
||||
SendOrCollectDebugOutput(StringFromFormat("Screenshot error: %f%%\n", errors * 100.0f));
|
||||
SendOrCollectDebugOutput(StringFromFormat("Screenshot MSE: %f\n", errors));
|
||||
|
||||
if (errors > 0 && !teamCityMode && !getenv("GITHUB_ACTIONS")) {
|
||||
if (comparer.SaveActualBitmap(Path("__testfailure.bmp")))
|
||||
|
Loading…
Reference in New Issue
Block a user