diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 21:44:23 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 21:44:23 -0500 |
| commit | b8563e949ed389fff20be91c73687a70b5213469 (patch) | |
| tree | d69c6817854ce0a14a67ff1fd0f1c39dec68a91f /scripts/linux-boot/boot-digest.sh | |
| parent | 00fc23b9a9eeb1a75f1fec2b58024bea15c26663 (diff) | |
| parent | 7ae1dd3de34f1542242bc8ccfc80d9b97d20cc01 (diff) | |
Merge main into D3D-448-GRAPHICS (#974)
main already lays graphics root arguments out in the console layout (from s8, one dword per table: #939's
graphics-root-layout patch in #984's form, pack_stage(Stage::Pixel), RootArgumentLayout::graphics_console,
graphics_arguments_end, LEONIDA_GRAPHICS_STAGE_LAYOUT=0 for pack()). That form stays. What this pull request adds
beyond it is carried onto it: the mesh-shader root window (translator, index "root_window", mesh_ok, the two
refusals) and its tests. Its own graphics spill handling (Spill::block) and LEONIDA_GRAPHICS_ROOT_LAYOUT=pc are not
carried: main keeps pack()'s s0 layout for a graphics signature past s31, and its switch does what =pc did.
Conflicts:
- runtime/src/root_signature.h, root_signature.cpp: main's pack_stage (compute spill array, spill_dword); the
Spill enum, first_spilled and spilled_dwords dropped. The header keeps the PR's evidence note, with Stage::Pixel.
- runtime/shims/d3d12_com.h: main's comment and members, with the mesh window described; mesh_ok added (false by
default, set only for a console-layout signature that Stage::Mesh also places); the PR's second graphics_console
dropped.
- runtime/shims/d3d12_vulkan_device.cpp (CreateRootSignature): main's pixel/packed form; the PR's Stage::Mesh pack
and its log line added, mesh_ok = pixel.ok && mesh.ok. The mesh-shader refusal without "root_window" (no
conflict) stays.
- runtime/shims/d3d12_com.cpp: DispatchMesh keeps main's any_nonempty_viewport() and graphics_user_data() after the
PR's mesh_ok check; address() keeps main's comment. The PR's kNoSgpr guard in constants()/address() stays,
reworded: in main a spilled compute parameter has first_sgpr kNoSgpr, and kNoSgpr + offset wrapped round to s0.
- runtime/src/shader_library.h: both (main's wave64_graphics, the PR's root_window).
- runtime/test/d3d12_mesh_test.cpp: main's mesh shader-kind byte on both containers (also the PR's ms_old); the
PR's two-parameter signature replaces main's 25-dword padding onto the s0 layout; both test blocks kept (the
PR's window refusals, main's DISPATCH_MESH command signature), each in its own scope. The =pc case is dropped
(main's switch is read once per process).
- runtime/CMakeLists.txt (no conflict): the mesh test uses ps_draw.spv again; the ps_draw_s0.spv rule is gone.
- runtime/test/glsl/ps_draw.frag, vs_depth.vert, vs_draw.vert, vs_draw_int.vert, ps_depth_write.frag and
runtime/test/shaders/ps_m15, ps_m2, ps_m2_array, ps_m2_literal, ps_m2_uoff, ps_m3, ps_m3_post, ps_m3_query,
vs_m15, vs_m3 (.asm): main's (the same s8 rewrite done twice); ps_draw.frag's mesh-test note updated.
- runtime/test/root_signature_test.cpp (no conflict): the Spill::block cases dropped, the window cases kept.
- docs/design.md: main's rows (loop guard, direct resource heap) and the PR's user-data row.
- docs/d3d12_vulkan.md (no conflict): section 3.5 and the CreateRootSignature bullet rewritten for main's form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts/linux-boot/boot-digest.sh')
| -rwxr-xr-x | scripts/linux-boot/boot-digest.sh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/scripts/linux-boot/boot-digest.sh b/scripts/linux-boot/boot-digest.sh new file mode 100755 index 000000000..dd2289e30 --- /dev/null +++ b/scripts/linux-boot/boot-digest.sh | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # ExecStopPost of a leonida-boot-* unit: runs after the boot ends however it ended (exit, crash, oomd kill, timeout). | ||
| 3 | # Writes /opt/leonida/work/<agent>/boot-<n>.digest.txt and appends a line to /opt/leonida/work/boots.tsv. | ||
| 4 | # Local only: digests quote trace lines, so they never go into commits or PRs. | ||
| 5 | set -u | ||
| 6 | AGENT=$1; N=$2; WORK=/opt/leonida/work/$AGENT; LOG=$WORK/boot-$N.log; RES=$WORK/boot-$N.resources.tsv | ||
| 7 | META=$WORK/boot-$N.meta; OUT=$WORK/boot-$N.digest.txt; LEDGER=/opt/leonida/work/boots.tsv | ||
| 8 | START=$(sed -n 's/^start_epoch=//p' "$META" 2>/dev/null); BOOT=$(sed -n 's/^boot_epoch=//p' "$META" 2>/dev/null) | ||
| 9 | START=${START:-$(date +%s)}; BOOT=${BOOT:-$START}; END=$(date +%s) | ||
| 10 | RESULT=${SERVICE_RESULT:-?}; ECODE=${EXIT_CODE:-?}; ESTAT=${EXIT_STATUS:-?} | ||
| 11 | D3D=$(grep -o 'd3d12=[^ ]*' "$LOG" 2>/dev/null | tail -1 | cut -d= -f2) | ||
| 12 | STDOUT=${D3D/d3d12-run-/stdout-run-} | ||
| 13 | CAP=/opt/leonida/capture/$AGENT-$N | ||
| 14 | |||
| 15 | verdict=OK | ||
| 16 | # systemd-oomd can kill the unit's processes without the unit ending in "oom-kill" (boot.sh then exits on its own). | ||
| 17 | if journalctl --user -u "leonida-boot-$AGENT-$N" --since "@$START" -q --no-pager 2>/dev/null | grep -q 'systemd-oomd killed'; then RESULT=oom-kill; fi | ||
| 18 | case "$RESULT" in | ||
| 19 | oom-kill) verdict="KILLED BY OOM (systemd-oomd or kernel): memory, not a crash" ;; | ||
| 20 | timeout) verdict="TIMEOUT" ;; | ||
| 21 | exit-code) verdict="EXITED WITH ERROR (code $ECODE status $ESTAT)" ;; | ||
| 22 | signal|core-dump) verdict="KILLED BY SIGNAL ($ESTAT)" ;; | ||
| 23 | success) verdict="OK (ran to its time limit or exited cleanly)" ;; | ||
| 24 | esac | ||
| 25 | grep -q 'time limit reached' "$LOG" 2>/dev/null && [ "$RESULT" = success ] && verdict="OK (ran its full time limit)" | ||
| 26 | |||
| 27 | cnt() { local c=0; [ -f "$D3D" ] && c=$(grep -a -c -E "$@" "$D3D"); echo "${c:-0}"; } | ||
| 28 | { | ||
| 29 | echo "== leonida boot $AGENT-$N: $verdict" | ||
| 30 | echo "unit result=$RESULT exit_code=$ECODE exit_status=$ESTAT" | ||
| 31 | echo "queued $((BOOT-START)) s, ran $((END-BOOT)) s; trace $D3D" | ||
| 32 | sed -n '/^LEONIDA_\|^WINEDEBUG\|^unit=/p' "$META" 2>/dev/null | tr '\n' ' '; echo | ||
| 33 | echo | ||
| 34 | echo "-- counts" | ||
| 35 | echo "PresentX ok $(cnt 'XboxPresentation::PresentX ok') refused $(cnt 'XboxPresentation::PresentX failed')" | ||
| 36 | echo "CreatePipelineState failed $(cnt 'CreatePipelineState failed') FSPX compute misses $(cnt 'no translated compute shader for FSPX') slot-67 failed $(cnt 'slot 67 call .* failed')" | ||
| 37 | echo "E_NOTIMPL $(cnt 'E_NOTIMPL') wine err: lines $(cnt '^[0-9a-f]{4}:err:|:err:') exceptions $(cnt -i 'exception|unhandled|page fault|access violation')" | ||
| 38 | grep -a -m1 -E 'translated shaders \(' "$D3D" 2>/dev/null | ||
| 39 | grep -a 'present-probe: source frame .* via' "$D3D" 2>/dev/null | tail -1 | sed 's/.*via/source via/' | cut -c1-120 | ||
| 40 | echo | ||
| 41 | echo "-- frames (swapchain; then the title's own backbuffer when LEONIDA_CAPTURE_SOURCE=1)" | ||
| 42 | [ -f "$CAP/index.txt" ] && { echo "$(wc -l < "$CAP/index.txt") captured; last: $(tail -1 "$CAP/index.txt" | cut -c1-110)"; awk '{m=$(NF-2)+$(NF-1)+$NF; if (m>0) n++} END{print n+0 " of " NR " frames non-black"}' "$CAP/index.txt"; } || echo "no capture index" | ||
| 43 | grep -a 'present-probe: source frame .* mean' "$D3D" 2>/dev/null | tail -2 | sed 's/.*source frame/source frame/' | cut -c1-140 | ||
| 44 | echo | ||
| 45 | echo "-- resources (2 s samples)" | ||
| 46 | [ -s "$RES" ] && awk -F'\t' 'NR>1{ if(min==""||$2<min)min=$2; if($3>sw)sw=$3; if($4>um)um=$4; if($5>us)us=$5; if($6+0>gm)gm=$6 } END{printf "min RAM available %s MB, max swap used %s MB, game peak %s MB RAM + %s MB swap, VRAM peak %s MB\n",min,sw,um,us,gm}' "$RES" || echo "no samples" | ||
| 47 | journalctl --user -u "leonida-boot-$AGENT-$N" --since "@$START" -q --no-pager 2>/dev/null | grep -E 'Consumed|oom|Failed' | sed 's/^.*\]: //' | sort -u | cut -c1-200 | ||
| 48 | # Compare with other boots instead of guessing: on the console (Series S) path the title itself grows to ~20 GB of | ||
| 49 | # RAM+swap by ~130 s (fsdraw-6: 9.9 GB + 11.2 GB), mostly zero pages that zram compresses well. | ||
| 50 | [ -s "$RES" ] && awk -F'\t' 'NR>1{t=$4+$5; if(t>m)m=t} END{printf "game peak RAM+swap %.1f GB (console-path baseline ~20 GB at 130 s; oomd kills when zram swap passes 98%%)\n", m/1024}' "$RES" | ||
| 51 | echo | ||
| 52 | echo "-- system events during the boot (OOM, GPU Xid, segfaults)" | ||
| 53 | { journalctl --since "@$BOOT" -q --no-pager 2>/dev/null | grep -i -E 'systemd-oomd.*(Marked|killed)|oom-kill|out of memory|NVRM: Xid|segfault|gta6rt|wineserver.*crash' ; } | cut -c1-200 | tail -15 | ||
| 54 | echo | ||
| 55 | echo "-- distinct error lines (normalised, with counts; top 60)" | ||
| 56 | for f in "$D3D" "$STDOUT"; do [ -f "$f" ] && cat "$f"; done 2>/dev/null \ | ||
| 57 | | grep -a -i -E 'error|fail|E_NOTIMPL|E_INVALIDARG|E_FAIL|0x8[0-9a-f]{7}|exception|assert|abort|unhandled|page fault|refused|not implemented|no translated|no emulation|crash|:err:|fatal|cannot|could not|unsupported|invalid' \ | ||
| 58 | | grep -a -v -E ' ok$| called$' \ | ||
| 59 | | sed -E 's/#[0-9]+/#N/g; s/0x[0-9a-fA-F]{6,}/0xADDR/g; s/\b[0-9a-f]{64}\b/SHA/g; s/[0-9]{4,}/NUM/g; s/^[0-9a-f]{4}:/TID:/' \ | ||
| 60 | | cut -c1-220 | sort | uniq -c | sort -rn | head -60 | ||
| 61 | echo | ||
| 62 | echo "-- where the trace ended" | ||
| 63 | [ -f "$D3D" ] && tail -n 8 "$D3D" | cut -c1-200 | ||
| 64 | } > "$OUT" 2>&1 | ||
| 65 | |||
| 66 | frames=$( [ -f "$CAP/index.txt" ] && awk '{m=$(NF-2)+$(NF-1)+$NF; if (m>0) n++} END{print (n+0) "/" NR}' "$CAP/index.txt" || echo "-") | ||
| 67 | peak=$( [ -s "$RES" ] && awk -F'\t' 'NR>1{if($4>u)u=$4} END{print u+0}' "$RES" || echo "-") | ||
| 68 | exec 7>>"$LEDGER"; flock 7 | ||
| 69 | # Both the unit's ExecStopPost and the outer wrapper call this; the first one to finish records the boot. | ||
| 70 | grep -q -P "^[^\t]*\t$AGENT\t$N\t" "$LEDGER" 2>/dev/null && exit 0 | ||
| 71 | [ -s "$LEDGER" ] || printf 'end\tagent\tn\tresult\tran_s\tpresentx_ok\tpso_failed\tfspx_miss\tnonblack_frames\tpeak_mb\tgta6rt\n' >&7 | ||
| 72 | printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$(date '+%F %T')" "$AGENT" "$N" "$RESULT" "$((END-BOOT))" \ | ||
| 73 | "$(cnt 'XboxPresentation::PresentX ok')" "$(cnt 'CreatePipelineState failed')" "$(cnt 'no translated compute shader for FSPX')" \ | ||
| 74 | "$frames" "$peak" "$(sed -n 's/^unit=.*gta6rt=\([^ ]*\).*/\1/p' "$META")" >&7 | ||
| 75 | exit 0 | ||