[vk_threads] post loss handling minor improvements

This commit is contained in:
xbzk 2026-05-08 14:45:02 -03:00
parent f37be7e51b
commit 512300a875
4 changed files with 41 additions and 3 deletions

View file

@ -16,6 +16,7 @@
#include <queue> #include <queue>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging.h"
#include "common/settings.h" #include "common/settings.h"
#include "common/thread.h" #include "common/thread.h"
#include "video_core/delayed_destruction_ring.h" #include "video_core/delayed_destruction_ring.h"
@ -214,7 +215,12 @@ private:
if (!current_fence->IsStubbed()) { if (!current_fence->IsStubbed()) {
WaitFence(current_fence); WaitFence(current_fence);
} }
PopAsyncFlushes(); try {
PopAsyncFlushes();
} catch (const std::exception& e) {
LOG_CRITICAL(Render_Vulkan, "GPUFencingThread: exception in PopAsyncFlushes: {}", e.what());
throw;
}
for (auto& operation : current_operations) { for (auto& operation : current_operations) {
operation(); operation();
} }

View file

@ -7,6 +7,7 @@
#include <thread> #include <thread>
#include <ranges> #include <ranges>
#include "common/logging.h"
#include "common/settings.h" #include "common/settings.h"
#include "video_core/renderer_vulkan/vk_master_semaphore.h" #include "video_core/renderer_vulkan/vk_master_semaphore.h"
#include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_device.h"
@ -221,7 +222,18 @@ void MasterSemaphore::WaitThread(std::stop_token token) {
wait_queue.pop(); wait_queue.pop();
} }
fence.Wait(); const VkResult wait_result = fence.Wait();
if (wait_result == VK_ERROR_DEVICE_LOST) {
LOG_CRITICAL(Render_Vulkan,
"Fence wait returned VK_ERROR_DEVICE_LOST on infinite wait (driver GPU hang).");
device.ReportLoss();
return;
}
if (wait_result != VK_SUCCESS) {
LOG_CRITICAL(Render_Vulkan, "Fence wait failed: result={}",
static_cast<int>(wait_result));
vk::Check(wait_result);
}
fence.Reset(); fence.Reset();
{ {

View file

@ -4,6 +4,7 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#include <atomic>
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
#include <map> #include <map>
@ -74,10 +75,20 @@ public:
switch (query_result) { switch (query_result) {
case VK_SUCCESS: case VK_SUCCESS:
return; return;
case VK_TIMEOUT: {
LOG_WARNING(Render_Vulkan,
"VK_TIMEOUT pool={} start={} size={}. Attempting to get over...",
index, start, size);
std::fill_n(&host_results[start], size, 0ULL);
return;
}
case VK_ERROR_DEVICE_LOST: case VK_ERROR_DEVICE_LOST:
device.ReportLoss(); device.ReportLoss();
[[fallthrough]]; [[fallthrough]];
default: default:
LOG_CRITICAL(Render_Vulkan,
"GetQueryResults failed: result={} pool={} start={} size={}",
static_cast<int>(query_result), index, start, size);
throw vk::Exception(query_result); throw vk::Exception(query_result);
} }
} }

View file

@ -227,7 +227,16 @@ void Scheduler::WorkerThread(std::stop_token stop_token) {
// Perform the work, tracking whether the chunk was a submission // Perform the work, tracking whether the chunk was a submission
// before executing. // before executing.
const bool has_submit = work->HasSubmit(); const bool has_submit = work->HasSubmit();
work->ExecuteAll(current_cmdbuf, current_upload_cmdbuf); try {
work->ExecuteAll(current_cmdbuf, current_upload_cmdbuf);
} catch (const vk::Exception& e) {
LOG_CRITICAL(Render_Vulkan, "VulkanWorker: vk::Exception in ExecuteAll: result={}",
static_cast<int>(e.GetResult()));
throw;
} catch (const std::exception& e) {
LOG_CRITICAL(Render_Vulkan, "VulkanWorker: exception in ExecuteAll: {}", e.what());
throw;
}
// If the chunk was a submission, reallocate the command buffer. // If the chunk was a submission, reallocate the command buffer.
if (has_submit) { if (has_submit) {