headless: Remove printfEmuLog, simplify output.

This commit is contained in:
Unknown W. Brackets
2023-03-26 10:17:34 -07:00
parent d8727cb515
commit 76ef95a841
10 changed files with 23 additions and 41 deletions
+2 -2
View File
@@ -142,8 +142,8 @@ inline void System_SetWindowTitle(const std::string &param) {
g_requestManager.MakeSystemRequest(SystemRequestType::SET_WINDOW_TITLE, nullptr, nullptr, param, "", 0);
}
inline void System_SendDebugOutput(const std::string &string) {
g_requestManager.MakeSystemRequest(SystemRequestType::SEND_DEBUG_OUTPUT, nullptr, nullptr, string, "", 0);
inline bool System_SendDebugOutput(const std::string &string) {
return g_requestManager.MakeSystemRequest(SystemRequestType::SEND_DEBUG_OUTPUT, nullptr, nullptr, string, "", 0);
}
inline void System_SendDebugScreenshot(const std::string &data, int height) {
-1
View File
@@ -61,7 +61,6 @@ struct CoreParameter {
std::string errorString;
bool startBreak;
bool printfEmuLog; // writes "emulator:" logging to stdout
std::string *collectEmuLog = nullptr;
bool headLess; // Try to avoid messageboxes etc
+4 -9
View File
@@ -2012,15 +2012,10 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
case EMULATOR_DEVCTL__SEND_OUTPUT:
{
std::string data(Memory::GetCharPointer(argAddr), argLen);
if (PSP_CoreParameter().printfEmuLog) {
System_SendDebugOutput(data);
} else {
if (PSP_CoreParameter().collectEmuLog) {
*PSP_CoreParameter().collectEmuLog += data;
} else {
DEBUG_LOG(SCEIO, "%s", data.c_str());
}
}
if (!System_SendDebugOutput(data))
DEBUG_LOG(SCEIO, "%s", data.c_str());
if (PSP_CoreParameter().collectEmuLog)
*PSP_CoreParameter().collectEmuLog += data;
return 0;
}
case EMULATOR_DEVCTL__IS_EMULATOR:
-1
View File
@@ -305,7 +305,6 @@ void EmuScreen::bootGame(const Path &filename) {
coreParam.mountIso.clear();
coreParam.mountRoot.clear();
coreParam.startBreak = !g_Config.bAutoRun;
coreParam.printfEmuLog = false;
coreParam.headLess = false;
if (g_Config.iInternalResolution == 0) {
-1
View File
@@ -95,7 +95,6 @@ bool RunTests() {
coreParam.mountIso.clear();
coreParam.mountRoot = baseDirectory / "pspautotests";
coreParam.startBreak = false;
coreParam.printfEmuLog = false;
coreParam.headLess = true;
coreParam.renderWidth = 480;
coreParam.renderHeight = 272;
+1 -1
View File
@@ -446,7 +446,6 @@ int main(int argc, const char* argv[])
coreParameter.mountIso = mountIso ? Path(std::string(mountIso)) : Path();
coreParameter.mountRoot = mountRoot ? Path(std::string(mountRoot)) : Path();
coreParameter.startBreak = false;
coreParameter.printfEmuLog = !testOptions.compare;
coreParameter.headLess = true;
coreParameter.renderScaleFactor = 1;
coreParameter.renderWidth = 480;
@@ -523,6 +522,7 @@ int main(int argc, const char* argv[])
if (screenshotFilename)
headlessHost->SetComparisonScreenshot(Path(std::string(screenshotFilename)), testOptions.maxScreenshotError);
headlessHost->SetWriteFailureScreenshot(!teamCityMode && !getenv("GITHUB_ACTIONS") && !testOptions.bench);
headlessHost->SetWriteDebugOutput(!testOptions.compare && !testOptions.bench);
#if PPSSPP_PLATFORM(ANDROID)
// For some reason the debugger installs it with this name?
+3 -13
View File
@@ -24,16 +24,6 @@
#include "headless/Compare.h"
#include "headless/HeadlessHost.h"
void HeadlessHost::SendOrCollectDebugOutput(const std::string &data)
{
if (PSP_CoreParameter().printfEmuLog)
SendDebugOutput(data);
else if (PSP_CoreParameter().collectEmuLog)
*PSP_CoreParameter().collectEmuLog += data;
else
DEBUG_LOG(COMMON, "%s", data.c_str());
}
void HeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) {
// Only if we're actually comparing.
if (comparisonScreenshot_.empty()) {
@@ -52,14 +42,14 @@ void HeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) {
ScreenshotComparer comparer(pixels, FRAME_STRIDE, FRAME_WIDTH, FRAME_HEIGHT);
double errors = comparer.Compare(comparisonScreenshot_);
if (errors < 0)
SendOrCollectDebugOutput(comparer.GetError() + "\n");
SendDebugOutput(comparer.GetError() + "\n");
if (errors > maxScreenshotError_)
SendOrCollectDebugOutput(StringFromFormat("Screenshot MSE: %f\n", errors));
SendDebugOutput(StringFromFormat("Screenshot MSE: %f\n", errors));
if (errors > maxScreenshotError_ && writeFailureScreenshot_) {
if (comparer.SaveActualBitmap(Path("__testfailure.bmp")))
SendOrCollectDebugOutput("Actual output written to: __testfailure.bmp\n");
SendDebugOutput("Actual output written to: __testfailure.bmp\n");
comparer.SaveVisualComparisonPNG(Path("__testcompare.png"));
}
}
+10 -9
View File
@@ -29,23 +29,26 @@ public:
virtual void ShutdownGraphics() {}
virtual void SendDebugOutput(const std::string &output) {
if (!writeDebugOutput_)
return;
if (output.find('\n') != output.npos) {
DoFlushDebugOutput();
FlushDebugOutput();
fwrite(output.data(), sizeof(char), output.length(), stdout);
} else {
debugOutputBuffer_ += output;
}
}
virtual void FlushDebugOutput() {
DoFlushDebugOutput();
}
inline void DoFlushDebugOutput() {
void FlushDebugOutput() {
if (!debugOutputBuffer_.empty()) {
fwrite(debugOutputBuffer_.data(), sizeof(char), debugOutputBuffer_.length(), stdout);
debugOutputBuffer_.clear();
}
}
void SetWriteDebugOutput(bool flag) {
writeDebugOutput_ = flag;
}
void SetComparisonScreenshot(const Path &filename, double maxError) {
comparisonScreenshot_ = filename;
maxScreenshotError_ = maxError;
@@ -54,18 +57,16 @@ public:
writeFailureScreenshot_ = flag;
}
virtual void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h);
void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h);
// Unique for HeadlessHost
virtual void SwapBuffers() {}
protected:
void SendOrCollectDebugOutput(const std::string &output);
Path comparisonScreenshot_;
double maxScreenshotError_ = 0.0;
std::string debugOutputBuffer_;
GPUCore gpuCore_;
GraphicsContext *gfx_ = nullptr;
bool writeFailureScreenshot_ = true;
bool writeDebugOutput_ = true;
};
+3 -3
View File
@@ -66,9 +66,9 @@ HWND CreateHiddenWindow() {
return CreateWindowEx(0, L"PPSSPPHeadless", L"PPSSPPHeadless", style, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, NULL, NULL);
}
void WindowsHeadlessHost::SendDebugOutput(const std::string &output)
{
fwrite(output.data(), sizeof(char), output.length(), stdout);
void WindowsHeadlessHost::SendDebugOutput(const std::string &output) {
if (writeDebugOutput_)
fwrite(output.data(), sizeof(char), output.length(), stdout);
OutputDebugStringUTF8(output.c_str());
}
-1
View File
@@ -1434,7 +1434,6 @@ bool retro_load_game(const struct retro_game_info *game)
coreParam.fileToStart = Path(std::string(game->path));
coreParam.mountIso.clear();
coreParam.startBreak = false;
coreParam.printfEmuLog = true;
coreParam.headLess = true;
coreParam.graphicsContext = ctx;
coreParam.gpuCore = ctx->GetGPUCore();