mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Merge NativeUpdate and NativeRender, we always call them together.
This commit is contained in:
parent
096c168dd7
commit
bcae36d8cb
@ -49,21 +49,16 @@ void NativeSetRestarting();
|
||||
// Retrieve current restarting flag.
|
||||
bool NativeIsRestarting();
|
||||
|
||||
// Called ~sixty times a second, delivers the current input state.
|
||||
// Main thread.
|
||||
void NativeUpdate();
|
||||
|
||||
// Delivers touch events "instantly", without waiting for the next frame so that NativeUpdate can deliver.
|
||||
// Useful for triggering audio events, saving a few ms.
|
||||
// If you don't care about touch latency, just do a no-op implementation of this.
|
||||
// time is not yet implemented. finger can be from 0 to 7, inclusive.
|
||||
// Delivers touch/key/axis events "instantly", without waiting for the next frame so that NativeFrame can deliver.
|
||||
// Some systems like UI will buffer these events internally but at least in gameplay we can get the minimum possible
|
||||
// input latency - assuming your main loop is architected properly (NativeFrame called from a different thread than input event handling).
|
||||
void NativeTouch(const TouchInput &touch);
|
||||
bool NativeKey(const KeyInput &key);
|
||||
void NativeAxis(const AxisInput &axis);
|
||||
|
||||
// Called when it's time to render. If the device can keep up, this
|
||||
// will also be called sixty times per second. Main thread.
|
||||
void NativeRender(GraphicsContext *graphicsContext);
|
||||
// Called when it's process a frame, including rendering. If the device can keep up, this
|
||||
// will be called sixty times per second. Main thread.
|
||||
void NativeFrame(GraphicsContext *graphicsContext);
|
||||
|
||||
// This should render num_samples 44khz stereo samples.
|
||||
// Try not to make too many assumptions on the granularity
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
void PostSystemSuccess(int requestId, const char *responseString, int responseValue = 0);
|
||||
void PostSystemFailure(int requestId);
|
||||
|
||||
// This must be called every frame from the beginning of NativeUpdate().
|
||||
// This must be called every frame from the beginning of NativeFrame().
|
||||
// This will call the callback of any finished requests.
|
||||
void ProcessRequests();
|
||||
|
||||
|
@ -210,8 +210,7 @@ void UpdateRunLoop() {
|
||||
sleep_ms(16);
|
||||
return;
|
||||
}
|
||||
NativeUpdate();
|
||||
NativeRender(graphicsContext);
|
||||
NativeFrame(graphicsContext);
|
||||
}
|
||||
|
||||
void KeepScreenAwake() {
|
||||
@ -325,7 +324,7 @@ void Core_ProcessStepping() {
|
||||
}
|
||||
|
||||
// Many platforms, like Android, do not call this function but handle things on their own.
|
||||
// Instead they simply call NativeRender and NativeUpdate directly.
|
||||
// Instead they simply call NativeFrame directly.
|
||||
bool Core_Run(GraphicsContext *ctx) {
|
||||
System_Notify(SystemNotification::DISASSEMBLY);
|
||||
while (true) {
|
||||
|
@ -151,6 +151,8 @@
|
||||
|
||||
#include <Core/HLE/Plugins.h>
|
||||
|
||||
void HandleGlobalMessage(const std::string &msg, const std::string &value);
|
||||
|
||||
ScreenManager *g_screenManager;
|
||||
std::string config_filename;
|
||||
|
||||
@ -1047,14 +1049,43 @@ void RenderOverlays(UIContext *dc, void *userdata) {
|
||||
}
|
||||
}
|
||||
|
||||
void NativeRender(GraphicsContext *graphicsContext) {
|
||||
void NativeFrame(GraphicsContext *graphicsContext) {
|
||||
PROFILE_END_FRAME();
|
||||
|
||||
std::vector<PendingMessage> toProcess;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pendingMutex);
|
||||
toProcess = std::move(pendingMessages);
|
||||
pendingMessages.clear();
|
||||
}
|
||||
|
||||
for (const auto &item : toProcess) {
|
||||
HandleGlobalMessage(item.msg, item.value);
|
||||
g_screenManager->sendMessage(item.msg.c_str(), item.value.c_str());
|
||||
}
|
||||
|
||||
g_requestManager.ProcessRequests();
|
||||
|
||||
// it's ok to call this redundantly with DoFrame from EmuScreen
|
||||
Achievements::Idle();
|
||||
|
||||
g_DownloadManager.Update();
|
||||
g_screenManager->update();
|
||||
|
||||
g_Discord.Update();
|
||||
g_BackgroundAudio.Play();
|
||||
|
||||
g_OSD.Update();
|
||||
|
||||
UI::SetSoundEnabled(g_Config.bUISound);
|
||||
|
||||
_dbg_assert_(graphicsContext != nullptr);
|
||||
_dbg_assert_(g_screenManager != nullptr);
|
||||
|
||||
g_GameManager.Update();
|
||||
|
||||
if (GetUIState() != UISTATE_INGAME) {
|
||||
// Note: We do this from NativeRender so that the graphics context is
|
||||
// Note: We do this from NativeFrame so that the graphics context is
|
||||
// guaranteed valid, to be safe - g_gameInfoCache messes around with textures.
|
||||
g_BackgroundAudio.Update();
|
||||
}
|
||||
@ -1206,37 +1237,6 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
|
||||
}
|
||||
}
|
||||
|
||||
void NativeUpdate() {
|
||||
PROFILE_END_FRAME();
|
||||
|
||||
std::vector<PendingMessage> toProcess;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pendingMutex);
|
||||
toProcess = std::move(pendingMessages);
|
||||
pendingMessages.clear();
|
||||
}
|
||||
|
||||
for (const auto &item : toProcess) {
|
||||
HandleGlobalMessage(item.msg, item.value);
|
||||
g_screenManager->sendMessage(item.msg.c_str(), item.value.c_str());
|
||||
}
|
||||
|
||||
g_requestManager.ProcessRequests();
|
||||
|
||||
// it's ok to call this redundantly with DoFrame from EmuScreen
|
||||
Achievements::Idle();
|
||||
|
||||
g_DownloadManager.Update();
|
||||
g_screenManager->update();
|
||||
|
||||
g_Discord.Update();
|
||||
g_BackgroundAudio.Play();
|
||||
|
||||
g_OSD.Update();
|
||||
|
||||
UI::SetSoundEnabled(g_Config.bUISound);
|
||||
}
|
||||
|
||||
bool NativeIsAtTopLevel() {
|
||||
// This might need some synchronization?
|
||||
if (!g_screenManager) {
|
||||
|
@ -165,7 +165,6 @@ void PPSSPP_UWPMain::CreateWindowSizeDependentResources() {
|
||||
// Returns true if the frame was rendered and is ready to be displayed.
|
||||
bool PPSSPP_UWPMain::Render() {
|
||||
ctx_->GetDrawContext()->HandleEvent(Draw::Event::PRESENTED, 0, 0, nullptr, nullptr);
|
||||
NativeUpdate();
|
||||
|
||||
static bool hasSetThreadName = false;
|
||||
if (!hasSetThreadName) {
|
||||
@ -212,7 +211,7 @@ bool PPSSPP_UWPMain::Render() {
|
||||
|
||||
context->RSSetViewports(1, &viewport);
|
||||
|
||||
NativeRender(ctx_.get());
|
||||
NativeFrame(ctx_.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1121,8 +1121,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendRequestResult(JNIEn
|
||||
|
||||
void LockedNativeUpdateRender() {
|
||||
std::lock_guard<std::mutex> renderGuard(renderLock);
|
||||
NativeUpdate();
|
||||
NativeRender(graphicsContext);
|
||||
NativeFrame(graphicsContext);
|
||||
}
|
||||
|
||||
void UpdateRunLoopAndroid(JNIEnv *env) {
|
||||
|
@ -94,8 +94,7 @@ public:
|
||||
};
|
||||
|
||||
// Temporary hacks around annoying linking errors.
|
||||
void NativeUpdate() { }
|
||||
void NativeRender(GraphicsContext *graphicsContext) { }
|
||||
void NativeFrame(GraphicsContext *graphicsContext) { }
|
||||
void NativeResized() { }
|
||||
|
||||
std::string System_GetProperty(SystemProperty prop) { return ""; }
|
||||
|
@ -238,8 +238,7 @@ extern float g_safeInsetBottom;
|
||||
|
||||
INFO_LOG(SYSTEM, "Emulation thread starting\n");
|
||||
while (threadEnabled) {
|
||||
NativeUpdate();
|
||||
NativeRender(graphicsContext);
|
||||
NativeFrame(graphicsContext);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1704,8 +1704,7 @@ void System_Notify(SystemNotification notification) {
|
||||
}
|
||||
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) { return false; }
|
||||
void System_PostUIMessage(const std::string &message, const std::string ¶m) {}
|
||||
void NativeUpdate() {}
|
||||
void NativeRender(GraphicsContext *graphicsContext) {}
|
||||
void NativeFrame(GraphicsContext *graphicsContext) {}
|
||||
void NativeResized() {}
|
||||
|
||||
void System_Toast(const char *str) {}
|
||||
|
@ -37,8 +37,7 @@
|
||||
#include "Core/HLE/HLE.h"
|
||||
|
||||
// Temporary hacks around annoying linking errors. Copied from Headless.
|
||||
void NativeUpdate() { }
|
||||
void NativeRender(GraphicsContext *graphicsContext) { }
|
||||
void NativeFrame(GraphicsContext *graphicsContext) { }
|
||||
void NativeResized() { }
|
||||
|
||||
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) { return false; }
|
||||
|
Loading…
Reference in New Issue
Block a user