Skip to content

Commit 8506c1b

Browse files
authored
Fix race condition where update_gfx could be called after renderer shutdown (#98)
1 parent db1b1a1 commit 8506c1b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

librecomp/src/recomp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ bool ultramodern::is_game_started() {
502502
}
503503

504504
std::atomic_bool exited = false;
505+
moodycamel::LightweightSemaphore graphics_shutdown_ready;
505506

506507
void ultramodern::quit() {
507508
exited.store(true);
@@ -763,6 +764,8 @@ void recomp::start(
763764
}
764765
}
765766

767+
graphics_shutdown_ready.signal();
768+
766769
game_thread.join();
767770
ultramodern::join_event_threads();
768771
ultramodern::join_thread_cleaner_thread();

ultramodern/src/events.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ uint64_t total_vis = 0;
105105

106106

107107
extern std::atomic_bool exited;
108+
extern moodycamel::LightweightSemaphore graphics_shutdown_ready;
108109

109110
void set_dummy_vi();
110111

@@ -318,6 +319,7 @@ void gfx_thread_func(uint8_t* rdram, moodycamel::LightweightSemaphore* thread_re
318319
}
319320
}
320321

322+
graphics_shutdown_ready.wait();
321323
renderer_context->shutdown();
322324
}
323325

0 commit comments

Comments
 (0)