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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,23 @@ powershell -ExecutionPolicy Bypass -File .\run-gta6.ps1
```

`measure-gta6.ps1` does the same with the diagnostics build, the frame log and the card meter on, and saves
everything the game prints to `%LOCALAPPDATA%\leonida\logs`.
everything the game prints to `%LOCALAPPDATA%\leonida\logs`. `-SpeedSwitches off` runs it without the frame-rate
switches, for a comparison in the same place.

### Testing for the project, with no programming experience

1. Download this repository (Code, Download ZIP) and unpack it, or clone it.
2. Double-click `start-measure.cmd`. If the Visual Studio C++ build tools or Rust are missing, it offers to install
them with winget (about 3 GB, 5 to 15 minutes, asks first). The first build takes about 5 to 10 minutes.
3. Give it the folder of your copy of the game, answer its questions, and play until the place you want to test.
4. Close the game window. The script offers a short test report: your graphics card, driver, CPU, RAM, Windows
version, the switches that were on and the frame rates. It shows all of it before anything is shared, and never
includes log files, game files, paths or your user name.
5. If you agree, it copies the report and opens `#test-results` on our [Discord](https://discord.gg/dxMD2XqyEJ).
Paste it with Ctrl+V and send it. Nothing is uploaded unless you post it yourself.

Run it once with the speed switches on and once with them off, in the same place: the pair is what lets us add a
profile for your card to `gpu-profiles.json`. Reports are kept in `%LOCALAPPDATA%\leonida\reports`.

`shot-run.ps1` runs the game unattended and takes frame shots (`-ShotAt`, with `-Keys` to get through the menus) into
`%LOCALAPPDATA%\leonida\shots`. Shots come from your game: keep them on your PC.
Expand Down
41 changes: 40 additions & 1 deletion measure-gta6.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
# Like run-gta6.ps1, but with the diagnostics build: frame log and card meter
# (per pipeline) on, and everything the emulator prints saved to a log file.
# Logs go under %LOCALAPPDATA%\leonida\logs (game-derived output stays out of the repo).
# When the game closes it offers a short test report (scripts\test-report.ps1): figures
# only, shown in full, and shared only if you say so.
#
# The first time, it asks for the folder of your copy of the game (the one with
# MicrosoftGame.config in it) and offers to remember it in leonida.toml, which git ignores.
#
# powershell -ExecutionPolicy Bypass -File .\measure-gta6.ps1
# powershell -ExecutionPolicy Bypass -File .\measure-gta6.ps1 -GameDir 'D:\Games\GTA VI' # this run only
# powershell -ExecutionPolicy Bypass -File .\measure-gta6.ps1 -WarmUp yes # warm up the shader cache without asking
# powershell -ExecutionPolicy Bypass -File .\measure-gta6.ps1 -SpeedSwitches off # the same run without the switches
# powershell -ExecutionPolicy Bypass -File .\measure-gta6.ps1 -Report no # no report afterwards

param(
[string]$GameDir = '',
# yes: warm up the shader cache before starting, no: skip it, ask: ask (default).
[ValidateSet('ask', 'yes', 'no')]
[string]$WarmUp = 'ask'
[string]$WarmUp = 'ask',
# on: the switches gpu-profiles.json picks for this card (default), off: none, ask: ask.
[ValidateSet('on', 'off', 'ask')]
[string]$SpeedSwitches = 'on',
# ask: offer a test report when the game closes (default), no: don't.
[ValidateSet('ask', 'no')]
[string]$Report = 'ask'
)

