From 34114063dce12ab75d31681b69818e2ee908efec Mon Sep 17 00:00:00 2001 From: bailu12300 Date: Tue, 24 Nov 2026 21:49:13 +0800 Subject: [PATCH] GPU: load the DirectX 12 Agility SDK, and map the console's packed 16-bit colour targets - Export D3D12SDKVersion/D3D12SDKPath and link them into the binary's export table (build.rs), so the D3D12 runtime loads D3D12Core.dll from ./D3D12/ instead of the in-box copy. Windows 10's 19041 runtime refuses the title's 0xC01 root signatures (CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | SAMPLER_HEAP_DIRECTLY_INDEXED | ALLOW_INPUT_ASSEMBLER), which cost every pipeline: drawn=0, no pipeline ever created, and a 0xC0000005 fault about 5 s in. With Agility 1.614 the same host builds the full pipeline set and holds 30 fps through the account picker, the startup art and the legal notice. - pc_format: map 86 (B5G5R5A1_UNORM) and 115 (B4G4R4A4_UNORM) to R8G8B8A8_UNORM. Both are render targets on the console but take no unordered access (86) and no render target at all (115) on the host, so the title's UI composition targets failed to create ("no host texture error 0x80070057", format: 86 and 115) and the whole UI layer drew nothing. Their 8-bit RGBA stand-in is a superset of both in range, so a target that only carries colour through the pipeline loses nothing but the packing. Verified on Windows 10 Pro 19045, RTX 5060 8 GB, title 1.0.2.1: no host texture count 0, menus at 30 fps, and the prologue title card renders. --- apps/victory/build.rs | 11 +++++++++++ apps/victory/src/main.rs | 18 ++++++++++++++++++ crates/victory-gpu/src/resource.rs | 10 ++++++++++ 3 files changed, 39 insertions(+) create mode 100644 apps/victory/build.rs diff --git a/apps/victory/build.rs b/apps/victory/build.rs new file mode 100644 index 0000000000..438fde4e20 --- /dev/null +++ b/apps/victory/build.rs @@ -0,0 +1,11 @@ +// Exports the two symbols the DirectX 12 Agility SDK looks for, so the D3D12 +// runtime loads `D3D12Core.dll` from the `D3D12` folder beside the executable +// instead of the system copy. Rust's bin crates carry no export table, so the +// linker is told explicitly; `#[unsafe(no_mangle)]` in `main.rs` keeps the +// names unmangled. +fn main() { + if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") { + println!("cargo:rustc-link-arg=/EXPORT:D3D12SDKVersion,DATA"); + println!("cargo:rustc-link-arg=/EXPORT:D3D12SDKPath,DATA"); + } +} diff --git a/apps/victory/src/main.rs b/apps/victory/src/main.rs index 4cf7c314f3..41336d3a1b 100644 --- a/apps/victory/src/main.rs +++ b/apps/victory/src/main.rs @@ -3,6 +3,24 @@ //! Every command reads the user's own files and writes only to stdout or to //! the user's cache directory (outside the repository). +// The DirectX 12 Agility SDK looks for these two symbols in the executable. +// Exporting them makes the D3D12 runtime load `D3D12Core.dll` from the `D3D12` +// folder beside the binary instead of the in-box copy, which is what lets the +// title's root signatures work on Windows 10 at all: they carry +// `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | SAMPLER_HEAP_DIRECTLY_INDEXED | +// ALLOW_INPUT_ASSEMBLER` (0xC01), and the 19041 runtime refuses the whole +// root signature over the two `*_HEAP_DIRECTLY_INDEXED` bits, so every +// pipeline fails to create and the title faults seconds in. +// +/// The version the runtime reads at load time; 614 selects Agility SDK 1.614. +#[unsafe(no_mangle)] +pub static D3D12SDKVersion: u32 = 614; + +/// The folder the runtime loads `D3D12Core.dll` from, relative to the +/// executable. Written once by the runtime at load time; never read here. +#[unsafe(no_mangle)] +pub static mut D3D12SDKPath: *const i8 = c".\\D3D12\\".as_ptr(); + mod census; mod inspect; mod run; diff --git a/crates/victory-gpu/src/resource.rs b/crates/victory-gpu/src/resource.rs index 46c5c71abf..c46c2e829e 100644 --- a/crates/victory-gpu/src/resource.rs +++ b/crates/victory-gpu/src/resource.rs @@ -228,8 +228,18 @@ fn footprint(desc: &ResourceDesc) -> Option { /// A format as the host has it. The console's 16-bit depth with stencil /// (and its typeless views) has no PC format: the 24-bit ones stand in. +/// +/// The console's packed 16-bit colour targets have no host format either: +/// `B5G5R5A1_UNORM` (86) takes no unordered access and `B4G4R4A4_UNORM` +/// (115) takes no render target, so both fail to create when the title asks +/// for a render target or UAV view. Their 8-bit RGBA stand-in is a superset +/// of both in range, so a target that only carries colour through the +/// pipeline loses nothing but the packing. Without this the title's UI +/// composition targets fail to create and the whole UI layer goes missing. pub(crate) fn pc_format(format: u32) -> u32 { match format { + 86 => 28, + 115 => 28, 118 => 45, 119 => 46, 120 => 47,