From f009d150785a9013387494a36ccde5ee0af7ee4e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Oct 2022 21:33:47 -0700 Subject: [PATCH 1/3] headless: Allow screenshot to not be 512x272. Ended up with a cropped screenshot for a frame dump, which just silently crashed. Could reject, but easy enough to support. --- headless/Compare.cpp | 13 ++++++++----- headless/Compare.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/headless/Compare.cpp b/headless/Compare.cpp index 76254d005a23..9c42887342b0 100644 --- a/headless/Compare.cpp +++ b/headless/Compare.cpp @@ -399,6 +399,7 @@ double ScreenshotComparer::Compare(const Path &screenshotFilename) { if (header[0] == 'B' && header[1] == 'M') { reference_ = (u32 *)calloc(stride_ * h_, sizeof(u32)); + referenceStride_ = stride_; asBitmap_ = true; // The bitmap header is 14 + 40 bytes. We could validate it but the test would fail either way. if (reference_ && loader->ReadAt(14 + 40, sizeof(u32), stride_ * h_, reference_) != stride_ * h_) { @@ -424,6 +425,8 @@ double ScreenshotComparer::Compare(const Path &screenshotFilename) { reference_ = nullptr; return -1.0f; } + + referenceStride_ = width; } } else { error_ = "Unable to read screenshot: " + screenshotFilename.ToVisualString(); @@ -439,15 +442,15 @@ double ScreenshotComparer::Compare(const Path &screenshotFilename) { if (asBitmap_) { // The reference is flipped and BGRA by default for the common BMP compare case. for (u32 y = 0; y < h_; ++y) { - u32 yoff = y * stride_; + u32 yoff = y * referenceStride_; for (u32 x = 0; x < w_; ++x) errors += ComparePixel(pixels_[y * stride_ + x], reference_[yoff + x]); } } else { // Just convert to BGRA for simplicity. - ConvertRGBA8888ToBGRA8888(reference_, reference_, h_ * stride_); + ConvertRGBA8888ToBGRA8888(reference_, reference_, h_ * referenceStride_); for (u32 y = 0; y < h_; ++y) { - u32 yoff = (h_ - y - 1) * stride_; + u32 yoff = (h_ - y - 1) * referenceStride_; for (u32 x = 0; x < w_; ++x) errors += ComparePixel(pixels_[y * stride_ + x], reference_[yoff + x]); } @@ -486,7 +489,7 @@ bool ScreenshotComparer::SaveVisualComparisonPNG(const Path &resultFilename) { if (asBitmap_) { // The reference is flipped and BGRA by default for the common BMP compare case. for (u32 y = 0; y < h_; ++y) { - u32 yoff = y * stride_; + u32 yoff = y * referenceStride_; u32 comparisonRow = (h_ - y - 1) * 2 * w_ * 2; for (u32 x = 0; x < w_; ++x) { PlotVisualComparison(comparison.get(), comparisonRow + x * 2, pixels_[y * stride_ + x], reference_[yoff + x]); @@ -495,7 +498,7 @@ bool ScreenshotComparer::SaveVisualComparisonPNG(const Path &resultFilename) { } else { // Reference is already in BGRA either way. for (u32 y = 0; y < h_; ++y) { - u32 yoff = (h_ - y - 1) * stride_; + u32 yoff = (h_ - y - 1) * referenceStride_; u32 comparisonRow = (h_ - y - 1) * 2 * w_ * 2; for (u32 x = 0; x < w_; ++x) { PlotVisualComparison(comparison.get(), comparisonRow + x * 2, pixels_[y * stride_ + x], reference_[yoff + x]); diff --git a/headless/Compare.h b/headless/Compare.h index 0ddd702af8a0..2a59039cdd3b 100644 --- a/headless/Compare.h +++ b/headless/Compare.h @@ -58,6 +58,7 @@ class ScreenshotComparer { u32 *reference_ = nullptr; bool asBitmap_ = false; std::string error_; + u32 referenceStride_ = 0; u32 stride_; u32 w_; u32 h_; From 21573f43028ddcf079e93569556e31c83307c436 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Oct 2022 21:34:59 -0700 Subject: [PATCH 2/3] headless: Fix crash running some tests on Vulkan. If there's no frame display, tests were crashing because no backbuffer present blit happened. This allows those tests to run. --- headless/Headless.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 5b2b8adfd3a3..ff5c3f94b485 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -203,8 +203,9 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const Core_UpdateDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops); PSP_BeginHostFrame(); - if (coreParameter.graphicsContext && coreParameter.graphicsContext->GetDrawContext()) - coreParameter.graphicsContext->GetDrawContext()->BeginFrame(); + Draw::DrawContext *draw = coreParameter.graphicsContext ? coreParameter.graphicsContext->GetDrawContext() : nullptr; + if (draw) + draw->BeginFrame(); bool passed = true; double deadline = time_now_d() + opt.timeout; @@ -238,8 +239,14 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const } PSP_EndHostFrame(); - if (coreParameter.graphicsContext && coreParameter.graphicsContext->GetDrawContext()) - coreParameter.graphicsContext->GetDrawContext()->EndFrame(); + if (draw) { + draw->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Headless"); + // Vulkan may get angry if we don't do a final present. + if (gpu) + gpu->CopyDisplayToOutput(true); + + draw->EndFrame(); + } PSP_Shutdown(); From 01896a82755320eb158c6f1958e192101d0bc101 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Oct 2022 21:35:51 -0700 Subject: [PATCH 3/3] headless: Update passing tests. --- test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index 2ae8d9237d55..4bc6b25ff952 100755 --- a/test.py +++ b/test.py @@ -163,6 +163,7 @@ def target(): "gpu/primitives/indices", "gpu/primitives/invalidprim", "gpu/primitives/points", + "gpu/primitives/rectangles", "gpu/primitives/trianglefan", "gpu/primitives/trianglestrip", "gpu/primitives/triangles", @@ -186,6 +187,7 @@ def target(): "gpu/textures/mipmap", "gpu/textures/rotate", "gpu/vertices/colors", + "gpu/vertices/texcoords", "hash/hash", "hle/check_not_used_uids", "intr/intr", @@ -412,7 +414,6 @@ def target(): "gpu/primitives/immediate", "gpu/primitives/lines", "gpu/primitives/linestrip", - "gpu/primitives/rectangles", "gpu/primitives/spline", "gpu/reflection/reflection", "gpu/rendertarget/rendertarget", @@ -426,7 +427,6 @@ def target(): "gpu/texmtx/uvs", "gpu/textures/size", "gpu/triangle/triangle", - "gpu/vertices/texcoords", "intr/registersub", "intr/releasesub", "intr/waits",