23 KiB
Repository Guidelines
Project Overview
VIctory-NVIDIA runs an Xbox Series X|S title's own x86-64 executable natively on Windows: no CPU emulation. The title image is mapped into our process, its console imports are bound to our implementations, its D3D12.X calls become host D3D12, and its RDNA2 shader binaries are translated to PC DXIL. This checkout is the NVIDIA fork of upstream VIctory (DLSS, DLSS frame generation, AMD FSR 3 frame generation, fork ray tracing).
Rule #1, before anything else: nothing from the game is ever committed — no assets, no executable bytes, no disassembly, no shader dumps, no screenshots (docs/asset-policy.md:3-15). The repository is text-only, enforced statically by cargo xtask policy and at run time by victory_core::ensure_outside_repo.
Issues and pull requests
These rules are for contributors' agents. The maintainer's own workflow is theirs. One person reviews every pull request, so the best result is often a test report on an existing pull request, or nothing posted at all.
Every time you start, and after every update of main (required, not optional)
- Read this file again from the latest
main. These rules change; following an old copy is not an excuse. - Close your own issues and pull requests that are no longer relevant. List them (
gh issue listandgh pr list, each with-R trustno1-coder/VIctory-NVIDIA --author "@me" --state open). Close each one thatmainor a release has fixed, another merged pull request has replaced, that no longer happens on the latest release, or that is an exact duplicate (see "Duplicates" below). When you close one, say why in one line and link what replaced or fixed it. As with every close, show your user the list first.
Before writing code
- Fetch the upstream repository (
trustno1-coder/VIctory-NVIDIA) and check that the problem still exists on its latestmain. - Search the open and closed issues and pull requests by issue number, symptom, and function or
VICTORY_*name:gh search prs --repo trustno1-coder/VIctory-NVIDIA "<words>"gh search issues --repo trustno1-coder/VIctory-NVIDIA "<words>"
- List the open pull requests that change the same main file. This takes about half a minute and can miss files in very large pull requests. In Bash:
gh pr list -R trustno1-coder/VIctory-NVIDIA --state open --limit 1000 --json number,title,files --jq '.[] | select(any(.files[]; .path == "<path>")) | "\(.number) \(.title)"' - Stop and tell your user if an open pull request covers the same problem, or someone has claimed the issue. Suggest testing or reviewing that work. Only suggest a competing pull request if you can say exactly what the existing one gets wrong. Sharing a file isn't enough reason to stop, but list that pull request as related.
- List your user's open pull requests (
gh pr list -R trustno1-coder/VIctory-NVIDIA --author "@me" --limit 100 --json number,title,mergeable). Update any that conflict withmain, and close any that are no longer needed, before opening another.
Making the change
- Make one change per pull request, on a new branch from upstream's latest
main. Never start from another of your branches: its commits would end up in this pull request too. If the change really needs another pull request first, wait for that one to merge. If it can't wait, open a draft that saysDepends on #N. - Check the final diff with
git diff --stat <upstream>/main...HEAD, where<upstream>is your remote for that repository. Remove anything the change doesn't need, such as reformatting,Cargo.lockchanges, workflow files, personal launchers, notes or benchmark logs. - If CI fails because of something already broken on
main, don't fix that in an unrelated pull request. Check that the same failure happens onmain, then say so in the description. Link the open pull request that fixes it, if there is one.
Opening the pull request
- Get your user's approval before every push, post or close, and show them the exact text of anything you'll post. Approval for one action doesn't cover the next.
gh pr create --bodyand--body-fileskip the template. Start from.github/pull_request_template.mdand keep its headings.- Labels are required and must be accurate (see "Labels" below). Start the title with exactly one
pr-type tag, then every area tag that applies:[pr-fix][memory][NVIDIA] Short description. - Write
Fixes #Nonly if the change fully fixes the issue. Otherwise, writeRefs #N. If there's no issue, remove the emptyFixes #line; don't open an issue just to fill it in. - Only tick the overlap box if you did the searches above. List the related pull requests, or write "none found".
- List only the commands you ran, with their results and the commit tested. Keep game results separate from
cargo test, and say what wasn't tested. Never make up hardware, frame rates or game results. Use only results your user gave you or that you measured. - A green tick may come only from the
labelbot. Only say CI passed if thecheckjob of theCIworkflow passed on the latest commit.
After it's open
- If it conflicts with
main, update the same pull request instead of opening a replacement, unless the maintainer asks for a new one. Retest after resolving the conflict. Ifmainor another pull request already fixes the problem, suggest closing yours with a link to that fix. - Put follow-up changes in a new pull request. If commits are added after the maintainer has merged an earlier version, GitHub won't show the pull request as merged.
- Don't post comments that only ask for a review or an update. Comment only to add something new, such as a test result, a reproduction or an answer.
Opening an issue
- Search open and closed issues first, and follow "Duplicates" below. Open one issue per problem, not one per log line or audit finding.
gh issue create --bodyskips the forms, so use the headings from the matching file in.github/ISSUE_TEMPLATE/. For bugs, include the release or commit, hardware, settings, steps and both logs. Separate what was seen from what you're guessing. Don't present a cause found only by reading code as a confirmed bug.- Labels are required and must be accurate (see "Labels" below). Without the form, start the title with the type tags, then every area tag that applies:
[bug][crash][shaders][NVIDIA] Short description. - Remove user names, PC names and tokens from logs. Never include game data, or links to or sources for the game.
Duplicates (required, not optional)
- If an open issue describes exactly the same problem, do not open a new issue. Add your findings to that issue as a comment instead: your logs, hardware, settings, steps, and anything new you found. Say in one line that it's the same problem.
- If an open pull request fixes exactly the same problem, do not open a new pull request. Test or review that one and post your results on it. Only open a competing pull request if you can say exactly what the existing one gets wrong, and say it in your description.
- "Exactly the same" means the same symptom with the same cause or evidence, such as the same crash code at the same address, or the same broken effect in the same place. A similar symptom with different evidence isn't a duplicate: open a new issue and link the similar one as related.
- If the same problem was closed as fixed but still happens on the latest release, open a new issue with logs from that release and link the closed one.
Labels (required, not optional)
Every issue and pull request must carry accurate labels: one type label and every area label that applies, and none that don't. Most contributors can't add labels directly, so put them as [tags] at the start of the title. A bot turns each tag that matches a label into that label and takes it out of the title.
- Use only names from the list:
gh label list -R trustno1-coder/VIctory-NVIDIA --limit 100. - Issue type, the same labels the matching form adds:
bugandcrashfor a crash or freeze,bugandrenderingfor broken graphics,performance,enhancementfor a feature request,reportfor test results with nothing to fix, ordocumentationorquestion. The forms add these for you. Withgh issue create, put them in the title. - Pull request type (exactly one):
pr-fix,pr-feature,pr-performance,pr-diagnostics,pr-docs,pr-refactororpr-tests. - Areas (every one that applies, for issues and pull requests):
rendering,lighting,shaders,dlss,frame-generation,memory,audio,startup,cutscene,input,linux-proton,series-s, and the GPU makersNVIDIA,AMDandINTELwhen the problem or change is specific to one. UseRAYTRACINGwhen it's about ray tracing. - After posting, check that the labels appeared and the tags left the title. A tag that stays in the title didn't match a label: fix the title.
- Leave the maintainer's labels to the maintainer:
confirmed,duplicate,fixed-on-main,upstream,wontfix,needs-info,needs-logsandneeds-rebase.
Architecture & Data Flow
game executable ─► victory-loader ──► title code runs natively (x86-64)
prepare/map/bind │ imports
▼
victory-hle ──► host Windows DLLs (HostPolicy)
│ D3D12.X
▼
victory-gpu ──► host D3D12 (+ Streamline/DLSS, FSR 3)
│ shader bytes at pipeline creation
▼
victory-shader ◄─► cache_dir (content-addressed)
victory run --execute(apps/victory/src/run.rs:106): CPU check →Config::load→streamline::Asked::from_env→victory_loader::prepare(rewrites the PE: clearsFORCE_INTEGRITY, zeroes the checksum, neuters the TLS callback and import directory) →load(map viaLoadLibraryExW) →bind_imports→write_sites::apply_asked→ crash reporter →spawn_main.- Import resolution order (
docs/architecture.md, "Import resolution"): ourvictory-hleregistry wins → host DLL ifHostPolicyallows it → a DLL the title ships → generated stub (--unimplemented trapbreaks and aborts,zerologs once and returns 0). - Console objects are not COM objects. A "pointer" the title holds is a Rust struct whose first field is a
Table<N>of rawextern "system"fn pointers;QueryInterfacegoes throughobject::answer(crates/victory-gpu/src/object.rs). Layouts arerepr(C)withconst _: () = assert!(size_of::<T>() == N)checks, and fields the title's inlined code reads stay zero on purpose (List::put,List::reserved: "all zero, so every inline check fails"). - Shaders are translated when the title creates a pipeline, from the bytes it passes, not from files (
docs/architecture.md:24-26).pipeline.rshashes the container (blake3) →shader_cache→victory_shader::emit::translate. Offlinevictory translate/warmonly pre-fill the same cache. - Shader stages:
Container::parse→native_programs(XDAT/XBCH/FSSM, zlib) →gfx10::decode→ir::build(SSA) →structure(removes EXEC: lane masks become per-lane booleans) →resource::track(descriptor → root parameter) →io::raise→emit::lower→ DXIL container + optionaldxil.dllvalidation. - Present path (
crates/victory-gpu/src/host.rs:10219):present_planes→ swap chain (FSR-3 / Streamline proxy / plain) → Series-S two-plane compose →streamline::present_*→ F3 panel and F1 menu drawn onto the back buffer.
Key Directories
| Path | Purpose |
|---|---|
apps/victory |
the victory CLI: run, play, census, inspect, translate, warm, preload, replay, get-* |
crates/victory-core |
Config, logging::init, ensure_outside_repo |
crates/victory-pe |
read-only PE32+/COFF import-library parsing (patching lives in the loader) |
crates/victory-loader |
prepare/map/bind/start the title; TLS redirect, threads, crash reporter, Zen 2-only instruction emulation |
crates/victory-hle |
console API surface, one module per DLL under src/modules/ |
crates/victory-gpu |
117K lines, the bulk: object model + command path, and host*/streamline*/replay* runtime |
crates/victory-shader |
51K lines: GFX10 → PC DXIL translator |
crates/victory-formats |
texture layouts, BCPack, XMA — zero dependencies, platform-level |
crates/victory-pipeline |
Converter trait + content-addressed Cache |
crates/victory-game |
the only title-specific crate (build identities, SGD5) |
xtask, .githooks |
asset policy, git hooks |
scripts/, *.cmd |
PowerShell/cmd launchers and vendor-SDK fetchers |
Development Commands
cargo clippy --workspace --all-targets --locked -- -D warnings # CI gate 1
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings # CI gate 2
cargo test --workspace --locked # CI gate 3 (no game data needed)
cargo build --release --locked -p victory # target\release\victory.exe
cargo build --locked --profile diag -p victory --features diagnostics # target\diag\victory.exe
cargo xtask policy # asset policy over the tree
cargo xtask policy --staged # what the pre-commit hook runs
cargo xtask install-hooks # git config core.hooksPath .githooks
Narrower checks while iterating: cargo test -p victory-shader --lib, cargo test -p victory-gpu, cargo clippy -p victory-gpu --all-targets -- -D warnings. There is no cargo fmt gate anywhere (CI, hook, docs), and the tree is far from rustfmt-clean: cargo fmt --all -- --check reports 3777 diff hunks, starting in apps/victory/src/main.rs:73. Never run cargo fmt here, and do not reformat lines you did not otherwise change.
Running a title: victory run <exe> --console series-s|series-x --execute, or the launchers scripts\play-nvidia.ps1 -Exe <exe> and PLAY_FRAMEGEN.cmd.
Code Conventions & Common Patterns
- Module docs explain why, with evidence. 231 of 238 tracked
.rsfiles open with a//!essay citing measured runs, dates, hardware, issue numbers and upstream commits ((VIctory upstream 0b35b7f),(From fxceless/victory-fork c36971b2.)). Keep that voice;shortcut:tags (170 in-tree) mark deliberate simplifications. Spelling leans British in prose (colour186 vscolor132 occurrences, the latter mostly in API identifiers likeTarget::Color). - Errors by layer. Binaries and the pipeline use
anyhow::Resultwith.with_context(|| format!("reading {}", path.display())); leaf crates definethiserrorenums (PeError,PolicyError,ShaderError::{NotDxbc, Malformed, Isa, Unsupported}); HLE and GPU code facing the title returnHRESULTi32(S_OK,E_NOTIMPL) and otherwisetracing::warn!and degrade. A fatal GPU loss goes throughhost::fail→tracing::error!→abort()or the hook given toon_failure. Do notunwrap()on a title thread; poisoned mutexes are recovered with.unwrap_or_else(|e| e.into_inner())(620 uses invictory-gpu). - Logging is
tracingonly (info!/warn!/debug!with structured fields such ashr = format_args!("{:#010x}", hr)); title output goes totarget: "title".victory_core::logging::initreadsVICTORY_LOG, falling back toRUST_LOG; the level is capped at INFO unless thediagnosticsfeature is on (crates/victory-core/src/logging.rs:16-28). - Env switches are the configuration system. 482 distinct
VICTORY_*names exist (grep -rhoE 'VICTORY_[A-Z0-9_]+' crates apps --include='*.rs' | sort -u | wc -l), 389 invictory-gpualone; there is no central registry, only the F1 menu's curatedITEMS(crates/victory-gpu/src/host/menu.rs) and the table indocs/dlss.md. Read them through the established helpers, never ad hoc:toggled!("VICTORY_X")= on unless the value is exactly"0";asked_for!("VICTORY_X")= on only when"1"(crates/victory-gpu/src/switch.rs:5-69). Values are cached in aOnceLockand read once, so a knob cannot change mid-run except viaVICTORY_ABor the twolive: truemenu items. - No async runtime anywhere.
std::thread::Builderwith named threads (victory-relay,victory-window,victory-heap-sync,victory-pipelines-{i},victory-list-{i}),Mutex/Condvar/mpsc/OnceLock/atomics. Async-shaped console APIs are implemented on top of threads:xasync::pending_withspawns a thread and completes theXOVERLAPPEDcall it began. - No dependency injection: crates call each other directly (
crates/victory-hle/src/modules/d3d12x.rsdoesuse victory_gpu::device;and callsdevice::create), and process-wide state lives instaticOnceLock/Mutex/RwLock(DEVICE,RETIRED,SHADER_HEAPS). - Unsafe is pervasive and documented: 2444
// SAFETY:comments for ~2461unsafeblocks.unsafe_op_in_unsafe_fnandunused_must_useare denied workspace-wide;undocumented_unsafe_blocksis allowed because, asCargo.tomlrecords, eleven blocks in the fork's newer GPU code still lack a comment — do not add a twelfth. - Naming: crates
victory-*, files single-word snake_case (descriptor.rs,copystat.rs); a module with children is eitherfoo.rs+foo/(host,pipeline,streamline) orfoo/mod.rs(replay,emit,gfx10,hle'smodules) — follow the directory you are in;extern "system"for Win32-shaped functions andextern "C"for CRT ones (__p___argc);SCREAMING_CASEconsts; test functions as snake_case sentences without atest_prefix (loads_binds_and_calls_probe,rejects_paths_inside_this_repo). - Adding a console import (
crates/victory-hle/src/modules/mod.rs:3-5): write apub extern "system" fnnamed exactly like the import, then list it withhle_export!(Name)in that module'sexportsin itsmodule()function;HleModule::servesmatches DLL names, with a trailing*as a prefix (API sets), and ordinals resolve as"#42". A new module also needs itspub modline and a place inall().victory censuslists what is still missing; registering nothing is what makes an import fall through to the host, a title DLL, or a stub.
Important Files
| File | Why it matters |
|---|---|
docs/architecture.md |
the authoritative 99-line overview; read it before any cross-crate change |
docs/asset-policy.md, xtask/src/policy.rs |
what may exist in the repo — the policy source is the authority |
apps/victory/src/main.rs |
the clap Command enum (:198); doc comments are the --help text |
crates/victory-core/src/config.rs |
Config::load: env > victory.toml (VICTORY_CONFIG) > defaults |
crates/victory-gpu/src/switch.rs |
toggled!/asked_for!, the only correct way to read a switch |
crates/victory-gpu/src/host.rs |
the one host device, queue, window, submission and present path |
crates/victory-shader/src/emit/mod.rs |
translate, emit, translation_fingerprint |
victory.example.toml |
copy to victory.toml (git-ignored); every path must be outside the repo |
.github/workflows/ci.yml |
the full definition of "green" |
Runtime/Tooling Preferences
- Rust, pinned.
rust-toolchain.tomlpins1.98.1with targetx86_64-pc-windows-msvcand components rustfmt + clippy;rust-version = 1.88is the declared MSRV. Workspaceresolver = "3",edition = "2024"— 2024 syntax is in use (#[unsafe(no_mangle)],unsafe extern, let-chains). - Windows-only in practice. Nothing fails to compile elsewhere (there is no
compile_error!), butcfg(not(windows))paths are stubs and CI only runswindows-latest. Never claim Linux support from green CI;docs/linux-proton.mdcovers cross-building withcargo xwinplus Proton. - Cargo only;
--lockedeverywhere. CommitCargo.lockwith any dependency change. Note that the lockfile is hashed intoVICTORY_TRANSLATOR(crates/victory-gpu/build.rs:24-28), so churning it invalidates every user's shader cache. cargo xtaskis the repo tool (.cargo/config.tomlaliases it torun --quiet --package xtask --).- Vendor SDKs are never in the tree.
Get-NVIDIA-DLSS.cmd(Streamline,nvngx_dlss.dll,sl.interposer.dll→nvidia-sdk\),Get-AMD-FSR.cmd(FidelityFX →amd-sdk\) andvictory get-d3d12(Agility SDK →D3D12\beside the exe) fetch them at run time. They are not needed to build. - Line endings:
*.ps1and*.cmdare CRLF, everything else LF (.gitattributes).
Testing & QA
- Plain
cargo testwith the built-in harness: 1233#[test]functions, no tokio, criterion, proptest or snapshot tooling; mostly inline#[cfg(test)] mod testsbeside the code, plus ten sibling*_tests.rsfiles incrates/victory-shader/src/emit/included as#[cfg(all(test, windows))] mod valu_tests;. - Integration tests:
crates/victory-loader/tests/{load_probe,title_dlls}.rs,crates/victory-hle/tests/no_dll_planting.rs,crates/victory-gpu/tests/replay{,_big}.rs,apps/victory/tests/census.rs.load_probebuildstests/fixtures/hle-probe(acdylibstandalone crate, excluded from the workspace) by shelling out to$CARGOwith its own--target-dir, because the outer cargo holds the lock on the main one. - The suite must pass on a bare runner: no game data, no GPU, no fixtures. Tests that need real files take paths from env vars and return early when unset; tests needing the adapter return early when
host()isNone, WARP ones whenWarpHarness::new()isNone. Never add a test that needs a title, and never commit reference data: a golden-style test pins its(len, hash)pairs in source (crates/victory-shader/src/emit/bitcode.rs:1248-1257). #[ignore]means "needs a rig", and the reason is the runbook:#[ignore = "benchmark"],#[ignore = "a measurement, not a check"],#[ignore = "wants VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 and a process of its own"]. Run them ascargo test --release -p <crate> <name> -- --ignored --nocapture. The only[[bench]]target iscargo bench -p victory-shader(guard_runs,harness = false, not run by CI).- Coverage trap:
cargo test --workspacenever compilescrates/victory-gpu/tests/replay*.rs— they are#![cfg(all(windows, feature = "diagnostics"))], and CI only type-checks them in the--all-featuresclippy step. Usecargo test -p victory-gpu --features diagnosticswhen touching replay. - Before committing, assume
cargo xtask policy --stagedwill run: a new.bin,.png,.logor any file over 640 KiB is refused, as is any long hex/base64 run. Allowed extensions are listed inxtask/src/policy.rs:17-19; the single exception in the tree iscrates/victory-formats/src/bcpack-tables.bin, anddocs/asset-policy.mdsays nothing else of that kind is accepted. A violation that lands needs a history rewrite, not a follow-up commit.