mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 14:05:57 +00:00
Merge pull request #1448: skip_cs leaves out the dispatches of listed compute shaders, a bisecting tool for the Intel 1.2.1 boot freeze (ShannoonRuaaa) (#1402, #994)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
6205940caf
4 files changed
+74
-4
No files matched your search
@@ -68,7 +68,8 @@ GPU semantics behind the graphics rows: [maxwell.md](../maxwell.md). The method
|
||||
|---|---|---|
|
||||
| device lost a few frames in, GPU writes to address 0 (older NVIDIA) | present from another thread or queue | every submit and present on one queue under one lock |
|
||||
| device lost or garbage on one AMD generation | views the driver branch mishandles (BC block views of 3D textures) | `vk: pass marks`, validation; the formats in the pass |
|
||||
| device lost on one scene, every run, one vendor | a shader or pass that driver cannot run | pass marks name the pass; skip shaders by hash to bisect |
|
||||
| device lost on one scene, every run, one vendor | a shader or pass that driver cannot run | pass marks name the pass; `skip_cs = <id>` (docs/settings.md) leaves out the dispatch the marks name, to bisect |
|
||||
| freeze on "Nintendo presents", then device lost, every run, Intel GPU (Windows driver and Mesa ANV), game 1.2.1 only; 1.4.3 boots (#994, #1402) | on ANV the pass marks put it in one compute dispatch of 1.2.1 after the startup logo (`dispatch 10 of submission 430`, `cs 75be3722f62cb67e`, absent from a 1.4.3 shader cache); the Windows driver has no pass marks, so the same dispatch there is a guess; the shader and why it hangs are not found yet | pass marks; `skip_cs = 75be3722f62cb67e`; game 1.4.3 |
|
||||
| GPU timeout after 1-2 min, single frames over 2 s | first-time shader stalls or a huge one-shot submission on a slow GPU | prepared shaders; submission sizes at boot |
|
||||
| GPU hang at boot with pipeline libraries | point lists without a point size | the shader writes point size or the device clamps it |
|
||||
| black window after a driver update | caches from another driver | the log line `vk_pipeline: ... written by another device or driver`; delete the caches next to `totk.exe` |
|
||||
|
||||
@@ -36,6 +36,7 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `perf_slow_ms` (default `50`) | Frames at least this many milliseconds long get a `perf: slow frame` log line with the time blocked per cause. | Changes how many frames are logged; a small value fills the log. | Safe |
|
||||
| `replay_check` | `1` reads every texture read-back a second time after a full drain of the replay queue and compares the two. | Stalls the replay queue at every read-back, so frames get much slower; mismatches are only counted and logged. | Caution |
|
||||
| `resolve_check` | `1` compares every cached pool lookup with the locked lookup and stops on a difference. | Slows every pool lookup; the game stops if the two ever differ. | Caution |
|
||||
| `skip_cs` | Leaves out every dispatch of the compute shaders it names: up to 16 ids, separated by commas or spaces, each the 16 hex digits after `cs` in a `vk: last started ...: dispatch ...` pass-mark line of a lost device (fewer digits match every id that starts with them). At the first dispatch the log names each listed id, and then the first dispatch it skipped of each. For finding the shader behind a GPU hang that the pass marks put in one dispatch, such as the hang after the startup logo on Intel GPUs with game 1.2.1 (#1402). | Whatever the skipped shader writes is missing, so parts of the picture can be wrong or black, and a shader whose results the game reads back can change what it does; remove the line once the test is done. | Risky |
|
||||
| `speed_probe` | `1` adds the player's position and ground speed to the frame-rate line that `TOTK_TRACE=perf` prints every 120 presents. | Only adds log text; has no effect without `TOTK_TRACE=perf`. | Safe |
|
||||
|
||||
## Profiling and measurement
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ static const char *const known[] = {
|
||||
"REPLAY_CHECK", "REPORT_GUARD", "RESOLVE_CHECK", "RESTART_WAIT", "RESTBL_CACHE", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES",
|
||||
"ROMFS_PROOF_DIR", "ROMFS_VERIFY", "RSTICK_DEADZONE", "RUMBLE", "RUMBLE_CURVE", "RUMBLE_STRENGTH", "RUMBLE_TRIGGERS", "SCENE_UPSCALER", "SHADER_CACHE",
|
||||
"SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", "SHUTTER_FIX",
|
||||
"SHOTS_FULL", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_DEADZONE", "STICK_SENS",
|
||||
"SHOTS_FULL", "SKIP_CS", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_DEADZONE", "STICK_SENS",
|
||||
"SWKBD_ANSWER", "SYNC_AHEAD",
|
||||
"SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PAD_RUMBLE_MS", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64", "VK_NO_HOST_IMPORT",
|
||||
"VK_PRESENT", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VMA_BLOCK_MIB", "VOLUME", "VOLUME_MASK_BIAS", "VOLUME_MUSIC", "VOLUME_SFX", "VOLUME_VOICE", "VRAM_HEADROOM", "VRAM_LIMIT_MIB", "VS_OUTS",
|
||||
|
||||
+70
-2
@@ -4513,6 +4513,74 @@ static void op_draw_idx_ind(VkExec *ex, const p_draw_idx_ind *d) {
|
||||
|
||||
// ---- dispatch and uniform buffer updates
|
||||
|
||||
// skip_cs (TOTK_SKIP_CS): compute shaders whose dispatches are left out, named by the id the pass marks print for a
|
||||
// dispatch ("cs 75be3722f62cb67e": the first 8 bytes of the shader's input id, vk_crumbs.c shader_id). Up to
|
||||
// SKIP_CS_MAX ids of 1 to 16 hex digits, separated by commas or spaces; an id shorter than 16 digits matches every
|
||||
// shader whose id starts with it. When the pass marks put a GPU hang in one dispatch, as on Intel GPUs on game 1.2.1
|
||||
// after the startup logo (#1402), this takes that dispatch out: the device survives if the shader was the cause, at the
|
||||
// cost of whatever the shader would have written. A bisecting tool and a stopgap, not a fix.
|
||||
#define SKIP_CS_MAX 16
|
||||
static struct { unsigned long long id, mask; } skip_cs[SKIP_CS_MAX];
|
||||
static int n_skip_cs;
|
||||
static PlatOnce skip_cs_once = PLAT_ONCE_INIT;
|
||||
|
||||
static void skip_cs_read(void *arg) {
|
||||
(void)arg;
|
||||
const char *v = cfg_get("TOTK_SKIP_CS");
|
||||
if (!v) return;
|
||||
for (const char *p = v; *p;) {
|
||||
while (*p == ',' || *p == ' ' || *p == '\t') p++;
|
||||
if (!*p) break;
|
||||
unsigned long long id = 0;
|
||||
int digits = 0;
|
||||
const char *entry = p;
|
||||
for (; *p && *p != ',' && *p != ' ' && *p != '\t'; p++) {
|
||||
int c = (unsigned char)*p, h = c >= '0' && c <= '9' ? c - '0' : c >= 'a' && c <= 'f' ? c - 'a' + 10
|
||||
: c >= 'A' && c <= 'F' ? c - 'A' + 10 : -1;
|
||||
if (h < 0 || digits == 16) { // not an id: skip the rest of this entry
|
||||
digits = -1;
|
||||
while (*p && *p != ',' && *p != ' ' && *p != '\t') p++;
|
||||
break;
|
||||
}
|
||||
id = id << 4 | (unsigned)h, digits++;
|
||||
}
|
||||
if (digits <= 0) {
|
||||
int len = 0;
|
||||
while (entry[len] && entry[len] != ',' && entry[len] != ' ' && entry[len] != '\t') len++;
|
||||
rt_log("vk: skip_cs: \"%.*s\" is not 1 to 16 hex digits; ignored", len, entry);
|
||||
continue;
|
||||
}
|
||||
if (n_skip_cs == SKIP_CS_MAX) {
|
||||
rt_log("vk: skip_cs: more than %d ids; the rest are ignored", SKIP_CS_MAX);
|
||||
break;
|
||||
}
|
||||
int shift = 4 * (16 - digits); // 0..60: digits is 1..16
|
||||
skip_cs[n_skip_cs].id = id << shift;
|
||||
skip_cs[n_skip_cs].mask = ~0ull << shift;
|
||||
n_skip_cs++;
|
||||
}
|
||||
for (int i = 0; i < n_skip_cs; i++)
|
||||
rt_log("vk: skip_cs: dispatches of compute shaders whose id starts with %0*llx are skipped (TOTK_SKIP_CS)",
|
||||
16 - __builtin_ctzll(skip_cs[i].mask) / 4, skip_cs[i].id >> __builtin_ctzll(skip_cs[i].mask));
|
||||
}
|
||||
|
||||
// 1 when skip_cs names cs; logs the first skipped dispatch of each listed id.
|
||||
static int cs_skipped(const GfxShader *cs) {
|
||||
plat_once(&skip_cs_once, skip_cs_read, NULL);
|
||||
if (!n_skip_cs) return 0;
|
||||
const uint8_t *iid = gfx_shader_input_id(cs);
|
||||
unsigned long long v = 0;
|
||||
for (int i = 0; i < 8; i++) v = v << 8 | iid[i];
|
||||
static uint32_t logged; // bit i: entry i was logged
|
||||
for (int i = 0; i < n_skip_cs; i++) {
|
||||
if ((v & skip_cs[i].mask) != skip_cs[i].id) continue;
|
||||
if (!(__atomic_fetch_or(&logged, 1u << i, __ATOMIC_RELAXED) & 1u << i))
|
||||
rt_log("vk: skip_cs: skipped a dispatch of cs %016llx (TOTK_SKIP_CS); later ones are not logged", v);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void op_dispatch(VkExec *ex, const p_dispatch *d) {
|
||||
VkExecDraw *D = ex->draw;
|
||||
if (d->x <= 0 || d->y <= 0 || d->z <= 0) return;
|
||||
@@ -4522,7 +4590,7 @@ static void op_dispatch(VkExec *ex, const p_dispatch *d) {
|
||||
dummies_init();
|
||||
int present;
|
||||
const GfxShader *cs = shader_for(ex, NVN_STAGE_CS, &present, NULL, 0); // synchronous: a skipped dispatch changes results
|
||||
if (!cs) return;
|
||||
if (!cs || cs_skipped(cs)) return;
|
||||
const VkPipeInfo *info = NULL;
|
||||
VkPipeline p = vk_pipeline_compute(cs, &info);
|
||||
if (!p || !info) return warn_once(W_PIPELINE, "a compute pipeline could not be created: dispatches with it are skipped");
|
||||
@@ -4551,7 +4619,7 @@ static void op_dispatch_ind(VkExec *ex, const p_dispatch_ind *d) {
|
||||
dummies_init();
|
||||
int present;
|
||||
const GfxShader *cs = shader_for(ex, NVN_STAGE_CS, &present, NULL, 0);
|
||||
if (!cs) return;
|
||||
if (!cs || cs_skipped(cs)) return;
|
||||
const VkPipeInfo *info = NULL;
|
||||
VkPipeline p = vk_pipeline_compute(cs, &info);
|
||||
if (!p || !info) return warn_once(W_PIPELINE, "a compute pipeline could not be created: dispatches with it are skipped");
|
||||
|
||||
Reference in new issue
Block a user