1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// The Agility SDK handshake: two symbols Windows' system `d3d12.dll` reads
// from the running EXE's PE export table at process start. When both are
// present and the named path resolves to a directory holding `D3D12Core.dll`,
// it loads that copy in place of the OS-bundled (older) D3D12 runtime. FFX FSR3
// needs the newer one -- see `post::upscale::fsr` -- and without it
// `ffxCreateContext` throws a C++ exception that aborts the process.
//
// An EXE only exports what its linker was told to export, so the statics alone
// are not enough: each package owning a final binary emits
// `/EXPORT:<name>,DATA` from its build script (concinnity-toolchain's
// `BinaryTargets`), and that argument is also what pulls these definitions out
// of the rlib. `,DATA` is critical -- without it the linker inserts a code thunk
// that `d3d12.dll` would dereference as a pointer.
//
// This is the only mechanism a shipped binary can use. The runtime alternative,
// `ID3D12SDKConfiguration::SetSDKVersion`, is documented as usable "only in
// Windows Developer Mode" -- it exists for tools like PIX, not for applications
// -- and returns DXGI_ERROR_INVALID_CALL everywhere else.
//
// The handshake has no fallback: if the directory is absent, D3D12 device
// creation fails outright rather than reverting to the OS runtime, and the
// renderer reports "no suitable D3D12 adapter found" (see `init::window`, which
// says so). A binary carrying these exports is therefore only portable together
// with the directory beside it.
//
// The version must match the Agility NuGet package the build script bundles:
// the directory name is `microsoft.direct3d.d3d12.1.<VERSION>.<PATCH>`, so
// `microsoft.direct3d.d3d12.1.619.3` is 619. `DEFAULT_AGILITY_SDK_ROOT` in
// concinnity-toolchain names the tree these bytes have to agree with.
// `pub` even though nothing in the crate names them: the visibility is what
// declares them as exported symbols alongside `#[unsafe(no_mangle)]`.
pub static D3D12SDKVersion: u32 = 619;
pub static D3D12SDKPath: & = b".\\D3D12\\\0";