Skip to content

Commit

Permalink
Merge branch 'master' into dpad
Browse files Browse the repository at this point in the history
  • Loading branch information
iota97 authored Mar 1, 2020
2 parents d9e9120 + 417796c commit ff00716
Show file tree
Hide file tree
Showing 88 changed files with 35,179 additions and 38,447 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
[submodule "ext/rapidjson"]
path = ext/rapidjson
url = https://github.com/Tencent/rapidjson.git
[submodule "ext/native/tools/prebuilt"]
path = ext/native/tools/prebuilt
url = https://github.com/hrydgard/ppsspp-freetype.git
17 changes: 3 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,6 @@ add_library(gason STATIC
ext/native/ext/gason/gason.h
)

add_library(rg_etc1 STATIC
ext/native/ext/rg_etc1/rg_etc1.cpp
ext/native/ext/rg_etc1/rg_etc1.h
)
include_directories(ext/native/ext/rg_etc1)

if(USE_FFMPEG)
if(NOT FFMPEG_DIR)
if(NOT USE_SYSTEM_FFMPEG)
Expand Down Expand Up @@ -780,10 +774,7 @@ elseif(IOS)
set(TargetBin PPSSPP)
elseif(USING_QT_UI)
set(CMAKE_AUTOMOC ON)
find_package(Qt5 COMPONENTS OpenGL Gui Core)
if(NOT SDL2_FOUND)
find_package(Qt5 COMPONENTS Multimedia)
endif(NOT SDL2_FOUND)
find_package(Qt5 COMPONENTS OpenGL Gui Core Multimedia)
list(APPEND NativeAppSource
Qt/QtMain.cpp
Qt/QtMain.h
Expand All @@ -797,7 +788,7 @@ elseif(USING_QT_UI)
add_definitions(-DQT_OPENGL_ES -DQT_OPENGL_ES_2)
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR} Qt)
set(nativeExtraLibs ${nativeExtraLibs} Qt5::OpenGL Qt5::Gui Qt5::Core)
set(nativeExtraLibs ${nativeExtraLibs} Qt5::OpenGL Qt5::Gui Qt5::Core Qt5::Multimedia)
set(TargetBin PPSSPPQt)

# Enable SDL if found
Expand All @@ -808,8 +799,6 @@ elseif(USING_QT_UI)
SDL/SDLJoystick.cpp
)
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
else(SDL2_FOUND)
set(nativeExtraLibs ${nativeExtraLibs} Qt5::Multimedia)
endif()

elseif(WIN32)
Expand Down Expand Up @@ -1087,7 +1076,7 @@ if(ANDROID)
set(ATOMIC_LIB atomic)
endif()

