diff options
| author | 2021-04-09 11:52:18 -0700 | |
|---|---|---|
| committer | 2021-04-09 11:52:18 -0700 | |
| commit | d6e5e053a6c4fe8538d4b97b8f5a1eba61e2fcac (patch) | |
| tree | 71dafa020afef119e3d3b57e22ca14f4ba42d9d8 /src/video_core/gpu_thread.h | |
| parent | Merge pull request #6164 from Morph1984/service-update-12.x (diff) | |
| parent | video_core: Use a CV for blocking commands. (diff) | |
| download | yuzu-d6e5e053a6c4fe8538d4b97b8f5a1eba61e2fcac.tar.gz yuzu-d6e5e053a6c4fe8538d4b97b8f5a1eba61e2fcac.tar.xz yuzu-d6e5e053a6c4fe8538d4b97b8f5a1eba61e2fcac.zip | |
Merge pull request #6162 from degasus/no_spin_loops
video_core: Avoid spin loops.
Diffstat (limited to 'src/video_core/gpu_thread.h')
| -rw-r--r-- | src/video_core/gpu_thread.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h index 18269e51c..11a648f38 100644 --- a/src/video_core/gpu_thread.h +++ b/src/video_core/gpu_thread.h | |||
| @@ -90,21 +90,24 @@ using CommandData = | |||
| 90 | struct CommandDataContainer { | 90 | struct CommandDataContainer { |
| 91 | CommandDataContainer() = default; | 91 | CommandDataContainer() = default; |
| 92 | 92 | ||
| 93 | explicit CommandDataContainer(CommandData&& data_, u64 next_fence_) | 93 | explicit CommandDataContainer(CommandData&& data_, u64 next_fence_, bool block_) |
| 94 | : data{std::move(data_)}, fence{next_fence_} {} | 94 | : data{std::move(data_)}, fence{next_fence_}, block(block_) {} |
| 95 | 95 | ||
| 96 | CommandData data; | 96 | CommandData data; |
| 97 | u64 fence{}; | 97 | u64 fence{}; |
| 98 | bool block{}; | ||
| 98 | }; | 99 | }; |
| 99 | 100 | ||
| 100 | /// Struct used to synchronize the GPU thread | 101 | /// Struct used to synchronize the GPU thread |
| 101 | struct SynchState final { | 102 | struct SynchState final { |
| 102 | std::atomic_bool is_running{true}; | 103 | std::atomic_bool is_running{true}; |
| 103 | 104 | ||
| 104 | using CommandQueue = Common::MPSCQueue<CommandDataContainer>; | 105 | using CommandQueue = Common::SPSCQueue<CommandDataContainer>; |
| 106 | std::mutex write_lock; | ||
| 105 | CommandQueue queue; | 107 | CommandQueue queue; |
| 106 | u64 last_fence{}; | 108 | u64 last_fence{}; |
| 107 | std::atomic<u64> signaled_fence{}; | 109 | std::atomic<u64> signaled_fence{}; |
| 110 | std::condition_variable cv; | ||
| 108 | }; | 111 | }; |
| 109 | 112 | ||
| 110 | /// Class used to manage the GPU thread | 113 | /// Class used to manage the GPU thread |
| @@ -132,14 +135,14 @@ public: | |||
| 132 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated | 135 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated |
| 133 | void FlushAndInvalidateRegion(VAddr addr, u64 size); | 136 | void FlushAndInvalidateRegion(VAddr addr, u64 size); |
| 134 | 137 | ||
| 135 | // Wait until the gpu thread is idle. | 138 | // Stops the GPU execution and waits for the GPU to finish working |
| 136 | void WaitIdle() const; | 139 | void ShutDown(); |
| 137 | 140 | ||
| 138 | void OnCommandListEnd(); | 141 | void OnCommandListEnd(); |
| 139 | 142 | ||
| 140 | private: | 143 | private: |
| 141 | /// Pushes a command to be executed by the GPU thread | 144 | /// Pushes a command to be executed by the GPU thread |
| 142 | u64 PushCommand(CommandData&& command_data); | 145 | u64 PushCommand(CommandData&& command_data, bool block = false); |
| 143 | 146 | ||
| 144 | Core::System& system; | 147 | Core::System& system; |
| 145 | const bool is_async; | 148 | const bool is_async; |