mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 07:20:31 +02:00
EmuThread_Join drains the render queue on the calling thread. On Android that is either the UI thread with no GL context (NativeApp.shutdown), or the GL thread with a brand new context after the old one was lost (displayInit the second time). The skip flag was only set once the emu thread reached NativeShutdownGraphics, so everything queued before that ran for real, against nothing or against the wrong context. Add GraphicsContext::NotifyContextLost() and call it before the join in both places. skipGLCalls_ is now atomic, since it's set from one thread and read from another. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "Common/GPU/GraphicsContext.h"
|
|
#include "Common/GPU/OpenGL/GLRenderManager.h"
|
|
#include "Common/GPU/thin3d_create.h"
|
|
|
|
// This one is mainly useful for the backends that already initialize GL in platform-specific code.
|
|
// It doesn't have the real initialization that we need to do on some platforms.
|
|
class OpenGLGraphicsContext : public GraphicsContext {
|
|
public:
|
|
OpenGLGraphicsContext();
|
|
~OpenGLGraphicsContext() override { delete draw_; }
|
|
|
|
bool NeedsSeparateEmuThread() const override { return true; }
|
|
|
|
bool InitSurface(WindowSystem winsys, void *data1, void *data2, std::string *error_message) override;
|
|
void ShutdownSurface() override;
|
|
|
|
void Resize() override {}
|
|
|
|
Draw::DrawContext *GetDrawContext() override {
|
|
return draw_;
|
|
}
|
|
|
|
// Called from render thread
|
|
void ThreadStart() override {
|
|
renderManager_->ThreadStart(draw_);
|
|
}
|
|
bool ThreadFrame() override {
|
|
return renderManager_->ThreadFrame();
|
|
}
|
|
void ThreadEnd() override {
|
|
renderManager_->ThreadEnd();
|
|
}
|
|
|
|
void NotifyContextLost() override {
|
|
if (renderManager_) {
|
|
renderManager_->SetSkipGLCalls();
|
|
}
|
|
}
|
|
|
|
// Call from emu thread
|
|
void NotifyEmuThreadExit() override {
|
|
renderManager_->SetSkipGLCalls();
|
|
renderManager_->NotifyEmuThreadExit();
|
|
}
|
|
|
|
private:
|
|
Draw::DrawContext *draw_ = nullptr;
|
|
GLRenderManager *renderManager_ = nullptr;
|
|
};
|
|
|