diff options
Diffstat (limited to 'src/video_core/vulkan_common')
| -rw-r--r-- | src/video_core/vulkan_common/nsight_aftermath_tracker.cpp | 47 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/nsight_aftermath_tracker.h | 3 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_library.cpp | 8 |
3 files changed, 34 insertions, 24 deletions
diff --git a/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp b/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp index 7a9d00d4f..f0ee76519 100644 --- a/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp +++ b/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #ifdef HAS_NSIGHT_AFTERMATH | 5 | #ifdef HAS_NSIGHT_AFTERMATH |
| 6 | 6 | ||
| 7 | #include <mutex> | 7 | #include <mutex> |
| 8 | #include <span> | ||
| 8 | #include <string> | 9 | #include <string> |
| 9 | #include <string_view> | 10 | #include <string_view> |
| 10 | #include <utility> | 11 | #include <utility> |
| @@ -12,9 +13,10 @@ | |||
| 12 | 13 | ||
| 13 | #include <fmt/format.h> | 14 | #include <fmt/format.h> |
| 14 | 15 | ||
| 15 | #include "common/common_paths.h" | ||
| 16 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 17 | #include "common/file_util.h" | 17 | #include "common/fs/file.h" |
| 18 | #include "common/fs/fs.h" | ||
| 19 | #include "common/fs/path_util.h" | ||
| 18 | #include "common/logging/log.h" | 20 | #include "common/logging/log.h" |
| 19 | #include "common/scope_exit.h" | 21 | #include "common/scope_exit.h" |
| 20 | #include "video_core/vulkan_common/nsight_aftermath_tracker.h" | 22 | #include "video_core/vulkan_common/nsight_aftermath_tracker.h" |
| @@ -46,9 +48,9 @@ NsightAftermathTracker::NsightAftermathTracker() { | |||
| 46 | LOG_ERROR(Render_Vulkan, "Failed to load Nsight Aftermath function pointers"); | 48 | LOG_ERROR(Render_Vulkan, "Failed to load Nsight Aftermath function pointers"); |
| 47 | return; | 49 | return; |
| 48 | } | 50 | } |
| 49 | dump_dir = Common::FS::GetUserPath(Common::FS::UserPath::LogDir) + "gpucrash"; | 51 | dump_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::LogDir) / "gpucrash"; |
| 50 | 52 | ||
| 51 | void(Common::FS::DeleteDirRecursively(dump_dir)); | 53 | void(Common::FS::RemoveDirRecursively(dump_dir)); |
| 52 | if (!Common::FS::CreateDir(dump_dir)) { | 54 | if (!Common::FS::CreateDir(dump_dir)) { |
| 53 | LOG_ERROR(Render_Vulkan, "Failed to create Nsight Aftermath dump directory"); | 55 | LOG_ERROR(Render_Vulkan, "Failed to create Nsight Aftermath dump directory"); |
| 54 | return; | 56 | return; |
| @@ -60,7 +62,8 @@ NsightAftermathTracker::NsightAftermathTracker() { | |||
| 60 | LOG_ERROR(Render_Vulkan, "GFSDK_Aftermath_EnableGpuCrashDumps failed"); | 62 | LOG_ERROR(Render_Vulkan, "GFSDK_Aftermath_EnableGpuCrashDumps failed"); |
| 61 | return; | 63 | return; |
| 62 | } | 64 | } |
| 63 | LOG_INFO(Render_Vulkan, "Nsight Aftermath dump directory is \"{}\"", dump_dir); | 65 | LOG_INFO(Render_Vulkan, "Nsight Aftermath dump directory is \"{}\"", |
| 66 | Common::FS::PathToUTF8String(dump_dir)); | ||
| 64 | initialized = true; | 67 | initialized = true; |
| 65 | } | 68 | } |
| 66 | 69 | ||
| @@ -89,12 +92,15 @@ void NsightAftermathTracker::SaveShader(const std::vector<u32>& spirv) const { | |||
| 89 | return; | 92 | return; |
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | Common::FS::IOFile file(fmt::format("{}/source_{:016x}.spv", dump_dir, hash.hash), "wb"); | 95 | const auto shader_file = dump_dir / fmt::format("source_{:016x}.spv", hash.hash); |
| 96 | |||
| 97 | Common::FS::IOFile file{shader_file, Common::FS::FileAccessMode::Write, | ||
| 98 | Common::FS::FileType::BinaryFile}; | ||
| 93 | if (!file.IsOpen()) { | 99 | if (!file.IsOpen()) { |
| 94 | LOG_ERROR(Render_Vulkan, "Failed to dump SPIR-V module with hash={:016x}", hash.hash); | 100 | LOG_ERROR(Render_Vulkan, "Failed to dump SPIR-V module with hash={:016x}", hash.hash); |
| 95 | return; | 101 | return; |
| 96 | } | 102 | } |
| 97 | if (file.WriteArray(spirv.data(), spirv.size()) != spirv.size()) { | 103 | if (file.Write(spirv) != spirv.size()) { |
| 98 | LOG_ERROR(Render_Vulkan, "Failed to write SPIR-V module with hash={:016x}", hash.hash); | 104 | LOG_ERROR(Render_Vulkan, "Failed to write SPIR-V module with hash={:016x}", hash.hash); |
| 99 | return; | 105 | return; |
| 100 | } | 106 | } |
| @@ -129,22 +135,24 @@ void NsightAftermathTracker::OnGpuCrashDumpCallback(const void* gpu_crash_dump, | |||
| 129 | return; | 135 | return; |
| 130 | } | 136 | } |
| 131 | 137 | ||
| 132 | const std::string base_name = [this] { | 138 | std::filesystem::path base_name = [this] { |
| 133 | const int id = dump_id++; | 139 | const int id = dump_id++; |
| 134 | if (id == 0) { | 140 | if (id == 0) { |
| 135 | return fmt::format("{}/crash.nv-gpudmp", dump_dir); | 141 | return dump_dir / "crash.nv-gpudmp"; |
| 136 | } else { | 142 | } else { |
| 137 | return fmt::format("{}/crash_{}.nv-gpudmp", dump_dir, id); | 143 | return dump_dir / fmt::format("crash_{}.nv-gpudmp", id); |
| 138 | } | 144 | } |
| 139 | }(); | 145 | }(); |
| 140 | 146 | ||
| 141 | std::string_view dump_view(static_cast<const char*>(gpu_crash_dump), gpu_crash_dump_size); | 147 | std::string_view dump_view(static_cast<const char*>(gpu_crash_dump), gpu_crash_dump_size); |
| 142 | if (Common::FS::WriteStringToFile(false, base_name, dump_view) != gpu_crash_dump_size) { | 148 | if (Common::FS::WriteStringToFile(base_name, Common::FS::FileType::BinaryFile, dump_view) != |
| 149 | gpu_crash_dump_size) { | ||
| 143 | LOG_ERROR(Render_Vulkan, "Failed to write dump file"); | 150 | LOG_ERROR(Render_Vulkan, "Failed to write dump file"); |
| 144 | return; | 151 | return; |
| 145 | } | 152 | } |
| 146 | const std::string_view json_view(json.data(), json.size()); | 153 | const std::string_view json_view(json.data(), json.size()); |
| 147 | if (Common::FS::WriteStringToFile(true, base_name + ".json", json_view) != json.size()) { | 154 | if (Common::FS::WriteStringToFile(base_name.concat(".json"), Common::FS::FileType::TextFile, |
| 155 | json_view) != json.size()) { | ||
| 148 | LOG_ERROR(Render_Vulkan, "Failed to write JSON"); | 156 | LOG_ERROR(Render_Vulkan, "Failed to write JSON"); |
| 149 | return; | 157 | return; |
| 150 | } | 158 | } |
| @@ -161,16 +169,17 @@ void NsightAftermathTracker::OnShaderDebugInfoCallback(const void* shader_debug_ | |||
| 161 | return; | 169 | return; |
| 162 | } | 170 | } |
| 163 | 171 | ||
| 164 | const std::string path = | 172 | const auto path = |
| 165 | fmt::format("{}/shader_{:016x}{:016x}.nvdbg", dump_dir, identifier.id[0], identifier.id[1]); | 173 | dump_dir / fmt::format("shader_{:016x}{:016x}.nvdbg", identifier.id[0], identifier.id[1]); |
| 166 | Common::FS::IOFile file(path, "wb"); | 174 | Common::FS::IOFile file{path, Common::FS::FileAccessMode::Write, |
| 175 | Common::FS::FileType::BinaryFile}; | ||
| 167 | if (!file.IsOpen()) { | 176 | if (!file.IsOpen()) { |
| 168 | LOG_ERROR(Render_Vulkan, "Failed to create file {}", path); | 177 | LOG_ERROR(Render_Vulkan, "Failed to create file {}", Common::FS::PathToUTF8String(path)); |
| 169 | return; | 178 | return; |
| 170 | } | 179 | } |
| 171 | if (file.WriteBytes(static_cast<const u8*>(shader_debug_info), shader_debug_info_size) != | 180 | if (file.WriteSpan(std::span(static_cast<const u8*>(shader_debug_info), |
| 172 | shader_debug_info_size) { | 181 | shader_debug_info_size)) != shader_debug_info_size) { |
| 173 | LOG_ERROR(Render_Vulkan, "Failed to write file {}", path); | 182 | LOG_ERROR(Render_Vulkan, "Failed to write file {}", Common::FS::PathToUTF8String(path)); |
| 174 | return; | 183 | return; |
| 175 | } | 184 | } |
| 176 | } | 185 | } |
diff --git a/src/video_core/vulkan_common/nsight_aftermath_tracker.h b/src/video_core/vulkan_common/nsight_aftermath_tracker.h index 1ce8d4e8e..4fe2b14d9 100644 --- a/src/video_core/vulkan_common/nsight_aftermath_tracker.h +++ b/src/video_core/vulkan_common/nsight_aftermath_tracker.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <filesystem> | ||
| 7 | #include <mutex> | 8 | #include <mutex> |
| 8 | #include <string> | 9 | #include <string> |
| 9 | #include <vector> | 10 | #include <vector> |
| @@ -54,7 +55,7 @@ private: | |||
| 54 | 55 | ||
| 55 | mutable std::mutex mutex; | 56 | mutable std::mutex mutex; |
| 56 | 57 | ||
| 57 | std::string dump_dir; | 58 | std::filesystem::path dump_dir; |
| 58 | int dump_id = 0; | 59 | int dump_id = 0; |
| 59 | 60 | ||
| 60 | bool initialized = false; | 61 | bool initialized = false; |
diff --git a/src/video_core/vulkan_common/vulkan_library.cpp b/src/video_core/vulkan_common/vulkan_library.cpp index 557871d81..22833fa56 100644 --- a/src/video_core/vulkan_common/vulkan_library.cpp +++ b/src/video_core/vulkan_common/vulkan_library.cpp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #include <string> | 6 | #include <string> |
| 7 | 7 | ||
| 8 | #include "common/dynamic_library.h" | 8 | #include "common/dynamic_library.h" |
| 9 | #include "common/file_util.h" | 9 | #include "common/fs/path_util.h" |
| 10 | #include "video_core/vulkan_common/vulkan_library.h" | 10 | #include "video_core/vulkan_common/vulkan_library.h" |
| 11 | 11 | ||
| 12 | namespace Vulkan { | 12 | namespace Vulkan { |
| @@ -18,9 +18,9 @@ Common::DynamicLibrary OpenLibrary() { | |||
| 18 | char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); | 18 | char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); |
| 19 | if (!libvulkan_env || !library.Open(libvulkan_env)) { | 19 | if (!libvulkan_env || !library.Open(libvulkan_env)) { |
| 20 | // Use the libvulkan.dylib from the application bundle. | 20 | // Use the libvulkan.dylib from the application bundle. |
| 21 | const std::string filename = | 21 | const auto filename = |
| 22 | Common::FS::GetBundleDirectory() + "/Contents/Frameworks/libvulkan.dylib"; | 22 | Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.dylib"; |
| 23 | void(library.Open(filename.c_str())); | 23 | void(library.Open(Common::FS::PathToUTF8String(filename).c_str())); |
| 24 | } | 24 | } |
| 25 | #else | 25 | #else |
| 26 | std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); | 26 | std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); |