diff options
| author | 2021-04-07 11:41:31 +0200 | |
|---|---|---|
| committer | 2021-04-07 22:38:52 +0200 | |
| commit | e8bd9aed8bf0f60455d0ae6a8f6f3abf92dd8305 (patch) | |
| tree | 042497b8c297e874b382f4b695bb601b6ea2d1cf /src/video_core/gpu_thread.h | |
| parent | video_core/gpu_thread: Keep the write lock for allocating the fence. (diff) | |
| download | yuzu-e8bd9aed8bf0f60455d0ae6a8f6f3abf92dd8305.tar.gz yuzu-e8bd9aed8bf0f60455d0ae6a8f6f3abf92dd8305.tar.xz yuzu-e8bd9aed8bf0f60455d0ae6a8f6f3abf92dd8305.zip | |
video_core: Use a CV for blocking commands.
There is no need for a busy loop here. Let's just use a condition variable to save some power.
Diffstat (limited to 'src/video_core/gpu_thread.h')
| -rw-r--r-- | src/video_core/gpu_thread.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h index cb901c22a..11a648f38 100644 --- a/src/video_core/gpu_thread.h +++ b/src/video_core/gpu_thread.h | |||
| @@ -90,11 +90,12 @@ 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 |
| @@ -106,6 +107,7 @@ struct SynchState final { | |||
| 106 | CommandQueue queue; | 107 | CommandQueue queue; |
| 107 | u64 last_fence{}; | 108 | u64 last_fence{}; |
| 108 | std::atomic<u64> signaled_fence{}; | 109 | std::atomic<u64> signaled_fence{}; |
| 110 | std::condition_variable cv; | ||
| 109 | }; | 111 | }; |
| 110 | 112 | ||
| 111 | /// Class used to manage the GPU thread | 113 | /// Class used to manage the GPU thread |
| @@ -140,10 +142,7 @@ public: | |||
| 140 | 142 | ||
| 141 | private: | 143 | private: |
| 142 | /// Pushes a command to be executed by the GPU thread | 144 | /// Pushes a command to be executed by the GPU thread |
| 143 | u64 PushCommand(CommandData&& command_data); | 145 | u64 PushCommand(CommandData&& command_data, bool block = false); |
| 144 | |||
| 145 | // Wait until the gpu thread is idle. | ||
| 146 | void WaitIdle() const; | ||
| 147 | 146 | ||
| 148 | Core::System& system; | 147 | Core::System& system; |
| 149 | const bool is_async; | 148 | const bool is_async; |