mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 11:29:58 -04:00
Take out the GPU address history of a lost device's report.
The author of the pull request it was ported from closed that request on 2026-11-11 with the words that they give no permission to use its code. The history (NX2NAVI_VA_REPORT, runtime/vk_vaddr.c, the stack walk it used and its notes in the docs and the example settings) goes; the lost device's report keeps the breadcrumbs, the pass marks, the video memory and the driver's fault information. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -73,7 +73,7 @@ static const char *const known[] = {
|
||||
"ZSTD_CHECK", "ZSTD_NATIVE",
|
||||
"BIND_REUSE", "DYN_DELTA", "STG_ARENA", "SUBMIT_BATCH", "ASTC_GPU_DESWIZZLE", "ASTC_SCRATCH_KEEP", "ASTC_ARENA",
|
||||
"TEXUP_LOG_MS", "DYN_RES", "DYN_RES_TARGET", "DYN_RES_STEP", "TEXTURE_DETAIL",
|
||||
"RECORDER_CORE", "RECORDER_PRIO", "REPLAY_TIME", "LOCK_TIME", "POOL_CREATE_BUDGET", "POOL_CREATE_MS", "POOL_FINI_IDLE", "POOL_LOAD_BACKLOG", "POOL_LOAD_MS", "VA_REPORT",
|
||||
"RECORDER_CORE", "RECORDER_PRIO", "REPLAY_TIME", "LOCK_TIME", "POOL_CREATE_BUDGET", "POOL_CREATE_MS", "POOL_FINI_IDLE", "POOL_LOAD_BACKLOG", "POOL_LOAD_MS",
|
||||
"VMA_BLOCK_MB", "ASTC_BC_PROBE", "SYNC_WAKE_ALL", "LOG_ASYNC", "DEVICE_LOST_AT",
|
||||
"COOP", "COOP_NAME", "COOP_SERVER", "COOP_PORT", "COOP_ROOM", "COOP_AUTO", "COOP_DROP", // co-op (coop.c); the last three have no menu row
|
||||
"COOP_PROGRESS", "COOP_ITEMS", "COOP_SONGS", "COOP_QUEST", "COOP_KEYS", "COOP_RUPEES", "COOP_AMMO", // the room's rules (coop_game.c)
|
||||
@@ -142,7 +142,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"VK_NAN_PRESERVE", "performance"}, {"VK_NAN_BITS", "performance"},
|
||||
{"TRACE", "diagnostics"}, {"FLIGHT", "diagnostics"}, {"PASS_CRUMBS", "diagnostics"}, {"FLIGHT_SPIKE_MS", "diagnostics"},
|
||||
{"WB_FENCE_LIMIT", "diagnostics"}, {"WB_MERGE", "diagnostics"}, {"WB_EXACT", "diagnostics"}, {"MEM_CENSUS", "diagnostics"}, {"WB_NO_REUP", "diagnostics"}, {"WB_PROBE", "diagnostics"}, {"WB_SPLIT", "performance"}, {"SHADOW_BULK_WRITE", "performance"}, {"WB_LAZY", "performance"}, {"HEAP_LAZY", "performance"}, {"BARRIER_GAME", "performance"}, {"MESH_AHEAD", "performance"}, {"MESH_FALLBACK", "performance"}, {"MESH_FALLBACK_MB", "performance"}, {"WB_LAZY_TOUCH", "diagnostics"}, {"WB_LAZY_CHUNK", "performance"}, {"FLUSH_UPLOAD", "diagnostics"}, {"GPA_TWIN_MAX_KB", "diagnostics"},
|
||||
{"WB_MERGE_MAX", "diagnostics"}, {"MV_SURVEY", "diagnostics"}, {"TEXUP_LOG_MS", "diagnostics"}, {"VA_REPORT", "diagnostics"},
|
||||
{"WB_MERGE_MAX", "diagnostics"}, {"MV_SURVEY", "diagnostics"}, {"TEXUP_LOG_MS", "diagnostics"},
|
||||
{"VMA_BLOCK_MB", "diagnostics"}, {"ASTC_BC_PROBE", "diagnostics"}, {"DEVICE_LOST_AT", "diagnostics"},
|
||||
};
|
||||
|
||||
@@ -322,7 +322,6 @@ static const CfgMeta metas[] = {
|
||||
{"VMA_BLOCK_MB", "64", "16..256", RESTART}, // vk_headroom.c vk_vma_block_size
|
||||
{"ASTC_BC_PROBE", "0", "0|1", RESTART}, // vk_texture.c astc_probe_alpha
|
||||
{"PASS_CRUMBS", "", "0|1", RESTART}, // vk_crumbs.c pass marks; unset: VK_AMD_buffer_marker only
|
||||
{"VA_REPORT", "0", "0|1|2", RESTART}, // vk_vaddr.c GPU address history for a lost device's report; 2: call stacks
|
||||
{"DEVICE_LOST_AT", "0", "0..1000000000", RESTART}, // vk_sync.c lost_at_due: a test of the lost device's end
|
||||
{"INPUT_RECORD", "", NULL, RESTART},
|
||||
};
|
||||
|
||||
@@ -1575,22 +1575,6 @@ int plat_module_of(uintptr_t addr, char *name, size_t cap, uintptr_t *base) {
|
||||
return snprintf(name, cap, "%s", n ? n + 1 : d.dli_fname) < (int)cap;
|
||||
}
|
||||
|
||||
typedef struct { uintptr_t *pc; int n, max; } StackWalk;
|
||||
|
||||
static _Unwind_Reason_Code stack_step(struct _Unwind_Context *ctx, void *p) {
|
||||
StackWalk *w = p;
|
||||
uintptr_t ip = _Unwind_GetIP(ctx);
|
||||
if (!ip || w->n == w->max) return _URC_END_OF_STACK;
|
||||
w->pc[w->n++] = ip;
|
||||
return _URC_NO_REASON;
|
||||
}
|
||||
|
||||
int plat_stack(uintptr_t *pc, int max) {
|
||||
StackWalk w = {pc, 0, max};
|
||||
_Unwind_Backtrace(stack_step, &w);
|
||||
return w.n;
|
||||
}
|
||||
|
||||
int plat_exe_path(char *out, size_t cap) {
|
||||
ssize_t n = readlink("/proc/self/exe", out, cap - 1);
|
||||
if (n <= 0 || (size_t)n >= cap - 1) return 0;
|
||||
|
||||
@@ -417,8 +417,6 @@ uintptr_t plat_exe_base(void); // where the executabl
|
||||
// The module (executable or library) holding code address addr: its file name without directories into name, its load
|
||||
// address into *base. 0 when none.
|
||||
int plat_module_of(uintptr_t addr, char *name, size_t cap, uintptr_t *base);
|
||||
// Return addresses of the calling thread's stack into pc, innermost first, at most max: their count.
|
||||
int plat_stack(uintptr_t *pc, int max);
|
||||
#define PLAT_PATH_MAX 1024 // path buffers of the runtime
|
||||
#ifdef _WIN32
|
||||
#define PLAT_EXE_SUFFIX ".exe" // of the programs the runtime starts (nx2navi_xlate)
|
||||
|
||||
@@ -1594,13 +1594,6 @@ int plat_module_of(uintptr_t addr, char *name, size_t cap, uintptr_t *base) {
|
||||
return WideCharToMultiByte(CP_UTF8, 0, n, -1, name, (int)cap, NULL, NULL) != 0;
|
||||
}
|
||||
|
||||
int plat_stack(uintptr_t *pc, int max) {
|
||||
void *f[62];
|
||||
USHORT n = RtlCaptureStackBackTrace(1, max < 62 ? (DWORD)max : 62, f, NULL);
|
||||
for (USHORT i = 0; i < n; i++) pc[i] = (uintptr_t)f[i];
|
||||
return n;
|
||||
}
|
||||
|
||||
int plat_exe_path(char *out, size_t cap) {
|
||||
wchar_t w[WPATH];
|
||||
DWORD n = GetModuleFileNameW(NULL, w, WPATH);
|
||||
|
||||
@@ -99,15 +99,6 @@ static inline int vk_device_is_lost(void) { return __atomic_load_n(&vk_lost, __A
|
||||
// callbacks: a lost device may report the submissions' timeline as reached (vk_sync.c completion_main).
|
||||
void vk_device_lost_poll(void);
|
||||
|
||||
// ---- GPU address history (vk_vaddr.c, NX2NAVI_VA_REPORT=1, 2 with call stacks): VK_EXT_device_address_binding_report's
|
||||
// reports, kept so the lost device report (vk_device.c device_fault_report) can name the objects that held a faulting address.
|
||||
int vk_vaddr_wanted(void);
|
||||
void vk_vaddr_start(VkInstance instance); // create_instance, after vkCreateInstance
|
||||
void vk_vaddr_device(int supported); // create_device: the driver reports address bindings
|
||||
void vk_vaddr_fault(uint64_t addr, uint64_t precision); // logs the reports whose range covered addr's page
|
||||
void vk_vaddr_dump(void); // the whole history to vaddr-history.txt beside the log
|
||||
void vk_vaddr_stop(VkInstance instance); // before vkDestroyInstance
|
||||
|
||||
// ---- GPU breadcrumbs (vk_crumbs.c): with VK_AMD_buffer_marker, each crumb has the GPU write its code into host memory
|
||||
// twice, when the command processor reaches it and when all work before it has finished. After a lost device the two
|
||||
// codes bracket the work that hung. Without the extension every call returns at once.
|
||||
|
||||
@@ -145,9 +145,8 @@ static int create_instance(void) {
|
||||
rt_log("vk: NX2NAVI_VK_VALIDATION set but %s is not installed; continuing without", layers[0]);
|
||||
validate = 0;
|
||||
}
|
||||
// DLSS Frame Generation: Streamline's plugins call its naming functions even when they say it is off; the GPU
|
||||
// address history (vk_vaddr.c) gets the driver's binding reports through a messenger
|
||||
if (validate || ((vk_dlssg_wanted() || vk_vaddr_wanted()) && instance_ext_present(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)))
|
||||
// DLSS Frame Generation: Streamline's plugins call its naming functions even when they say it is off
|
||||
if (validate || (vk_dlssg_wanted() && instance_ext_present(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)))
|
||||
ext[n_ext++] = VK_EXT_DEBUG_UTILS_EXTENSION_NAME;
|
||||
// armed, not wanted: the menu switches HDR on during the run (vk_hdr.c), and the extensions are fixed here
|
||||
if (vk_hdr_armed() && instance_ext_present(VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME)) // HDR10 surface formats
|
||||
@@ -173,7 +172,6 @@ static int create_instance(void) {
|
||||
.pfnUserCallback = debug_cb};
|
||||
if (f) f(g_vk.instance, &mi, NULL, &g_vk.messenger);
|
||||
}
|
||||
vk_vaddr_start(g_vk.instance);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -305,7 +303,6 @@ typedef struct {
|
||||
VkPhysicalDeviceShaderMaximalReconvergenceFeaturesKHR mrc;
|
||||
VkPhysicalDeviceMaintenance5FeaturesKHR m5;
|
||||
VkPhysicalDevicePipelineBinaryFeaturesKHR pbin;
|
||||
VkPhysicalDeviceAddressBindingReportFeaturesEXT abr;
|
||||
} FeatureChain;
|
||||
|
||||
// One line for a fatal error's report (dispatch.h rt_fatal_note_add): the card, its driver, and the settings in effect
|
||||
@@ -378,12 +375,6 @@ static int create_device(void) {
|
||||
CHAIN(fbl, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT);
|
||||
CHAIN(lr, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_LOCAL_READ_FEATURES_KHR);
|
||||
}
|
||||
// The GPU address history for a lost device's report (vk_vaddr.c, NX2NAVI_VA_REPORT=1)
|
||||
int want_va = vk_vaddr_wanted() && has_ext(ep, ne, VK_EXT_DEVICE_ADDRESS_BINDING_REPORT_EXTENSION_NAME);
|
||||
if (want_va) {
|
||||
ext[n_ext++] = VK_EXT_DEVICE_ADDRESS_BINDING_REPORT_EXTENSION_NAME;
|
||||
CHAIN(abr, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ADDRESS_BINDING_REPORT_FEATURES_EXT);
|
||||
}
|
||||
vk_dlaa_device_exts(ep, ne, ext, &n_ext, 40); // NGX's; the eight slots after it stay for the eight below
|
||||
// FSR 3.1 (vk_ffx.cpp): its Vulkan back end looks vkGetBufferMemoryRequirements2KHR up by that name, which resolves
|
||||
// only with the extension enabled (the core function has no suffix); without it the back end called address 0.
|
||||
@@ -453,7 +444,6 @@ static int create_device(void) {
|
||||
else if (!h->textureCompressionBC) miss = "textureCompressionBC";
|
||||
if (miss) { rt_log("vk: required feature missing on %s: %s", g_vk.props.deviceName, miss); free(c); return 0; }
|
||||
if (!c->fault.deviceFault) g_vk.has_device_fault = 0;
|
||||
if (vk_vaddr_wanted()) vk_vaddr_device(want_va && c->abr.reportAddressBinding);
|
||||
if (g_vk.has_vrs) { // the rate is set per draw; no rate attachment and no per-primitive rates
|
||||
c->vrs.attachmentFragmentShadingRate = c->vrs.primitiveFragmentShadingRate = VK_FALSE;
|
||||
if (!c->vrs.pipelineFragmentShadingRate) g_vk.has_vrs = 0;
|
||||
@@ -573,7 +563,6 @@ static void destroy_all(void) {
|
||||
(PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(g_vk.instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||
if (f) f(g_vk.instance, g_vk.messenger, NULL);
|
||||
}
|
||||
vk_vaddr_stop(g_vk.instance);
|
||||
if (g_vk.instance) vkDestroyInstance(g_vk.instance, NULL);
|
||||
g_errors_total += g_vk.validation_errors;
|
||||
memset(&g_vk, 0, sizeof g_vk);
|
||||
@@ -627,7 +616,6 @@ static void device_fault_report(void) {
|
||||
if (!get) {
|
||||
rt_log("vk: device lost; no fault report (VK_EXT_device_fault %s)", c && c->has_device_fault ? "has no entry point"
|
||||
: "not enabled");
|
||||
vk_vaddr_dump(); // the history still names what held a page another report (the kernel's log) gives
|
||||
return;
|
||||
}
|
||||
VkDeviceFaultCountsEXT n = {.sType = VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT};
|
||||
@@ -644,16 +632,13 @@ static void device_fault_report(void) {
|
||||
rt_log("vk: device fault: \"%s\" (%u address infos, %u vendor infos, vendor binary %llu bytes)", info.description,
|
||||
n.addressInfoCount, n.vendorInfoCount, (unsigned long long)binary);
|
||||
// The faulting access lies in the precision-aligned range around the reported address.
|
||||
for (uint32_t i = 0; i < n.addressInfoCount; i++) {
|
||||
for (uint32_t i = 0; i < n.addressInfoCount; i++)
|
||||
rt_log("vk: device fault address %u: %s at %#llx, precision %#llx", i, fault_address_type(ai[i].addressType),
|
||||
(unsigned long long)ai[i].reportedAddress, (unsigned long long)ai[i].addressPrecision);
|
||||
vk_vaddr_fault(ai[i].reportedAddress, ai[i].addressPrecision);
|
||||
}
|
||||
for (uint32_t i = 0; i < n.vendorInfoCount; i++)
|
||||
rt_log("vk: device fault vendor info %u: \"%s\" code %#llx data %#llx", i, vi[i].description,
|
||||
(unsigned long long)vi[i].vendorFaultCode, (unsigned long long)vi[i].vendorFaultData);
|
||||
}
|
||||
vk_vaddr_dump();
|
||||
free(ai);
|
||||
free(vi);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,6 @@ static void top_up(const VkCtx *c, uint32_t type) {
|
||||
static void headroom_main(void *arg) {
|
||||
(void)arg;
|
||||
__atomic_store_n(&H.tid, plat_thread_id(), __ATOMIC_RELEASE);
|
||||
if (vk_vaddr_wanted()) rt_log("vk: headroom: thread %u", H.tid); // names this thread in the address history (vk_vaddr.c)
|
||||
plat_thread_priority(PLAT_PRIO_BELOW_NORMAL);
|
||||
uint64_t watch = 0; // memory types seen so far
|
||||
for (;;) {
|
||||
|
||||
Reference in New Issue
Block a user