aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/gpu_thread.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-09 11:52:18 -0700
committerGitHub <noreply@github.com>2021-04-09 11:52:18 -0700
commitd6e5e053a6c4fe8538d4b97b8f5a1eba61e2fcac (patch)
tree71dafa020afef119e3d3b57e22ca14f4ba42d9d8 /src/video_core/gpu_thread.h
parentc34249559d4e6184a65a18d601dfcc19010df8a6 (diff)
parente8bd9aed8bf0f60455d0ae6a8f6f3abf92dd8305 (diff)
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.h15
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 =
struct CommandDataContainer {
CommandDataContainer() = default;
- explicit CommandDataContainer(CommandData&& data_, u64 next_fence_)
- : data{std::move(data_)}, fence{next_fence_} {}
+ explicit CommandDataContainer(CommandData&& data_, u64 next_fence_, bool block_)
+ : data{std::move(data_)}, fence{next_fence_}, block(block_) {}
CommandData data;
u64 fence{};
+ bool block{};
};
/// Struct used to synchronize the GPU thread
struct SynchState final {
std::atomic_bool is_running{true};
- using CommandQueue = Common::MPSCQueue<CommandDataContainer>;
+ using CommandQueue = Common::SPSCQueue<CommandDataContainer>;
+ std::mutex write_lock;
CommandQueue queue;
u64 last_fence{};
std::atomic<u64> signaled_fence{};
+ std::condition_variable cv;
};
/// Class used to manage the GPU thread
@@ -132,14 +135,14 @@ public:
/// Notify rasterizer that any caches of the specified region should be flushed and invalidated
void FlushAndInvalidateRegion(VAddr addr, u64 size);
- // Wait until the gpu thread is idle.
- void WaitIdle() const;
+ // Stops the GPU execution and waits for the GPU to finish working
+ void ShutDown();
void OnCommandListEnd();
private:
/// Pushes a command to be executed by the GPU thread
- u64 PushCommand(CommandData&& command_data);
+ u64 PushCommand(CommandData&& command_data, bool block = false);
Core::System& system;
const bool is_async;