aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/gpu_thread.cpp
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-04-29 19:23:20 +0200
committercrueter <crueter@eden-emu.dev>2026-04-29 19:23:20 +0200
commit8765b4951201a94673d5b561f6ba5094b2af0fa5 (patch)
treeeda339e386199eec0761307bfa14a0c9ed162e7c /src/video_core/gpu_thread.cpp
parenta587b7dc3ae5eb475ca63c747afe8866a590d499 (diff)
[video_core] fix H264 and jthread() causing spurious errors (#3907)
fixes regression by #3878 Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3907 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Diffstat (limited to 'src/video_core/gpu_thread.cpp')
-rw-r--r--src/video_core/gpu_thread.cpp73
1 files changed, 32 insertions, 41 deletions
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp
index 68f2530668..d7c8ac391c 100644
--- a/src/video_core/gpu_thread.cpp
+++ b/src/video_core/gpu_thread.cpp
@@ -19,45 +19,6 @@
namespace VideoCommon::GPUThread {
-/// Runs the GPU thread
-static void RunThread(std::stop_token stop_token, Core::System& system,
- VideoCore::RendererBase& renderer, Core::Frontend::GraphicsContext& context,
- Tegra::Control::Scheduler& scheduler, SynchState& state) {
- Common::SetCurrentThreadName("GPU");
- Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical);
- system.RegisterHostThread();
-
- auto current_context = context.Acquire();
- VideoCore::RasterizerInterface* const rasterizer = renderer.ReadRasterizer();
-
- CommandDataContainer next;
-
- while (!stop_token.stop_requested()) {
- state.queue.PopWait(next, stop_token);
- if (stop_token.stop_requested()) {
- break;
- }
- if (auto* submit_list = std::get_if<SubmitListCommand>(&next.data)) {
- scheduler.Push(submit_list->channel, std::move(submit_list->entries));
- } else if (std::holds_alternative<GPUTickCommand>(next.data)) {
- system.GPU().TickWork();
- } else if (const auto* flush = std::get_if<FlushRegionCommand>(&next.data)) {
- rasterizer->FlushRegion(flush->addr, flush->size);
- } else if (const auto* invalidate = std::get_if<InvalidateRegionCommand>(&next.data)) {
- rasterizer->OnCacheInvalidation(invalidate->addr, invalidate->size);
- } else {
- ASSERT(false);
- }
- state.signaled_fence.store(next.fence);
- if (next.block) {
- // We have to lock the write_lock to ensure that the condition_variable wait not get a
- // race between the check and the lock itself.
- std::scoped_lock lk{state.write_lock};
- state.cv.notify_all();
- }
- }
-}
-
ThreadManager::ThreadManager(Core::System& system_, bool is_async_)
: system{system_}, is_async{is_async_} {}
@@ -65,8 +26,38 @@ ThreadManager::~ThreadManager() = default;
void ThreadManager::StartThread(VideoCore::RendererBase& renderer, Core::Frontend::GraphicsContext& context, Tegra::Control::Scheduler& scheduler) {
rasterizer = renderer.ReadRasterizer();
- thread = std::jthread(RunThread, std::ref(system), std::ref(renderer), std::ref(context),
- std::ref(scheduler), std::ref(state));
+ thread = std::jthread([&](std::stop_token stop_token) {
+ Common::SetCurrentThreadName("GPU");
+ Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical);
+ system.RegisterHostThread();
+
+ auto current_context = context.Acquire();
+ CommandDataContainer next;
+ while (!stop_token.stop_requested()) {
+ state.queue.PopWait(next, stop_token);
+ if (stop_token.stop_requested()) {
+ break;
+ }
+ if (auto* submit_list = std::get_if<SubmitListCommand>(&next.data)) {
+ scheduler.Push(submit_list->channel, std::move(submit_list->entries));
+ } else if (std::holds_alternative<GPUTickCommand>(next.data)) {
+ system.GPU().TickWork();
+ } else if (const auto* flush = std::get_if<FlushRegionCommand>(&next.data)) {
+ renderer.ReadRasterizer()->FlushRegion(flush->addr, flush->size);
+ } else if (const auto* invalidate = std::get_if<InvalidateRegionCommand>(&next.data)) {
+ renderer.ReadRasterizer()->OnCacheInvalidation(invalidate->addr, invalidate->size);
+ } else {
+ ASSERT(false);
+ }
+ state.signaled_fence.store(next.fence);
+ if (next.block) {
+ // We have to lock the write_lock to ensure that the condition_variable wait not get a
+ // race between the check and the lock itself.
+ std::scoped_lock lk{state.write_lock};
+ state.cv.notify_all();
+ }
+ }
+ });
}
void ThreadManager::SubmitList(s32 channel, Tegra::CommandList&& entries) {