From fcbc20f240094a9cca45ce2e3be0ec379a9c3429 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 24 Feb 2017 18:59:41 +0100 Subject: [PATCH 1/6] Small changes to make Common and Core build under my preliminary UWP setup. --- Common/ArmABI.cpp | 14 +++++++--- Common/ChunkFile.cpp | 12 ++++----- Common/ConsoleListener.cpp | 3 +++ Common/FileUtil.cpp | 30 +++++++++++++++++++--- Common/MemArenaWin32.cpp | 8 ++++++ Common/OSVersion.cpp | 8 ++++++ Common/StringUtils.h | 4 +++ Common/Timer.cpp | 6 +++++ Core/Config.cpp | 2 ++ Core/Core.cpp | 12 ++++++--- Core/FileLoaders/HTTPFileLoader.cpp | 1 + Core/FileSystems/DirectoryFileSystem.cpp | 25 ++++++++++++++---- Core/FileSystems/VirtualDiscFileSystem.cpp | 8 +++++- Core/HLE/sceMpeg.cpp | 7 +++++ Core/HW/SimpleAudioDec.cpp | 2 ++ Core/PSPLoaders.cpp | 9 ++++--- Core/Reporting.cpp | 3 +-- Core/Screenshot.cpp | 8 +++--- Core/System.cpp | 8 +++++- Core/Util/BlockAllocator.cpp | 8 +++--- GPU/GPU.cpp | 14 ++++++++++ Windows/WindowsHost.cpp | 7 +++++ ext/native/base/mutex.h | 2 ++ ext/native/net/http_client.h | 11 +++----- ext/native/thin3d/thin3d.h | 3 ++- ext/native/thread/thread.h | 2 ++ ppsspp_config.h | 6 +++++ 27 files changed, 178 insertions(+), 45 deletions(-) diff --git a/Common/ArmABI.cpp b/Common/ArmABI.cpp index a3781a7eafea..af74470e37f8 100644 --- a/Common/ArmABI.cpp +++ b/Common/ArmABI.cpp @@ -15,6 +15,10 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include "ppsspp_config.h" + +#if PPSSPP_ARCH(ARM) + #include "ArmEmitter.h" #include "ArmABI.h" @@ -108,15 +112,17 @@ void ARMXEmitter::UpdateAPSR(bool NZCVQ, u8 Flags, bool GE, u8 GEval) ARMABI_MOVI2R(R14, Imm); _MSR(true, true, R14); } - else - if(NZCVQ) + else { + if (NZCVQ) { Operand2 value(Flags << 1, 3); _MSR(true, false, value); - } - else if(GE) + } else if (GE) { Operand2 value(GEval << 2, 9); _MSR(false, true, value); } + } } + +#endif \ No newline at end of file diff --git a/Common/ChunkFile.cpp b/Common/ChunkFile.cpp index a3288b27c028..8285f7b514cb 100644 --- a/Common/ChunkFile.cpp +++ b/Common/ChunkFile.cpp @@ -19,6 +19,7 @@ #include #include "ChunkFile.h" +#include "StringUtils.h" PointerWrapSection PointerWrap::Section(const char *title, int ver) { return Section(title, ver, ver); @@ -28,9 +29,8 @@ PointerWrapSection PointerWrap::Section(const char *title, int minVer, int ver) char marker[16] = {0}; int foundVersion = ver; - strncpy(marker, title, sizeof(marker)); - if (!ExpectVoid(marker, sizeof(marker))) - { + truncate_cpy(marker, title); + if (!ExpectVoid(marker, sizeof(marker))) { // Might be before we added name markers for safety. if (foundVersion == 1 && ExpectVoid(&foundVersion, sizeof(foundVersion))) DoMarker(title); @@ -283,13 +283,11 @@ CChunkFileReader::Error CChunkFileReader::SaveFile(const std::string &filename, header.Revision = REVISION_CURRENT; header.ExpectedSize = (u32)sz; header.UncompressedSize = (u32)sz; - strncpy(header.GitVersion, gitVersion, 32); - header.GitVersion[31] = '\0'; + truncate_cpy(header.GitVersion, gitVersion); // Setup the fixed-length title. char titleFixed[128]; - strncpy(titleFixed, title.c_str(), sizeof(titleFixed)); - titleFixed[sizeof(titleFixed) - 1] = '\0'; + truncate_cpy(titleFixed, title.c_str()); // Write to file if (compress) { diff --git a/Common/ConsoleListener.cpp b/Common/ConsoleListener.cpp index 700d3d01fe55..a212daaa3103 100644 --- a/Common/ConsoleListener.cpp +++ b/Common/ConsoleListener.cpp @@ -27,6 +27,7 @@ #include #endif +#include "ppsspp_config.h" #include "thread/threadutil.h" #include "util/text/utf8.h" #include "Common.h" @@ -64,6 +65,8 @@ ConsoleListener::ConsoleListener() : bHidden(true) bUseColor = false; #elif defined(IOS) bUseColor = false; +#elif PPSSPP_PLATFORM(UWP) + bUseColor = false; #else bUseColor = isatty(fileno(stdout)); #endif diff --git a/Common/FileUtil.cpp b/Common/FileUtil.cpp index 05a70d092381..968bcf199330 100644 --- a/Common/FileUtil.cpp +++ b/Common/FileUtil.cpp @@ -22,6 +22,8 @@ #endif #endif +#include "ppsspp_config.h" + #include "FileUtil.h" #include "StringUtils.h" @@ -121,6 +123,9 @@ bool Exists(const std::string &filename) { StripTailDirSlashes(fn); #if defined(_WIN32) +#if PPSSPP_PLATFORM(UWP) + return false; +#else std::wstring copy = ConvertUTF8ToWString(fn); // Make sure Windows will no longer handle critical errors, which means no annoying "No disk" dialog @@ -128,6 +133,7 @@ bool Exists(const std::string &filename) { bool success = GetFileAttributes(copy.c_str()) != INVALID_FILE_ATTRIBUTES; SetErrorMode(OldMode); return success; +#endif #else struct stat64 file_info; return stat64(fn.c_str(), &file_info) == 0; @@ -142,11 +148,12 @@ bool IsDirectory(const std::string &filename) #if defined(_WIN32) std::wstring copy = ConvertUTF8ToWString(fn); - DWORD result = GetFileAttributes(copy.c_str()); - if (result == INVALID_FILE_ATTRIBUTES) { + WIN32_FILE_ATTRIBUTE_DATA data{}; + if (!GetFileAttributesEx(copy.c_str(), GetFileExInfoStandard, &data)) { WARN_LOG(COMMON, "GetFileAttributes failed on %s: %08x", fn.c_str(), GetLastError()); return false; } + DWORD result = data.dwFileAttributes; return (result & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY; #else std::string copy(fn); @@ -328,9 +335,14 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) INFO_LOG(COMMON, "Copy: %s --> %s", srcFilename.c_str(), destFilename.c_str()); #ifdef _WIN32 +#if PPSSPP_PLATFORM(UWP) + if (CopyFile2(ConvertUTF8ToWString(srcFilename).c_str(), ConvertUTF8ToWString(destFilename).c_str(), nullptr)) + return true; + return false; +#else if (CopyFile(ConvertUTF8ToWString(srcFilename).c_str(), ConvertUTF8ToWString(destFilename).c_str(), FALSE)) return true; - +#endif ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); return false; @@ -544,11 +556,15 @@ bool CreateEmptyFile(const std::string &filename) return true; } +#if !PPSSPP_PLATFORM(UWP) + // Deletes the given directory and anything under it. Returns true on success. bool DeleteDirRecursively(const std::string &directory) { INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str()); + #ifdef _WIN32 + // Find the first file in the directory. WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(ConvertUTF8ToWString(directory + "\\*").c_str(), &ffd); @@ -617,6 +633,8 @@ bool DeleteDirRecursively(const std::string &directory) return true; } +#endif + // Create directory and copy contents (does not overwrite existing files) void CopyDir(const std::string &source_path, const std::string &dest_path) { @@ -653,12 +671,17 @@ void CopyDir(const std::string &source_path, const std::string &dest_path) else if (!File::Exists(dest)) File::Copy(source, dest); } closedir(dirp); +#else + ERROR_LOG(COMMON, "CopyDir not supported on this platform"); #endif } void openIniFile(const std::string fileName) { std::string iniFile; #if defined(_WIN32) +#if PPSSPP_PLATFORM(UWP) + // Not supported +#else iniFile = fileName; // Can't rely on a .txt file extension to auto-open in the right editor, // so let's find notepad @@ -690,6 +713,7 @@ void openIniFile(const std::string fileName) { } CloseHandle(pi.hThread); CloseHandle(pi.hProcess); +#endif #elif !defined(MOBILE_DEVICE) #if defined(__APPLE__) iniFile = "open "; diff --git a/Common/MemArenaWin32.cpp b/Common/MemArenaWin32.cpp index 4e7868e3f43c..3a2219712769 100644 --- a/Common/MemArenaWin32.cpp +++ b/Common/MemArenaWin32.cpp @@ -40,12 +40,20 @@ void MemArena::ReleaseSpace() { void *MemArena::CreateView(s64 offset, size_t size, void *base) { size = roundup(size); +#if PPSSPP_PLATFORM(UWP) + // TODO + void *ptr = nullptr; +#else void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base); +#endif return ptr; } void MemArena::ReleaseView(void* view, size_t size) { +#if PPSSPP_PLATFORM(UWP) +#else UnmapViewOfFile(view); +#endif } bool MemArena::NeedsProbing() { diff --git a/Common/OSVersion.cpp b/Common/OSVersion.cpp index 99c6382f8f60..646c0b257999 100644 --- a/Common/OSVersion.cpp +++ b/Common/OSVersion.cpp @@ -1,3 +1,4 @@ +#include "ppsspp_config.h" #ifdef _MSC_VER @@ -6,6 +7,12 @@ #include "Common/CommonWindows.h" bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool greater) { +#if PPSSPP_PLATFORM(UWP) + if (greater) + return true; + else + return major >= 7; +#else uint64_t conditionMask = 0; OSVERSIONINFOEX osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); @@ -25,6 +32,7 @@ bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, u const uint32_t typeMask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR; return VerifyVersionInfo(&osvi, typeMask, conditionMask) != FALSE; +#endif } std::string GetWindowsVersion() { diff --git a/Common/StringUtils.h b/Common/StringUtils.h index a7b699962fc9..5b53423a03b4 100644 --- a/Common/StringUtils.h +++ b/Common/StringUtils.h @@ -23,6 +23,10 @@ void truncate_cpy(char *dest, size_t destSize, const char *src); +template +inline void truncate_cpy(char(&out)[Count], const char *src) { + truncate_cpy(out, Count, src); +} long parseHexLong(std::string s); long parseLong(std::string s); diff --git a/Common/Timer.cpp b/Common/Timer.cpp index b8cc80f1843a..390b315ea465 100644 --- a/Common/Timer.cpp +++ b/Common/Timer.cpp @@ -17,6 +17,8 @@ #include +#include "ppsspp_config.h" + #ifdef _WIN32 #include "CommonWindows.h" #include @@ -34,7 +36,11 @@ namespace Common u32 Timer::GetTimeMs() { #if defined(_WIN32) +#if PPSSPP_PLATFORM(UWP) + return 0; // TODO UWP +#else return timeGetTime(); +#endif #else // REALTIME is probably not a good idea for measuring updates. struct timeval t; diff --git a/Core/Config.cpp b/Core/Config.cpp index 6ce51f07b70c..df0a22392092 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -451,7 +451,9 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("FrameRate", &g_Config.iFpsLimit, 0, true, true), #ifdef _WIN32 ConfigSetting("FrameSkipUnthrottle", &g_Config.bFrameSkipUnthrottle, false, true, true), +#if defined(USING_WIN_UI) ConfigSetting("RestartRequired", &g_Config.bRestartRequired, false, false), +#endif #else ConfigSetting("FrameSkipUnthrottle", &g_Config.bFrameSkipUnthrottle, true), #endif diff --git a/Core/Core.cpp b/Core/Core.cpp index d5862b178504..afc4b698f169 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include #include "base/NativeApp.h" @@ -30,11 +32,9 @@ #include "Core/SaveState.h" #include "Core/System.h" #include "Core/MIPS/MIPS.h" +#include "Common/GraphicsContext.h" #ifdef _WIN32 -#include "Windows/GPU/WindowsGLContext.h" -#include "Windows/GPU/D3D9Context.h" -#include "Windows/GPU/WindowsVulkanContext.h" #include "Windows/InputDevice.h" #endif @@ -131,6 +131,11 @@ bool Core_GetPowerSaving() { } #ifdef _WIN32 +#if PPSSPP_PLATFORM(UWP) +static int ScreenDPI() { + return 96; // TODO UWP +} +#else static int ScreenDPI() { HDC screenDC = GetDC(nullptr); int dotsPerInch = GetDeviceCaps(screenDC, LOGPIXELSY); @@ -138,6 +143,7 @@ static int ScreenDPI() { return dotsPerInch; } #endif +#endif static bool IsWindowSmall(int pixelWidth, int pixelHeight) { // Can't take this from config as it will not be set if windows is maximized. diff --git a/Core/FileLoaders/HTTPFileLoader.cpp b/Core/FileLoaders/HTTPFileLoader.cpp index 4585dee0e927..ec699f5f8dc8 100644 --- a/Core/FileLoaders/HTTPFileLoader.cpp +++ b/Core/FileLoaders/HTTPFileLoader.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include + #include "base/stringutil.h" #include "Common/Common.h" #include "Core/FileLoaders/HTTPFileLoader.h" diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index e6479ee8cb94..879af26bf2e5 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include #include "file/free.h" #include "file/zip_read.h" @@ -215,8 +217,13 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil } else { openmode = OPEN_EXISTING; } - //Let's do it! + + // Let's do it! +#if PPSSPP_PLATFORM(UWP) + hFile = CreateFile2(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, openmode, nullptr); +#else hFile = CreateFile(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, 0, openmode, 0, 0); +#endif bool success = hFile != INVALID_HANDLE_VALUE; if (!success) { DWORD w32err = GetLastError(); @@ -224,7 +231,11 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil if (w32err == ERROR_SHARING_VIOLATION) { // Sometimes, the file is locked for write, let's try again. sharemode |= FILE_SHARE_WRITE; +#if PPSSPP_PLATFORM(UWP) + hFile = CreateFile2(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, openmode, nullptr); +#else hFile = CreateFile(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, 0, openmode, 0, 0); +#endif success = hFile != INVALID_HANDLE_VALUE; if (!success) { w32err = GetLastError(); @@ -380,8 +391,12 @@ size_t DirectoryFileHandle::Seek(s32 position, FileMove type) case FILEMOVE_CURRENT: moveMethod = FILE_CURRENT; break; case FILEMOVE_END: moveMethod = FILE_END; break; } - DWORD newPos = SetFilePointer(hFile, (LONG)position, 0, moveMethod); - return newPos; + + LARGE_INTEGER distance; + distance.QuadPart = position; + LARGE_INTEGER cursor; + DWORD newPos = SetFilePointerEx(hFile, distance, &cursor, moveMethod); + return cursor.QuadPart; #else int moveMethod = 0; switch (type) { @@ -512,7 +527,7 @@ int DirectoryFileSystem::RenameFile(const std::string &from, const std::string & const char * fullToC = fullTo.c_str(); #ifdef _WIN32 - bool retValue = (MoveFile(ConvertUTF8ToWString(fullFrom).c_str(), ConvertUTF8ToWString(fullToC).c_str()) == TRUE); + bool retValue = (MoveFileEx(ConvertUTF8ToWString(fullFrom).c_str(), ConvertUTF8ToWString(fullToC).c_str(), 0) == TRUE); #else bool retValue = (0 == rename(fullFrom.c_str(), fullToC)); #endif @@ -742,7 +757,7 @@ std::vector DirectoryFileSystem::GetDirListing(std::string path) { std::string w32path = GetLocalPath(path) + "\\*.*"; - hFind = FindFirstFile(ConvertUTF8ToWString(w32path).c_str(), &findData); + hFind = FindFirstFileEx(ConvertUTF8ToWString(w32path).c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); if (hFind == INVALID_HANDLE_VALUE) { return myVector; //the empty list diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 544b19502d92..872a1c00b6e0 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include "Common/FileUtil.h" #include "Common/StringUtils.h" #include "Common/ChunkFile.h" @@ -668,7 +670,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(std::string path) std::string w32path = GetLocalPath(path) + "\\*.*"; - hFind = FindFirstFile(ConvertUTF8ToWString(w32path).c_str(), &findData); + hFind = FindFirstFileEx(ConvertUTF8ToWString(w32path).c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); if (hFind == INVALID_HANDLE_VALUE) { return myVector; //the empty list @@ -806,6 +808,8 @@ void VirtualDiscFileSystem::HandlerLogger(void *arg, HandlerHandle handle, LogTy } } +#if !PPSSPP_PLATFORM(UWP) + VirtualDiscFileSystem::Handler::Handler(const char *filename, VirtualDiscFileSystem *const sys) { #ifdef _WIN32 #define dlopen(name, ignore) (void *)LoadLibrary(ConvertUTF8ToWString(name).c_str()) @@ -852,3 +856,5 @@ VirtualDiscFileSystem::Handler::~Handler() { #endif } } + +#endif \ No newline at end of file diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index e8e523e89fee..4e51cda3ed0b 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -901,6 +901,8 @@ static H264Frames *pmpframes; // decode pmp video to RGBA format static bool decodePmpVideo(PSPPointer ringbuffer, u32 pmpctxAddr){ + +#ifdef USE_FFMPEG // the current video is pmp iff pmp_videoSource is a valid addresse MpegContext* ctx = getMpegCtx(pmpctxAddr); if (Memory::IsValidAddress(pmp_videoSource)){ @@ -1014,6 +1016,9 @@ static bool decodePmpVideo(PSPPointer ringbuffer, u32 pmpctxA } // not a pmp video, return false return false; +#else + return false; +#endif } @@ -1098,6 +1103,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr ctx->mediaengine->setVideoStream(avcAu.esBuffer); if (ispmp){ +#ifdef USE_FFMPEG while (pmp_queue.size() != 0){ // playing all pmp_queue frames ctx->mediaengine->m_pFrameRGB = pmp_queue.front(); @@ -1110,6 +1116,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr hleDelayResult(0, "pmp video decode", 30); pmp_queue.pop_front(); } +#endif } else if(ctx->mediaengine->stepVideo(ctx->videoPixelMode)) { int bufferSize = ctx->mediaengine->writeVideoImage(buffer, frameWidth, ctx->videoPixelMode); diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index 093e707dab37..05d36541f841 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -134,6 +134,7 @@ void SimpleAudio::SetChannels(int channels) { // Do nothing, already set. return; } +#ifdef USE_FFMPEG if (codecOpen_) { ERROR_LOG(ME, "Codec already open, cannot change channels"); @@ -142,6 +143,7 @@ void SimpleAudio::SetChannels(int channels) { codecCtx_->channels = channels_; codecCtx_->channel_layout = channels_ == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; } +#endif } SimpleAudio::~SimpleAudio() { diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index 36cc3e874243..1985949faa1f 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "file/file_util.h" +#include "util/text/utf8.h" #include "Common/StringUtils.h" @@ -249,15 +250,17 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) { static std::string NormalizePath(const std::string &path) { #ifdef _WIN32 - char buf[512] = {0}; - if (GetFullPathNameA(path.c_str(), sizeof(buf) - 1, buf, NULL) == 0) + wchar_t buf[512] = {0}; + std::wstring wpath = ConvertUTF8ToWString(path); + if (GetFullPathName(wpath.c_str(), sizeof(buf) - 1, buf, NULL) == 0) return ""; + return ConvertWStringToUTF8(buf); #else char buf[PATH_MAX + 1]; if (realpath(path.c_str(), buf) == NULL) return ""; -#endif return buf; +#endif } bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) { diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index cbe150e2b3f2..2c0a2ca5d40d 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -32,7 +32,6 @@ #include "Core/ELF/ParamSFO.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" -#include "GPU/GLES/FramebufferManagerGLES.h" #include "net/http_client.h" #include "net/resolve.h" #include "net/url.h" @@ -452,7 +451,7 @@ namespace Reporting bool IsSupported() { // Disabled when using certain hacks, because they make for poor reports. - if (g_Config.iRenderingMode >= FBO_READFBOMEMORY_MIN) + if (g_Config.iRenderingMode >= 2) // FBO_READFBOMEMORY_MIN return false; if (g_Config.bTimerHack) return false; diff --git a/Core/Screenshot.cpp b/Core/Screenshot.cpp index e4bce8d542d3..51900e8de7f6 100644 --- a/Core/Screenshot.cpp +++ b/Core/Screenshot.cpp @@ -15,6 +15,9 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + +#include #ifdef USING_QT_UI #include #else @@ -26,11 +29,8 @@ #include "Common/FileUtil.h" #include "Core/Config.h" #include "Core/Screenshot.h" +#include "Core/Core.h" #include "GPU/Common/GPUDebugInterface.h" -#ifdef _WIN32 -#include "GPU/Directx9/GPU_DX9.h" -#endif -#include "GPU/GLES/GPU_GLES.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" diff --git a/Core/System.cpp b/Core/System.cpp index a5d764ed5961..342bd44c6ec8 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #ifdef _WIN32 #pragma warning(disable:4091) #include "Common/CommonWindows.h" @@ -616,10 +618,14 @@ void InitSysDirectories() { g_Config.flash0Directory = path + "flash0/"; // Detect the "My Documents"(XP) or "Documents"(on Vista/7/8) folder. +#if PPSSPP_PLATFORM(UWP) + const std::string myDocsPath = ""; // TODO UWP + const HRESULT result = E_FAIL; +#else wchar_t myDocumentsPath[MAX_PATH]; const HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, myDocumentsPath); const std::string myDocsPath = ConvertWStringToUTF8(myDocumentsPath) + "/PPSSPP/"; - +#endif const std::string installedFile = path + "installed.txt"; const bool installed = File::Exists(installedFile); diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index 0dbeeee2f051..2d7e5e67f5b9 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -19,6 +19,7 @@ #include "Common/Log.h" #include "Common/ChunkFile.h" +#include "Common/StringUtils.h" #include "Core/Util/BlockAllocator.h" #include "Core/Reporting.h" @@ -480,16 +481,15 @@ void BlockAllocator::DoState(PointerWrap &p) BlockAllocator::Block::Block(u32 _start, u32 _size, bool _taken, Block *_prev, Block *_next) : start(_start), size(_size), taken(_taken), prev(_prev), next(_next) { - strcpy(tag, "(untitled)"); + truncate_cpy(tag, "(untitled)"); } void BlockAllocator::Block::SetTag(const char *_tag) { if (_tag) - strncpy(tag, _tag, 32); + truncate_cpy(tag, _tag); else - strncpy(tag, "---", 32); - tag[31] = 0; + truncate_cpy(tag, "---"); } void BlockAllocator::Block::DoState(PointerWrap &p) diff --git a/GPU/GPU.cpp b/GPU/GPU.cpp index 797c8cbb6320..22147fd94093 100644 --- a/GPU/GPU.cpp +++ b/GPU/GPU.cpp @@ -15,12 +15,19 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include "Common/GraphicsContext.h" #include "Core/Core.h" #include "GPU/GPU.h" #include "GPU/GPUInterface.h" #include "GPU/GLES/GPU_GLES.h" + +#if PPSSPP_PLATFORM(UWP) +#include "GPU/D3D11/GPU_D3D11.h" +#else + #ifndef NO_VULKAN #include "GPU/Vulkan/GPU_Vulkan.h" #endif @@ -32,6 +39,8 @@ #include "GPU/D3D11/GPU_D3D11.h" #endif +#endif + GPUStatistics gpuStats; GPUInterface *gpu; GPUDebugInterface *gpuDebug; @@ -47,6 +56,10 @@ static void SetGPU(T *obj) { #endif bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) { +#if PPSSPP_PLATFORM(UWP) + SetGPU(new GPU_D3D11(ctx, draw)); + return true; +#else switch (PSP_CoreParameter().gpuCore) { case GPUCORE_NULL: SetGPU(new NullGPU()); @@ -83,6 +96,7 @@ bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) { } return gpu != NULL; +#endif } #ifdef USE_CRT_DBG #define new DBG_NEW diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index c42b48dc85e9..dce71a987865 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include // For shell links @@ -47,10 +49,15 @@ #include "Windows/DSoundStream.h" #include "Windows/WindowsHost.h" #include "Windows/MainWindow.h" + +#if PPSSPP_PLATFORM(UWP) +#include "Windows/GPU/D3D11Context.h" +#else #include "Windows/GPU/WindowsGLContext.h" #include "Windows/GPU/WindowsVulkanContext.h" #include "Windows/GPU/D3D9Context.h" #include "Windows/GPU/D3D11Context.h" +#endif #include "Windows/Debugger/DebuggerShared.h" #include "Windows/Debugger/Debugger_Disasm.h" diff --git a/ext/native/base/mutex.h b/ext/native/base/mutex.h index 970db159f2b8..9f017be406b2 100644 --- a/ext/native/base/mutex.h +++ b/ext/native/base/mutex.h @@ -9,7 +9,9 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX #define NOMINMAX +#endif #include #include #include diff --git a/ext/native/net/http_client.h b/ext/native/net/http_client.h index 1469b98a228b..e23360364d78 100644 --- a/ext/native/net/http_client.h +++ b/ext/native/net/http_client.h @@ -1,5 +1,4 @@ -#ifndef _NET_HTTP_HTTP_CLIENT -#define _NET_HTTP_HTTP_CLIENT +#pragma once #include #include @@ -9,7 +8,9 @@ #include "thread/thread.h" #ifdef _WIN32 +#ifndef NOMINMAX #define NOMINMAX +#endif #include #else #include @@ -165,8 +166,4 @@ class Downloader { std::vector> downloads_; }; - -} // http - -#endif // _NET_HTTP_HTTP_CLIENT - +} // http \ No newline at end of file diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index e81593d5ef85..11cfb5e1225f 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -16,8 +16,9 @@ class Matrix4x4; #ifdef _WIN32 - +#ifndef NOMINMAX #define NOMINMAX +#endif #define WIN32_LEAN_AND_MEAN #include diff --git a/ext/native/thread/thread.h b/ext/native/thread/thread.h index 538c22029e8c..057afb02c51b 100644 --- a/ext/native/thread/thread.h +++ b/ext/native/thread/thread.h @@ -29,7 +29,9 @@ // WIN32 #define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX #define NOMINMAX +#endif #include #if defined(_MSC_VER) && defined(_MT) diff --git a/ppsspp_config.h b/ppsspp_config.h index 0148255cd925..ec4f1659d04d 100644 --- a/ppsspp_config.h +++ b/ppsspp_config.h @@ -76,6 +76,12 @@ #if defined(_WIN32) // Covers both 32 and 64bit Windows #define PPSSPP_PLATFORM_WINDOWS 1 + // UWP trickery + #ifdef WINAPI_FAMILY + #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + #define PPSSPP_PLATFORM_UWP 1 + #endif + #endif #elif defined(__APPLE__) #include #if TARGET_IPHONE_SIMULATOR From f5fa238e22329be4ac0fb9489771acec12b45ada Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 24 Feb 2017 20:26:38 +0100 Subject: [PATCH 2/6] More minor changes to make GPU and native build on UWP later --- GPU/Common/DepalettizeShaderCommon.cpp | 8 +++++--- GPU/Common/GPUStateUtils.h | 2 ++ GPU/Common/SplineCommon.cpp | 2 +- GPU/D3D11/StencilBufferD3D11.cpp | 1 - GPU/Directx9/PixelShaderGeneratorDX9.cpp | 1 - ext/native/base/timeutil.cpp | 9 ++++----- ext/native/file/file_util.cpp | 13 +++++++------ ext/native/gfx_es2/draw_buffer.cpp | 2 -- ext/native/gfx_es2/gpu_features.cpp | 2 +- ext/native/thin3d/thin3d_d3d11.cpp | 8 ++++++++ 10 files changed, 28 insertions(+), 20 deletions(-) diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index 29f68ce07886..6b6125cf1d17 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -15,15 +15,17 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include +#include +#include "gfx_es2/gpu_features.h" + +#include "GPU/Common/ShaderId.h" +#include "GPU/Common/ShaderCommon.h" #include "Common/Log.h" #include "Core/Reporting.h" #include "GPU/GPUState.h" -#include "ext/native/gfx/GLStateCache.h" #include "GPU/Common/DepalettizeShaderCommon.h" - #define WRITE p+=sprintf // TODO: Add a compute shader path. Complete waste of time to set up a graphics state. diff --git a/GPU/Common/GPUStateUtils.h b/GPU/Common/GPUStateUtils.h index efde6834595f..e6b231d8e16d 100644 --- a/GPU/Common/GPUStateUtils.h +++ b/GPU/Common/GPUStateUtils.h @@ -1,5 +1,7 @@ #pragma once +#include "Common/CommonTypes.h" + #include "GPU/ge_constants.h" // TODO: Replace enums and structs with same from thin3d.h, for convenient mapping. diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index 2da30a203162..f9fae37606f6 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -1023,7 +1023,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi // Bezier patches share less control points than spline patches. Otherwise they are pretty much the same (except bezier don't support the open/close thing) int num_patches_u = (count_u - 1) / 3; int num_patches_v = (count_v - 1) / 3; - BezierPatch *patches; + BezierPatch *patches = nullptr; if (g_Config.bHardwareTessellation && g_Config.bHardwareTransform && !g_Config.bSoftwareRendering) { for (int idx = 0; idx < count_u * count_v; idx++) { SimpleVertex *point = simplified_control_points + (indices ? idxConv.convert(idx) : idx); diff --git a/GPU/D3D11/StencilBufferD3D11.cpp b/GPU/D3D11/StencilBufferD3D11.cpp index e585dd479231..59998c8842e3 100644 --- a/GPU/D3D11/StencilBufferD3D11.cpp +++ b/GPU/D3D11/StencilBufferD3D11.cpp @@ -19,7 +19,6 @@ #include "base/logging.h" -#include "gfx/d3d9_state.h" #include "ext/native/thin3d/thin3d.h" #include "Core/Reporting.h" #include "GPU/D3D11/FramebufferManagerD3D11.h" diff --git a/GPU/Directx9/PixelShaderGeneratorDX9.cpp b/GPU/Directx9/PixelShaderGeneratorDX9.cpp index a90bfa387281..c5a1b8195247 100644 --- a/GPU/Directx9/PixelShaderGeneratorDX9.cpp +++ b/GPU/Directx9/PixelShaderGeneratorDX9.cpp @@ -19,7 +19,6 @@ #include "Core/Reporting.h" #include "Core/Config.h" -#include "gfx/d3d9_shader.h" #include "GPU/Directx9/PixelShaderGeneratorDX9.h" #include "GPU/ge_constants.h" #include "GPU/Common/GPUStateUtils.h" diff --git a/ext/native/base/timeutil.cpp b/ext/native/base/timeutil.cpp index f1f7d6d30ad0..8a8c5065d7ba 100644 --- a/ext/native/base/timeutil.cpp +++ b/ext/native/base/timeutil.cpp @@ -1,18 +1,17 @@ +#include + #include "base/basictypes.h" #include "base/logging.h" #include "base/timeutil.h" -// For NV time functions. Ugly! -#include "gfx/gl_common.h" -#include "gfx_es2/gpu_features.h" - #ifdef _WIN32 #include #else +#include "gfx/gl_common.h" +#include "gfx_es2/gpu_features.h" #include #include #endif -#include static double curtime = 0; static float curtime_f = 0; diff --git a/ext/native/file/file_util.cpp b/ext/native/file/file_util.cpp index 58b75fab286b..ea5dcdc8bc46 100644 --- a/ext/native/file/file_util.cpp +++ b/ext/native/file/file_util.cpp @@ -1,3 +1,5 @@ +#include "ppsspp_config.h" + #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -215,12 +217,7 @@ size_t getFilesInDir(const char *directory, std::vector *files, const #ifdef _WIN32 // Find the first file in the directory. WIN32_FIND_DATA ffd; -#ifdef UNICODE - - HANDLE hFind = FindFirstFile((ConvertUTF8ToWString(directory) + L"\\*").c_str(), &ffd); -#else - HANDLE hFind = FindFirstFile((std::string(directory) + "\\*").c_str(), &ffd); -#endif + HANDLE hFind = FindFirstFileEx((ConvertUTF8ToWString(directory) + L"\\*").c_str(), FindExInfoStandard, &ffd, FindExSearchNameMatch, NULL, 0); if (hFind == INVALID_HANDLE_VALUE) { FindClose(hFind); return 0; @@ -296,6 +293,9 @@ size_t getFilesInDir(const char *directory, std::vector *files, const // Returns a vector with the device names std::vector getWindowsDrives() { +#if PPSSPP_PLATFORM(UWP) + return std::vector(); // TODO UWP http://stackoverflow.com/questions/37404405/how-to-get-logical-drives-names-in-windows-10 +#else std::vector drives; const DWORD buffsize = GetLogicalDriveStrings(0, NULL); @@ -315,5 +315,6 @@ std::vector getWindowsDrives() } } return drives; +#endif } #endif diff --git a/ext/native/gfx_es2/draw_buffer.cpp b/ext/native/gfx_es2/draw_buffer.cpp index 7cbf5d9ba0e7..594cf7eb5ecd 100644 --- a/ext/native/gfx_es2/draw_buffer.cpp +++ b/ext/native/gfx_es2/draw_buffer.cpp @@ -9,10 +9,8 @@ #include "math/math_util.h" #include "gfx/texture_atlas.h" #include "gfx/gl_debug_log.h" -#include "gfx/gl_common.h" #include "gfx_es2/draw_buffer.h" #include "gfx_es2/draw_text.h" -#include "gfx_es2/glsl_program.h" #include "util/text/utf8.h" #include "util/text/wrap_text.h" diff --git a/ext/native/gfx_es2/gpu_features.cpp b/ext/native/gfx_es2/gpu_features.cpp index f020e1a42203..ca4e48faff22 100644 --- a/ext/native/gfx_es2/gpu_features.cpp +++ b/ext/native/gfx_es2/gpu_features.cpp @@ -5,7 +5,7 @@ #include "gfx/gl_common.h" #include "gfx_es2/gpu_features.h" -#ifdef _WIN32 +#if defined(_WIN32) #include "GL/wglew.h" #endif diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index f44961f9ceb1..596a49338b76 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -1,3 +1,5 @@ +#include "ppsspp_config.h" + #include "thin3d/thin3d.h" #include "thin3d/d3d11_loader.h" #include "math/dataconv.h" @@ -168,10 +170,16 @@ class D3D11DrawContext : public DrawContext { }; static void GetRes(HWND hWnd, int &xres, int &yres) { +#if PPSSPP_PLATFORM(UWP) + // TEMPORARY TODO UWP + xres = 1024; + yres = 768; +#else RECT rc; GetClientRect(hWnd, &rc); xres = rc.right - rc.left; yres = rc.bottom - rc.top; +#endif } D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Device1 *device1, ID3D11DeviceContext1 *deviceContext1, HWND hWnd) From fa80cfa4aad0ef2bd4c89525ebf074d059b991a1 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 24 Feb 2017 20:50:27 +0100 Subject: [PATCH 3/6] Additional UWP preparations --- Common/Crypto/md5.cpp | 33 ----------------------------- Common/Crypto/sha1.cpp | 32 ---------------------------- Common/OSVersion.cpp | 19 +++++++++++++++++ Common/OSVersion.h | 1 + GPU/Common/ShaderId.h | 1 + GPU/GLES/FramebufferManagerGLES.cpp | 2 +- GPU/GLES/FramebufferManagerGLES.h | 3 +-- UI/EmuScreen.cpp | 17 +++++++++++---- UI/GameScreen.cpp | 4 +++- UI/GameSettingsScreen.cpp | 17 +++++++++++---- UI/NativeApp.cpp | 11 +++++----- Windows/DSoundStream.cpp | 2 ++ Windows/GPU/D3D9Context.cpp | 1 + Windows/W32Util/Misc.cpp | 20 ++++++----------- Windows/W32Util/Misc.h | 7 +----- 15 files changed, 69 insertions(+), 101 deletions(-) diff --git a/Common/Crypto/md5.cpp b/Common/Crypto/md5.cpp index 7fff7713da27..22a83956563f 100644 --- a/Common/Crypto/md5.cpp +++ b/Common/Crypto/md5.cpp @@ -35,7 +35,6 @@ #include "md5.h" #include -#include /* * 32-bit integer manipulation macros (little endian) @@ -291,38 +290,6 @@ void md5( unsigned char *input, int ilen, unsigned char output[16] ) memset( &ctx, 0, sizeof( md5_context ) ); } -/* - * output = MD5( file contents ) - */ -int md5_file( char *path, unsigned char output[16] ) -{ - FILE *f; - size_t n; - md5_context ctx; - unsigned char buf[1024]; - - if( ( f = fopen( path, "rb" ) ) == NULL ) - return( 1 ); - - md5_starts( &ctx ); - - while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) - md5_update( &ctx, buf, (int) n ); - - md5_finish( &ctx, output ); - - memset( &ctx, 0, sizeof( md5_context ) ); - - if( ferror( f ) != 0 ) - { - fclose( f ); - return( 2 ); - } - - fclose( f ); - return( 0 ); -} - /* * MD5 HMAC context setup */ diff --git a/Common/Crypto/sha1.cpp b/Common/Crypto/sha1.cpp index 17ad93098643..05deccc97fca 100644 --- a/Common/Crypto/sha1.cpp +++ b/Common/Crypto/sha1.cpp @@ -325,38 +325,6 @@ void sha1( unsigned char *input, int ilen, unsigned char output[20] ) memset( &ctx, 0, sizeof( sha1_context ) ); } -/* - * output = SHA-1( file contents ) - */ -int sha1_file( char *path, unsigned char output[20] ) -{ - FILE *f; - size_t n; - sha1_context ctx; - unsigned char buf[1024]; - - if( ( f = fopen( path, "rb" ) ) == NULL ) - return( 1 ); - - sha1_starts( &ctx ); - - while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) - sha1_update( &ctx, buf, (int) n ); - - sha1_finish( &ctx, output ); - - memset( &ctx, 0, sizeof( sha1_context ) ); - - if( ferror( f ) != 0 ) - { - fclose( f ); - return( 2 ); - } - - fclose( f ); - return( 0 ); -} - /* * SHA-1 HMAC context setup */ diff --git a/Common/OSVersion.cpp b/Common/OSVersion.cpp index 646c0b257999..ef60b85ef5ee 100644 --- a/Common/OSVersion.cpp +++ b/Common/OSVersion.cpp @@ -35,6 +35,25 @@ bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, u #endif } +bool IsVistaOrHigher() { +#if PPSSPP_PLATFORM(UWP) + return true; +#else + OSVERSIONINFOEX osvi; + DWORDLONG dwlConditionMask = 0; + int op = VER_GREATER_EQUAL; + ZeroMemory(&osvi, sizeof(osvi)); + osvi.dwOSVersionInfoSize = sizeof(osvi); + osvi.dwMajorVersion = 6; // Vista is 6.0 + osvi.dwMinorVersion = 0; + + VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op); + VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op); + + return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE; +#endif +} + std::string GetWindowsVersion() { const bool IsWindowsXPSP2 = DoesVersionMatchWindows(5, 1, 2, 0, false); const bool IsWindowsXPSP3 = DoesVersionMatchWindows(5, 1, 3, 0, false); diff --git a/Common/OSVersion.h b/Common/OSVersion.h index 7e8283fcdba1..2b17d304eb80 100644 --- a/Common/OSVersion.h +++ b/Common/OSVersion.h @@ -4,6 +4,7 @@ #ifdef _MSC_VER +bool IsVistaOrHigher(); bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool acceptGreater); std::string GetWindowsVersion(); std::string GetWindowsSystemArchitecture(); diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index 07060d80e6aa..324c8b73eb39 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "base/basictypes.h" diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 838c88477631..3cc97c5e32a8 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -19,7 +19,7 @@ #include #include "profiler/profiler.h" - +#include "gfx/gl_common.h" #include "gfx_es2/glsl_program.h" #include "thin3d/thin3d.h" diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index 958189a97817..d7081d6a8ca4 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -21,7 +21,6 @@ #include #include -#include "gfx/gl_common.h" #include "ext/native/thin3d/thin3d.h" // Keeps track of allocated FBOs. // Also provides facilities for drawing and later converting raw @@ -40,7 +39,7 @@ class ShaderManagerGLES; // Simple struct for asynchronous PBO readbacks struct AsyncPBO { - GLuint handle; + uint32_t handle; u32 maxSize; u32 fb_address; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 9d8d06a4f3a0..ed04784b289b 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include #include "base/display.h" @@ -69,9 +71,12 @@ #include "UI/InstallZipScreen.h" #include "UI/ProfilerDraw.h" -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) #include "Windows/MainWindow.h" #endif +#if !PPSSPP_PLATFORM(UWP) +#include "gfx/gl_common.h" +#endif #ifndef MOBILE_DEVICE AVIDump avi; @@ -150,15 +155,16 @@ void EmuScreen::bootGame(const std::string &filename) { coreParam.cpuCore = (CPUCore)g_Config.iCpuCore; coreParam.gpuCore = GPUCORE_GLES; switch (GetGPUBackend()) { + case GPUBackend::DIRECT3D11: + coreParam.gpuCore = GPUCORE_DIRECTX11; + break; +#if !PPSSPP_PLATFORM(UWP) case GPUBackend::OPENGL: coreParam.gpuCore = GPUCORE_GLES; break; case GPUBackend::DIRECT3D9: coreParam.gpuCore = GPUCORE_DIRECTX9; break; - case GPUBackend::DIRECT3D11: - coreParam.gpuCore = GPUCORE_DIRECTX11; - break; case GPUBackend::VULKAN: coreParam.gpuCore = GPUCORE_VULKAN; if (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) { @@ -172,6 +178,7 @@ void EmuScreen::bootGame(const std::string &filename) { #endif } break; +#endif } if (g_Config.bSoftwareRendering) { coreParam.gpuCore = GPUCORE_SOFTWARE; @@ -228,6 +235,7 @@ void EmuScreen::bootComplete() { #endif memset(virtKeys, 0, sizeof(virtKeys)); +#if !PPSSPP_PLATFORM(UWP) if (GetGPUBackend() == GPUBackend::OPENGL) { const char *renderer = (const char*)glGetString(GL_RENDERER); if (strstr(renderer, "Chainfire3D") != 0) { @@ -240,6 +248,7 @@ void EmuScreen::bootComplete() { osm.Show("WARNING: GfxDebugOutput is enabled via ppsspp.ini. Things may be slow.", 10.0f, 0xFF30a0FF, -1, true); } } +#endif if (Core_GetPowerSaving()) { I18NCategory *sy = GetI18NCategory("System"); diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 4d0bccbd2d8e..74d8d5fcbbc3 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -16,6 +16,8 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include + +#include "ppsspp_config.h" #include "base/colorutil.h" #include "base/timeutil.h" #include "gfx_es2/draw_buffer.h" @@ -253,7 +255,7 @@ void GameScreen::update(InputState &input) { } UI::EventReturn GameScreen::OnShowInFolder(UI::EventParams &e) { -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) std::string str = std::string("explorer.exe /select,\"") + ReplaceAll(gamePath_, "/", "\\") + "\""; _wsystem(ConvertUTF8ToWString(str).c_str()); #endif diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3d462e416644..e8a03277110a 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include "base/display.h" // Only to check screen aspect ratio with pixel_yres/pixel_xres #include "base/colorutil.h" @@ -59,8 +61,10 @@ #include #include "util/text/utf8.h" #include "Windows/W32Util/ShellUtil.h" -#include "Windows/W32Util/Misc.h" +#endif +#if !PPSSPP_PLATFORM(UWP) +#include "gfx/gl_common.h" #endif #ifdef IOS @@ -80,6 +84,10 @@ bool GameSettingsScreen::UseVerticalLayout() const { // This needs before run CheckGPUFeatures() // TODO: Remove this if fix the issue bool CheckSupportInstancedTessellation() { +#if PPSSPP_PLATFORM(UWP) + return true; +#else + // TODO: Make work with non-GL backends int maxVertexTextureImageUnits; glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &maxVertexTextureImageUnits); bool vertexTexture = maxVertexTextureImageUnits >= 3; // At least 3 for hardware tessellation @@ -88,6 +96,7 @@ bool CheckSupportInstancedTessellation() { bool textureFloat = gl_extensions.ARB_texture_float || gl_extensions.OES_texture_float || gl_extensions.OES_texture_half_float; return instanceRendering && vertexTexture && textureFloat; +#endif } void GameSettingsScreen::CreateViews() { @@ -647,7 +656,7 @@ void GameSettingsScreen::CreateViews() { #if defined(USING_WIN_UI) systemSettings->Add(new CheckBox(&g_Config.bBypassOSKWithKeyboard, sy->T("Enable Windows native keyboard", "Enable Windows native keyboard"))); #endif -#if defined(_WIN32) +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) SavePathInMyDocumentChoice = systemSettings->Add(new CheckBox(&installed_, sy->T("Save path in My Documents", "Save path in My Documents"))); SavePathInMyDocumentChoice->OnClick.Handle(this, &GameSettingsScreen::OnSavePathMydoc); SavePathInOtherChoice = systemSettings->Add(new CheckBox(&otherinstalled_, sy->T("Save path in installed.txt", "Save path in installed.txt"))); @@ -809,7 +818,7 @@ UI::EventReturn GameSettingsScreen::OnJitAffectingSetting(UI::EventParams &e) { return UI::EVENT_DONE; } -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) UI::EventReturn GameSettingsScreen::OnSavePathMydoc(UI::EventParams &e) { const std::string PPSSPPpath = File::GetExeDirectory(); @@ -987,7 +996,7 @@ void GlobalSettingsScreen::CreateViews() { }*/ void GameSettingsScreen::CallbackRenderingBackend(bool yes) { -#if defined(_WIN32) +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) // If the user ends up deciding not to restart, set the config back to the current backend // so it doesn't get switched by accident. if (yes) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 35c4f9d232f0..f69bea1a870f 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -23,6 +23,7 @@ // // Windows has its own code that bypasses the framework entirely. +#include "ppsspp_config.h" // Background worker threads should be spawned in NativeInit and joined // in NativeShutdown. @@ -268,7 +269,7 @@ void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, boo #endif } -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) bool CheckFontIsUsable(const wchar_t *fontFace) { wchar_t actualFontFace[1024] = { 0 }; @@ -481,7 +482,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch // Note to translators: do not translate this/add this to PPSSPP-lang's files. // It's intended to be custom for every user. // Only add it to your own personal copies of PPSSPP. -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) // TODO: Could allow a setting to specify a font file to load? // TODO: Make this a constant if we can sanely load the font on other systems? AddFontResourceEx(L"assets/Roboto-Condensed.ttf", FR_PRIVATE, NULL); @@ -535,7 +536,7 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) { // memset(&ui_theme, 0, sizeof(ui_theme)); // New style theme -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) ui_theme.uiFont = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 22); ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 15); ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 12); @@ -582,7 +583,7 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) { if (!uiTexture) { PanicAlert("Failed to load ui_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory."); ELOG("Failed to load ui_atlas.zim"); -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) UINT ExitCode = 0; ExitProcess(ExitCode); #endif @@ -1046,7 +1047,7 @@ void NativeShutdown() { exit(0); #endif -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) RemoveFontResourceEx(L"assets/Roboto-Condensed.ttf", FR_PRIVATE, NULL); #endif } diff --git a/Windows/DSoundStream.cpp b/Windows/DSoundStream.cpp index 33c57b7df923..60b000f32e3a 100644 --- a/Windows/DSoundStream.cpp +++ b/Windows/DSoundStream.cpp @@ -4,9 +4,11 @@ #include #include "thread/threadutil.h" +#include "Common/OSVersion.h" #include "Core/Reporting.h" #include "Core/Util/AudioFormat.h" #include "Windows/W32Util/Misc.h" +#include "Common/OSVersion.h" #include "dsoundstream.h" diff --git a/Windows/GPU/D3D9Context.cpp b/Windows/GPU/D3D9Context.cpp index 543ce0229f83..12c5c1244a82 100644 --- a/Windows/GPU/D3D9Context.cpp +++ b/Windows/GPU/D3D9Context.cpp @@ -9,6 +9,7 @@ #include "Core/Config.h" #include "Core/Reporting.h" +#include "Common/OSVersion.h" #include "Windows/GPU/D3D9Context.h" #include "Windows/W32Util/Misc.h" #include "thin3d/thin3d.h" diff --git a/Windows/W32Util/Misc.cpp b/Windows/W32Util/Misc.cpp index ae4905a1c7d0..f7db70d477d9 100644 --- a/Windows/W32Util/Misc.cpp +++ b/Windows/W32Util/Misc.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "ppsspp_config.h" #include "CommonWindows.h" #include @@ -8,19 +9,12 @@ #include "Misc.h" #include "util/text/utf8.h" -bool IsVistaOrHigher() { - OSVERSIONINFOEX osvi; - DWORDLONG dwlConditionMask = 0; - int op = VER_GREATER_EQUAL; - ZeroMemory(&osvi, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(osvi); - osvi.dwMajorVersion = 6; // Vista is 6.0 - osvi.dwMinorVersion = 0; - - VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op); - VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op); - - return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE; +bool KeyDownAsync(int vkey) { +#if PPSSPP_PLATFORM(UWP) + return 0; +#else + return (GetAsyncKeyState(vkey) & 0x8000) != 0; +#endif } namespace W32Util diff --git a/Windows/W32Util/Misc.h b/Windows/W32Util/Misc.h index 2d0030ba0b31..f73e72b5489c 100644 --- a/Windows/W32Util/Misc.h +++ b/Windows/W32Util/Misc.h @@ -2,8 +2,6 @@ #include "Common/CommonWindows.h" -bool IsVistaOrHigher(); - namespace W32Util { void CenterWindow(HWND hwnd); @@ -36,10 +34,7 @@ struct GenericListViewDef // the most significant bit states whether the key is currently down. // simply checking if it's != 0 is not enough, as bit0 is set if // the key was pressed between the last call to GetAsyncKeyState -inline bool KeyDownAsync(int vkey) -{ - return (GetAsyncKeyState(vkey) & 0x8000) != 0; -} +bool KeyDownAsync(int vkey); class GenericListControl { From 03dab0fdbd6ab6347e6fa29ba61c52fbda22314e Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 25 Feb 2017 00:25:46 +0100 Subject: [PATCH 4/6] More UWP prep --- Common/CommonFuncs.h | 5 +- Common/FileUtil.cpp | 8 +-- Common/Vulkan/VulkanContext.cpp | 95 +------------------------- Core/AVIDump.cpp | 55 ++++++++++----- Core/Debugger/SymbolMap.cpp | 3 +- Core/Dialog/PSPSaveDialog.cpp | 2 +- GPU/Common/ShaderCommon.cpp | 101 ++++++++++++++++++++++++++++ GPU/Common/ShaderCommon.h | 5 +- GPU/Common/ShaderTranslation.cpp | 2 +- GPU/Common/SplineCommon.cpp | 2 +- GPU/GPU.cpp | 2 +- GPU/GPU.vcxproj | 1 + GPU/GPU.vcxproj.filters | 3 + GPU/Software/TransformUnit.cpp | 2 +- UI/DevScreens.cpp | 2 + UI/GameSettingsScreen.cpp | 9 ++- UI/MainScreen.cpp | 4 ++ UI/NativeApp.cpp | 4 ++ Windows/MainWindow.h | 7 ++ ext/native/ext/jpge/jpge.cpp | 77 --------------------- ext/native/gfx_es2/draw_text.cpp | 2 +- ext/native/gfx_es2/draw_text.h | 4 +- ext/native/gfx_es2/gpu_features.cpp | 15 ++++- ext/native/net/http_server.cpp | 3 + ext/native/net/sinks.cpp | 2 + ext/udis86/udis86.c | 2 +- ppsspp_config.h | 2 +- 27 files changed, 210 insertions(+), 209 deletions(-) create mode 100644 GPU/Common/ShaderCommon.cpp diff --git a/Common/CommonFuncs.h b/Common/CommonFuncs.h index a1d26ba26d7e..3f885639b73e 100644 --- a/Common/CommonFuncs.h +++ b/Common/CommonFuncs.h @@ -78,10 +78,7 @@ inline u64 __rotr64(u64 x, unsigned int shift){ #if _M_IX86 #define Crash() {__asm int 3} #else -extern "C" { - __declspec(dllimport) void __stdcall DebugBreak(void); -} - #define Crash() {DebugBreak();} + #define Crash() {__debugbreak();} #endif // M_IX86 #endif // WIN32 ndef diff --git a/Common/FileUtil.cpp b/Common/FileUtil.cpp index 968bcf199330..eac8240a9388 100644 --- a/Common/FileUtil.cpp +++ b/Common/FileUtil.cpp @@ -556,11 +556,12 @@ bool CreateEmptyFile(const std::string &filename) return true; } -#if !PPSSPP_PLATFORM(UWP) - // Deletes the given directory and anything under it. Returns true on success. bool DeleteDirRecursively(const std::string &directory) { +#if PPSSPP_PLATFORM(UWP) + return false; +#else INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str()); #ifdef _WIN32 @@ -629,11 +630,10 @@ bool DeleteDirRecursively(const std::string &directory) closedir(dirp); #endif File::DeleteDir(directory); - return true; +#endif } -#endif // Create directory and copy contents (does not overwrite existing files) void CopyDir(const std::string &source_path, const std::string &dest_path) diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index 053aa06a7df5..1cc81ac4144e 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -7,6 +7,7 @@ #include "base/basictypes.h" #include "VulkanContext.h" +#include "GPU/Common/ShaderCommon.h" #ifdef USE_CRT_DBG #undef new @@ -1327,100 +1328,6 @@ void TransitionImageLayout(VkCommandBuffer cmd, VkImage image, VkImageAspectFlag vkCmdPipelineBarrier(cmd, src_stages, dest_stages, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } -void init_resources(TBuiltInResource &Resources) { - Resources.maxLights = 32; - Resources.maxClipPlanes = 6; - Resources.maxTextureUnits = 32; - Resources.maxTextureCoords = 32; - Resources.maxVertexAttribs = 64; - Resources.maxVertexUniformComponents = 4096; - Resources.maxVaryingFloats = 64; - Resources.maxVertexTextureImageUnits = 32; - Resources.maxCombinedTextureImageUnits = 80; - Resources.maxTextureImageUnits = 32; - Resources.maxFragmentUniformComponents = 4096; - Resources.maxDrawBuffers = 32; - Resources.maxVertexUniformVectors = 128; - Resources.maxVaryingVectors = 8; - Resources.maxFragmentUniformVectors = 16; - Resources.maxVertexOutputVectors = 16; - Resources.maxFragmentInputVectors = 15; - Resources.minProgramTexelOffset = -8; - Resources.maxProgramTexelOffset = 7; - Resources.maxClipDistances = 8; - Resources.maxComputeWorkGroupCountX = 65535; - Resources.maxComputeWorkGroupCountY = 65535; - Resources.maxComputeWorkGroupCountZ = 65535; - Resources.maxComputeWorkGroupSizeX = 1024; - Resources.maxComputeWorkGroupSizeY = 1024; - Resources.maxComputeWorkGroupSizeZ = 64; - Resources.maxComputeUniformComponents = 1024; - Resources.maxComputeTextureImageUnits = 16; - Resources.maxComputeImageUniforms = 8; - Resources.maxComputeAtomicCounters = 8; - Resources.maxComputeAtomicCounterBuffers = 1; - Resources.maxVaryingComponents = 60; - Resources.maxVertexOutputComponents = 64; - Resources.maxGeometryInputComponents = 64; - Resources.maxGeometryOutputComponents = 128; - Resources.maxFragmentInputComponents = 128; - Resources.maxImageUnits = 8; - Resources.maxCombinedImageUnitsAndFragmentOutputs = 8; - Resources.maxCombinedShaderOutputResources = 8; - Resources.maxImageSamples = 0; - Resources.maxVertexImageUniforms = 0; - Resources.maxTessControlImageUniforms = 0; - Resources.maxTessEvaluationImageUniforms = 0; - Resources.maxGeometryImageUniforms = 0; - Resources.maxFragmentImageUniforms = 8; - Resources.maxCombinedImageUniforms = 8; - Resources.maxGeometryTextureImageUnits = 16; - Resources.maxGeometryOutputVertices = 256; - Resources.maxGeometryTotalOutputComponents = 1024; - Resources.maxGeometryUniformComponents = 1024; - Resources.maxGeometryVaryingComponents = 64; - Resources.maxTessControlInputComponents = 128; - Resources.maxTessControlOutputComponents = 128; - Resources.maxTessControlTextureImageUnits = 16; - Resources.maxTessControlUniformComponents = 1024; - Resources.maxTessControlTotalOutputComponents = 4096; - Resources.maxTessEvaluationInputComponents = 128; - Resources.maxTessEvaluationOutputComponents = 128; - Resources.maxTessEvaluationTextureImageUnits = 16; - Resources.maxTessEvaluationUniformComponents = 1024; - Resources.maxTessPatchComponents = 120; - Resources.maxPatchVertices = 32; - Resources.maxTessGenLevel = 64; - Resources.maxViewports = 16; - Resources.maxVertexAtomicCounters = 0; - Resources.maxTessControlAtomicCounters = 0; - Resources.maxTessEvaluationAtomicCounters = 0; - Resources.maxGeometryAtomicCounters = 0; - Resources.maxFragmentAtomicCounters = 8; - Resources.maxCombinedAtomicCounters = 8; - Resources.maxAtomicCounterBindings = 1; - Resources.maxVertexAtomicCounterBuffers = 0; - Resources.maxTessControlAtomicCounterBuffers = 0; - Resources.maxTessEvaluationAtomicCounterBuffers = 0; - Resources.maxGeometryAtomicCounterBuffers = 0; - Resources.maxFragmentAtomicCounterBuffers = 1; - Resources.maxCombinedAtomicCounterBuffers = 1; - Resources.maxAtomicCounterBufferSize = 16384; - Resources.maxTransformFeedbackBuffers = 4; - Resources.maxTransformFeedbackInterleavedComponents = 64; - Resources.maxCullDistances = 8; - Resources.maxCombinedClipAndCullDistances = 8; - Resources.maxSamples = 4; - Resources.limits.nonInductiveForLoops = 1; - Resources.limits.whileLoops = 1; - Resources.limits.doWhileLoops = 1; - Resources.limits.generalUniformIndexing = 1; - Resources.limits.generalAttributeMatrixVectorIndexing = 1; - Resources.limits.generalVaryingIndexing = 1; - Resources.limits.generalSamplerIndexing = 1; - Resources.limits.generalVariableIndexing = 1; - Resources.limits.generalConstantMatrixVectorIndexing = 1; -} EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type) { switch (shader_type) { diff --git a/Core/AVIDump.cpp b/Core/AVIDump.cpp index 3074d23eaae1..226f44dabd99 100644 --- a/Core/AVIDump.cpp +++ b/Core/AVIDump.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #ifndef MOBILE_DEVICE + #if defined(__FreeBSD__) #define __STDC_CONSTANT_MACROS 1 #endif @@ -11,6 +12,8 @@ #include #include +#ifdef USE_FFMPEG + extern "C" { #include #include @@ -18,6 +21,8 @@ extern "C" { #include } +#endif + #include "Common/FileUtil.h" #include "Common/MsgHandler.h" #include "Common/ColorConv.h" @@ -29,6 +34,8 @@ extern "C" { #include "GPU/Common/GPUDebugInterface.h" +#ifdef USE_FFMPEG + #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 28, 1) #define av_frame_alloc avcodec_alloc_frame #define av_frame_free avcodec_free_frame @@ -38,8 +45,11 @@ static AVFormatContext* s_format_context = nullptr; static AVStream* s_stream = nullptr; static AVFrame* s_src_frame = nullptr; static AVFrame* s_scaled_frame = nullptr; -static int s_bytes_per_pixel; static SwsContext* s_sws_context = nullptr; + +#endif + +static int s_bytes_per_pixel; static int s_width; static int s_height; static bool s_start_dumping = false; @@ -48,12 +58,12 @@ static int s_current_height; static int s_file_index = 0; static GPUDebugBuffer buf; -static void InitAVCodec() -{ +static void InitAVCodec() { static bool first_run = true; - if (first_run) - { + if (first_run) { +#ifdef USE_FFMPEG av_register_all(); +#endif first_run = false; } } @@ -72,8 +82,8 @@ bool AVIDump::Start(int w, int h) return success; } -bool AVIDump::CreateAVI() -{ +bool AVIDump::CreateAVI() { +#ifdef USE_FFMPEG AVCodec* codec = nullptr; s_format_context = avformat_alloc_context(); @@ -132,15 +142,21 @@ bool AVIDump::CreateAVI() } return true; +#else + return false; +#endif } -static void PreparePacket(AVPacket* pkt) -{ +#ifdef USE_FFMPEG + +static void PreparePacket(AVPacket* pkt) { av_init_packet(pkt); pkt->data = nullptr; pkt->size = 0; } +#endif + void AVIDump::AddFrame() { gpuDebug->GetCurrentFramebuffer(buf, GPU_DBG_FRAMEBUF_DISPLAY); @@ -149,6 +165,9 @@ void AVIDump::AddFrame() CheckResolution(w, h); u8 *flipbuffer = nullptr; const u8 *buffer = ConvertBufferTo888RGB(buf, flipbuffer, w, h); + +#ifdef USE_FFMPEG + s_src_frame->data[0] = const_cast(buffer); s_src_frame->linesize[0] = w * 3; s_src_frame->format = AV_PIX_FMT_RGB24; @@ -194,18 +213,22 @@ void AVIDump::AddFrame() } if (error) ERROR_LOG(G3D, "Error while encoding video: %d", error); +#endif } -void AVIDump::Stop() -{ +void AVIDump::Stop() { +#ifdef USE_FFMPEG + av_write_trailer(s_format_context); CloseFile(); s_file_index = 0; +#endif NOTICE_LOG(G3D, "Stopping frame dump"); } -void AVIDump::CloseFile() -{ +void AVIDump::CloseFile() { +#ifdef USE_FFMPEG + if (s_stream) { if (s_stream->codec) @@ -233,10 +256,11 @@ void AVIDump::CloseFile() sws_freeContext(s_sws_context); s_sws_context = nullptr; } +#endif } -void AVIDump::CheckResolution(int width, int height) -{ +void AVIDump::CheckResolution(int width, int height) { +#ifdef USE_FFMPEG // We check here to see if the requested width and height have changed since the last frame which // was dumped, then create a new file accordingly. However, is it possible for the width and height // to have a value of zero. If this is the case, simply keep the last known resolution of the video @@ -250,5 +274,6 @@ void AVIDump::CheckResolution(int width, int height) s_current_width = width; s_current_height = height; } +#endif USE_FFMPEG } #endif diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index 7528a53673b2..80935a9db627 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -956,7 +956,7 @@ void SymbolMap::GetLabels(std::vector &dest) const } } -#if defined(_WIN32) +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) struct DefaultSymbol { u32 address; @@ -1026,5 +1026,4 @@ void SymbolMap::FillSymbolListBox(HWND listbox,SymbolType symType) const { SendMessage(listbox, WM_SETREDRAW, TRUE, 0); RedrawWindow(listbox, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); } - #endif diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index ef818e70fb74..601bb0b5b8bc 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -323,7 +323,7 @@ void PSPSaveDialog::DisplaySaveList(bool canMove) w = 144; h = 80; x = 27; - b = 1.2; + b = 1.2f; PPGeDrawRect(x-b, y-b, x+w+b, y, CalcFadedColor(0xD0FFFFFF)); // top border PPGeDrawRect(x-b, y, x, y+h, CalcFadedColor(0xD0FFFFFF)); // left border PPGeDrawRect(x-b, y+h, x+w+b, y+h+b, CalcFadedColor(0xD0FFFFFF)); //bottom border diff --git a/GPU/Common/ShaderCommon.cpp b/GPU/Common/ShaderCommon.cpp new file mode 100644 index 000000000000..1cbc7d3be582 --- /dev/null +++ b/GPU/Common/ShaderCommon.cpp @@ -0,0 +1,101 @@ +#ifdef USE_CRT_DBG +#undef new +#endif + + +#include "ext/glslang/SPIRV/GlslangToSpv.h" + +void init_resources(TBuiltInResource &Resources) { + Resources.maxLights = 32; + Resources.maxClipPlanes = 6; + Resources.maxTextureUnits = 32; + Resources.maxTextureCoords = 32; + Resources.maxVertexAttribs = 64; + Resources.maxVertexUniformComponents = 4096; + Resources.maxVaryingFloats = 64; + Resources.maxVertexTextureImageUnits = 32; + Resources.maxCombinedTextureImageUnits = 80; + Resources.maxTextureImageUnits = 32; + Resources.maxFragmentUniformComponents = 4096; + Resources.maxDrawBuffers = 32; + Resources.maxVertexUniformVectors = 128; + Resources.maxVaryingVectors = 8; + Resources.maxFragmentUniformVectors = 16; + Resources.maxVertexOutputVectors = 16; + Resources.maxFragmentInputVectors = 15; + Resources.minProgramTexelOffset = -8; + Resources.maxProgramTexelOffset = 7; + Resources.maxClipDistances = 8; + Resources.maxComputeWorkGroupCountX = 65535; + Resources.maxComputeWorkGroupCountY = 65535; + Resources.maxComputeWorkGroupCountZ = 65535; + Resources.maxComputeWorkGroupSizeX = 1024; + Resources.maxComputeWorkGroupSizeY = 1024; + Resources.maxComputeWorkGroupSizeZ = 64; + Resources.maxComputeUniformComponents = 1024; + Resources.maxComputeTextureImageUnits = 16; + Resources.maxComputeImageUniforms = 8; + Resources.maxComputeAtomicCounters = 8; + Resources.maxComputeAtomicCounterBuffers = 1; + Resources.maxVaryingComponents = 60; + Resources.maxVertexOutputComponents = 64; + Resources.maxGeometryInputComponents = 64; + Resources.maxGeometryOutputComponents = 128; + Resources.maxFragmentInputComponents = 128; + Resources.maxImageUnits = 8; + Resources.maxCombinedImageUnitsAndFragmentOutputs = 8; + Resources.maxCombinedShaderOutputResources = 8; + Resources.maxImageSamples = 0; + Resources.maxVertexImageUniforms = 0; + Resources.maxTessControlImageUniforms = 0; + Resources.maxTessEvaluationImageUniforms = 0; + Resources.maxGeometryImageUniforms = 0; + Resources.maxFragmentImageUniforms = 8; + Resources.maxCombinedImageUniforms = 8; + Resources.maxGeometryTextureImageUnits = 16; + Resources.maxGeometryOutputVertices = 256; + Resources.maxGeometryTotalOutputComponents = 1024; + Resources.maxGeometryUniformComponents = 1024; + Resources.maxGeometryVaryingComponents = 64; + Resources.maxTessControlInputComponents = 128; + Resources.maxTessControlOutputComponents = 128; + Resources.maxTessControlTextureImageUnits = 16; + Resources.maxTessControlUniformComponents = 1024; + Resources.maxTessControlTotalOutputComponents = 4096; + Resources.maxTessEvaluationInputComponents = 128; + Resources.maxTessEvaluationOutputComponents = 128; + Resources.maxTessEvaluationTextureImageUnits = 16; + Resources.maxTessEvaluationUniformComponents = 1024; + Resources.maxTessPatchComponents = 120; + Resources.maxPatchVertices = 32; + Resources.maxTessGenLevel = 64; + Resources.maxViewports = 16; + Resources.maxVertexAtomicCounters = 0; + Resources.maxTessControlAtomicCounters = 0; + Resources.maxTessEvaluationAtomicCounters = 0; + Resources.maxGeometryAtomicCounters = 0; + Resources.maxFragmentAtomicCounters = 8; + Resources.maxCombinedAtomicCounters = 8; + Resources.maxAtomicCounterBindings = 1; + Resources.maxVertexAtomicCounterBuffers = 0; + Resources.maxTessControlAtomicCounterBuffers = 0; + Resources.maxTessEvaluationAtomicCounterBuffers = 0; + Resources.maxGeometryAtomicCounterBuffers = 0; + Resources.maxFragmentAtomicCounterBuffers = 1; + Resources.maxCombinedAtomicCounterBuffers = 1; + Resources.maxAtomicCounterBufferSize = 16384; + Resources.maxTransformFeedbackBuffers = 4; + Resources.maxTransformFeedbackInterleavedComponents = 64; + Resources.maxCullDistances = 8; + Resources.maxCombinedClipAndCullDistances = 8; + Resources.maxSamples = 4; + Resources.limits.nonInductiveForLoops = 1; + Resources.limits.whileLoops = 1; + Resources.limits.doWhileLoops = 1; + Resources.limits.generalUniformIndexing = 1; + Resources.limits.generalAttributeMatrixVectorIndexing = 1; + Resources.limits.generalVaryingIndexing = 1; + Resources.limits.generalSamplerIndexing = 1; + Resources.limits.generalVariableIndexing = 1; + Resources.limits.generalConstantMatrixVectorIndexing = 1; +} \ No newline at end of file diff --git a/GPU/Common/ShaderCommon.h b/GPU/Common/ShaderCommon.h index 4392e4ae4d15..5cf3c05c1438 100644 --- a/GPU/Common/ShaderCommon.h +++ b/GPU/Common/ShaderCommon.h @@ -113,4 +113,7 @@ class ShaderManagerCommon { virtual ~ShaderManagerCommon() {} virtual void DirtyLastShader() = 0; -}; \ No newline at end of file +}; + +struct TBuiltInResource; +void init_resources(TBuiltInResource &Resources); diff --git a/GPU/Common/ShaderTranslation.cpp b/GPU/Common/ShaderTranslation.cpp index fdf79d5c6835..675451fca619 100644 --- a/GPU/Common/ShaderTranslation.cpp +++ b/GPU/Common/ShaderTranslation.cpp @@ -15,7 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#ifndef ANDROID +#if !defined(ANDROID) #include #include diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index f9fae37606f6..d53b75202f08 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -456,7 +456,7 @@ static void SplinePatchFullQuality(u8 *&dest, u16 *indices, int &count, const Sp char temp[512]; snprintf(temp, sizeof(temp), "count_u: %d count_v: %d patch_w: %d patch_h: %d ii: %d jj: %d iu: %d iv: %d patch_div_s: %d patch_div_t: %d\n", spatch.count_u, spatch.count_v, patch_w, patch_h, ii, jj, iu, iv, patch_div_s, patch_div_t); OutputDebugStringA(temp); - DebugBreak(); + Crash(); }*/ SimpleVertex *a = spatch.points[idx]; AccumulateWeighted(vert_pos, a->pos, fv); diff --git a/GPU/GPU.cpp b/GPU/GPU.cpp index 22147fd94093..0cd5c85c4998 100644 --- a/GPU/GPU.cpp +++ b/GPU/GPU.cpp @@ -22,11 +22,11 @@ #include "GPU/GPU.h" #include "GPU/GPUInterface.h" -#include "GPU/GLES/GPU_GLES.h" #if PPSSPP_PLATFORM(UWP) #include "GPU/D3D11/GPU_D3D11.h" #else +#include "GPU/GLES/GPU_GLES.h" #ifndef NO_VULKAN #include "GPU/Vulkan/GPU_Vulkan.h" diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index 281010b16fba..ec6a24e1aa9d 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -273,6 +273,7 @@ + diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters index 931b4a97d044..9032efdb16a2 100644 --- a/GPU/GPU.vcxproj.filters +++ b/GPU/GPU.vcxproj.filters @@ -507,5 +507,8 @@ Common + + Common + \ No newline at end of file diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index c45bc37c0ec6..5fd39c6974b2 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -19,7 +19,7 @@ #include "Core/Host.h" #include "Core/Config.h" #include "GPU/GPUState.h" -#include "GPU/GLES/DrawEngineGLES.h" +#include "GPU/Common/DrawEngineCommon.h" #include "GPU/Common/VertexDecoderCommon.h" #include "GPU/Common/SplineCommon.h" diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 1a3b236a1624..d98e4b464652 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -359,9 +359,11 @@ void SystemInfoScreen::CreateViews() { deviceSpecs->Add(new InfoItem("Model", draw->GetInfoString(InfoField::RENDERER))); #ifdef _WIN32 deviceSpecs->Add(new InfoItem("Driver Version", System_GetProperty(SYSPROP_GPUDRIVER_VERSION))); +#if !PPSSPP_PLATFORM(UWP) if (GetGPUBackend() == GPUBackend::DIRECT3D9) { deviceSpecs->Add(new InfoItem("D3DX Version", StringFromFormat("%d", GetD3DXVersion()))); } +#endif #endif deviceSpecs->Add(new ItemHeader("OS Information")); deviceSpecs->Add(new InfoItem("Memory Page Size", StringFromFormat("%d bytes", GetMemoryProtectPageSize()))); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index e8a03277110a..5dfe5eeeb236 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -25,6 +25,7 @@ #include "gfx_es2/gpu_features.h" #include "gfx_es2/draw_buffer.h" #include "i18n/i18n.h" +#include "util/text/utf8.h" #include "ui/view.h" #include "ui/viewgroup.h" #include "ui/ui_context.h" @@ -55,11 +56,10 @@ #include "GPU/GPUInterface.h" #include "GPU/GLES/FramebufferManagerGLES.h" -#if defined(_WIN32) +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) #pragma warning(disable:4091) // workaround bug in VS2015 headers #include "Windows/MainWindow.h" #include -#include "util/text/utf8.h" #include "Windows/W32Util/ShellUtil.h" #endif @@ -1176,8 +1176,10 @@ void DeveloperToolsScreen::CreateViews() { list->Add(new CheckBox(&g_Config.bShowDeveloperMenu, dev->T("Show Developer Menu"))); list->Add(new CheckBox(&g_Config.bDumpDecryptedEboot, dev->T("Dump Decrypted Eboot", "Dump Decrypted EBOOT.BIN (If Encrypted) When Booting Game"))); +#if !PPSSPP_PLATFORM(UWP) Choice *cpuTests = new Choice(dev->T("Run CPU Tests")); list->Add(cpuTests)->OnClick.Handle(this, &DeveloperToolsScreen::OnRunCPUTests); + #ifdef IOS const std::string testDirectory = g_Config.flash0Directory + "../"; #else @@ -1186,6 +1188,7 @@ void DeveloperToolsScreen::CreateViews() { if (!File::Exists(testDirectory + "pspautotests/tests/")) { cpuTests->SetEnabled(false); } +#endif list->Add(new CheckBox(&g_Config.bEnableLogging, dev->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged); list->Add(new Choice(dev->T("Logging Channels")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLogConfig); @@ -1237,7 +1240,9 @@ UI::EventReturn DeveloperToolsScreen::OnLoggingChanged(UI::EventParams &e) { } UI::EventReturn DeveloperToolsScreen::OnRunCPUTests(UI::EventParams &e) { +#if !PPSSPP_PLATFORM(UWP) RunTests(); +#endif return UI::EVENT_DONE; } diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index b014a0888ccc..b8ccc4042e9b 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -430,11 +430,15 @@ UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) { else return UI::EVENT_DONE; #elif defined(_WIN32) +#if PPSSPP_PLATFORM(UWP) + // TODO UWP +#else I18NCategory *mm = GetI18NCategory("MainMenu"); std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), mm->T("Choose folder")); if (!folder.size()) return UI::EVENT_DONE; path_.SetPath(folder); +#endif #else path_.SetPath(getenv("HOME")); #endif diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index f69bea1a870f..b2ba6ad4ea80 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -634,7 +634,11 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) { #ifdef _WIN32 winAudioBackend = CreateAudioBackend((AudioBackendType)g_Config.iAudioBackend); +#if PPSSPP_PLATFORM(UWP) + // TODO UWP +#else winAudioBackend->Init(MainWindow::GetHWND(), &Win32Mix, 44100); +#endif #endif g_gameInfoCache = new GameInfoCache(); diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index c03b2b2687e4..17d8a8651ec6 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -1,11 +1,16 @@ #pragma once +#include "ppsspp_config.h" + +#if !PPSSPP_PLATFORM(UWP) + #include "Common/CommonWindows.h" #include #include "Core/System.h" #include "MainWindowMenu.h" + namespace MainWindow { enum { @@ -68,3 +73,5 @@ namespace MainWindow void SetInternalResolution(int res = -1); void SetWindowSize(int zoom); } + +#endif \ No newline at end of file diff --git a/ext/native/ext/jpge/jpge.cpp b/ext/native/ext/jpge/jpge.cpp index d355b4f41474..1800e500e99c 100644 --- a/ext/native/ext/jpge/jpge.cpp +++ b/ext/native/ext/jpge/jpge.cpp @@ -896,83 +896,6 @@ bool jpeg_encoder::process_scanline(const void* pScanline) return m_all_stream_writes_succeeded; } -class cfile_stream : public output_stream -{ - cfile_stream(const cfile_stream &); - cfile_stream &operator= (const cfile_stream &); - - FILE* m_pFile; - bool m_bStatus; - -public: - cfile_stream() : m_pFile(NULL), m_bStatus(false) { } - - virtual ~cfile_stream() - { - close(); - } - - bool open(const char *pFilename) - { - close(); - m_pFile = fopen(pFilename, "wb"); - m_bStatus = (m_pFile != NULL); - return m_bStatus; - } - - bool close() - { - if (m_pFile) - { - if (fclose(m_pFile) == EOF) - { - m_bStatus = false; - } - m_pFile = NULL; - } - return m_bStatus; - } - - virtual bool put_buf(const void* pBuf, int len) - { - m_bStatus = m_bStatus && (fwrite(pBuf, len, 1, m_pFile) == 1); - return m_bStatus; - } - - uint get_size() const - { - return m_pFile ? ftell(m_pFile) : 0; - } -}; - -// Writes JPEG image to file. -bool compress_image_to_jpeg_file(const char *pFilename, int width, int height, int num_channels, const uint8 *pImage_data, const params &comp_params) -{ - cfile_stream dst_stream; - if (!dst_stream.open(pFilename)) - return false; - - jpge::jpeg_encoder dst_image; - if (!dst_image.init(&dst_stream, width, height, num_channels, comp_params)) - return false; - - for (uint pass_index = 0; pass_index < dst_image.get_total_passes(); pass_index++) - { - for (int i = 0; i < height; i++) - { - const uint8* pBuf = pImage_data + i * width * num_channels; - if (!dst_image.process_scanline(pBuf)) - return false; - } - if (!dst_image.process_scanline(NULL)) - return false; - } - - dst_image.deinit(); - - return dst_stream.close(); -} - class memory_stream : public output_stream { memory_stream(const memory_stream &); diff --git a/ext/native/gfx_es2/draw_text.cpp b/ext/native/gfx_es2/draw_text.cpp index d574f4396b5c..7fedca678efe 100644 --- a/ext/native/gfx_es2/draw_text.cpp +++ b/ext/native/gfx_es2/draw_text.cpp @@ -31,7 +31,7 @@ float TextDrawerWordWrapper::MeasureWidth(const char *str, size_t bytes) { return w; } -#if defined(_WIN32) && !defined(USING_QT_UI) +#if defined(_WIN32) && !defined(USING_QT_UI) && !PPSSPP_PLATFORM(UWP) #define WIN32_LEAN_AND_MEAN #include diff --git a/ext/native/gfx_es2/draw_text.h b/ext/native/gfx_es2/draw_text.h index 1d47d7629158..12efdf0148f3 100644 --- a/ext/native/gfx_es2/draw_text.h +++ b/ext/native/gfx_es2/draw_text.h @@ -8,6 +8,8 @@ #pragma once +#include "ppsspp_config.h" + #include #include @@ -80,7 +82,7 @@ class TextDrawer { TextDrawerContext *ctx_; #if defined(USING_QT_UI) std::map fontMap_; -#elif defined(_WIN32) +#elif defined(_WIN32) && !PPSSPP_PLATFORM(UWP) std::map> fontMap_; #endif diff --git a/ext/native/gfx_es2/gpu_features.cpp b/ext/native/gfx_es2/gpu_features.cpp index ca4e48faff22..afe59835dfc4 100644 --- a/ext/native/gfx_es2/gpu_features.cpp +++ b/ext/native/gfx_es2/gpu_features.cpp @@ -1,13 +1,20 @@ +#include "ppsspp_config.h" + #include #include "base/logging.h" #include "base/stringutil.h" + +#if !PPSSPP_PLATFORM(UWP) #include "gfx/gl_common.h" -#include "gfx_es2/gpu_features.h" #if defined(_WIN32) #include "GL/wglew.h" #endif +#endif + +#include "gfx_es2/gpu_features.h" + #if defined(USING_GLES2) #if defined(__ANDROID__) @@ -75,6 +82,9 @@ void ProcessGPUFeatures() { // http://stackoverflow.com/questions/16147700/opengl-es-using-tegra-specific-extensions-gl-ext-texture-array void CheckGLExtensions() { + +#if !PPSSPP_PLATFORM(UWP) + // Make sure to only do this once. It's okay to call CheckGLExtensions from wherever. if (extensionsDone) return; @@ -394,6 +404,9 @@ void CheckGLExtensions() { int error = glGetError(); if (error) ELOG("GL error in init: %i", error); + +#endif + } void SetGLCoreContext(bool flag) { diff --git a/ext/native/net/http_server.cpp b/ext/native/net/http_server.cpp index 4d55afcdaf4a..45fb1fe8b459 100644 --- a/ext/native/net/http_server.cpp +++ b/ext/native/net/http_server.cpp @@ -2,7 +2,10 @@ #ifdef _WIN32 +#ifndef NOMINMAX #define NOMINMAX +#endif + #include #include #include diff --git a/ext/native/net/sinks.cpp b/ext/native/net/sinks.cpp index 39339c87b4ef..aaac2f18881a 100644 --- a/ext/native/net/sinks.cpp +++ b/ext/native/net/sinks.cpp @@ -1,6 +1,8 @@ #ifdef _WIN32 +#ifndef NOMINMAX #define NOMINMAX +#endif #include #include #include diff --git a/ext/udis86/udis86.c b/ext/udis86/udis86.c index f957de45ec96..ffc45733a34f 100644 --- a/ext/udis86/udis86.c +++ b/ext/udis86/udis86.c @@ -168,7 +168,7 @@ ud_insn_hex(struct ud* u) /* for each byte used to decode instruction */ for (i = 0; i < ud_insn_len(u) && i < sizeof(u->insn_hexcode) / 2; ++i, ++src_ptr) { - sprintf(src_hex, "%02x", *src_ptr & 0xFF); + snprintf(src_hex, 64 - i * 2, "%02x", *src_ptr & 0xFF); src_hex += 2; } } diff --git a/ppsspp_config.h b/ppsspp_config.h index ec4f1659d04d..a05ce6fbe712 100644 --- a/ppsspp_config.h +++ b/ppsspp_config.h @@ -77,7 +77,7 @@ // Covers both 32 and 64bit Windows #define PPSSPP_PLATFORM_WINDOWS 1 // UWP trickery - #ifdef WINAPI_FAMILY + #if defined(WINAPI_FAMILY) && defined(WINAPI_FAMILY_PARTITION) #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) #define PPSSPP_PLATFORM_UWP 1 #endif From b8757e3e312045a0d058f908cb7768e535987703 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 25 Feb 2017 00:52:42 +0100 Subject: [PATCH 5/6] Path fixes --- Core/Config.h | 2 +- Globals.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Config.h b/Core/Config.h index fac7a9513dd6..12b9fc3fb44a 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -21,7 +21,7 @@ #include #include -#include "CommonTypes.h" +#include "Common/CommonTypes.h" extern const char *PPSSPP_GIT_VERSION; diff --git a/Globals.h b/Globals.h index 23c61a3d3284..4d3fcf7f160f 100644 --- a/Globals.h +++ b/Globals.h @@ -24,9 +24,9 @@ #include #include "ppsspp_config.h" -#include "Log.h" -#include "CommonTypes.h" +#include "Common/Log.h" +#include "Common/CommonTypes.h" #define IS_LITTLE_ENDIAN (*(const u16 *)"\0\xff" >= 0x100) #define IS_BIG_ENDIAN (*(const u16 *)"\0\xff" < 0x100) From c219ae9e63b18c67ab12d0e5e4244801f33d0624 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 25 Feb 2017 01:38:48 +0100 Subject: [PATCH 6/6] Further UWP fixes --- Core/FileSystems/VirtualDiscFileSystem.cpp | 7 ++++--- Core/System.cpp | 1 + GPU/D3D11/D3D11Util.cpp | 8 ++++++++ Windows/WindowsHost.cpp | 4 ---- android/jni/Android.mk | 1 + ext/native/thin3d/d3d11_loader.h | 4 +++- ext/native/thin3d/thin3d_d3d11.cpp | 4 ++++ 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 872a1c00b6e0..9992cf717963 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -808,9 +808,8 @@ void VirtualDiscFileSystem::HandlerLogger(void *arg, HandlerHandle handle, LogTy } } -#if !PPSSPP_PLATFORM(UWP) - VirtualDiscFileSystem::Handler::Handler(const char *filename, VirtualDiscFileSystem *const sys) { +#if !PPSSPP_PLATFORM(UWP) #ifdef _WIN32 #define dlopen(name, ignore) (void *)LoadLibrary(ConvertUTF8ToWString(name).c_str()) #define dlsym(mod, name) GetProcAddress((HMODULE)mod, name) @@ -843,18 +842,20 @@ VirtualDiscFileSystem::Handler::Handler(const char *filename, VirtualDiscFileSys #undef dlsym #undef dlclose #endif +#endif } VirtualDiscFileSystem::Handler::~Handler() { if (library != NULL) { Shutdown(); +#if !PPSSPP_PLATFORM(UWP) #ifdef _WIN32 FreeLibrary((HMODULE)library); #else dlclose(library); +#endif #endif } } -#endif \ No newline at end of file diff --git a/Core/System.cpp b/Core/System.cpp index 342bd44c6ec8..21d7cb27e313 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -621,6 +621,7 @@ void InitSysDirectories() { #if PPSSPP_PLATFORM(UWP) const std::string myDocsPath = ""; // TODO UWP const HRESULT result = E_FAIL; + #else wchar_t myDocumentsPath[MAX_PATH]; const HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, myDocumentsPath); diff --git a/GPU/D3D11/D3D11Util.cpp b/GPU/D3D11/D3D11Util.cpp index 35923a68c9da..4ef01f1f0ce9 100644 --- a/GPU/D3D11/D3D11Util.cpp +++ b/GPU/D3D11/D3D11Util.cpp @@ -1,9 +1,17 @@ +#include "ppsspp_config.h" + #include #include #include #include + +#if PPSSPP_PLATFORM(UWP) +#define ptr_D3DCompile D3DCompile +#else #include "thin3d/d3d11_loader.h" +#endif + #include "base/logging.h" #include "base/stringutil.h" diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index dce71a987865..7494e74836a7 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -50,14 +50,10 @@ #include "Windows/WindowsHost.h" #include "Windows/MainWindow.h" -#if PPSSPP_PLATFORM(UWP) -#include "Windows/GPU/D3D11Context.h" -#else #include "Windows/GPU/WindowsGLContext.h" #include "Windows/GPU/WindowsVulkanContext.h" #include "Windows/GPU/D3D9Context.h" #include "Windows/GPU/D3D11Context.h" -#endif #include "Windows/Debugger/DebuggerShared.h" #include "Windows/Debugger/Debugger_Disasm.h" diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 9a73162e85d5..9f7fe881d99d 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -219,6 +219,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/GPU/Common/VertexDecoderCommon.cpp.arm \ $(SRC)/GPU/Common/TextureCacheCommon.cpp.arm \ $(SRC)/GPU/Common/TextureScalerCommon.cpp.arm \ + $(SRC)/GPU/Common/ShaderCommon.cpp \ $(SRC)/GPU/Common/SplineCommon.cpp.arm \ $(SRC)/GPU/Common/DrawEngineCommon.cpp.arm \ $(SRC)/GPU/Common/TransformCommon.cpp.arm \ diff --git a/ext/native/thin3d/d3d11_loader.h b/ext/native/thin3d/d3d11_loader.h index 2392e1f0c807..53f467893827 100644 --- a/ext/native/thin3d/d3d11_loader.h +++ b/ext/native/thin3d/d3d11_loader.h @@ -1,5 +1,7 @@ #pragma once +#include "ppsspp_config.h" + // Standard Windows includes #include #include @@ -23,4 +25,4 @@ enum class LoadD3D11Error { }; LoadD3D11Error LoadD3D11(); -bool UnloadD3D11(); \ No newline at end of file +bool UnloadD3D11(); diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index 596a49338b76..24e35baf1464 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -1,7 +1,11 @@ #include "ppsspp_config.h" #include "thin3d/thin3d.h" +#if PPSSPP_PLATFORM(UWP) +#define ptr_D3DCompile D3DCompile +#else #include "thin3d/d3d11_loader.h" +#endif #include "math/dataconv.h" #include "util/text/utf8.h"