Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/hrydgard/ppsspp into cull…
Browse files Browse the repository at this point in the history
…face
  • Loading branch information
weihuoya committed Aug 23, 2018
2 parents bb6cfc9 + 1f274a2 commit 8ff6d0c
Show file tree
Hide file tree
Showing 239 changed files with 3,960 additions and 1,563 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@
[submodule "ext/SPIRV-Cross"]
path = ext/SPIRV-Cross
url = https://github.com/KhronosGroup/SPIRV-Cross.git
[submodule "ext/discord-rpc"]
path = ext/discord-rpc
url = https://github.com/discordapp/discord-rpc.git
[submodule "ext/rapidjson"]
path = ext/rapidjson
url = https://github.com/Tencent/rapidjson.git
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
message("Clang enabled")
endif()

if(FORCED_CPU)
message("Detected CPU (${CMAKE_SYSTEM_PROCESSOR}) overridden as: ${FORCED_CPU}")
set(CMAKE_SYSTEM_PROCESSOR ${FORCED_CPU})
endif()

# Detect CPU from CMAKE configuration. Toolchains should set this up
if(CMAKE_SYSTEM_PROCESSOR)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm")
Expand Down Expand Up @@ -109,6 +114,7 @@ option(USING_EGL "Set to ON if target environment uses EGL" ${USING_EGL})
option(USING_FBDEV "Set to ON if target environment uses fbdev (eg. Pandora)" ${USING_FBDEV})
option(USING_GLES2 "Set to ON if target device uses OpenGL ES 2.0" ${USING_GLES2})
option(RASPBIAN "Set to ON to workaround threading issues when building for ARMV7 on Raspbian" ${RASPBIAN})
option(USING_X11_VULKAN "Set to OFF if target environment doesn't use X11 for Vulkan" ON)
# :: Frontends
option(USING_QT_UI "Set to ON if you wish to use the Qt frontend wrapper" ${USING_QT_UI})
option(MOBILE_DEVICE "Set to ON when targeting a mobile device" ${MOBILE_DEVICE})
Expand All @@ -124,7 +130,12 @@ option(USE_WAYLAND_WSI "Set to ON to require Wayland support for Vulkan" ${USE_W
option(USE_ADDRESS_SANITIZER "Use Clang memory sanitizer" ${USE_ADDRESS_SANITIZER})

if(UNIX AND NOT (APPLE OR ANDROID) AND VULKAN)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
if(USING_X11_VULKAN)
message("Using X11 for Vulkan")
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
else()
message("NOT using X11 for Vulkan")
endif()
# add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
find_package(Wayland)
if (USE_WAYLAND_WSI AND NOT WAYLAND_FOUND)
Expand Down Expand Up @@ -811,6 +822,7 @@ endif()

list(APPEND NativeAppSource
android/jni/TestRunner.cpp
UI/DiscordIntegration.cpp
UI/NativeApp.cpp
UI/BackgroundAudio.cpp
UI/DevScreens.cpp
Expand Down Expand Up @@ -1381,6 +1393,7 @@ add_library(${CoreLibName} ${CoreLinkType}
${CoreExtra}
Core/Config.cpp
Core/Config.h
Core/ConfigValues.h
Core/Core.cpp
Core/Core.h
Core/Compatibility.cpp
Expand Down Expand Up @@ -1414,6 +1427,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Debugger/WebSocket/GameBroadcaster.h
Core/Debugger/WebSocket/GameSubscriber.cpp
Core/Debugger/WebSocket/GameSubscriber.h
Core/Debugger/WebSocket/GPUBufferSubscriber.cpp
Core/Debugger/WebSocket/GPUBufferSubscriber.h
Core/Debugger/WebSocket/HLESubscriber.cpp
Core/Debugger/WebSocket/HLESubscriber.h
Core/Debugger/WebSocket/LogBroadcaster.cpp
Expand Down Expand Up @@ -1595,6 +1610,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/HLE/sceUmd.h
Core/HLE/sceUsb.cpp
Core/HLE/sceUsb.h
Core/HLE/sceUsbAcc.cpp
Core/HLE/sceUsbAcc.h
Core/HLE/sceUsbCam.cpp
Core/HLE/sceUsbCam.h
Core/HLE/sceUsbGps.cpp
Expand Down
12 changes: 9 additions & 3 deletions Common/ChunkFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ CChunkFileReader::Error CChunkFileReader::GetFileTitle(const std::string &filena
return LoadFileHeader(pFile, header, title);
}

CChunkFileReader::Error CChunkFileReader::LoadFile(const std::string &filename, const char *gitVersion, u8 *&_buffer, size_t &sz, std::string *failureReason) {
CChunkFileReader::Error CChunkFileReader::LoadFile(const std::string &filename, std::string *gitVersion, u8 *&_buffer, size_t &sz, std::string *failureReason) {
if (!File::Exists(filename)) {
*failureReason = "LoadStateDoesntExist";
ERROR_LOG(SAVESTATE, "ChunkReader: File doesn't exist");
Expand Down Expand Up @@ -264,6 +264,12 @@ CChunkFileReader::Error CChunkFileReader::LoadFile(const std::string &filename,
delete [] buffer;
}

if (header.GitVersion[31]) {
*gitVersion = std::string(header.GitVersion, 32);
} else {
*gitVersion = header.GitVersion;
}

return ERROR_NONE;
}

Expand Down Expand Up @@ -294,15 +300,15 @@ CChunkFileReader::Error CChunkFileReader::SaveFile(const std::string &filename,
}

// Create header
SChunkHeader header;
SChunkHeader header{};
header.Compress = compressed_buffer ? 1 : 0;
header.Revision = REVISION_CURRENT;
header.ExpectedSize = (u32)write_len;
header.UncompressedSize = (u32)sz;
truncate_cpy(header.GitVersion, gitVersion);

// Setup the fixed-length title.
char titleFixed[128];
char titleFixed[128]{};
truncate_cpy(titleFixed, title.c_str());

// Now let's start writing out the file...
Expand Down
4 changes: 2 additions & 2 deletions Common/ChunkFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ class CChunkFileReader

// Load file template
template<class T>
static Error Load(const std::string &filename, const char *gitVersion, T& _class, std::string *failureReason)
static Error Load(const std::string &filename, std::string *gitVersion, T& _class, std::string *failureReason)
{
*failureReason = "LoadStateWrongVersion";

Expand Down Expand Up @@ -700,7 +700,7 @@ class CChunkFileReader
REVISION_CURRENT = REVISION_TITLE,
};

static Error LoadFile(const std::string &filename, const char *gitVersion, u8 *&buffer, size_t &sz, std::string *failureReason);
static Error LoadFile(const std::string &filename, std::string *gitVersion, u8 *&buffer, size_t &sz, std::string *failureReason);
static Error SaveFile(const std::string &filename, const std::string &title, const char *gitVersion, u8 *buffer, size_t sz);
static Error LoadFileHeader(File::IOFile &pFile, SChunkHeader &header, std::string *title);
};
2 changes: 0 additions & 2 deletions Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down Expand Up @@ -108,7 +107,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
59 changes: 59 additions & 0 deletions Common/FileUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,65 @@ bool OpenCPPFile(std::fstream & stream, const std::string &filename, std::ios::o
return stream.is_open();
}

std::string ResolvePath(const std::string &path) {
#ifdef _WIN32
typedef DWORD (WINAPI *getFinalPathNameByHandleW_f)(HANDLE hFile, LPWSTR lpszFilePath, DWORD cchFilePath, DWORD dwFlags);
static getFinalPathNameByHandleW_f getFinalPathNameByHandleW = nullptr;

if (!getFinalPathNameByHandleW) {
// We leak this, but that's okay since the process should hold onto this DLL for the entire lifetime anyway.
HMODULE kernel32 = LoadLibraryW(L"kernel32.dll");
getFinalPathNameByHandleW = (getFinalPathNameByHandleW_f)GetProcAddress(kernel32, "GetFinalPathNameByHandleW");
}

static const int BUF_SIZE = 32768;
wchar_t *buf = new wchar_t[BUF_SIZE];
memset(buf, 0, BUF_SIZE);

std::wstring input = ConvertUTF8ToWString(path);
if (getFinalPathNameByHandleW) {
HANDLE hFile = CreateFile(input.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
wcscpy_s(buf, BUF_SIZE - 1, input.c_str());
} else {
int result = getFinalPathNameByHandleW(hFile, buf, BUF_SIZE - 1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
if (result >= BUF_SIZE || result == 0)
wcscpy_s(buf, BUF_SIZE - 1, input.c_str());
}
} else {
wchar_t *longBuf = new wchar_t[BUF_SIZE];
memset(buf, 0, BUF_SIZE);

int result = GetLongPathNameW(input.c_str(), longBuf, BUF_SIZE - 1);
if (result >= BUF_SIZE || result == 0)
wcscpy_s(longBuf, BUF_SIZE - 1, input.c_str());

result = GetFullPathNameW(longBuf, BUF_SIZE - 1, buf, nullptr);
if (result >= BUF_SIZE || result == 0)
wcscpy_s(buf, BUF_SIZE - 1, input.c_str());

delete [] longBuf;

// Normalize slashes just in case.
for (int i = 0; i < BUF_SIZE; ++i) {
if (buf[i] == '\\')
buf[i] = '/';
}
}

// Undo the \\?\C:\ syntax that's normally returned.
std::string output = ConvertWStringToUTF8(buf);
if (buf[0] == '\\' && buf[1] == '\\' && buf[2] == '?' && buf[3] == '\\' && isalpha(buf[4]) && buf[5] == ':')
output = output.substr(4);
delete [] buf;
return output;
#else
char buf[PATH_MAX + 1];
if (realpath(path.c_str(), buf) == nullptr)
return path;
return buf;
#endif
}

// Remove any ending forward slashes from directory paths
// Modifies argument.
Expand Down
3 changes: 3 additions & 0 deletions Common/FileUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ struct FileDetails {
FILE *OpenCFile(const std::string &filename, const char *mode);
bool OpenCPPFile(std::fstream & stream, const std::string &filename, std::ios::openmode mode);

// Resolves symlinks and similar.
std::string ResolvePath(const std::string &path);

// Returns true if file filename exists
bool Exists(const std::string &filename);

Expand Down
2 changes: 2 additions & 0 deletions Common/FixedSizeQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class FixedSizeQueue {
head_ = 0;
tail_ = 0;
count_ = 0;
// Not entirely necessary, but keeps things clean.
memset(storage_, 0, sizeof(T) * N);
}

void push(T t) {
Expand Down
33 changes: 28 additions & 5 deletions Common/GL/GLInterface/EGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,21 @@ bool cInterfaceEGL::ChooseAndCreate(void *window_handle, bool core, bool use565)

EGLint ctx_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE, 0
EGL_NONE, 0,
EGL_NONE, 0,
EGL_NONE, 0,
EGL_NONE, 0,
};

switch (s_opengl_mode) {
case MODE_OPENGL:
EGL_ILOG("Setting RENDERABLE_TYPE to EGL_OPENGL_BIT");
attribs[1] = EGL_OPENGL_BIT;
ctx_attribs[0] = EGL_NONE;
// 1 will be major version, and 3 the minor version.
ctx_attribs[2] = 0x30FB; /* EGL_CONTEXT_MINOR_VERSION_KHR */
// Let's always use a core profile here.
ctx_attribs[4] = 0x30FD; /* EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR */
ctx_attribs[5] = 1; /* EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR */
break;
case MODE_OPENGLES2:
EGL_ILOG("Setting RENDERABLE_TYPE to EGL_OPENGL_ES2_BIT");
Expand All @@ -230,7 +237,7 @@ bool cInterfaceEGL::ChooseAndCreate(void *window_handle, bool core, bool use565)
EGL_ILOG("Calling eglChooseConfig to get number of configs (use16bit=%d)...", (int)use565);

EGLConfig *configs;
EGLint num_configs;
EGLint num_configs = 0;
if (!eglChooseConfig(egl_dpy, attribs, NULL, 0, &num_configs) || num_configs == 0) {
EGL_ILOG("Error: couldn't get a number of configs. Trying with fallback config (no stencil, not specifying transparent:none)\n");
attribsFallback[1] = attribs[1];
Expand Down Expand Up @@ -298,7 +305,23 @@ bool cInterfaceEGL::ChooseAndCreate(void *window_handle, bool core, bool use565)
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
EGL_ILOG("EGL_CLIENT_APIS = %s\n", s);

egl_ctx = eglCreateContext(egl_dpy, configs[chosenConfig], EGL_NO_CONTEXT, ctx_attribs);

if (s_opengl_mode == MODE_OPENGL) {
EGL_ILOG("Finding a good GL version");
egl_ctx = nullptr;
for (int minor = 6; minor >= 0 && !egl_ctx; --minor) {
ctx_attribs[1] = 4;
ctx_attribs[3] = minor;
egl_ctx = eglCreateContext(egl_dpy, configs[chosenConfig], EGL_NO_CONTEXT, ctx_attribs);
}
if (!egl_ctx) {
ctx_attribs[1] = 3;
ctx_attribs[3] = 3;
egl_ctx = eglCreateContext(egl_dpy, configs[chosenConfig], EGL_NO_CONTEXT, ctx_attribs);
}
} else {
egl_ctx = eglCreateContext(egl_dpy, configs[chosenConfig], EGL_NO_CONTEXT, ctx_attribs);
}
if (!egl_ctx) {
EGL_ILOG("Error: eglCreateContext failed: %s\n", EGLGetErrorString(eglGetError()));
delete[] configs;
Expand Down Expand Up @@ -339,7 +362,7 @@ bool cInterfaceEGL::Create(void *window_handle, bool core, bool use565) {
if (s_opengl_mode == MODE_DETECT || s_opengl_mode == MODE_DETECT_ES)
DetectMode();

if (!ChooseAndCreate(window_handle, core, use565) && s_opengl_mode == MODE_OPENGLES3) {
if (!ChooseAndCreate(window_handle, core, use565) && (s_opengl_mode == MODE_OPENGLES3 || s_opengl_mode == MODE_OPENGL)) {
// Fallback to ES 2.0 and try again.
s_opengl_mode = MODE_OPENGLES2;
if (!ChooseAndCreate(window_handle, core, use565)) {
Expand Down
2 changes: 2 additions & 0 deletions Common/KeyMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ const KeyMap_IntStrPair psp_button_names[] = {
{VIRTKEY_RAPID_FIRE, "RapidFire"},
{VIRTKEY_UNTHROTTLE, "Unthrottle"},
{VIRTKEY_SPEED_TOGGLE, "SpeedToggle"},
{VIRTKEY_SPEED_CUSTOM1, "Alt speed 1"},
{VIRTKEY_SPEED_CUSTOM2, "Alt speed 2"},
{VIRTKEY_PAUSE, "Pause"},
#ifndef MOBILE_DEVICE
{VIRTKEY_FRAME_ADVANCE, "Frame Advance"},
Expand Down
2 changes: 2 additions & 0 deletions Common/KeyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ enum {
VIRTKEY_DEVMENU = 0x40000014,
VIRTKEY_FRAME_ADVANCE = 0x40000015,
VIRTKEY_RECORD = 0x40000016,
VIRTKEY_SPEED_CUSTOM1 = 0x40000017,
VIRTKEY_SPEED_CUSTOM2 = 0x40000018,
VIRTKEY_LAST,
VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST
};
Expand Down
5 changes: 5 additions & 0 deletions Common/Vulkan/VulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,17 @@ int VulkanContext::GetBestPhysicalDevice() {
case VK_PHYSICAL_DEVICE_TYPE_CPU:
score += 1;
break;
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
score += 2;
break;
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
score += 20;
break;
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
score += 10;
break;
default:
break;
}
if (props.vendorID == VULKAN_VENDOR_AMD) {
score += 5;
Expand Down
3 changes: 2 additions & 1 deletion Common/Vulkan/VulkanDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ VkBool32 VKAPI_CALL Vulkan_Dbg(VkDebugReportFlagsEXT msgFlags, VkDebugReportObje
return false;
if (msgCode == 64) // Another useless perf warning that will be seen less and less as we optimize - vkCmdClearAttachments() issued on command buffer object 0x00000195296C6D40 prior to any Draw Cmds. It is recommended you use RenderPass LOAD_OP_CLEAR on Attachments prior to any Draw.
return false;

if (msgCode == 5)
return false; // Not exactly a false positive, see https://github.com/KhronosGroup/glslang/issues/1418
#ifdef _WIN32
std::string msg = message.str();
OutputDebugStringA(msg.c_str());
Expand Down
2 changes: 2 additions & 0 deletions Common/Vulkan/VulkanLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ bool VulkanMayBeAvailable() {
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
anyGood = true;
break;
default:
break;
}
// TODO: Should also check queuefamilyproperties for a GRAPHICS queue family? Oh well.
}
Expand Down
Loading

0 comments on commit 8ff6d0c

Please sign in to comment.