Skip to content
Closed
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
75 changes: 74 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ Requirements: Windows 10/11 x64, a CPU with AVX2, a Direct3D 12 GPU with
shader model 6.6 (and mesh shaders for the world), Rust (pinned in
`rust-toolchain.toml`).

On Windows 10 the in-box D3D12 runtime stops at shader model 6.5, so the host
refuses every translated pipeline. `cargo xtask agility` fetches Microsoft's
D3D12 Agility SDK runtime (a pinned, hash-checked NuGet package) into
`target\<profile>\D3D12\`, where `victory.exe` makes D3D12 load it. Windows 11
needs nothing.

The title also needs several GiB of available Windows commit at startup.
Check **Committed** under **Task Manager → Performance → Memory**. If
`crashes.log` reports Windows error 1455, close other applications or increase
Expand All @@ -58,6 +64,7 @@ the Windows paging file size, then retry.
```powershell
cargo xtask install-hooks # asset-policy check on every commit
copy victory.example.toml victory.toml # then set your paths (outside the repo)
cargo xtask agility # Windows 10 only: newer D3D12 runtime
cargo test --workspace # needs no game data
cargo run -p victory -- config # check your paths
```
Expand Down
8 changes: 8 additions & 0 deletions apps/victory/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {
// The D3D12 Agility SDK exports (src/agility.rs): D3D12 finds them on
// the executable. Only the MSVC linker takes /EXPORT on a binary.
if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") {
println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKVersion,DATA");
println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKPath,DATA");
}
}
34 changes: 34 additions & 0 deletions apps/victory/src/agility.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//! The D3D12 Agility SDK: which D3D12 runtime the host uses.
//!
//! Windows 10's in-box runtime stops at shader model 6.5 and refuses root
//! signatures that index the descriptor heaps directly (flags 0x400, 0x800),
//! which every translated pipeline uses. D3D12 looks for these two exports on
//! the process's executable; when they name a runtime newer than the
//! system's, it loads `D3D12Core.dll` from `D3D12SDKPath` (relative to the
//! executable) instead. `cargo xtask agility` puts it there. Without the
//! folder, or on a system whose runtime is newer, the in-box one is used.
//!
//! `build.rs` exports both symbols.
#![allow(non_upper_case_globals)]

/// The runtime's SDK version: the minor number of the
/// `Microsoft.Direct3D.D3D12` package `cargo xtask agility` fetches
/// (1.620.2). Keep the two in step.
#[unsafe(no_mangle)]
pub static D3D12SDKVersion: u32 = 620;

/// A C string pointer D3D12 reads once at device creation.
#[repr(transparent)]
pub struct SdkPath(*const std::ffi::c_char);

// SAFETY: points at a static, immutable C string.
unsafe impl Sync for SdkPath {}

/// Where `D3D12Core.dll` is, relative to the executable.
#[unsafe(no_mangle)]
pub static D3D12SDKPath: SdkPath = SdkPath(c".\\D3D12\\".as_ptr());

/// The folder `D3D12SDKPath` names, beside the running executable.
pub fn runtime_dir() -> Option<std::path::PathBuf> {
Some(std::env::current_exe().ok()?.parent()?.join("D3D12"))
}
11 changes: 11 additions & 0 deletions apps/victory/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! Every command reads the user's own files and writes only to stdout or to
//! the user's cache directory (outside the repository).

mod agility;
mod census;
mod inspect;
mod run;
Expand Down Expand Up @@ -180,6 +181,16 @@ fn show_config() -> Result<()> {
);
println!("game_dir : {}", status(&cfg.game_dir));
println!("cache_dir : {}", cfg.cache_dir.display());
match agility::runtime_dir().map(|d| d.join("D3D12Core.dll")) {
Some(dll) if dll.exists() => println!(
"d3d12 sdk : {} (version {})",
dll.display(),
agility::D3D12SDKVersion
),
_ => println!(
"d3d12 sdk : not beside the executable (needed on Windows 10: `cargo xtask agility`)"
),
}
for t in &cfg.test_titles {
println!("test_title : {}", status(&Some(t.clone())));
}
Expand Down
3 changes: 2 additions & 1 deletion crates/victory-shader/src/emit/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ impl Host {
.map_err(err)?;
if sm.HighestShaderModel.0 < D3D_SHADER_MODEL_6_6.0 {
return Err(format!(
"the device supports SM {:#x} only",
"the device supports SM {:#x} only (on Windows 10, \
`cargo xtask agility` puts a newer D3D12 runtime beside victory.exe)",
sm.HighestShaderModel.0
));
}
Expand Down
5 changes: 4 additions & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xtask"
description = "Repository maintenance: asset-policy enforcement and git hooks."
description = "Repository maintenance: asset-policy enforcement, git hooks, the D3D12 Agility SDK runtime."
version.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand All @@ -11,6 +11,9 @@ publish.workspace = true
anyhow.workspace = true
clap.workspace = true
walkdir.workspace = true
miniz_oxide.workspace = true
# SHA-512 of the Agility SDK package (`cargo xtask agility`).
sha2 = "0.10"

[lints]
workspace = true
Loading