aboutsummaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-07-09 19:02:26 +0200
committercrueter <crueter@eden-emu.dev>2026-07-09 19:02:26 +0200
commit3fd6eeaf9fb42c942ffbc2a60a50dd8ebfd8dfee (patch)
tree374fbcafa21b93faca67f5e9a9d58e6c183f61e0 /src/video_core
parent372bdfccbc06aead40fc4d14620df6c292728656 (diff)
Revert #3970 #4177 (#4187)
3970 revert fixes crash caused by scheduler 4177 fix mario galaxy and metroid prime 4 not booting Co-authored-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4187 Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_vulkan/vk_scheduler.cpp105
-rw-r--r--src/video_core/renderer_vulkan/vk_scheduler.h2
2 files changed, 56 insertions, 51 deletions
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp
index 48268df708..3bf7a9ac78 100644
--- a/src/video_core/renderer_vulkan/vk_scheduler.cpp
+++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp
@@ -60,57 +60,7 @@ Scheduler::Scheduler(const Device& device_, StateTracker& state_tracker_)
AcquireNewChunk();
AllocateWorkerCommandBuffer();
- worker_thread = std::jthread([this](std::stop_token stop_token) {
- Common::SetCurrentThreadName("VulkanWorker");
- const auto TryPopQueue{[this](auto& work) -> bool {
- if (work_queue.empty()) {
- return false;
- }
-
- work = std::move(work_queue.front());
- work_queue.pop();
- event_cv.notify_all();
- return true;
- }};
-
- while (!stop_token.stop_requested()) {
- std::unique_ptr<CommandChunk> work;
-
- {
- std::unique_lock lk{queue_mutex};
-
- // Wait for work.
- event_cv.wait(lk, stop_token, [&] { return TryPopQueue(work); });
-
- // If we've been asked to stop, we're done.
- if (stop_token.stop_requested()) {
- return;
- }
-
- // Exchange lock ownership so that we take the execution lock before
- // the queue lock goes out of scope. This allows us to force execution
- // to complete in the next step.
- std::exchange(lk, std::unique_lock{execution_mutex});
-
- // Perform the work, tracking whether the chunk was a submission
- // before executing.
- const bool has_submit = work->HasSubmit();
- work->ExecuteAll(current_cmdbuf, current_upload_cmdbuf);
-
- // If the chunk was a submission, reallocate the command buffer.
- if (has_submit) {
- AllocateWorkerCommandBuffer();
- }
- }
-
- {
- std::scoped_lock rl{reserve_mutex};
-
- // Recycle the chunk back to the reserve.
- chunk_reserve.emplace_back(std::move(work));
- }
- }
- });
+ worker_thread = std::jthread([this](std::stop_token token) { WorkerThread(token); });
}
Scheduler::~Scheduler() = default;
@@ -248,6 +198,59 @@ bool Scheduler::UpdateRescaling(bool is_rescaling) {
return true;
}
+void Scheduler::WorkerThread(std::stop_token stop_token) {
+ Common::SetCurrentThreadName("VulkanWorker");
+
+ const auto TryPopQueue{[this](auto& work) -> bool {
+ if (work_queue.empty()) {
+ return false;
+ }
+
+ work = std::move(work_queue.front());
+ work_queue.pop();
+ event_cv.notify_all();
+ return true;
+ }};
+
+ while (!stop_token.stop_requested()) {
+ std::unique_ptr<CommandChunk> work;
+
+ {
+ std::unique_lock lk{queue_mutex};
+
+ // Wait for work.
+ event_cv.wait(lk, stop_token, [&] { return TryPopQueue(work); });
+
+ // If we've been asked to stop, we're done.
+ if (stop_token.stop_requested()) {
+ return;
+ }
+
+ // Exchange lock ownership so that we take the execution lock before
+ // the queue lock goes out of scope. This allows us to force execution
+ // to complete in the next step.
+ std::exchange(lk, std::unique_lock{execution_mutex});
+
+ // Perform the work, tracking whether the chunk was a submission
+ // before executing.
+ const bool has_submit = work->HasSubmit();
+ work->ExecuteAll(current_cmdbuf, current_upload_cmdbuf);
+
+ // If the chunk was a submission, reallocate the command buffer.
+ if (has_submit) {
+ AllocateWorkerCommandBuffer();
+ }
+ }
+
+ {
+ std::scoped_lock rl{reserve_mutex};
+
+ // Recycle the chunk back to the reserve.
+ chunk_reserve.emplace_back(std::move(work));
+ }
+ }
+}
+
void Scheduler::AllocateWorkerCommandBuffer() {
current_cmdbuf = vk::CommandBuffer(command_pool->Commit(), device.GetDispatchLoader());
current_cmdbuf.Begin({
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h
index 6f471f6247..51ccd102f8 100644
--- a/src/video_core/renderer_vulkan/vk_scheduler.h
+++ b/src/video_core/renderer_vulkan/vk_scheduler.h
@@ -251,6 +251,8 @@ private:
bool needs_state_enable_refresh = false;
};
+ void WorkerThread(std::stop_token stop_token);
+
void AllocateWorkerCommandBuffer();
u64 SubmitExecution(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore);