Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headless: Update tests and fix crash running tests on Vulkan #16256

Merged
merged 3 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions headless/Compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand All @@ -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();
Expand All @@ -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]);
}
Expand Down Expand Up @@ -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]);
Expand All @@ -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]);
Expand Down
1 change: 1 addition & 0 deletions headless/Compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ScreenshotComparer {
u32 *reference_ = nullptr;
bool asBitmap_ = false;
std::string error_;
u32 referenceStride_ = 0;
u32 stride_;
u32 w_;
u32 h_;
Expand Down
15 changes: 11 additions & 4 deletions headless/Headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -426,7 +427,6 @@ def target():
"gpu/texmtx/uvs",
"gpu/textures/size",
"gpu/triangle/triangle",
"gpu/vertices/texcoords",
"intr/registersub",
"intr/releasesub",
"intr/waits",
Expand Down