mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
SDL: Add a way to reset OpenGL graphics by pressing F7.
This commit is contained in:
parent
7912eef0b7
commit
d167a11b1c
3 changed files with 50 additions and 8 deletions
|
@ -626,11 +626,11 @@ bool CheckGLExtensions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetGLCoreContext(bool flag) {
|
void SetGLCoreContext(bool flag) {
|
||||||
_assert_msg_(!extensionsDone, "SetGLCoreContext() after CheckGLExtensions()");
|
if (!extensionsDone) {
|
||||||
|
useCoreContext = flag;
|
||||||
useCoreContext = flag;
|
// For convenience, it'll get reset later.
|
||||||
// For convenience, it'll get reset later.
|
gl_extensions.IsCoreContext = useCoreContext;
|
||||||
gl_extensions.IsCoreContext = useCoreContext;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetGLExtensions() {
|
void ResetGLExtensions() {
|
||||||
|
|
|
@ -449,9 +449,12 @@ void SDLGLGraphicsContext::Shutdown() {
|
||||||
void SDLGLGraphicsContext::ShutdownFromRenderThread() {
|
void SDLGLGraphicsContext::ShutdownFromRenderThread() {
|
||||||
delete draw_;
|
delete draw_;
|
||||||
draw_ = nullptr;
|
draw_ = nullptr;
|
||||||
|
renderManager_ = nullptr;
|
||||||
|
|
||||||
#ifdef USING_EGL
|
#ifdef USING_EGL
|
||||||
EGL_Close();
|
EGL_Close();
|
||||||
#endif
|
#endif
|
||||||
SDL_GL_DeleteContext(glContext);
|
SDL_GL_DeleteContext(glContext);
|
||||||
|
glContext = nullptr;
|
||||||
|
window_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -589,7 +589,7 @@ static void EmuThreadStart(GraphicsContext *context) {
|
||||||
emuThread = std::thread(&EmuThreadFunc, context);
|
emuThread = std::thread(&EmuThreadFunc, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EmuThreadStop() {
|
static void EmuThreadStop(const char *reason) {
|
||||||
emuThreadState = (int)EmuThreadState::QUIT_REQUESTED;
|
emuThreadState = (int)EmuThreadState::QUIT_REQUESTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,9 +931,11 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
#if PPSSPP_PLATFORM(MAC)
|
#if PPSSPP_PLATFORM(MAC)
|
||||||
// setup menu items for macOS
|
// setup menu items for macOS
|
||||||
initializeOSXExtras();
|
initializeOSXExtras();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool rebootEmuThread = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
double startTime = time_now_d();
|
double startTime = time_now_d();
|
||||||
|
|
||||||
|
@ -1046,6 +1048,13 @@ int main(int argc, char *argv[]) {
|
||||||
key.keyCode = mapped->second;
|
key.keyCode = mapped->second;
|
||||||
key.deviceId = DEVICE_ID_KEYBOARD;
|
key.deviceId = DEVICE_ID_KEYBOARD;
|
||||||
NativeKey(key);
|
NativeKey(key);
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
if (k == SDLK_F7 && useEmuThread) {
|
||||||
|
printf("f7 pressed - rebooting emuthread\n");
|
||||||
|
rebootEmuThread = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
|
@ -1349,6 +1358,36 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rebootEmuThread) {
|
||||||
|
printf("rebooting emu thread");
|
||||||
|
rebootEmuThread = false;
|
||||||
|
EmuThreadStop("shutdown");
|
||||||
|
// Skipping GL calls, the old context is gone.
|
||||||
|
while (graphicsContext->ThreadFrame()) {
|
||||||
|
INFO_LOG(SYSTEM, "graphicsContext->ThreadFrame executed to clear buffers");
|
||||||
|
}
|
||||||
|
EmuThreadJoin();
|
||||||
|
graphicsContext->ThreadEnd();
|
||||||
|
graphicsContext->ShutdownFromRenderThread();
|
||||||
|
|
||||||
|
printf("OK, shutdown complete. starting up graphics again.\n");
|
||||||
|
|
||||||
|
if (g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
|
||||||
|
SDLGLGraphicsContext *ctx = (SDLGLGraphicsContext *)graphicsContext;
|
||||||
|
if (!ctx->Init(window, x, y, w, h, mode, &error_message)) {
|
||||||
|
printf("Failed to reinit graphics.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!graphicsContext->InitFromRenderThread(&error_message)) {
|
||||||
|
System_Toast("Graphics initialization failed. Quitting.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EmuThreadStart(graphicsContext);
|
||||||
|
graphicsContext->ThreadStart();
|
||||||
|
}
|
||||||
|
|
||||||
// Simple throttling to not burn the GPU in the menu.
|
// Simple throttling to not burn the GPU in the menu.
|
||||||
if (GetUIState() != UISTATE_INGAME || !PSP_IsInited() || renderThreadPaused) {
|
if (GetUIState() != UISTATE_INGAME || !PSP_IsInited() || renderThreadPaused) {
|
||||||
double diffTime = time_now_d() - startTime;
|
double diffTime = time_now_d() - startTime;
|
||||||
|
@ -1361,7 +1400,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useEmuThread) {
|
if (useEmuThread) {
|
||||||
EmuThreadStop();
|
EmuThreadStop("shutdown");
|
||||||
while (graphicsContext->ThreadFrame()) {
|
while (graphicsContext->ThreadFrame()) {
|
||||||
// Need to keep eating frames to allow the EmuThread to exit correctly.
|
// Need to keep eating frames to allow the EmuThread to exit correctly.
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue