From c91f9f3a2c4be1d52078478387892ff8f430d417 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 20 Apr 2017 21:09:55 -0700 Subject: [PATCH 1/3] Windows: Fix buffer overflow on load. This was causing headless to crash, not sure what it was doing otherwise. --- Core/PSPLoaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index d94a102fb8..0a7fd9b16c 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -255,7 +255,7 @@ static std::string NormalizePath(const std::string &path) { #ifdef _WIN32 wchar_t buf[512] = {0}; std::wstring wpath = ConvertUTF8ToWString(path); - if (GetFullPathName(wpath.c_str(), sizeof(buf) - 1, buf, NULL) == 0) + if (GetFullPathName(wpath.c_str(), (int)ARRAY_SIZE(buf) - 1, buf, NULL) == 0) return ""; return ConvertWStringToUTF8(buf); #else From 930d6c0558c401e7e73a58ee09f90451eb957acb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 20 Apr 2017 21:10:59 -0700 Subject: [PATCH 2/3] Headless: Fix graphics tests. The draw context wasn't being passed through, so it was segfaulting. --- headless/Headless.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 264973bea7..3bc2ac03dc 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -9,6 +9,7 @@ #include "file/zip_read.h" #include "profiler/profiler.h" #include "Common/FileUtil.h" +#include "Common/GraphicsContext.h" #include "Core/Config.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -292,7 +293,7 @@ int main(int argc, const char* argv[]) host = headlessHost; std::string error_string; - GraphicsContext *graphicsContext; + GraphicsContext *graphicsContext = nullptr; bool glWorking = host->InitGraphics(&error_string, &graphicsContext); LogManager::Init(); @@ -311,6 +312,7 @@ int main(int argc, const char* argv[]) coreParameter.cpuCore = cpuCore; coreParameter.gpuCore = glWorking ? gpuCore : GPUCORE_NULL; coreParameter.graphicsContext = graphicsContext; + coreParameter.thin3d = graphicsContext ? graphicsContext->GetDrawContext() : nullptr; coreParameter.enableSound = false; coreParameter.mountIso = mountIso ? mountIso : ""; coreParameter.mountRoot = mountRoot ? mountRoot : ""; From b483444fab0ca294f9c04aac5fdca98aa31038bd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 20 Apr 2017 21:11:40 -0700 Subject: [PATCH 3/3] IR: Cleanup some invalid ops. --- Core/MIPS/IR/IRCompVFPU.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/MIPS/IR/IRCompVFPU.cpp b/Core/MIPS/IR/IRCompVFPU.cpp index 412e8484f9..f28eba53d6 100644 --- a/Core/MIPS/IR/IRCompVFPU.cpp +++ b/Core/MIPS/IR/IRCompVFPU.cpp @@ -833,6 +833,8 @@ namespace MIPSComp { ir.Write(IROp::FNeg, tempregs[i], tempregs[i]); break; case 28: // d[i] = 1.0f / expf(s[i] * (float)M_LOG2E); break; // vrexp2 + DISABLE; + break; default: INVALIDOP; } @@ -1276,7 +1278,7 @@ namespace MIPSComp { } // Otherwise, n should already be ins + 1. else if (n != ins + 1) { - DISABLE; + INVALIDOP; } u8 sregs[16], dregs[4], tregs[4]; @@ -1895,7 +1897,7 @@ namespace MIPSComp { int n = GetNumVectorElements(sz); if (n != 2 && n != 4) { // Bad instructions - DISABLE; + INVALIDOP; } u8 sregs[4], dregs[4];