Say in the crash report when the crash is in another program's module, and report video memory when the device is lost.

A crash inside a recorder's Vulkan layer read like a fault of the game: the report now says that the module is not part of the game and what to do. A lost device now logs the video memory in use against the driver's budget, so a report from a card with little memory shows whether the memory ran out.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 12:26:31 -05:00
parent 63c7d3cb74
commit 0a9bbed34a
4 changed files with 29 additions and 0 deletions

View File

@@ -35,6 +35,7 @@
// Also here: the runtime services the generated code calls besides rt_dispatch and rt_svc (rt_brk, rt_udf,
// rt_ticks, the function profiler hook), logging, SHA-256, and the crash reporter (a vectored exception handler that
// names the lifted function, the guest registers and the guest frame-pointer chain).
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@@ -256,6 +257,17 @@ static uint64_t lifted_function(uintptr_t rip) {
static int readable(uint64_t a, uint64_t n) { return plat_mem_readable(a, n); }
// A module another program put into the game's process: the Vulkan layer or the hook of a recorder, an overlay or a
// capture tool, by the words such files carry in their names. A crash inside one is that program's: one report was an
// access violation in a recorder's layer the moment the present mode changed and the swapchain was made again.
static int foreign_hook(const char *module) {
char low[160];
size_t n = 0;
for (; module && module[n] && n < sizeof low - 1; n++) low[n] = (char)tolower((unsigned char)module[n]);
low[n] = 0;
return strstr(low, "vk_layer") || strstr(low, "hook") || strstr(low, "overlay");
}
static void crash_handler(const PlatCrash *x) {
static volatile int32_t busy;
if (plat_xchg32(&busy, 1)) plat_exit(71);
@@ -269,6 +281,9 @@ static void crash_handler(const PlatCrash *x) {
rt_logf(", %s address %#llx", x->access == 1 ? "writing" : x->access == 8 ? "executing" : "reading",
(unsigned long long)x->addr);
rt_log_raw("\n", 1);
if (foreign_hook(x->module))
rt_logf(" %s is not part of the game: a recording, overlay or capture program put it into the game. Close that "
"program or turn off its Vulkan capture, then start the game again\n", x->module);
uint64_t f = x->module ? 0 : lifted_function(rip);
if (f) rt_logf(" in lifted function f_%llx = %s\n", (unsigned long long)f, ldr_describe(f, d, sizeof d));
// abort and invalid parameter: where the host code called it; a fault in another module: the host calls that led

View File

@@ -353,6 +353,7 @@ void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDevic
int vk_mem_class_of(uint64_t addr); // VK_MCLS_* of the pool at addr (NONE when unbacked)
void vk_mem_census(uint64_t frame); // at each present: pool census and traffic, logged at frame 1800 and,
// with NX2NAVI_TRACE=perf, every 1800 frames
void vk_mem_lost_report(void); // a line with the video memory in use and its budget (device lost)
float vk_mem_device_used_mb(void); // device-local memory this process holds (the driver's budget
// figure), MB; -1 without VK_EXT_memory_budget. Any thread.
void vk_mem_stage_log(const char *stage); // one line after a boot stage: device memory, process commit

View File

@@ -588,6 +588,7 @@ void vk_device_fault_report(VkResult r) {
done = 1;
vk_crumbs_report();
vk_pass_marks_report();
vk_mem_lost_report();
VkCtx *c = vk_ctx();
PFN_vkGetDeviceFaultInfoEXT get =
c && c->has_device_fault ? (PFN_vkGetDeviceFaultInfoEXT)vk_dpa(c->device, "vkGetDeviceFaultInfoEXT")

View File

@@ -3247,6 +3247,18 @@ static void outside_watch(uint64_t frame) {
// The overlay's "game" figure beside the card's memory in use (perfmon.c, its sampling thread): what the driver
// counts for this process on the device-local heaps, the same figure vram_use_log splits by use.
// With the device lost report (vk_device.c): the video memory in use and the budget the driver gives the game. A lost
// device with the memory at or over its budget points at the memory; one far below it does not, and the report of a
// card with 8 GB that ended this way held neither number.
void vk_mem_lost_report(void) {
uint64_t used, budget;
int exact;
if (!vram_query(&used, &budget, &exact)) return;
rt_log("vk: video memory when the device was lost: %llu MiB in use of a budget of %llu MiB (%s)",
(unsigned long long)(used >> 20), (unsigned long long)(budget >> 20),
exact ? "the driver's figures, every program counted in the budget" : "this game's own allocations only");
}
float vk_mem_device_used_mb(void) {
VkCtx *c = vk_ctx();
if (!c || !c->has_memory_budget) return -1;