2020-03-30 10:21:59 +02:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-04-11 07:50:30 +02:00
|
|
|
#include <span>
|
2020-03-30 10:21:59 +02:00
|
|
|
|
2021-01-23 08:13:37 +01:00
|
|
|
#include "common/common_types.h"
|
2020-03-30 10:21:59 +02:00
|
|
|
|
|
|
|
#ifdef HAS_NSIGHT_AFTERMATH
|
2022-03-19 05:06:57 +01:00
|
|
|
#include <filesystem>
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
// Vulkan headers must be included before Aftermath
|
|
|
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
|
|
|
|
2020-03-30 10:21:59 +02:00
|
|
|
#include <GFSDK_Aftermath_Defines.h>
|
|
|
|
#include <GFSDK_Aftermath_GpuCrashDump.h>
|
|
|
|
#include <GFSDK_Aftermath_GpuCrashDumpDecoding.h>
|
2022-03-19 05:06:57 +01:00
|
|
|
|
|
|
|
#include "common/dynamic_library.h"
|
2020-03-30 10:21:59 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Vulkan {
|
|
|
|
|
|
|
|
class NsightAftermathTracker {
|
|
|
|
public:
|
|
|
|
NsightAftermathTracker();
|
|
|
|
~NsightAftermathTracker();
|
|
|
|
|
|
|
|
NsightAftermathTracker(const NsightAftermathTracker&) = delete;
|
|
|
|
NsightAftermathTracker& operator=(const NsightAftermathTracker&) = delete;
|
|
|
|
|
|
|
|
// Delete move semantics because Aftermath initialization uses a pointer to this.
|
|
|
|
NsightAftermathTracker(NsightAftermathTracker&&) = delete;
|
|
|
|
NsightAftermathTracker& operator=(NsightAftermathTracker&&) = delete;
|
|
|
|
|
2021-04-11 07:50:30 +02:00
|
|
|
void SaveShader(std::span<const u32> spirv) const;
|
2020-03-30 10:21:59 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
#ifdef HAS_NSIGHT_AFTERMATH
|
|
|
|
static void GpuCrashDumpCallback(const void* gpu_crash_dump, u32 gpu_crash_dump_size,
|
|
|
|
void* user_data);
|
|
|
|
|
|
|
|
static void ShaderDebugInfoCallback(const void* shader_debug_info, u32 shader_debug_info_size,
|
|
|
|
void* user_data);
|
|
|
|
|
|
|
|
static void CrashDumpDescriptionCallback(
|
|
|
|
PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription add_description, void* user_data);
|
|
|
|
|
|
|
|
void OnGpuCrashDumpCallback(const void* gpu_crash_dump, u32 gpu_crash_dump_size);
|
|
|
|
|
|
|
|
void OnShaderDebugInfoCallback(const void* shader_debug_info, u32 shader_debug_info_size);
|
|
|
|
|
|
|
|
void OnCrashDumpDescriptionCallback(
|
|
|
|
PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription add_description);
|
|
|
|
|
|
|
|
mutable std::mutex mutex;
|
|
|
|
|
2021-05-26 01:32:56 +02:00
|
|
|
std::filesystem::path dump_dir;
|
2020-03-30 10:21:59 +02:00
|
|
|
int dump_id = 0;
|
|
|
|
|
|
|
|
bool initialized = false;
|
|
|
|
|
|
|
|
Common::DynamicLibrary dl;
|
2021-04-11 07:50:30 +02:00
|
|
|
PFN_GFSDK_Aftermath_DisableGpuCrashDumps GFSDK_Aftermath_DisableGpuCrashDumps{};
|
|
|
|
PFN_GFSDK_Aftermath_EnableGpuCrashDumps GFSDK_Aftermath_EnableGpuCrashDumps{};
|
|
|
|
PFN_GFSDK_Aftermath_GetShaderDebugInfoIdentifier GFSDK_Aftermath_GetShaderDebugInfoIdentifier{};
|
|
|
|
PFN_GFSDK_Aftermath_GetShaderHashSpirv GFSDK_Aftermath_GetShaderHashSpirv{};
|
|
|
|
PFN_GFSDK_Aftermath_GpuCrashDump_CreateDecoder GFSDK_Aftermath_GpuCrashDump_CreateDecoder{};
|
|
|
|
PFN_GFSDK_Aftermath_GpuCrashDump_DestroyDecoder GFSDK_Aftermath_GpuCrashDump_DestroyDecoder{};
|
|
|
|
PFN_GFSDK_Aftermath_GpuCrashDump_GenerateJSON GFSDK_Aftermath_GpuCrashDump_GenerateJSON{};
|
|
|
|
PFN_GFSDK_Aftermath_GpuCrashDump_GetJSON GFSDK_Aftermath_GpuCrashDump_GetJSON{};
|
2020-03-30 10:21:59 +02:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef HAS_NSIGHT_AFTERMATH
|
|
|
|
inline NsightAftermathTracker::NsightAftermathTracker() = default;
|
|
|
|
inline NsightAftermathTracker::~NsightAftermathTracker() = default;
|
2021-04-11 07:50:30 +02:00
|
|
|
inline void NsightAftermathTracker::SaveShader(std::span<const u32>) const {}
|
2020-03-30 10:21:59 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace Vulkan
|