target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} rg_etc1 gason udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB})
target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} gason udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB})
if(TARGET Ext::GLEW)
target_link_libraries(native Ext::GLEW)
endif()
Expand Down
1 change: 1 addition & 0 deletions Common/KeyMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ const KeyMap_IntStrPair psp_button_names[] = {
{VIRTKEY_TEXTURE_DUMP, "Texture Dumping"},
{VIRTKEY_TEXTURE_REPLACE, "Texture Replacement"},
{VIRTKEY_SCREENSHOT, "Screenshot"},
{VIRTKEY_MUTE_TOGGLE, "Mute toggle"},

{CTRL_HOME, "Home"},
{CTRL_HOLD, "Hold"},
Expand Down
1 change: 1 addition & 0 deletions Common/KeyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum {
VIRTKEY_TEXTURE_DUMP = 0x40000019,
VIRTKEY_TEXTURE_REPLACE = 0x4000001A,
VIRTKEY_SCREENSHOT = 0x4000001B,
VIRTKEY_MUTE_TOGGLE = 0x4000001C,
VIRTKEY_LAST,
VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST
};
Expand Down
3 changes: 3 additions & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ static ConfigSetting generalSettings[] = {
ConfigSetting("EnableStateUndo", &g_Config.bEnableStateUndo, &DefaultEnableStateUndo, true, true),
ConfigSetting("RewindFlipFrequency", &g_Config.iRewindFlipFrequency, 0, true, true),

ConfigSetting("ShowRegionOnGameIcon", &g_Config.bShowRegionOnGameIcon, false, true, true),
ConfigSetting("ShowIDOnGameIcon", &g_Config.bShowIDOnGameIcon, false, true, true),
ConfigSetting("GridView1", &g_Config.bGridView1, true),
ConfigSetting("GridView2", &g_Config.bGridView2, true),
ConfigSetting("GridView3", &g_Config.bGridView3, false),
Expand Down Expand Up @@ -985,6 +987,7 @@ static ConfigSetting debuggerSettings[] = {
ConfigSetting("ShowGpuProfile", &g_Config.bShowGpuProfile, false, false),
ConfigSetting("SkipDeadbeefFilling", &g_Config.bSkipDeadbeefFilling, false),
ConfigSetting("FuncHashMap", &g_Config.bFuncHashMap, false),
ConfigSetting("DrawFrameGraph", &g_Config.bDrawFrameGraph, false),

ConfigSetting(false),
};
Expand Down
3 changes: 3 additions & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ struct Config {
// UI
bool bShowDebuggerOnLoad;
int iShowFPSCounter;
bool bShowRegionOnGameIcon;
bool bShowIDOnGameIcon;

// TODO: Maybe move to a separate theme system.
uint32_t uItemStyleFg;
Expand Down Expand Up @@ -409,6 +411,7 @@ struct Config {
// Double edged sword: much easier debugging, but not accurate.
bool bSkipDeadbeefFilling;
bool bFuncHashMap;
bool bDrawFrameGraph;

// Volatile development settings
bool bShowFrameProfiler;
Expand Down
10 changes: 10 additions & 0 deletions Core/HLE/ReplaceTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,15 @@ static int Hook_starocean_clear_framebuf_after() {
return 0;
}

static int Hook_motorstorm_pixel_read() {
u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_A0] + 0x18);
u32 fb_height = Memory::Read_U16(currentMIPS->r[MIPS_REG_A0] + 0x26);
u32 fb_stride = Memory::Read_U16(currentMIPS->r[MIPS_REG_A0] + 0x28);
gpu->PerformMemoryDownload(fb_address, fb_height * fb_stride);
CBreakPoints::ExecMemCheck(fb_address, true, fb_height * fb_stride, currentMIPS->pc);
return 0;
}

#define JITFUNC(f) (&MIPSComp::MIPSFrontendInterface::f)

// Can either replace with C functions or functions emitted in Asm/ArmAsm.
Expand Down Expand Up @@ -1341,6 +1350,7 @@ static const ReplacementTableEntry entries[] = {
{ "marvelalliance1_copy", &Hook_marvelalliance1_copy_after, 0, REPFLAG_HOOKENTER, 0x69c },
{ "starocean_clear_framebuf", &Hook_starocean_clear_framebuf_before, 0, REPFLAG_HOOKENTER, 0 },
{ "starocean_clear_framebuf", &Hook_starocean_clear_framebuf_after, 0, REPFLAG_HOOKEXIT, 0 },
{ "motorstorm_pixel_read", &Hook_motorstorm_pixel_read, 0, REPFLAG_HOOKENTER, 0 },
{}
};

Expand Down
46 changes: 44 additions & 2 deletions Core/HLE/sceDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ static double fpsHistory[120];
static int fpsHistorySize = (int)ARRAY_SIZE(fpsHistory);
static int fpsHistoryPos = 0;
static int fpsHistoryValid = 0;
static double frameTimeHistory[600];
static double frameSleepHistory[600];
static const int frameTimeHistorySize = (int)ARRAY_SIZE(frameTimeHistory);
static int frameTimeHistoryPos = 0;
static int frameTimeHistoryValid = 0;
static double lastFrameTimeHistory = 0.0;
static double monitorFpsUntil = 0.0;
static int lastNumFlips = 0;
static float flips = 0.0f;
Expand Down Expand Up @@ -235,6 +241,9 @@ void __DisplayInit() {
lastNumFlips = 0;
fpsHistoryValid = 0;
fpsHistoryPos = 0;
frameTimeHistoryValid = 0;
frameTimeHistoryPos = 0;
lastFrameTimeHistory = 0.0;

__KernelRegisterWaitTypeFuncs(WAITTYPE_VBLANK, __DisplayVblankBeginCallback, __DisplayVblankEndCallback);
}
Expand Down Expand Up @@ -463,6 +472,23 @@ static void CalculateFPS() {
++fpsHistoryValid;
}
}

if (g_Config.bDrawFrameGraph) {
frameTimeHistory[frameTimeHistoryPos++] = now - lastFrameTimeHistory;
lastFrameTimeHistory = now;
frameTimeHistoryPos = frameTimeHistoryPos % frameTimeHistorySize;
if (frameTimeHistoryValid < frameTimeHistorySize) {
++frameTimeHistoryValid;
}
frameSleepHistory[frameTimeHistoryPos] = 0.0;
}
}

