diff options
| author | 2019-12-19 02:09:05 -0300 | |
|---|---|---|
| committer | 2019-12-19 16:31:33 -0300 | |
| commit | 54747d60bc6cce24b51af737ef2b26b6b120661e (patch) | |
| tree | 680d3f9d5d893d676769bd1b409ea67419cc196f /src | |
| parent | vk_device: Add query for RGBA8Uint (diff) | |
| download | yuzu-54747d60bc6cce24b51af737ef2b26b6b120661e.tar.gz yuzu-54747d60bc6cce24b51af737ef2b26b6b120661e.tar.xz yuzu-54747d60bc6cce24b51af737ef2b26b6b120661e.zip | |
vk_device: Add entry to catch device losses
VK_NV_device_diagnostic_checkpoints allows us to push data to a Vulkan
queue and then query it even after a device loss. This allows us to push
the current pipeline object and see what was the call that killed the
device.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_device.cpp | 21 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_device.h | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_resource_manager.cpp | 11 |
3 files changed, 40 insertions, 1 deletions
diff --git a/src/video_core/renderer_vulkan/vk_device.cpp b/src/video_core/renderer_vulkan/vk_device.cpp index a57428059..939eebe83 100644 --- a/src/video_core/renderer_vulkan/vk_device.cpp +++ b/src/video_core/renderer_vulkan/vk_device.cpp | |||
| @@ -3,12 +3,15 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <bitset> | 5 | #include <bitset> |
| 6 | #include <chrono> | ||
| 6 | #include <cstdlib> | 7 | #include <cstdlib> |
| 7 | #include <optional> | 8 | #include <optional> |
| 8 | #include <set> | 9 | #include <set> |
| 9 | #include <string_view> | 10 | #include <string_view> |
| 11 | #include <thread> | ||
| 10 | #include <vector> | 12 | #include <vector> |
| 11 | #include "common/assert.h" | 13 | #include "common/assert.h" |
| 14 | #include "core/settings.h" | ||
| 12 | #include "video_core/renderer_vulkan/declarations.h" | 15 | #include "video_core/renderer_vulkan/declarations.h" |
| 13 | #include "video_core/renderer_vulkan/vk_device.h" | 16 | #include "video_core/renderer_vulkan/vk_device.h" |
| 14 | 17 | ||
| @@ -201,6 +204,22 @@ vk::Format VKDevice::GetSupportedFormat(vk::Format wanted_format, | |||
| 201 | return wanted_format; | 204 | return wanted_format; |
| 202 | } | 205 | } |
| 203 | 206 | ||
| 207 | void VKDevice::ReportLoss() const { | ||
| 208 | LOG_CRITICAL(Render_Vulkan, "Device loss occured!"); | ||
| 209 | |||
| 210 | // Wait some time to let the log flush | ||
| 211 | std::this_thread::sleep_for(std::chrono::seconds{1}); | ||
| 212 | |||
| 213 | if (!nv_device_diagnostic_checkpoints) { | ||
| 214 | return; | ||
| 215 | } | ||
| 216 | |||
| 217 | [[maybe_unused]] const std::vector data = graphics_queue.getCheckpointDataNV(dld); | ||
| 218 | // Catch here in debug builds (or with optimizations disabled) the last graphics pipeline to be | ||
| 219 | // executed. It can be done on a debugger by evaluating the expression: | ||
| 220 | // *(VKGraphicsPipeline*)data[0] | ||
| 221 | } | ||
| 222 | |||
| 204 | bool VKDevice::IsOptimalAstcSupported(const vk::PhysicalDeviceFeatures& features, | 223 | bool VKDevice::IsOptimalAstcSupported(const vk::PhysicalDeviceFeatures& features, |
| 205 | const vk::DispatchLoaderDynamic& dldi) const { | 224 | const vk::DispatchLoaderDynamic& dldi) const { |
| 206 | // Disable for now to avoid converting ASTC twice. | 225 | // Disable for now to avoid converting ASTC twice. |
| @@ -381,6 +400,8 @@ std::vector<const char*> VKDevice::LoadExtensions(const vk::DispatchLoaderDynami | |||
| 381 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, true); | 400 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, true); |
| 382 | Test(extension, ext_subgroup_size_control, VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME, | 401 | Test(extension, ext_subgroup_size_control, VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME, |
| 383 | false); | 402 | false); |
| 403 | Test(extension, nv_device_diagnostic_checkpoints, | ||
| 404 | VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME, true); | ||
| 384 | } | 405 | } |
| 385 | 406 | ||
| 386 | if (khr_shader_float16_int8) { | 407 | if (khr_shader_float16_int8) { |
diff --git a/src/video_core/renderer_vulkan/vk_device.h b/src/video_core/renderer_vulkan/vk_device.h index a844c52df..72603f9f6 100644 --- a/src/video_core/renderer_vulkan/vk_device.h +++ b/src/video_core/renderer_vulkan/vk_device.h | |||
| @@ -39,6 +39,9 @@ public: | |||
| 39 | vk::Format GetSupportedFormat(vk::Format wanted_format, vk::FormatFeatureFlags wanted_usage, | 39 | vk::Format GetSupportedFormat(vk::Format wanted_format, vk::FormatFeatureFlags wanted_usage, |
| 40 | FormatType format_type) const; | 40 | FormatType format_type) const; |
| 41 | 41 | ||
| 42 | /// Reports a device loss. | ||
| 43 | void ReportLoss() const; | ||
| 44 | |||
| 42 | /// Returns the dispatch loader with direct function pointers of the device. | 45 | /// Returns the dispatch loader with direct function pointers of the device. |
| 43 | const vk::DispatchLoaderDynamic& GetDispatchLoader() const { | 46 | const vk::DispatchLoaderDynamic& GetDispatchLoader() const { |
| 44 | return dld; | 47 | return dld; |
| @@ -159,6 +162,11 @@ public: | |||
| 159 | return ext_shader_viewport_index_layer; | 162 | return ext_shader_viewport_index_layer; |
| 160 | } | 163 | } |
| 161 | 164 | ||
| 165 | /// Returns true if the device supports VK_NV_device_diagnostic_checkpoints. | ||
| 166 | bool IsNvDeviceDiagnosticCheckpoints() const { | ||
| 167 | return nv_device_diagnostic_checkpoints; | ||
| 168 | } | ||
| 169 | |||
| 162 | /// Returns the vendor name reported from Vulkan. | 170 | /// Returns the vendor name reported from Vulkan. |
| 163 | std::string_view GetVendorName() const { | 171 | std::string_view GetVendorName() const { |
| 164 | return vendor_name; | 172 | return vendor_name; |
| @@ -218,6 +226,7 @@ private: | |||
| 218 | bool ext_index_type_uint8{}; ///< Support for VK_EXT_index_type_uint8. | 226 | bool ext_index_type_uint8{}; ///< Support for VK_EXT_index_type_uint8. |
| 219 | bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted. | 227 | bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted. |
| 220 | bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer. | 228 | bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer. |
| 229 | bool nv_device_diagnostic_checkpoints{}; ///< Support for VK_NV_device_diagnostic_checkpoints. | ||
| 221 | 230 | ||
| 222 | // Telemetry parameters | 231 | // Telemetry parameters |
| 223 | std::string vendor_name; ///< Device's driver name. | 232 | std::string vendor_name; ///< Device's driver name. |
diff --git a/src/video_core/renderer_vulkan/vk_resource_manager.cpp b/src/video_core/renderer_vulkan/vk_resource_manager.cpp index 13c46e5b8..a0ca5f2ae 100644 --- a/src/video_core/renderer_vulkan/vk_resource_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_resource_manager.cpp | |||
| @@ -72,9 +72,18 @@ VKFence::VKFence(const VKDevice& device, UniqueFence handle) | |||
| 72 | VKFence::~VKFence() = default; | 72 | VKFence::~VKFence() = default; |
| 73 | 73 | ||
| 74 | void VKFence::Wait() { | 74 | void VKFence::Wait() { |
| 75 | static constexpr u64 timeout = std::numeric_limits<u64>::max(); | ||
| 75 | const auto dev = device.GetLogical(); | 76 | const auto dev = device.GetLogical(); |
| 76 | const auto& dld = device.GetDispatchLoader(); | 77 | const auto& dld = device.GetDispatchLoader(); |
| 77 | dev.waitForFences({*handle}, true, std::numeric_limits<u64>::max(), dld); | 78 | switch (const auto result = dev.waitForFences(1, &*handle, true, timeout, dld)) { |
| 79 | case vk::Result::eSuccess: | ||
| 80 | return; | ||
| 81 | case vk::Result::eErrorDeviceLost: | ||
| 82 | device.ReportLoss(); | ||
| 83 | [[fallthrough]]; | ||
| 84 | default: | ||
| 85 | vk::throwResultException(result, "vk::waitForFences"); | ||
| 86 | } | ||
| 78 | } | 87 | } |
| 79 | 88 | ||
| 80 | void VKFence::Release() { | 89 | void VKFence::Release() { |