diff --git a/src/xenia/gpu/graphics_system.cc b/src/xenia/gpu/graphics_system.cc index f36af1c2f..fbcb1d744 100644 --- a/src/xenia/gpu/graphics_system.cc +++ b/src/xenia/gpu/graphics_system.cc @@ -26,13 +26,16 @@ GraphicsSystem::GraphicsSystem(Emulator* emulator) : emulator_(emulator), memory_(emulator->memory()), thread_(0), running_(false), driver_(0), worker_(0), interrupt_callback_(0), interrupt_callback_data_(0), - last_interrupt_time_(0), swap_pending_(false) { + last_interrupt_time_(0), swap_pending_(false), + thread_wait_(NULL) { // Create the run loop used for any windows/etc. // This must be done on the thread we create the driver. run_loop_ = xe_run_loop_create(); + thread_wait_ = CreateEvent(NULL, TRUE, FALSE, NULL); } GraphicsSystem::~GraphicsSystem() { + CloseHandle(thread_wait_); } X_STATUS GraphicsSystem::Setup() { @@ -58,7 +61,7 @@ X_STATUS GraphicsSystem::Setup() { "GraphicsSystem", (xe_thread_callback)ThreadStartThunk, this); xe_thread_start(thread_); - + WaitForSingleObject(thread_wait_, INFINITE); return X_STATUS_SUCCESS; } @@ -68,6 +71,7 @@ void GraphicsSystem::ThreadStart() { // Initialize driver and ringbuffer. Initialize(); XEASSERTNOTNULL(driver_); + SetEvent(thread_wait_); // Main run loop. while (running_) { diff --git a/src/xenia/gpu/graphics_system.h b/src/xenia/gpu/graphics_system.h index 08d00d9b4..5c1f03f8d 100644 --- a/src/xenia/gpu/graphics_system.h +++ b/src/xenia/gpu/graphics_system.h @@ -88,6 +88,7 @@ protected: uint32_t interrupt_callback_data_; double last_interrupt_time_; bool swap_pending_; + HANDLE thread_wait_; };