Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RpfPreview/
*.wav

# ---- build output and caches ----
/ucode.elf
build/
build-*/
bin/
Expand Down
3 changes: 3 additions & 0 deletions scripts/windows-boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Set `LEONIDA_GAME_DIR`, `LEONIDA_SHADERS` (and `GTA6RT`, `LEONIDA_RUNS` if you u
profile and the parameters can be left out. Defaults: `gta6rt` from `runtime\build\RelWithDebInfo\` of this
checkout, the executable from the game folder (`-Exe` or `LEONIDA_EXE` when it lives elsewhere), outputs in `$HOME\leonida-runs`.
The script refuses an output folder inside the repository.
The runtime starts in `<out>\work_<name>`, where driver artifacts such as `ucode.elf` can land. Relative path
parameters are resolved from the caller's PowerShell location. Use absolute paths for additional runtime switches
supplied through `-ExtraArgs` or custom environment variables.

### Private crash diagnostics

Expand Down
41 changes: 30 additions & 11 deletions scripts/windows-boot/boot.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ function Get-FirstValue {
return ""
}

function Get-BootPath {
param([string]$Path)
if ($Path) { return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path) }
return ""
}

function Read-SideFile {
# One line from a text file make_game.py writes beside gta6rt.exe (game_path.txt, shader_path.txt).
param([string]$Path)
Expand Down Expand Up @@ -197,14 +203,14 @@ if (-not $Name) { $Name = "boot-" + (Get-Date -Format "yyyyMMdd-HHmmss") }
if ($NoInput) { $InputScript = "" }
if ($Name -notmatch '^[A-Za-z0-9._-]+$') { throw "-Name may hold letters, digits, '.', '_' and '-' only: $Name" }

$Runtime = Get-FirstValue @($Runtime, $env:GTA6RT, (Join-Path $RepoRoot "runtime\build\RelWithDebInfo\gta6rt.exe"))
$Runtime = Get-BootPath (Get-FirstValue @($Runtime, $env:GTA6RT, (Join-Path $RepoRoot "runtime\build\RelWithDebInfo\gta6rt.exe")))
$RuntimeDir = Split-Path -Parent $Runtime
$GameDir = Get-FirstValue @($GameDir, $env:LEONIDA_GAME_DIR, (Read-SideFile (Join-Path $RuntimeDir "game_path.txt")))
$Exe = Get-FirstValue @($Exe, $env:LEONIDA_EXE, $(if ($GameDir) { Join-Path $GameDir $ExeName } else { "" }))
$Shaders = Get-FirstValue @($Shaders, $env:LEONIDA_SHADERS)
$OutDir = Get-FirstValue @($OutDir, $env:LEONIDA_RUNS, (Join-Path $HOME "leonida-runs"))
$OutDir = [System.IO.Path]::GetFullPath($OutDir)
$Overlay = Get-FirstValue @($Overlay, (Join-Path $OutDir "overlay"))
$GameDir = Get-BootPath (Get-FirstValue @($GameDir, $env:LEONIDA_GAME_DIR, (Read-SideFile (Join-Path $RuntimeDir "game_path.txt"))))
$Exe = Get-BootPath (Get-FirstValue @($Exe, $env:LEONIDA_EXE, $(if ($GameDir) { Join-Path $GameDir $ExeName } else { "" })))
$Shaders = Get-BootPath (Get-FirstValue @($Shaders, $env:LEONIDA_SHADERS))
$OutDir = Get-BootPath (Get-FirstValue @($OutDir, $env:LEONIDA_RUNS, (Join-Path $HOME "leonida-runs")))
$Overlay = Get-BootPath (Get-FirstValue @($Overlay, (Join-Path $OutDir "overlay")))
$RunDirectory = Join-Path $OutDir ("work_" + $Name)
$Capture = Join-Path $OutDir ("cap_" + $Name)
$LogFile = Join-Path $OutDir ($Name + ".log")
$StdoutFile = Join-Path $OutDir ($Name + ".stdout.log")
Expand Down Expand Up @@ -295,8 +301,7 @@ if ($bootEnv["LEONIDA_CAPTURE"]) { $Capture = $bootEnv["LEONIDA_CAPTURE"] }
# is read here as the runtime's read-only seed (LEONIDA_PIPELINE_JOURNAL_SEED_DIR, docs/d3d12_vulkan.md), so the pipelines
# it holds are not compiled again in the boot's own cache folder. Only when this shell or -SetEnv/KEY= did not decide, and
# when the two journals are distinct: the runtime turns its journal off for a seed that is, holds or sits in its writable
# journal (pipeline_cache_journal.h, resolve_roots). A relative cache folder is resolved by the runtime against its own
# working folder, so it gets no seed here; a name that cannot be resolved gets none either, rather than a stop.
# journal (pipeline_cache_journal.h, resolve_roots). A relative or unresolvable cache folder gets no automatic seed.
if (-not $bootEnv.Contains("LEONIDA_PIPELINE_JOURNAL_SEED_DIR")) {
# Windows' final path of a folder (GetFinalPathNameByHandle) sees through junctions, symbolic links, substituted
# and mapped drives, short 8.3 names and the \\?\ and \\.\ prefixes, as the runtime's std::filesystem checks do.
Expand Down Expand Up @@ -361,6 +366,19 @@ public static class LeonidaFinalPath {
if ($seed) { $bootEnv["LEONIDA_PIPELINE_JOURNAL_SEED_DIR"] = $seed }
}

foreach ($key in @("LEONIDA_SHADERS", "LEONIDA_PIPELINE_CACHE_DIR")) {
if ($bootEnv[$key]) { $bootEnv[$key] = Get-BootPath $bootEnv[$key] }
}
foreach ($key in @("LEONIDA_COMPAT_DIR", "LEONIDA_DSTORAGE_HISTORY", "LEONIDA_SAVE_DIR",
"LEONIDA_WRITE_DIR", "LEONIDA_XMEM_BACKING_DIR")) {
$value = $bootEnv[$key]
if ($value -and -not [System.IO.Path]::IsPathRooted($value)) {
$bootEnv[$key] = Get-BootPath (Join-Path $RepoRoot $value)
}
}
$Capture = Get-BootPath $Capture
if ($bootEnv["LEONIDA_CAPTURE"]) { $bootEnv["LEONIDA_CAPTURE"] = $Capture }

$launchMode = if ($FirstRunUi) { "--first-run-ui" } else { "--run" }
$gameArgs = @($launchMode, $Exe, "--game-dir", $GameDir, "--overlay", $Overlay, "--trace", $TraceFile, "--trace-d3d12") + $ExtraArgs
$argLine = ($gameArgs | ForEach-Object { ConvertTo-ProcessArgument ([string]$_) }) -join " "
Expand All @@ -369,6 +387,7 @@ if (-not $DigestOnly) {
Write-Output "[boot] $Name ${Seconds}s repo $RepoRoot"
Write-Output "[boot] gta6rt $Runtime"
Write-Output "[boot] out $OutDir"
Write-Output "[boot] cwd $RunDirectory"
foreach ($k in $bootEnv.Keys) { if ($bootEnv[$k] -ne "") { Write-Output ("[boot] env {0}={1}" -f $k, $bootEnv[$k]) } }
Write-Output "[boot] command $(ConvertTo-ProcessArgument $Runtime) $argLine"
}
Expand Down Expand Up @@ -408,7 +427,7 @@ if (-not $DigestOnly) {
}
}

foreach ($d in @($OutDir, $Overlay)) { New-Item -ItemType Directory -Force -Path $d | Out-Null }
foreach ($d in @($OutDir, $Overlay, $RunDirectory)) { New-Item -ItemType Directory -Force -Path $d | Out-Null }
if ($bootEnv["LEONIDA_PIPELINE_CACHE_DIR"]) {
New-Item -ItemType Directory -Force -Path $bootEnv["LEONIDA_PIPELINE_CACHE_DIR"] | Out-Null
}
Expand Down Expand Up @@ -440,7 +459,7 @@ if (-not $DigestOnly) {
$launchArgs = (@($RepoRoot, $crashDir, $Seconds, $runtimePath, $childCommand) |
ForEach-Object { ConvertTo-ProcessArgument ([string]$_) }) -join " "
}
$proc = Start-Process -FilePath $launchFile -ArgumentList $launchArgs -WorkingDirectory $RepoRoot -NoNewWindow -PassThru `
$proc = Start-Process -FilePath $launchFile -ArgumentList $launchArgs -WorkingDirectory $RunDirectory -NoNewWindow -PassThru `
-RedirectStandardError $LogFile -RedirectStandardOutput $StdoutFile
$handle = $proc.Handle # keeps the exit code readable after the process ends
$stopped = $false
Expand Down
6 changes: 4 additions & 2 deletions tests/test_windows_boot_journal_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ def test_a_sibling_folder_is_not_an_overlap(self):
self.assertEqual(os.path.normcase(lines.get(SEED, "")), os.path.normcase(str(self.runtime / "pipeline_cache.d")))

def test_no_seed_for_a_relative_cache_folder(self):
# The runtime resolves it against its own working folder, which this script cannot check.
(self.runtime / "pipeline_cache.d").mkdir()
self.assertNotIn(SEED, self.env_lines("LEONIDA_PIPELINE_CACHE_DIR=relative\\cache"))
lines = self.env_lines("LEONIDA_PIPELINE_CACHE_DIR=relative\\cache", command_in=str(self.tmp))
self.assertNotIn(SEED, lines)
self.assertEqual(os.path.normcase(lines["LEONIDA_PIPELINE_CACHE_DIR"]),
os.path.normcase(str(self.tmp / "relative" / "cache")))

def test_a_long_path_prefix_names_the_same_folder(self):
(self.runtime / "pipeline_cache.d").mkdir()
Expand Down
Loading