summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2022-03-08 12:36:57 -0800
committerGravatar GitHub2022-03-08 12:36:57 -0800
commitf2743b41b0f8f82bcfe678cf735819ea987b62b4 (patch)
treef5cd00237eda3d4ea49a434e8f01f2a912ded9ce
parentMerge pull request #7989 from degasus/maxwell_LUT3 (diff)
parentvideo_core: Cancel Scoped's exit call on GPU failure (diff)
downloadyuzu-f2743b41b0f8f82bcfe678cf735819ea987b62b4.tar.gz
yuzu-f2743b41b0f8f82bcfe678cf735819ea987b62b4.tar.xz
yuzu-f2743b41b0f8f82bcfe678cf735819ea987b62b4.zip
Merge pull request #7986 from lat9nq/vk-callback
core, video_core: Fix two crashes when failing to create the emulated GPU instance
Diffstat (limited to '')
-rw-r--r--src/core/core.cpp4
-rw-r--r--src/core/frontend/emu_window.h11
-rw-r--r--src/video_core/video_core.cpp1
3 files changed, 14 insertions, 2 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index b0cfee3ee..c60a784c3 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -326,7 +326,9 @@ struct System::Impl {
326 is_powered_on = false; 326 is_powered_on = false;
327 exit_lock = false; 327 exit_lock = false;
328 328
329 gpu_core->NotifyShutdown(); 329 if (gpu_core != nullptr) {
330 gpu_core->NotifyShutdown();
331 }
330 332
331 services.reset(); 333 services.reset();
332 service_manager.reset(); 334 service_manager.reset();
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h
index e413a520a..b3bffecb2 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -42,11 +42,20 @@ public:
42 context.MakeCurrent(); 42 context.MakeCurrent();
43 } 43 }
44 ~Scoped() { 44 ~Scoped() {
45 context.DoneCurrent(); 45 if (active) {
46 context.DoneCurrent();
47 }
48 }
49
50 /// In the event that context was destroyed before the Scoped is destroyed, this provides a
51 /// mechanism to prevent calling a destroyed object's method during the deconstructor
52 void Cancel() {
53 active = false;
46 } 54 }
47 55
48 private: 56 private:
49 GraphicsContext& context; 57 GraphicsContext& context;
58 bool active{true};
50 }; 59 };
51 60
52 /// Calls MakeCurrent on the context and calls DoneCurrent when the scope for the returned value 61 /// Calls MakeCurrent on the context and calls DoneCurrent when the scope for the returned value
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index 329bf4def..2f2594585 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -50,6 +50,7 @@ std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor
50 gpu->BindRenderer(std::move(renderer)); 50 gpu->BindRenderer(std::move(renderer));
51 return gpu; 51 return gpu;
52 } catch (const std::runtime_error& exception) { 52 } catch (const std::runtime_error& exception) {
53 scope.Cancel();
53 LOG_ERROR(HW_GPU, "Failed to initialize GPU: {}", exception.what()); 54 LOG_ERROR(HW_GPU, "Failed to initialize GPU: {}", exception.what());
54 return nullptr; 55 return nullptr;
55 } 56 }