$ErrorActionPreference = 'Stop'
Expand Down Expand Up @@ -61,6 +71,24 @@ try {
. (Join-Path $PSScriptRoot 'scripts\leonida-settings.ps1')
Set-LeonidaProfiles $PSScriptRoot

# Whatever LEONIDA_* is set now, besides paths and logging, is a speed switch.
$notSwitches = 'LEONIDA_CONFIG', 'LEONIDA_GAME_DIR', 'LEONIDA_CACHE_DIR', 'LEONIDA_DATA_DIR', 'LEONIDA_PROFILE', 'LEONIDA_LOG', 'LEONIDA_KEEP_WINDOW'
$switches = @(Get-ChildItem Env:LEONIDA_* | Where-Object { $_.Name -notin $notSwitches })
if ($SpeedSwitches -eq 'ask') {
Write-Host ''
Write-Host 'Turn the speed switches on? They are the frame-rate switches measured faster for your card:'
Write-Host (($switches | ForEach-Object { $_.Name -replace '^LEONIDA_', '' }) -join ', ')
Write-Host 'To help compare, play once with them and once without, in the same place in the game.'
$answer = Read-Host 'Speed switches on? [Y/n]'
$SpeedSwitches = if ($answer.Trim() -match '^(y|yes)?$') { 'on' } else { 'off' }
}
if ($SpeedSwitches -eq 'off') {
$switches | ForEach-Object { Remove-Item -LiteralPath "Env:$($_.Name)" }
$switches = @()
Write-Host 'speed switches: off'
}
$switchList = @($switches | ForEach-Object { '{0}={1}' -f $_.Name, $_.Value })

$env:LEONIDA_FRAME_LOG = '1'
$env:LEONIDA_CARD_METER = '1'
$env:LEONIDA_CARD_METER_PIPELINES = '1'
Expand Down Expand Up @@ -89,7 +117,18 @@ try {

# The emulator logs to stderr; PowerShell 5.1 wraps those lines as errors, so don't stop on them.
$ErrorActionPreference = 'Continue'
$started = Get-Date
& $exe run --execute 2>&1 | ForEach-Object { "$_" } | Tee-Object -FilePath $log
$exitCode = $LASTEXITCODE

if ($Report -eq 'ask') {
try {
& (Join-Path $PSScriptRoot 'scripts\test-report.ps1') -Log $log -SpeedSwitches $switchList `
-SwitchMode $SpeedSwitches -WarmUp $WarmUp -Started $started -ExitCode "$exitCode" -Exe $exe
} catch {
Write-Warning "the test report failed: $_"
}
}
} finally {
Pop-Location
}
81 changes: 81 additions & 0 deletions scripts/check-tools.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Checks for what building Leonida Legacy needs: the Visual Studio C++ build tools and
# Rust (rustup). Offers to install what is missing with winget, after asking. Run by
# start-measure.cmd; exits 1 when something is still missing.
#
# powershell -ExecutionPolicy Bypass -File .\scripts\check-tools.ps1

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot

function Test-BuildTools {
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
if (-not (Test-Path -LiteralPath $vswhere)) { return $false }
$path = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
[bool]$path
}

function Find-Rustup {
$cmd = Get-Command rustup -ErrorAction SilentlyContinue
if ($cmd) { return $cmd.Source }
# Installed in this session: the window's PATH doesn't have it yet.
$own = Join-Path $env:USERPROFILE '.cargo\bin\rustup.exe'
if (Test-Path -LiteralPath $own) { return $own }
$null
}

function Install-WithWinget([string]$id, [string[]]$extra) {
& winget install --id $id --exact --accept-package-agreements --accept-source-agreements @extra
# winget returns a non-zero code when the package is already there; the checks after decide.
}

$needTools = -not (Test-BuildTools)
$needRust = -not (Find-Rustup)
if (-not $needTools -and -not $needRust) {
Write-Host 'Build tools: found. Rust: found.'
} else {
Write-Host ''
Write-Host 'Building Leonida Legacy needs these, and this PC is missing:'
if ($needTools) { Write-Host ' - Visual Studio 2022 Build Tools with C++ (about 3 GB, 5 to 15 minutes; Windows asks for admin rights)' }
if ($needRust) { Write-Host ' - Rust, through rustup (about 300 MB, a few minutes)' }
$winget = Get-Command winget -ErrorAction SilentlyContinue
if (-not $winget) {
Write-Host ''
Write-Host 'winget is not on this PC, so they have to be installed by hand:'
if ($needTools) { Write-Host ' https://visualstudio.microsoft.com/visual-cpp-build-tools/ (pick "Desktop development with C++")' }
if ($needRust) { Write-Host ' https://rustup.rs/' }
Write-Host 'Then start this again.'
exit 1
}
$answer = Read-Host 'Install them now with winget? [Y/n]'
if ($answer.Trim() -notmatch '^(y|yes)?$') {
Write-Host 'Nothing installed. Install them yourself and start this again.'
exit 1
}
# The build tools first: rustup's installer looks for them.
if ($needTools) {
Install-WithWinget 'Microsoft.VisualStudio.2022.BuildTools' @(
'--override', '--wait --passive --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended')
if (-not (Test-BuildTools)) {
Write-Host 'The C++ build tools are still missing. Install them from'
Write-Host 'https://visualstudio.microsoft.com/visual-cpp-build-tools/ and start this again.'
exit 1
}
}
if ($needRust) {
Install-WithWinget 'Rustlang.Rustup' @()
if (-not (Find-Rustup)) {
Write-Host 'Rust is still missing. Install it from https://rustup.rs/ and start this again.'
exit 1
}
}
}

# The Rust version rust-toolchain.toml pins; rustup installs it once and keeps it.
$rustup = Find-Rustup
Push-Location $root
try {
& $rustup toolchain install
if ($LASTEXITCODE -ne 0) { Write-Warning "rustup could not install the pinned Rust version (exit $LASTEXITCODE)" }
} finally {
Pop-Location
}
Loading
Loading