startup: show the build revision in the output window title #2203
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2211"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-25T05:21:05Z.
What
This is a debug aid. The presenter window title and the
D3D12XboxCreateDevicelog line now show which source revision the shim was built from:Xbox2Windows <rev> - output;Xbox2Windows <rev> - frame N, F fps, D translated draws (...);x2w-d3d12 D3D12XboxCreateDevice ... -> 0x........line ends withbuild=<rev>.<rev>isgit rev-parse --short=8 HEAD. It gets-dirtywhen tracked files differ from HEAD; untracked files do not count. It isunknownwhen git is missing or the source directory is not the top of a work tree, for example a tarball. A tarball unpacked inside another repository also reportsunknown. A build started with an inheritedGIT_DIRignores it.Why
When a screenshot or log comes back, the reader can tell which build produced it without asking.
Design
cmake/x2w_build_rev.cmakeruns on every build from an always-run custom target. It writes a tiny generated source,generated/x2w_build_rev.cpp, that definesx2w_build_revandx2w_build_rev_w(declared insrc/x2w_build_rev.h). It rewrites the file only when the text changes, so an unchanged revision recompiles nothing.x2w_build_revlibrary (/Zl, so it links into targets with either CRT). It is linked into every target that compilesd3d12_xs_device.cpp:d3d12_xs_shim,offscreen_checkandcpu_placed_dxr_provider.%ls/%s). The revision is not a macro in a header included byd3d12_xs_device.cpp. That file takes 64–100 s to compile, and a header would recompile it on every commit and on every clean/dirty flip. Now only the tiny source recompiles and the DLLs relink.CMAKE_CONFIGURE_DEPENDSon.git/HEADunreliable.git -C <src>and--no-optional-locks, so a build never takes the index lock.GIT_CEILING_DIRECTORIESis set to the source parent.Tests
New check
tests/startup_build_rev_check.py. It is added to the python-linux list inwindows.ymland toAGENTS.md, and registered as cteststartup_build_rev_controlsandstartup_build_rev_dll.Controls (no arguments): run the generator against temporary git repositories with an empty global config, no system config and a test identity. There are 10 cases:
GIT_DIR;The check exits 77 only when git or cmake is not on PATH.
dll <d3d12_xs.dll> <x2w_build_rev.cpp>: the built shim must contain the generated revision, both ASCII and UTF-16LE. It must also contain both UTF-16LE title formats and the full log format ending inbuild=%s. A generated source without the definitions fails as unmeasured.Results on
75756a7f(Linux, clang-cl 19 + xwin SDK cross build with Ninja, host Python 3; runtime under Proton Wine):python -B tools/run_checks_parallel.py <the windows.yml python-linux list, 95 checks>all 95 checks passed, exit 0cmake --build <b> --target d3d12_xs_shim offscreen_check cpu_placed_dxr_provider startup_null_views_checkpython3 -B tests/startup_build_rev_check.pystartup_build_rev_check: 10 cases ok, exit 0python3 -B tests/startup_build_rev_check.py dll <b>/d3d12_xs.dll <b>/generated/x2w_build_rev.cppok ...: revision 75756a7f, 5 strings, exit 0wine startup_null_views_check.exe hardware(links the shim)... -> 0x00000000 build=75756a7f,device OK, exit 0ninja -n -d explainnever mentionsd3d12_xs_device.cpp.obj; the generated source recompiles and the shim relinksMutations: each was run once and the file restored by hash. Every one fails the check on its own case.
-dirtysuffix--untracked-files=nofile(CONFIGURE)->file(WRITE)GIT_CEILING_DIRECTORIESGIT_DIRGIT_DIRbuild=%sNot measured
ctest --preset dev/releaseand the Visual Studio generator. This PR's CI compiles the shim andoffscreen_checkwith MSVC, but the PR test filter does not run thestartup_build_rev_*ctests. Windows git path forms in the controls (backslash temp paths,GIT_CEILING_DIRECTORIES) are therefore not exercised on Windows by the PR job.Limitation
tools/startup/triage_run.pykeeps only allowlisted fields, so redacted triage output will not carrybuild=. Adding it is a follow-up.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:25:18Z.
Review: COMMENTED
Review of head
75756a7f634db7068a69f39d97b697d6cd02b0d8(comment only).Result: no P1, no P2.
What I checked
cmake/x2w_build_rev.cmake: short HEAD,-dirtyonly for tracked changes,unknownwithout git, outside a top-level work tree, or with an inheritedGIT_DIR.GIT_CEILING_DIRECTORIESstops the lookup above the source dir.--no-optional-locksavoids index-lock contention. The output is rewritten only when its text changes.x2w_build_revis a static library built with/Zland linked into all three targets that compiled3d12_xs_device.cpp(d3d12_xs_shim,offscreen_check,cpu_placed_dxr_provider). I found no sibling target that compiles that file and misses the link.Commands run locally on the PR head
python3 tests/startup_build_rev_check.py->10 cases okpython3 tests/docs_links_check.py->Checked 18 Markdown files and 407 links.python3 tests/bidi_controls_check.py->no bidirectional controls.git diff --check origin/main...HEAD-> cleanMutation checks (each reverted with
git checkout -- .)--untracked-files=nochanged toall: the test FAILS ("untracked file only: revision '...-dirty', expected ...").-dirtysuffix removed: the test FAILS ("tracked edit").GIT_CEILING_DIRECTORIESline removed: the test FAILS ("directory inside another repository").So the new logic is guarded by tests that fail when it breaks.
Nits (non-blocking)
src/startup_stubs/d3d12_xs_device.cpp:16: the new#include "x2w_build_rev.h"sits between thestartup_stubs/*includes. Moving it next to the other top-level includes would be tidier.startup_build_rev_dlltest depends on the built shim, so I did not run it on Linux. I did not run a separate Windows VM job. The change is not shader or math code, and the CI Windows job covers the build and test.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T05:56:22Z.
Verified
75756a7fon Windows x64 Release before merging.ctest --preset release --no-tests=error -R "^startup_(build_rev|null_views)" -Vpassed 4/4. The revision generator passed all 10 controls, including tracked edits, a new commit and an unchanged rerun. The built DLL contains the title strings, and D3D12XboxCreateDevice loggedbuild=75756a7fon both RTX 4060 Laptop and WARP.