소스 검색

common/threadsafe_queue: Provide Wait() method.

It shall block until there is something to consume in the queue.

And use it for the GPU emulation instead of the spin loop.
This is only in booting the emulator, however in BOTW this is the case for about 1 second.
Markus Wick 5 년 전
부모
커밋
4aec060f6d
2개의 변경된 파일10개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 1
      src/common/threadsafe_queue.h
  2. 1 2
      src/video_core/gpu_thread.cpp

+ 9 - 1
src/common/threadsafe_queue.h

@@ -83,11 +83,15 @@ public:
         return true;
     }
 
-    T PopWait() {
+    void Wait() {
         if (Empty()) {
             std::unique_lock lock{cv_mutex};
             cv.wait(lock, [this]() { return !Empty(); });
         }
+    }
+
+    T PopWait() {
+        Wait();
         T t;
         Pop(t);
         return t;
@@ -156,6 +160,10 @@ public:
         return spsc_queue.Pop(t);
     }
 
+    void Wait() {
+        spsc_queue.Wait();
+    }
+
     T PopWait() {
         return spsc_queue.PopWait();
     }

+ 1 - 2
src/video_core/gpu_thread.cpp

@@ -29,8 +29,7 @@ static void RunThread(Core::System& system, VideoCore::RendererBase& renderer,
     system.RegisterHostThread();
 
     // Wait for first GPU command before acquiring the window context
-    while (state.queue.Empty())
-        ;
+    state.queue.Wait();
 
     // If emulation was stopped during disk shader loading, abort before trying to acquire context
     if (!state.is_running) {