double *__DisplayGetFrameTimes(int *out_valid, int *out_pos, double **out_sleep) {
*out_valid = frameTimeHistoryValid;
*out_pos = frameTimeHistoryPos;
*out_sleep = frameSleepHistory;
return frameTimeHistory;
}

void __DisplayGetDebugStats(char *stats, size_t bufsize) {
Expand Down Expand Up @@ -615,7 +641,8 @@ static void DoFrameIdleTiming() {

time_update();

double dist = time_now_d() - lastFrameTime;
double before = time_now_d();
double dist = before - lastFrameTime;
// Ignore if the distance is just crazy. May mean wrap or pause.
if (dist < 0.0 || dist >= 15 * timePerVblank) {
return;
Expand All @@ -633,7 +660,7 @@ static void DoFrameIdleTiming() {
// This prevents fast forward during loading screens.
// Give a little extra wiggle room in case the next vblank does more work.
const double goal = lastFrameTime + (numVBlanksSinceFlip - 1) * scaledVblank - 0.001;
if (numVBlanksSinceFlip >= 2 && time_now_d() < goal) {
if (numVBlanksSinceFlip >= 2 && before < goal) {
while (time_now_d() < goal) {
#ifdef _WIN32
sleep_ms(1);
Expand All @@ -643,6 +670,10 @@ static void DoFrameIdleTiming() {
#endif
time_update();
}

if (g_Config.bDrawFrameGraph) {
frameSleepHistory[frameTimeHistoryPos] += time_now_d() - before;
}
}
}

Expand Down Expand Up @@ -713,6 +744,7 @@ void __DisplayFlip(int cyclesLate) {
postEffectRequiresFlip = shaderInfo->requires60fps;
const bool fbDirty = gpu->FramebufferDirty();
if (fbDirty || noRecentFlip || postEffectRequiresFlip) {
int frameSleepPos = frameTimeHistoryPos;
CalculateFPS();

// Let the user know if we're running slow, so they know to adjust settings.
Expand Down Expand Up @@ -774,6 +806,11 @@ void __DisplayFlip(int cyclesLate) {

CoreTiming::ScheduleEvent(0 - cyclesLate, afterFlipEvent, 0);
numVBlanksSinceFlip = 0;

if (g_Config.bDrawFrameGraph) {
// Track how long we sleep (whether vsync or sleep_ms.)
frameSleepHistory[frameSleepPos] += real_time_now() - lastFrameTimeHistory;
}
} else {
// Okay, there's no new frame to draw. But audio may be playing, so we need to time still.
DoFrameIdleTiming();
Expand Down Expand Up @@ -820,6 +857,7 @@ void hleLagSync(u64 userdata, int cyclesLate) {

const double goal = lastLagSync + (scale / 1000.0f);
time_update();
double before = time_now_d();
// Don't lag too long ever, if they leave it paused.
while (time_now_d() < goal && goal < time_now_d() + 0.01) {
#ifndef _WIN32
Expand All @@ -832,6 +870,10 @@ void hleLagSync(u64 userdata, int cyclesLate) {
const int emuOver = (int)cyclesToUs(cyclesLate);
const int over = (int)((time_now_d() - goal) * 1000000);
ScheduleLagSync(over - emuOver);

if (g_Config.bDrawFrameGraph) {
frameSleepHistory[frameTimeHistoryPos] += time_now_d() - before;
}
}

static u32 sceDisplayIsVblank() {
Expand Down
1 change: 1 addition & 0 deletions Core/HLE/sceDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void __DisplayGetDebugStats(char stats[], size_t bufsize);
void __DisplayGetFPS(float *out_vps, float *out_fps, float *out_actual_fps);
void __DisplayGetVPS(float *out_vps);
void __DisplayGetAveragedFPS(float *out_vps, float *out_fps);
double *__DisplayGetFrameTimes(int *out_valid, int *out_pos, double **out_sleep);
int __DisplayGetNumVblanks();
int __DisplayGetVCount();
int __DisplayGetFlipCount();
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ const HLEFunction ThreadManForUser[] =
{0X3B183E26, &WrapI_I<sceKernelGetThreadExitStatus>, "sceKernelGetThreadExitStatus", 'i', "i" },
{0X52089CA1, &WrapI_I<sceKernelGetThreadStackFreeSize>, "sceKernelGetThreadStackFreeSize", 'i', "i" },
{0XFFC36A14, &WrapU_UU<sceKernelReferThreadRunStatus>, "sceKernelReferThreadRunStatus", 'x', "xx" },
{0X17C1684E, &WrapU_UU<sceKernelReferThreadStatus>, "sceKernelReferThreadStatus", 'x', "xx" },
{0X17C1684E, &WrapU_UU<sceKernelReferThreadStatus>, "sceKernelReferThreadStatus", 'i', "xp" },
{0X2C34E053, &WrapI_I<sceKernelReleaseWaitThread>, "sceKernelReleaseWaitThread", 'i', "i" },
{0X75156E8F, &WrapI_I<sceKernelResumeThread>, "sceKernelResumeThread", 'i', "i" },
{0X3AD58B8C, &WrapU_V<sceKernelSuspendDispatchThread>, "sceKernelSuspendDispatchThread", 'x', "", HLE_NOT_IN_INTERRUPT },
Expand Down
31 changes: 12 additions & 19 deletions Core/HLE/sceKernelThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,44 +1256,37 @@ u32 sceKernelReferThreadStatus(u32 threadID, u32 statusPtr)

u32 error;
Thread *t = kernelObjects.Get<Thread>(threadID, error);
if (!t)
{
ERROR_LOG(SCEKERNEL, "%08x=sceKernelReferThreadStatus(%i, %08x): bad thread", error, threadID, statusPtr);
return error;
if (!t) {
hleEatCycles(700);
hleReSchedule("refer thread status");
return hleLogError(SCEKERNEL, error, "bad thread");
}

u32 wantedSize = Memory::Read_U32(statusPtr);

if (sceKernelGetCompiledSdkVersion() > 0x02060010)
{
if (wantedSize > THREADINFO_SIZE_AFTER_260)
{
ERROR_LOG(SCEKERNEL, "%08x=sceKernelReferThreadStatus(%i, %08x): bad size %d", SCE_KERNEL_ERROR_ILLEGAL_SIZE, threadID, statusPtr, wantedSize);
return SCE_KERNEL_ERROR_ILLEGAL_SIZE;
if (sceKernelGetCompiledSdkVersion() > 0x02060010) {
if (wantedSize > THREADINFO_SIZE_AFTER_260) {
hleEatCycles(1200);
hleReSchedule("refer thread status");
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_SIZE, "bad size %d", wantedSize);
}

VERBOSE_LOG(SCEKERNEL, "sceKernelReferThreadStatus(%i, %08x)", threadID, statusPtr);

t->nt.nativeSize = THREADINFO_SIZE_AFTER_260;
if (wantedSize != 0)
Memory::Memcpy(statusPtr, &t->nt, std::min(wantedSize, (u32)sizeof(t->nt)));
// TODO: What is this value? Basic tests show 0...
if (wantedSize > sizeof(t->nt))
Memory::Memset(statusPtr + sizeof(t->nt), 0, wantedSize - sizeof(t->nt));
}
else
{
VERBOSE_LOG(SCEKERNEL, "sceKernelReferThreadStatus(%i, %08x)", threadID, statusPtr);

} else {
t->nt.nativeSize = THREADINFO_SIZE;
u32 sz = std::min(THREADINFO_SIZE, wantedSize);
if (sz != 0)
Memory::Memcpy(statusPtr, &t->nt, sz);
}

hleEatCycles(1220);
hleEatCycles(1400);
hleReSchedule("refer thread status");
return 0;
return hleLogSuccessVerboseI(SCEKERNEL, 0);
}

// Thanks JPCSP
Expand Down
4 changes: 2 additions & 2 deletions Core/HLE/scePsmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class PsmfPlayer {

bool HasReachedEnd() {
// The pts are ignored - the end is when we're out of data.
return mediaengine->IsVideoEnd() && mediaengine->IsNoAudioData();
return mediaengine->IsVideoEnd() && (mediaengine->IsNoAudioData() || !mediaengine->IsActuallyPlayingAudio());
}

u32 filehandle;
Expand Down Expand Up @@ -1617,7 +1617,7 @@ static int scePsmfPlayerGetVideoData(u32 psmfPlayer, u32 videoDataAddr)
bool doVideoStep = true;
if (psmfplayer->playMode == PSMF_PLAYER_MODE_PAUSE) {
doVideoStep = false;
} else if (!psmfplayer->mediaengine->IsNoAudioData()) {
} else if (!psmfplayer->mediaengine->IsNoAudioData() && psmfplayer->mediaengine->IsActuallyPlayingAudio()) {
s64 deltapts = psmfplayer->mediaengine->getVideoTimeStamp() - psmfplayer->mediaengine->getAudioTimeStamp();
// Don't skip the very first frame, sometimes audio starts with an early timestamp.
if (deltapts > 0 && psmfplayer->mediaengine->getVideoTimeStamp() > 0) {
Expand Down
Loading

0 comments on commit ff00716

Please sign in to comment.