2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #3927 from jroweboy/fix-bug

Frontend: Remove tracking for context wrapper
This commit is contained in:
bunnei 2020-05-14 00:07:38 -04:00 committed by GitHub
commit 024c84d2db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -150,18 +150,19 @@ public:
} }
void MakeCurrent() override { void MakeCurrent() override {
if (is_current) { // We can't track the current state of the underlying context in this wrapper class because
return; // Qt may make the underlying context not current for one reason or another. In particular,
// the WebBrowser uses GL, so it seems to conflict if we aren't careful.
// Instead of always just making the context current (which does not have any caching to
// check if the underlying context is already current) we can check for the current context
// in the thread local data by calling `currentContext()` and checking if its ours.
if (QOpenGLContext::currentContext() != context.get()) {
context->makeCurrent(surface);
} }
is_current = context->makeCurrent(surface);
} }
void DoneCurrent() override { void DoneCurrent() override {
if (!is_current) {
return;
}
context->doneCurrent(); context->doneCurrent();
is_current = false;
} }
QOpenGLContext* GetShareContext() { QOpenGLContext* GetShareContext() {
@ -178,7 +179,6 @@ private:
std::unique_ptr<QOpenGLContext> context; std::unique_ptr<QOpenGLContext> context;
std::unique_ptr<QOffscreenSurface> offscreen_surface{}; std::unique_ptr<QOffscreenSurface> offscreen_surface{};
QSurface* surface; QSurface* surface;
bool is_current = false;
}; };
class DummyContext : public Core::Frontend::GraphicsContext {}; class DummyContext : public Core::Frontend::GraphicsContext {};