Skip to content

build: share the D3D12 device object across two test targets - #1752

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
tedin7:x2w-cmake-fastlink-obj
Nov 24, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
tedin7:x2w-cmake-fastlink-obj

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Current scope: shared D3D12 device object only. The earlier FASTLINK proposal was removed after reproducing LNK4315 with Visual Studio 2026. The original comparison is preserved below.

Two build-time changes, no test or target name changes.

A. dev preset links with /debug:fastlink. CMakePresets.json sets the Debug linker flags of the dev configure preset to /debug:fastlink /INCREMENTAL (the CMake default was /debug /INCREMENTAL) for EXE, DLL and module links. The release preset is untouched. Only the PDB content changes; the binaries and their unwind tables are the same.

B. One compile of src/startup_stubs/d3d12_xs_device.cpp for two test targets. offscreen_check and cpu_placed_dxr_provider compiled the file with the same flags (default CRT, desktop SDK headers; the file and its .inl includes read none of the per-target definitions such as FFX_*, DXC_VERSION_STRING or OFFSCREEN_AGILITY_620). They now link an OBJECT library d3d12_xs_device_obj.

  • With OFFSCREEN_AGILITY_620_DIR set, the fixture compiles against the Agility headers, so no library is created and both targets keep their own copy, as before.
  • d3d12_xs_shim uses the static CRT and still compiles its own copy.

Checks run locally (Linux)

  • git diff --check origin/main...HEAD, python3 -m json.tool CMakePresets.json, python3 -B tests/docs_links_check.py, python3 -B tests/bidi_controls_check.py: pass.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 8a07e812fda488e26cd2c1aad45c68a0a46b3575

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check cpu_placed_dxr_provider cpu_placed_dxr cpu_placed_dxr_lifted pe_map cpu_exe_io d3d12_xs_shim -- -j 8): 21.49s (configure 1.64s); d3d12_xs_device_obj compiled once and shared by offscreen_check and cpu_placed_dxr_provider, while d3d12_xs_shim compiled its own static-CRT copy.
    • Test (ctest --preset dev -R '^(offscreen_warp|dxr_placed_build_warp|sampler_index_control_warp|dual_uav_warp|descriptor_heap_paging_warp|cpu_placed_dxr_warp)$' --parallel 6 --no-tests=error --output-on-failure): 6/6 passed (2.51s: dual_uav_warp 0.06s, offscreen_warp 0.06s, descriptor_heap_paging_warp 0.05s, sampler_index_control_warp 0.05s, dxr_placed_build_warp 0.07s, cpu_placed_dxr_warp 2.43s).
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check cpu_placed_dxr_provider cpu_placed_dxr cpu_placed_dxr_lifted pe_map cpu_exe_io d3d12_xs_shim -- -j 8): 42.41s (configure 1.73s).
    • Test (ctest --preset release -R '^(offscreen_warp|dxr_placed_build_warp|sampler_index_control_warp|dual_uav_warp|descriptor_heap_paging_warp|cpu_placed_dxr_warp)$' --parallel 6 --no-tests=error --output-on-failure): 6/6 passed (2.79s: offscreen_warp 0.05s, sampler_index_control_warp 0.08s, dxr_placed_build_warp 0.10s, dual_uav_warp 0.07s, descriptor_heap_paging_warp 0.05s, cpu_placed_dxr_warp 2.70s).
  • sccache: 11/16 hits, 0 errors; total wall 78.5s.

AI-assisted; commands listed were executed locally.

Note on pr preset scope: pr inherits dev (and therefore /debug:fastlink) intentionally — windows.yml does not publish PDB artifacts, so reference PDBs keep CI link times faster while release preserves full PDBs.

…e file once for two test targets

The dev preset links Debug binaries with /debug:fastlink (the default /INCREMENTAL stays), so the many test DLLs and EXEs no longer build a full PDB. The release preset is unchanged.

offscreen_check and cpu_placed_dxr_provider compile src/startup_stubs/d3d12_xs_device.cpp with the same flags, so they now link one OBJECT library. With OFFSCREEN_AGILITY_620_DIR the fixture uses the Agility headers and both targets keep compiling their own copy. d3d12_xs_shim uses the static CRT and is not shared. No target or CTest name changes.
@tedin7 tedin7 changed the title build: link the dev preset with fast debug info and compile the device file once for two test targets build: use /debug:fastlink in dev preset and share d3d12_xs_device obj Nov 24, 2026
@tedin7
tedin7 marked this pull request as ready for review November 24, 2026 18:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T18:19:59.461083Z 8a07e81 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Checked the two build changes on Windows

At 8a07e812, MSVC 14.44.35207, Windows 11 build 26300.9974:

cmake --preset dev
cmake --build --preset dev --target offscreen_check cpu_placed_dxr_provider
ctest --preset dev -R '^offscreen_warp$|^cpu_placed_dxr'
configure:  done, no warnings
build:      exit 0
1/3 Test #245: offscreen_warp .........   Passed  0.28 sec
2/3 Test #629: cpu_placed_dxr_warp ....   Passed  3.53 sec
3/3 Test #630: cpu_placed_dxr_hardware    Passed 14.12 sec
100% tests passed, 0 tests failed out of 3

A. The flag reaches the linker. build.ninja carries debug:fastlink 948 times after configuring, and a forced relink
of offscreen_check.exe (deleted the exe, rebuilt) produced no LNK or other warning, and the re-linked binary still
passes offscreen_warp. /debug:fastlink together with /INCREMENTAL is what the PR claims, and the toolchain is quiet
about it.

