Make EmuThreadFunc match Android's EmuThreadFunc

This commit is contained in:
Henrik Rydgård committed 2026-07-24 15:31:42 +02:00
1 parent 02017ad41e
commit b2c5fdc39f
2 files changed
+14 -14

No files matched your search

+12 -1
View File
@@ -41,14 +41,22 @@ bool MainThread_Ready() {
}
static void EmuThreadFunc(GraphicsContext *graphicsContext, std::function<void()> postFrame) {
INFO_LOG(Log::G3D, "Entering emu thread");
SetCurrentThreadName("EmuThread");
AndroidJNIThreadContext context;
// There's no real requirement that NativeInit happen on this thread.
// We just call the update/render loop here.
g_emuThreadState = EmuThreadState::RUNNING;
NativeInitGraphics(graphicsContext);
if (!NativeInitGraphics(graphicsContext)) {
_assert_msg_(false, "NativeInitGraphics failed, might as well bail");
// If this fails, which it normally shouldn't, let's bail.
g_emuThreadState = EmuThreadState::QUIT_REQUESTED;
} else {
INFO_LOG(Log::G3D, "EmuThread: Entering loop");
}
while (g_emuThreadState != EmuThreadState::QUIT_REQUESTED) {
// We're here again, so the game quit. Restart Run() which controls the UI.
@@ -63,9 +71,12 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext, std::function<void()
}
}
INFO_LOG(Log::System, "emuThreadState was set to QUIT_REQUESTED, left EmuThreadFunc loop. Setting state to STOPPED.");
g_emuThreadState = EmuThreadState::STOPPED;
NativeShutdownGraphics();
INFO_LOG(Log::System, "Leaving emu thread");
}
std::thread EmuThread_Start(GraphicsContext *graphicsContext, std::function<void()> postFrame) {
+2 -13
View File
@@ -272,11 +272,7 @@ static void EmuThreadFunc() {
INFO_LOG(Log::System, "Entering emu thread");
// Wait for render loop to get started.
INFO_LOG(Log::System, "Runloop: Waiting for displayInit...");
_dbg_assert_(graphicsContext);
// Check the state of the graphics context before we try to feed it into NativeInitGraphics.
_assert_(graphicsContext);
if (!NativeInitGraphics(graphicsContext)) {
_assert_msg_(false, "NativeInitGraphics failed, might as well bail");
emuThreadState = (int)EmuThreadState::QUIT_REQUESTED;
@@ -1754,14 +1750,7 @@ static void VulkanEmuThread(ANativeWindow *wnd) {
AndroidJNIThreadContext ctx;
JNIEnv *env = getEnv();
if (!graphicsContext) {
ERROR_LOG(Log::G3D, "runVulkanRenderLoop: Tried to enter without a created graphics context.");
renderLoopRunning = false;
exitRenderLoop = false;
ANativeWindow_release(wnd);
return;
}
_assert_(graphicsContext);
if (exitRenderLoop) {
WARN_LOG(Log::G3D, "runVulkanRenderLoop: ExitRenderLoop requested at start, skipping the whole thing.");