diff options
| author | enlight3d <19186686+enlight3d@users.noreply.github.com> | 2026-11-27 18:48:46 +0100 |
|---|---|---|
| committer | enlight3d <19186686+enlight3d@users.noreply.github.com> | 2026-11-27 18:50:56 +0100 |
| commit | 2893fae21ca70143557e844e48bb7e3ccaba49c4 (patch) | |
| tree | 4c6297552c1898c2b90bd1f9f3bb856d4402223b /scripts/windows-boot | |
| parent | ba19ca8adacf791700c115bef5146f076ef3a990 (diff) | |
windows-boot: compare the boot's journal and the seed by Windows' final paths (BOOT-PRECOMPILED-JOURNAL)
The seed was kept when LEONIDA_PIPELINE_CACHE_DIR named the precompiled folder under another spelling (a
junction, or the \\.\ device prefix), although the runtime's std::filesystem checks see one folder and turn
the journal off. Ask Windows for each folder's final path (GetFinalPathNameByHandle, from the deepest
existing parent), which sees through junctions, symbolic links, substituted and mapped drives, 8.3 names and
the \\?\ and \\.\ prefixes; the spelled paths remain the fallback when the helper is not available.
Reported by TheGeogeo's agent (repro on #2481); the approach was suggested by OreoFR's agent. The test file
gains the \\.\ and junction cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts/windows-boot')
| -rw-r--r-- | scripts/windows-boot/README.md | 2 | ||||
| -rw-r--r-- | scripts/windows-boot/boot.ps1 | 48 |
2 files changed, 44 insertions, 6 deletions
diff --git a/scripts/windows-boot/README.md b/scripts/windows-boot/README.md index 3254020b6..ac76ecdaa 100644 --- a/scripts/windows-boot/README.md +++ b/scripts/windows-boot/README.md | |||
| @@ -38,7 +38,7 @@ Only when your shell has not set them already (`-DryRun` prints the final list): | |||
| 38 | | `LEONIDA_PIPELINE_CACHE_BYTES` | `4294967296` | pipeline cache size limit | | 38 | | `LEONIDA_PIPELINE_CACHE_BYTES` | `4294967296` | pipeline cache size limit | |
| 39 | | `LEONIDA_STARTUP_CACHE_CHECKPOINTS` | `1` | save the pipeline cache during startup | | 39 | | `LEONIDA_STARTUP_CACHE_CHECKPOINTS` | `1` | save the pipeline cache during startup | |
| 40 | | `LEONIDA_PIPELINE_CACHE_DIR` | `<out>\pipeline-cache` | one warmed cache shared by every build you boot | | 40 | | `LEONIDA_PIPELINE_CACHE_DIR` | `<out>\pipeline-cache` | one warmed cache shared by every build you boot | |
| 41 | | `LEONIDA_PIPELINE_JOURNAL_SEED_DIR` | `pipeline_cache.d` beside `gta6rt.exe`, when it exists | the journal `gta6rt --precompile-pipelines` fills there when it runs without `LEONIDA_PIPELINE_CACHE_DIR`, read-only, so its pipelines are not compiled again. Not set when the boot's own journal (`<cache folder>\pipeline_cache.d`, or beside `gta6rt.exe` when the cache folder is empty) is that folder or one holds the other, or when the cache folder is a relative path. A cache folder that reaches it under another name (a junction, symbolic link, substituted or mapped drive, or short 8.3 name) is not recognised; the runtime then logs `[rt] d3d12: invalid or overlapping compute journal directories; journal disabled`, and `LEONIDA_PIPELINE_JOURNAL_SEED_DIR=` (empty) fixes it. That empty value turns the seed off in any case. On NVIDIA, run the pre-compile with the same `LEONIDA_DEVICE_FAULT` as the boot (this script sets `1`): the diagnostics config is part of the journal's file names | | 41 | | `LEONIDA_PIPELINE_JOURNAL_SEED_DIR` | `pipeline_cache.d` beside `gta6rt.exe`, when it exists | the journal `gta6rt --precompile-pipelines` fills there when it runs without `LEONIDA_PIPELINE_CACHE_DIR`, read-only, so its pipelines are not compiled again. Not set when the boot's own journal (`<cache folder>\pipeline_cache.d`, or beside `gta6rt.exe` when the cache folder is empty) is that folder or one holds the other, compared through Windows' final paths (so a junction, symbolic link, substituted or mapped drive, 8.3 name or `\\?\` / `\\.\` prefix counts as the same folder), or when the cache folder is a relative path. `LEONIDA_PIPELINE_JOURNAL_SEED_DIR=` (empty) turns the seed off. If the runtime still logs `[rt] d3d12: invalid or overlapping compute journal directories; journal disabled`, set it so. On NVIDIA, run the pre-compile with the same `LEONIDA_DEVICE_FAULT` as the boot (this script sets `1`): the diagnostics config is part of the journal's file names | |
| 42 | | `LEONIDA_PEEK` / `_SECONDS` | the game-state and session-state RVAs from `LEONIDA_GAME_STATE_RVA` and `LEONIDA_SESSION_STATE_RVA` (measured locally, not kept here; unset: no peek) / `5` | game state and session state (low dword), the two numbers every RESULT reports | | 42 | | `LEONIDA_PEEK` / `_SECONDS` | the game-state and session-state RVAs from `LEONIDA_GAME_STATE_RVA` and `LEONIDA_SESSION_STATE_RVA` (measured locally, not kept here; unset: no peek) / `5` | game state and session state (low dword), the two numbers every RESULT reports | |
| 43 | | `LEONIDA_DEVICE_FAULT` | `1` | on device loss: `VK_EXT_device_fault` info, checkpoints, last replay steps | | 43 | | `LEONIDA_DEVICE_FAULT` | `1` | on device loss: `VK_EXT_device_fault` info, checkpoints, last replay steps | |
| 44 | | `LEONIDA_KEYBOARD_PAD` | `always` (with an input script) | keyboard as a pad even unfocused, so the script's presses arrive | | 44 | | `LEONIDA_KEYBOARD_PAD` | `always` (with an input script) | keyboard as a pad even unfocused, so the script's presses arrive | |
diff --git a/scripts/windows-boot/boot.ps1 b/scripts/windows-boot/boot.ps1 index 60c06fcb7..9b218d63e 100644 --- a/scripts/windows-boot/boot.ps1 +++ b/scripts/windows-boot/boot.ps1 | |||
| @@ -288,6 +288,46 @@ if ($bootEnv["LEONIDA_CAPTURE"]) { $Capture = $bootEnv["LEONIDA_CAPTURE"] } | |||
| 288 | # journal (pipeline_cache_journal.h, resolve_roots). A relative cache folder is resolved by the runtime against its own | 288 | # journal (pipeline_cache_journal.h, resolve_roots). A relative cache folder is resolved by the runtime against its own |
| 289 | # working folder, so it gets no seed here; a name that cannot be resolved gets none either, rather than a stop. | 289 | # working folder, so it gets no seed here; a name that cannot be resolved gets none either, rather than a stop. |
| 290 | if (-not $bootEnv.Contains("LEONIDA_PIPELINE_JOURNAL_SEED_DIR")) { | 290 | if (-not $bootEnv.Contains("LEONIDA_PIPELINE_JOURNAL_SEED_DIR")) { |
| 291 | # Windows' final path of a folder (GetFinalPathNameByHandle) sees through junctions, symbolic links, substituted | ||
| 292 | # and mapped drives, short 8.3 names and the \\?\ and \\.\ prefixes, as the runtime's std::filesystem checks do. | ||
| 293 | # A folder that does not exist yet is named from its deepest existing parent. Without the helper (a compile error, | ||
| 294 | # a restricted session), the comparison falls back to the spelled paths. | ||
| 295 | function Get-FinalFolderPath([string]$path) { | ||
| 296 | $plain = ($path -replace '^\\\\[?.]\\UNC\\', '\\' -replace '^\\\\[?.]\\', '').TrimEnd('\', '/') | ||
| 297 | try { | ||
| 298 | if (-not ('LeonidaFinalPath' -as [type])) { | ||
| 299 | Add-Type -ErrorAction Stop -TypeDefinition @' | ||
| 300 | using System; using System.Runtime.InteropServices; using System.Text; using Microsoft.Win32.SafeHandles; | ||
| 301 | public static class LeonidaFinalPath { | ||
| 302 | [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] | ||
| 303 | static extern SafeFileHandle CreateFileW(string name, uint access, uint share, IntPtr sa, uint disposition, uint flags, IntPtr template); | ||
| 304 | [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] | ||
| 305 | static extern uint GetFinalPathNameByHandleW(SafeFileHandle handle, StringBuilder buffer, uint length, uint flags); | ||
| 306 | public static string Of(string path) { | ||
| 307 | // No access asked, all sharing, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS (needed to open a folder). | ||
| 308 | using (SafeFileHandle h = CreateFileW(path, 0, 7, IntPtr.Zero, 3, 0x02000000, IntPtr.Zero)) { | ||
| 309 | if (h.IsInvalid) return null; | ||
| 310 | StringBuilder b = new StringBuilder(32768); | ||
| 311 | uint n = GetFinalPathNameByHandleW(h, b, (uint)b.Capacity, 0); | ||
| 312 | return (n == 0 || n >= b.Capacity) ? null : b.ToString(); | ||
| 313 | } | ||
| 314 | } | ||
| 315 | } | ||
| 316 | '@ | ||
| 317 | } | ||
| 318 | $existing = $path.TrimEnd('\', '/'); $tail = @() | ||
| 319 | while ($existing -and -not [System.IO.Directory]::Exists($existing)) { | ||
| 320 | $tail = @([System.IO.Path]::GetFileName($existing)) + $tail | ||
| 321 | $existing = [System.IO.Path]::GetDirectoryName($existing) | ||
| 322 | } | ||
| 323 | if (-not $existing) { return $plain } | ||
| 324 | $final = [LeonidaFinalPath]::Of($existing) | ||
| 325 | if (-not $final) { return $plain } | ||
| 326 | $final = $final -replace '^\\\\\?\\UNC\\', '\\' -replace '^\\\\\?\\', '' | ||
| 327 | foreach ($part in $tail) { $final = [System.IO.Path]::Combine($final, $part) } | ||
| 328 | return $final.TrimEnd('\', '/') | ||
| 329 | } catch { return $plain } | ||
| 330 | } | ||
| 291 | $seed = $null | 331 | $seed = $null |
| 292 | try { | 332 | try { |
| 293 | $runtimeFull = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RuntimeDir) | 333 | $runtimeFull = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RuntimeDir) |
| @@ -300,12 +340,10 @@ if (-not $bootEnv.Contains("LEONIDA_PIPELINE_JOURNAL_SEED_DIR")) { | |||
| 300 | $ownJournal = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($cacheDir, "pipeline_cache.d")).TrimEnd('\', '/') | 340 | $ownJournal = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($cacheDir, "pipeline_cache.d")).TrimEnd('\', '/') |
| 301 | } | 341 | } |
| 302 | if ($ownJournal) { | 342 | if ($ownJournal) { |
| 303 | # \\?\ spellings name the same folder for the runtime: compare without the prefix. | 343 | $a = Get-FinalFolderPath $ownJournal |
| 304 | $ownJournal = $ownJournal -replace '^\\\\\?\\UNC\\', '\\' -replace '^\\\\\?\\', '' | 344 | $b = Get-FinalFolderPath $precompiled |
| 305 | $precompiled = $precompiled -replace '^\\\\\?\\UNC\\', '\\' -replace '^\\\\\?\\', '' | ||
| 306 | $c = [System.StringComparison]::OrdinalIgnoreCase | 345 | $c = [System.StringComparison]::OrdinalIgnoreCase |
| 307 | $overlap = $ownJournal.Equals($precompiled, $c) -or $ownJournal.StartsWith($precompiled + '\', $c) -or | 346 | $overlap = $a.Equals($b, $c) -or $a.StartsWith($b + '\', $c) -or $b.StartsWith($a + '\', $c) |
| 308 | $precompiled.StartsWith($ownJournal + '\', $c) | ||
| 309 | if (-not $overlap) { $seed = $precompiled } | 347 | if (-not $overlap) { $seed = $precompiled } |
| 310 | } | 348 | } |
| 311 | } | 349 | } |