diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 22:12:48 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 22:13:02 -0500 |
| commit | 3ee0037fd3accba459d0d5ecd8acad831174d4d7 (patch) | |
| tree | 55953ce44091103e4f7c4a2f45490be961282b27 /scripts/linux-boot/boot-inner.sh | |
| parent | 9b8707c03dabb59ba2e29b9b0749d3c3eb1f3903 (diff) | |
| parent | 5115f0887940595aa0f46fed7fc9db28b64151ff (diff) | |
Merge main into RT-DIRECT-HEAP-GRAPHICS (#1232)
This merges #1064 as prepared (its head + a merge of main), so it brings #1232 up to date with main and
with #1064. #1232's branch carried #974 (merged into main since) and an older head of #1064 (7c47fd946).
main already supplies the directly indexed heaps to graphics draws (integration #984):
graphics_user_data() on DrawInstanced, DrawIndexedInstanced and DispatchMesh, at
RootArgumentLayout::graphics_arguments_end (pack_stage(Stage::Pixel)'s end_sgpr, set when the console
layout places the signature), LEONIDA_GRAPHICS_DIRECT_HEAPS=0, its notes for a signature on the s0
layout or one that fills s31, and d3d12_graphics_direct_heaps_test (recorded draws and the VS/PS GPU
reads). That form stays. What this pull request adds beyond it is carried onto it: the mesh case.
Conflicts (all taken from #1064's merged branch, then the PR's mesh parts carried over):
- runtime/shims/d3d12_com.cpp: main's graphics_user_data()/with_direct_heaps() and notes. The PR's own
graphics_user_data(), GetEnvironmentVariableA switch and no-room notes are main's in another form and
dropped. Carried: the comment says a mesh shader reads push dword d as s(d + 8) through #974's window,
so it gets the heaps after its arguments from s16 (main's comment still said the mesh stage gets none);
and DispatchMesh reports once when a heap falls past the mesh window (push dword 24 and up, s32 for the
mesh shader), the case raised in the review of #1232 (mesh_ok accepts arguments up to push dword 24).
- runtime/shims/d3d12_com.h, runtime/shims/d3d12_vulkan_device.cpp: main's (graphics_arguments_end from
pixel.end_sgpr; the PR set it from its Spill::block form, which main did not take from #974).
- runtime/test/glsl/cs_user_data.comp: main's (identical direct-indexing mode).
- docs/d3d12_vulkan.md: main's section 3.4 with #1064's compute paragraph; the graphics paragraph's
"a mesh shader ... is not modelled" replaced by the mesh window position, cited to issue #14 comment
7143020922 as a report not reproduced here, the window-overflow note and the mesh test.
- runtime/test/d3d12_mesh_test.cpp (no conflict): the PR's recorded-argument checks kept (vertex and mesh
draw with 4 constants, resource-only rebind, 23 constants, 30 constants); the 30-constant comment now
says it keeps pack()'s s0 layout on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts/linux-boot/boot-inner.sh')
| -rwxr-xr-x | scripts/linux-boot/boot-inner.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/linux-boot/boot-inner.sh b/scripts/linux-boot/boot-inner.sh new file mode 100755 index 000000000..e52d3daef --- /dev/null +++ b/scripts/linux-boot/boot-inner.sh | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # Runs inside the leonida-boot-* unit (see run-boot.sh). Waits for memory, takes the locks, samples resources, boots. | ||
| 3 | set -u | ||
| 4 | WORK=/opt/leonida/work/$BOOT_AGENT; N=$BOOT_N; LOG=$WORK/boot-$N.log; RES=$WORK/boot-$N.resources.tsv | ||
| 5 | META=$WORK/boot-$N.meta | ||
| 6 | : > "$LOG" | ||
| 7 | echo "start_epoch=$(date +%s)" > "$META" | ||
| 8 | echo "unit=leonida-boot-$BOOT_AGENT-$N gta6rt=$GTA6RT secs=$BOOT_SECS" >> "$META" | ||
| 9 | env | grep -E '^(LEONIDA_|WINEDEBUG=)' | sort >> "$META" | ||
| 10 | |||
| 11 | mem_free_mb() { # RAM available plus a third of free zram swap (zram pages cost RAM, roughly 3:1) | ||
| 12 | awk '/^MemAvailable:/{a=$2} /^SwapFree:/{s=$2} END{printf "%d", (a + s/3)/1024}' /proc/meminfo | ||
| 13 | } | ||
| 14 | NEED=${LEONIDA_BOOT_MIN_FREE_MB:-6500} | ||
| 15 | swap_pct() { awk '/^SwapTotal:/{t=$2} /^SwapFree:/{f=$2} END{printf "%d", t ? (t-f)*100/t : 0}' /proc/meminfo; } | ||
| 16 | |||
| 17 | exec 8>/opt/leonida/.gpu.lock; flock 8 # one boot at a time | ||
| 18 | echo "[run-boot] $(date +%T) got the GPU lock" >> "$LOG" | ||
| 19 | for i in $(seq 1 40); do # up to 10 min for memory headroom | ||
| 20 | f=$(mem_free_mb); sp=$(swap_pct); [ "$f" -ge "$NEED" ] && [ "$sp" -lt 70 ] && break | ||
| 21 | echo "[run-boot] $(date +%T) waiting for memory: ${f} MB free (need ${NEED}), swap ${sp}% (need < 70%)" >> "$LOG"; sleep 15 | ||
| 22 | done | ||
| 23 | echo "[run-boot] $(date +%T) memory before boot: $(mem_free_mb) MB free, swap $(swap_pct)%" >> "$LOG" | ||
| 24 | exec 9>/opt/leonida/.build.lock; flock 9 # no compiles while the game runs | ||
| 25 | echo "[run-boot] $(date +%T) got the build lock; booting" >> "$LOG" | ||
| 26 | echo "boot_epoch=$(date +%s)" >> "$META" | ||
| 27 | |||
| 28 | CG=/sys/fs/cgroup$(cut -d: -f3 /proc/self/cgroup) | ||
| 29 | ( printf 'time\tmem_avail_mb\tswap_used_mb\tunit_mem_mb\tunit_swap_mb\tgpu_mem_mb\tgpu_util\n' | ||
| 30 | while :; do | ||
| 31 | read -r ma su < <(awk '/^MemAvailable:/{a=$2} /^SwapTotal:/{t=$2} /^SwapFree:/{f=$2} END{print int(a/1024), int((t-f)/1024)}' /proc/meminfo) | ||
| 32 | um=$(( $(cat "$CG/memory.current" 2>/dev/null || echo 0) / 1048576 )); us=$(( $(cat "$CG/memory.swap.current" 2>/dev/null || echo 0) / 1048576 )) | ||
| 33 | g=$(nvidia-smi --query-gpu=memory.used,utilization.gpu --format=csv,noheader,nounits 2>/dev/null | tr -d ' ' | tr ',' '\t') | ||
| 34 | printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$(date +%T)" "$ma" "$su" "$um" "$us" "${g:-? ?}" | ||
| 35 | sleep 2 | ||
| 36 | done ) > "$RES" 2>/dev/null & | ||
| 37 | SAMPLER=$! | ||
| 38 | |||
| 39 | /opt/leonida/boot.sh run "$BOOT_SECS" >> "$LOG" 2>&1 | ||
| 40 | rc=$? | ||
| 41 | kill $SAMPLER 2>/dev/null | ||
| 42 | echo "[run-boot] $(date +%T) boot.sh exit $rc" >> "$LOG" | ||
| 43 | # boot.sh stops the title with timeout(1) at the time limit: 124 means it ran the whole time, which is success here. | ||
| 44 | [ "$rc" = 124 ] && { echo "[run-boot] time limit reached" >> "$LOG"; rc=0; } | ||
| 45 | exit $rc | ||