mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-10 02:23:17 +00:00
Merge pull request #10599 from unknownbrackets/gl-render-manager
Fix yet more shutdown shenanigans
This commit is contained in:
commit
030de0ad0b
@ -32,6 +32,7 @@ public:
|
||||
virtual void ThreadStart() {}
|
||||
virtual bool ThreadFrame() { return true; }
|
||||
virtual void ThreadEnd() {}
|
||||
virtual void StopThread() {}
|
||||
|
||||
virtual Draw::DrawContext *GetDrawContext() = 0;
|
||||
};
|
||||
|
@ -208,6 +208,7 @@ void MainUI::EmuThreadFunc() {
|
||||
emuThreadState = (int)EmuThreadState::STOPPED;
|
||||
|
||||
NativeShutdownGraphics();
|
||||
graphicsContext->StopThread();
|
||||
}
|
||||
|
||||
void MainUI::EmuThreadStart() {
|
||||
|
@ -82,6 +82,11 @@ public:
|
||||
renderManager_->ThreadEnd();
|
||||
}
|
||||
|
||||
void StopThread() override {
|
||||
renderManager_->WaitUntilQueueIdle();
|
||||
renderManager_->StopThread();
|
||||
}
|
||||
|
||||
private:
|
||||
Draw::DrawContext *draw_ = nullptr;
|
||||
GLRenderManager *renderManager_ = nullptr;
|
||||
|
@ -38,6 +38,11 @@ public:
|
||||
renderManager_->ThreadEnd();
|
||||
}
|
||||
|
||||
void StopThread() override {
|
||||
renderManager_->WaitUntilQueueIdle();
|
||||
renderManager_->StopThread();
|
||||
}
|
||||
|
||||
private:
|
||||
Draw::DrawContext *draw_ = nullptr;
|
||||
SDL_Window *window_;
|
||||
|
@ -423,6 +423,7 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext) {
|
||||
emuThreadState = (int)EmuThreadState::STOPPED;
|
||||
|
||||
NativeShutdownGraphics();
|
||||
graphicsContext->StopThread();
|
||||
}
|
||||
|
||||
static void EmuThreadStart(GraphicsContext *context) {
|
||||
|
@ -86,6 +86,9 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext) {
|
||||
emuThreadState = (int)EmuThreadState::STOPPED;
|
||||
|
||||
NativeShutdownGraphics();
|
||||
|
||||
// Ask the main thread to stop. This prevents a hang on a race condition.
|
||||
graphicsContext->StopThread();
|
||||
}
|
||||
|
||||
static void EmuThreadStart(GraphicsContext *graphicsContext) {
|
||||
@ -231,6 +234,10 @@ void MainThreadFunc() {
|
||||
}
|
||||
}
|
||||
Core_Stop();
|
||||
if (!useEmuThread) {
|
||||
// Process the shutdown. Without this, non-GL delays 800ms on shutdown.
|
||||
Core_Run(g_graphicsContext);
|
||||
}
|
||||
Core_WaitInactive(800);
|
||||
|
||||
g_inLoop = false;
|
||||
|
@ -432,3 +432,8 @@ bool WindowsGLContext::ThreadFrame() {
|
||||
void WindowsGLContext::ThreadEnd() {
|
||||
renderManager_->ThreadEnd();
|
||||
}
|
||||
|
||||
void WindowsGLContext::StopThread() {
|
||||
renderManager_->WaitUntilQueueIdle();
|
||||
renderManager_->StopThread();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
void ThreadStart() override;
|
||||
void ThreadEnd() override;
|
||||
bool ThreadFrame() override;
|
||||
void StopThread() override;
|
||||
|
||||
Draw::DrawContext *GetDrawContext() override { return draw_; }
|
||||
|
||||
|
@ -915,7 +915,7 @@ namespace MainWindow
|
||||
MainThread_Stop();
|
||||
coreState = CORE_POWERUP;
|
||||
ResetUIState();
|
||||
MainThread_Start(false);
|
||||
MainThread_Start(g_Config.iGPUBackend == (int)GPUBackend::OPENGL);
|
||||
InputDevice::BeginPolling();
|
||||
break;
|
||||
|
||||
|
@ -27,5 +27,4 @@ void AndroidJavaEGLGraphicsContext::ShutdownFromRenderThread() {
|
||||
}
|
||||
|
||||
void AndroidJavaEGLGraphicsContext::Shutdown() {
|
||||
// TODO
|
||||
}
|
||||
|
@ -44,6 +44,11 @@ public:
|
||||
renderManager_->ThreadEnd();
|
||||
}
|
||||
|
||||
void StopThread() override {
|
||||
renderManager_->WaitUntilQueueIdle();
|
||||
renderManager_->StopThread();
|
||||
}
|
||||
|
||||
private:
|
||||
Draw::DrawContext *draw_ = nullptr;
|
||||
GLRenderManager *renderManager_ = nullptr;
|
||||
|
@ -196,6 +196,9 @@ static void EmuThreadFunc() {
|
||||
|
||||
NativeShutdownGraphics();
|
||||
|
||||
// Also ask the main thread to stop, so it doesn't hang waiting for a new frame.
|
||||
graphicsContext->StopThread();
|
||||
|
||||
gJvm->DetachCurrentThread();
|
||||
ILOG("Leaving emu thread");
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ bool OpenGLContext::CopyFramebufferToMemorySync(Framebuffer *src, int channelBit
|
||||
aspect |= GL_DEPTH_BUFFER_BIT;
|
||||
if (channelBits & FB_STENCIL_BIT)
|
||||
aspect |= GL_STENCIL_BUFFER_BIT;
|
||||
renderManager_.CopyFramebufferToMemorySync(fb->framebuffer, aspect, x, y, w, h, dataFormat, (uint8_t *)pixels, pixelStride);
|
||||
renderManager_.CopyFramebufferToMemorySync(fb ? fb->framebuffer : nullptr, aspect, x, y, w, h, dataFormat, (uint8_t *)pixels, pixelStride);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user