B. The shared object library is in effect. build.ninja has a d3d12_xs_device_obj target, and
d3d12_xs_device.cpp.obj appears as a compile input in both configurations — once through the object library for
offscreen_check, and separately for d3d12_xs_shim as the PR says it keeps its own copy. Both consumers of the shared
object build and run.

One question about scope

CMakePresets.json has pr (both the configure preset and the test preset) deriving from dev:

{ "name": "pr", "configurePreset": "dev", ... }
{ "name": "pr", "inherits": "dev", "displayName": "Windows pull request smoke tests", ... }

so CI gets /debug:fastlink too, not just local dev builds. Two consequences worth a line in the PR body or docs:

  1. A fastlink PDB is a reference file: it points back at the .obj files and the absolute build directory, so it is not
    a self-contained artifact. Anyone who downloads a CI build to inspect a crash will find the PDB unusable once the
    workspace is gone — the opposite of what /debug normally gives.
  2. /debug:fastlink is documented as not supported together with /DEBUG:FULL post-processing tools that expect a
    complete PDB (for example link /DEBUG:FULL re-runs), and /Zi edit-and-continue needs a full PDB as well.

Neither is a defect in this change; it is a question of whether CI is the intended holder of reference PDBs. If the intent
is local-only, setting the flags on a dev-specific cache variable and leaving pr alone would say that in the file
rather than in a PR comment. If CI is fine with reference PDBs, one sentence saying so is enough for the next reader.

Otherwise

The header/definition reasoning for sharing the object (no FFX_*, DXC_VERSION_STRING or OFFSCREEN_AGILITY_620
dependency, and the OFFSCREEN_AGILITY_620_DIR branch keeping the old behaviour) matches what the CMake code does, and the
shim's separate copy is preserved. Both targets that consume the shared object compile and their tests pass.

Verdict

Reviewed 8a07e812. Both changes do what they say on this machine, with no linker warning and no test change. The only open
point is whether pr should inherit fastlink.

Notes

  • AI-assisted review.

@tedin7

tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for testing both changes on Windows 11 and confirming zero linker warnings and 3/3 pass!

Good catch on pr inheriting dev (and therefore /debug:fastlink): that is intentional for CI, because windows.yml does not publish or archive PDBs as build artifacts (it only builds and runs CTest in the ephemeral runner workspace, where /debug:fastlink speeds up the ~940 test links), while the release preset keeps full PDBs unchanged. I will also add a brief note to the PR description so this scope is explicit for future readers.

AI-assisted.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Both claims verified on a Windows build

Windows 11 build 26300.9974, MSVC 19.44, dev preset.

A. /debug:fastlink really reaches the linker

cmake --preset dev
# CMakePresets.json now carries
#   "CMAKE_EXE_LINKER_FLAGS_DEBUG": "/debug:fastlink /INCREMENTAL"
#   "CMAKE_SHARED_LINKER_FLAGS_DEBUG": ... and CMAKE_MODULE_LINKER_FLAGS_DEBUG ...

Select-String -Path out/build/dev/build.ninja -Pattern 'LINK_FLAGS = ' | Select-Object -First 2
  LINK_FLAGS = /machine:x64 /debug:fastlink /INCREMENTAL /subsystem:console
  LINK_FLAGS = /machine:x64 /debug:fastlink /INCREMENTAL /subsystem:console

948 occurrences in the generated build, i.e. every Debug link line, and the release preset keeps its own flags. So this is
not a preset key that CMake silently ignores — the flag is on the command line that runs.

B. One compile of d3d12_xs_device.cpp, shared by both targets

With --clean-first, building offscreen_check and cpu_placed_dxr_provider together compiles the file exactly once:

[5/128] Building CXX object CMakeFiles\d3d12_xs_device_obj.dir\src\startup_stubs\d3d12_xs_device.cpp.obj

and offscreen_warp still passes (100% tests passed). The dependency-sensitive part of the description — that the file reads
none of the per-target definitions — is consistent with that single compile succeeding for both consumers; if it did read
OFFSCREEN_AGILITY_620 or an FFX_* define, one of the two would now be built with the wrong value and the fixture would
notice.

What I did not verify

  • The speed-up itself. I confirmed fewer compiles and the flag on the link line, not measured build wall time. My tree is
    warm and single-config, so a timing number from it would be meaningless.
  • The Agility path. OFFSCREEN_AGILITY_620_DIR is unset here, so the else() branch (no OBJECT library, each target keeps
    its own copy) never ran. If you want that branch exercised in CI, it needs its own job.

One question

set_property(SOURCE ... APPEND PROPERTY COMPILE_OPTIONS /bigobj) still applies to the source; it now reaches the OBJECT
library rather than the two targets. Since the property is source-scoped, the object built once inherits it — worth a word in
the description so nobody re-adds a per-target /bigobj later and quietly creates a second compile.

Verdict

Reviewed. Both changes do what the description says on this machine, the release preset is untouched, and the fixture still
passes. No objections.

Notes

  • AI-assisted review.

@R0Y00

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

MSVC 14.51 on Visual Studio 2026 reports LNK4315 for /DEBUG:FASTLINK. Microsoft documents its removal. I dropped only the preset override. The remaining object-library sharing builds offscreen_check and cpu_placed_dxr_provider in Debug with one shared object. desktop_root_signature and offscreen_warp both pass.

@R0Y00 R0Y00 changed the title build: use /debug:fastlink in dev preset and share d3d12_xs_device obj build: share the D3D12 device object across two test targets Nov 24, 2026
@R0Y00
R0Y00 merged commit 18fe83d into R0Y00:main Nov 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants