CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/headless/HeadlessHost.cpp
Views: 1401
// Copyright (c) 2017- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#include "Common/File/FileUtil.h"18#include "Common/Log.h"19#include "Common/StringUtils.h"20#include "Core/CoreParameter.h"21#include "Core/System.h"22#include "GPU/Common/GPUDebugInterface.h"23#include "headless/Compare.h"24#include "headless/HeadlessHost.h"2526void HeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) {27// Only if we're actually comparing.28if (comparisonScreenshot_.empty()) {29return;30}3132// We ignore the current framebuffer parameters and just grab the full screen.33const static u32 FRAME_STRIDE = 512;34const static u32 FRAME_WIDTH = 480;35const static u32 FRAME_HEIGHT = 272;3637GPUDebugBuffer buffer;38gpuDebug->GetCurrentFramebuffer(buffer, GPU_DBG_FRAMEBUF_DISPLAY);39const std::vector<u32> pixels = TranslateDebugBufferToCompare(&buffer, 512, 272);4041ScreenshotComparer comparer(pixels, FRAME_STRIDE, FRAME_WIDTH, FRAME_HEIGHT);42double errors = comparer.Compare(comparisonScreenshot_);43if (errors < 0)44SendAndCollectOutput(comparer.GetError() + "\n");4546if (errors > maxScreenshotError_)47SendAndCollectOutput(StringFromFormat("Screenshot MSE: %f\n", errors));4849if (errors > maxScreenshotError_ && writeFailureScreenshot_) {50if (comparer.SaveActualBitmap(Path("__testfailure.bmp")))51SendAndCollectOutput("Actual output written to: __testfailure.bmp\n");52comparer.SaveVisualComparisonPNG(Path("__testcompare.png"));53}54}5556void HeadlessHost::SendAndCollectOutput(const std::string &output) {57SendDebugOutput(output);58if (PSP_CoreParameter().collectDebugOutput)59*PSP_CoreParameter().collectDebugOutput += output;60}616263