D3D12.X: report debug layer messages by id, and gate new ids in smoke #2039

Open
github-bot wants to merge 2 commits from github-bot/gh-2039 into main AGit
Owner

@⁠brandostrong on GitHub · 2026-11-25 01:33 UTC · original
brandostrong:d3d12x-debug-layer-report → main · +120 −10 · 4 files · 2 commits · open

The debug layer's messages reach XCL's log, but only the first 8 of each message id are printed: a run that hit one 5 151 times looked like eight hits. report.json now carries d3d12.debug_layer – every message counted, by id, with the first text of each id – smoke.ps1 -DebugLayer prints debug layer messages: 538x5151 745x5307 from it, and pr_check.py refuses a PR whose run shows ids main's run did not: new validation errors, which frames and peak commit say nothing about. Ids main's run showed and the PR's no longer shows are a fix, not a problem.

Part of the validation line claimed on #1269.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: the per-id counts, already in the callback but a local static nothing could read, become a module static; every message is counted, the first text of each id is kept, and both reach report.json as d3d12.debug_layer. debug_layer_counts_from turns a map into the report form, so the report test works on its own map and never touches the global one. Two unit tests (counted past the cap, ids in order with the first text cut to 200 characters).
  • scripts/smoke.ps1: a -DebugLayer switch and the debug layer messages: line – n/a when the layer was off, none when there were none. The caller's own XCL_D3D12_DEBUG is restored after the run, not deleted.
  • scripts/pr_check.py: smoke_ids and the new-id comparison, only between blocks that both report them.
  • scripts/test_pr_check.py: new ids fail; same, fewer, n/a and no line all pass.

Tested

  • NVIDIA GeForce RTX 4090 (driver 32.0.16.1664), i9-13900K, Windows 11 Pro 26200, rustc 1.100.0, debug and release
  • on the head 1039318: cargo build --workspace then cargo test --workspace -- --test-threads=4: 1156 passed, 0 failed, 46 ignored; 24 GPU tests skipped (20 no wave64, 1 no heap windows, 3 refused on the #1426 semantics)
  • python scripts/test_pr_check.py: OK, 15 tests; pwsh scripts/smoke-title.tests.ps1: smoke-title: ok
  • the switch is a switch: with a fixture xcl, XCL_D3D12_DEBUG is set only when -DebugLayer is passed and does not leak after the run; the line renders from a fixture report.json as 538x5151, n/a and none
  • a 150 s debug-layer run of a retail title, release build of this branch (before the switch and the first-text field were added, so its report.json has the counts and not the texts): 13 273 messages counted against 57 lines in the log – 538×5 151 resource-state errors, 745×5 307 GetGPUVirtualAddress on non-buffer resources, 1047×1 618 simultaneous-access hazards across queues, 677×491, 679×252, 680×45, 1422×9. 745 is XCL's own address probe in res_gpu_va_x (it asks the PC method, gets 0, substitutes the title's address), so it is expected in any debug-layer run, on both sides of a pair.

Regression run

Both runs have the debug layer on – main's through XCL_D3D12_DEBUG=1 in the environment, because the -DebugLayer switch is this PR's – so the two sides pay the same cost. Main's block has no debug layer messages: line, so the new-id comparison is skipped for this pair.

main cbc296a:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 4090
title: 3c290c16
seconds: 180
exit: 0x0
frames shown: 1758 (PresentX 1758)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 35960 MB

this PR's head 1039318 (-DebugLayer):

xcl-smoke v1
commit: 1039318fce8565e8298b5fea211f23f524a59bf1
gpu: NVIDIA GeForce RTX 4090
title: 3c290c16
seconds: 180
exit: 0x0
frames shown: 1552 (PresentX 1552)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 36313 MB
debug layer messages: 538x4580 677x491 679x257 680x46 745x5454 1047x1428 1422x12

Not tested

  • AMD, WARP, and machines without the Graphics Tools optional feature – there the layer is unavailable, XCL logs that once, and the line stays n/a, which is why -DebugLayer is a switch and not the default (#1444 is about device creation failing in exactly that case)
  • #1008's polled ID3D12InfoQueue path for Windows 10 does not feed this counter yet: it needs the same note_debug_message call when that PR lands, or Windows 10 runs will log messages the report does not count
  • the id comparison against a main block that itself has the line: main has no -DebugLayer switch, so this pair exercises only the head side (the tests cover same / fewer / n/a / no line)

AI use

  • Claude Code, Claude Opus 5.5: wrote the code, the tests and this description, ran both suites and the 150 s game run; the user reviewed the diff.
  • Claude Code, Claude Fable 5: the two review fixes (debug_layer_counts_from, restoring the caller's XCL_D3D12_DEBUG), the rebase onto cbc296a, the suite rerun and both regression runs.

🤖 Generated with Claude Code

**@⁠brandostrong** on GitHub · 2026-11-25 01:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2039) `brandostrong:d3d12x-debug-layer-report` → `main` · +120 −10 · 4 files · 2 commits · open The debug layer's messages reach XCL's log, but only the first 8 of each message id are printed: a run that hit one 5 151 times looked like eight hits. `report.json` now carries `d3d12.debug_layer` – every message counted, by id, with the first text of each id – `smoke.ps1 -DebugLayer` prints `debug layer messages: 538x5151 745x5307` from it, and `pr_check.py` refuses a PR whose run shows ids main's run did not: new validation errors, which frames and peak commit say nothing about. Ids main's run showed and the PR's no longer shows are a fix, not a problem. Part of the validation line claimed on #1269. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: the per-id counts, already in the callback but a local static nothing could read, become a module static; every message is counted, the first text of each id is kept, and both reach `report.json` as `d3d12.debug_layer`. `debug_layer_counts_from` turns a map into the report form, so the report test works on its own map and never touches the global one. Two unit tests (counted past the cap, ids in order with the first text cut to 200 characters). - `scripts/smoke.ps1`: a `-DebugLayer` switch and the `debug layer messages:` line – `n/a` when the layer was off, `none` when there were none. The caller's own `XCL_D3D12_DEBUG` is restored after the run, not deleted. - `scripts/pr_check.py`: `smoke_ids` and the new-id comparison, only between blocks that both report them. - `scripts/test_pr_check.py`: new ids fail; same, fewer, `n/a` and no line all pass. **Tested** - NVIDIA GeForce RTX 4090 (driver 32.0.16.1664), i9-13900K, Windows 11 Pro 26200, rustc 1.100.0, debug and release - on the head `1039318`: `cargo build --workspace` then `cargo test --workspace -- --test-threads=4`: 1156 passed, 0 failed, 46 ignored; 24 GPU tests skipped (20 `no wave64`, 1 `no heap windows`, 3 refused on the #1426 semantics) - `python scripts/test_pr_check.py`: OK, 15 tests; `pwsh scripts/smoke-title.tests.ps1`: `smoke-title: ok` - the switch is a switch: with a fixture `xcl`, `XCL_D3D12_DEBUG` is set only when `-DebugLayer` is passed and does not leak after the run; the line renders from a fixture `report.json` as `538x5151`, `n/a` and `none` - a 150 s debug-layer run of a retail title, release build of this branch (before the switch and the first-text field were added, so its `report.json` has the counts and not the texts): **13 273 messages counted against 57 lines in the log** – 538×5 151 resource-state errors, 745×5 307 `GetGPUVirtualAddress` on non-buffer resources, 1047×1 618 simultaneous-access hazards across queues, 677×491, 679×252, 680×45, 1422×9. 745 is XCL's own address probe in `res_gpu_va_x` (it asks the PC method, gets 0, substitutes the title's address), so it is expected in any debug-layer run, on both sides of a pair. **Regression run** Both runs have the debug layer on – main's through `XCL_D3D12_DEBUG=1` in the environment, because the `-DebugLayer` switch is this PR's – so the two sides pay the same cost. Main's block has no `debug layer messages:` line, so the new-id comparison is skipped for this pair. `main` `cbc296a`: ``` xcl-smoke v1 commit: cbc296ab65a2661a61e3e2da109134bcd5319f60 gpu: NVIDIA GeForce RTX 4090 title: 3c290c16 seconds: 180 exit: 0x0 frames shown: 1758 (PresentX 1758) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 35960 MB ``` this PR's head `1039318` (`-DebugLayer`): ``` xcl-smoke v1 commit: 1039318fce8565e8298b5fea211f23f524a59bf1 gpu: NVIDIA GeForce RTX 4090 title: 3c290c16 seconds: 180 exit: 0x0 frames shown: 1552 (PresentX 1552) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 36313 MB debug layer messages: 538x4580 677x491 679x257 680x46 745x5454 1047x1428 1422x12 ``` **Not tested** - AMD, WARP, and machines without the Graphics Tools optional feature – there the layer is unavailable, XCL logs that once, and the line stays `n/a`, which is why `-DebugLayer` is a switch and not the default (#1444 is about device creation failing in exactly that case) - #1008's polled `ID3D12InfoQueue` path for Windows 10 does not feed this counter yet: it needs the same `note_debug_message` call when that PR lands, or Windows 10 runs will log messages the report does not count - the id comparison against a main block that itself has the line: main has no `-DebugLayer` switch, so this pair exercises only the head side (the tests cover same / fewer / `n/a` / no line) **AI use** - Claude Code, Claude Opus 5.5: wrote the code, the tests and this description, ran both suites and the 150 s game run; the user reviewed the diff. - Claude Code, Claude Fable 5: the two review fixes (`debug_layer_counts_from`, restoring the caller's `XCL_D3D12_DEBUG`), the rebase onto `cbc296a`, the suite rerun and both regression runs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The debug layer's messages reach XCL's log but only the first 8 of each id are
printed, so a run that hit one 5 151 times looked like eight hits in the report.
The per-id counts already existed in the callback; they were a local static
nothing could read. Hoist them to a module static, count every message, keep
the first text of each id and expose them in report.json as d3d12.debug_layer,
sorted by id.

Measured on a 150 s debug-layer run of a retail title: 13 273 messages in the
report against 57 lines in the log – 5 307 GetGPUVirtualAddress-on-non-buffer
warnings (XCL's own address probes), 5 151 resource-state errors, 1 618
simultaneous-access hazards across queues and 9 render targets created
CREATE_NOT_ZEROED and never initialized before use.

The log caps are unchanged: printing still stops at 8 per id and 3 000 in all.

Co-Authored-By: Claude Code <[email protected]>
A run that picked up new validation errors looked clean in the block: frames
and peak commit say nothing about them, and the log's per-id cap hides how
often each one fired. smoke.ps1 prints `debug layer messages: 538x5151 745x5307`
from report.json (n/a when the layer was off, none when there were none) and
pr_check.py refuses a PR whose run shows ids main's run did not; ids main's run
showed and the PR's no longer shows are a fix, not a problem.

-DebugLayer turns the layer on for the run so the line has ids in it. It is a
switch and not the default: with the layer requested and no Graphics Tools
device creation can fail outright (#1444), so forcing it would break smoke runs
there. Both runs of a pair get it; blocks without the line still pass.

Co-Authored-By: Claude Code <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:16:09 +00:00
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:43 UTC · original

Code review on 60f8fc5:

  • Counting debug-layer messages per ID into DEBUG_MSGS (BTreeMap<i32, (u32, String)>) while keeping DEBUG_MSG_LOG_LIMIT = 8 on log output, exposing D3d12Stats.debug_layer, and gating newly introduced IDs in scripts/pr_check.py / scripts/smoke.ps1 -DebugLayer is very clean and practical.
  • Two minor notes:
    1. debug_layer_report_tests::the_report_lists_ids_in_order_with_full_counts (crates/xcl/src/hle/d3d12x/real.rs) mutates the process-global DEBUG_MSGS static and asserts exact contents (vec![(541, 1), (725, 3)]). If another GPU test runs concurrently in the same binary with XCL_D3D12_DEBUG=1 (e.g., --test-threads=4), real debug-layer callbacks can race into DEBUG_MSGS and break that assertion. Extracting a debug_layer_counts_from(msgs: &BTreeMap<...>) helper lets the test stay isolated.
    2. In scripts/smoke.ps1, if ($DebugLayer) { Remove-Item Env:XCL_D3D12_DEBUG } unconditionally deletes Env:XCL_D3D12_DEBUG even if the calling shell had it set beforehand (similar to #521).
  • Build and test (Windows, no GPU) is green.

Remaining before merge: Addressing PR description (and the global-state test isolation note above) plus AMD and NVIDIA verification on the updated head.

**@⁠raylitebull** on GitHub · 2026-11-25 01:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/2039#issuecomment-7149888186) Code review on `60f8fc5`: - Counting debug-layer messages per ID into `DEBUG_MSGS` (`BTreeMap<i32, (u32, String)>`) while keeping `DEBUG_MSG_LOG_LIMIT = 8` on log output, exposing `D3d12Stats.debug_layer`, and gating newly introduced IDs in `scripts/pr_check.py` / `scripts/smoke.ps1 -DebugLayer` is very clean and practical. - **Two minor notes:** 1. `debug_layer_report_tests::the_report_lists_ids_in_order_with_full_counts` (`crates/xcl/src/hle/d3d12x/real.rs`) mutates the process-global `DEBUG_MSGS` static and asserts exact contents (`vec![(541, 1), (725, 3)]`). If another GPU test runs concurrently in the same binary with `XCL_D3D12_DEBUG=1` (e.g., `--test-threads=4`), real debug-layer callbacks can race into `DEBUG_MSGS` and break that assertion. Extracting a `debug_layer_counts_from(msgs: &BTreeMap<...>)` helper lets the test stay isolated. 2. In `scripts/smoke.ps1`, `if ($DebugLayer) { Remove-Item Env:XCL_D3D12_DEBUG }` unconditionally deletes `Env:XCL_D3D12_DEBUG` even if the calling shell had it set beforehand (similar to `#521`). - `Build and test (Windows, no GPU)` is green. **Remaining before merge:** Addressing `PR description` (and the global-state test isolation note above) plus **AMD** and **NVIDIA** verification on the updated head.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 04:28 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 04:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/2039#issuecomment-7152877905) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠brandostrong on GitHub · 2026-11-25 09:54 UTC · original

Both notes are addressed at the current head 1039318f (the review was on 60f8fc5):

  1. the_report_lists_ids_in_order_with_full_counts no longer touches the global: it fills a local BTreeMap and asserts through the extracted debug_layer_counts_from(&msgs) (crates/xcl/src/hle/d3d12x/real.rs:176 for the helper, :7220 for the test), with a comment naming the race you spotted — a concurrent GPU test with XCL_D3D12_DEBUG=1 feeds the global map. counts_every_message_and_caps_only_the_printing was already local-map only.
  2. scripts/smoke.ps1 now saves the caller's value first (:57) and restores it after the run (:70-72): with -DebugLayer it sets 1 for the child and puts back what the shell had, removing the variable only if the shell had none.

Tested on the current head: cargo test --release --offline --workspace -- --test-threads=4 on an RTX 4090 — 1155 passed, 0 failed, 46 ignored, 23 SKIPPED (no wave64 and the direct path's refused f16 / f32 forms). AMD and a second NVIDIA card are still the gap, as you say.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

**@⁠brandostrong** on GitHub · 2026-11-25 09:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/2039#issuecomment-7158952458) Both notes are addressed at the current head `1039318f` (the review was on `60f8fc5`): 1. `the_report_lists_ids_in_order_with_full_counts` no longer touches the global: it fills a local `BTreeMap` and asserts through the extracted `debug_layer_counts_from(&msgs)` (`crates/xcl/src/hle/d3d12x/real.rs:176` for the helper, `:7220` for the test), with a comment naming the race you spotted — a concurrent GPU test with `XCL_D3D12_DEBUG=1` feeds the global map. `counts_every_message_and_caps_only_the_printing` was already local-map only. 2. `scripts/smoke.ps1` now saves the caller's value first (`:57`) and restores it after the run (`:70-72`): with `-DebugLayer` it sets `1` for the child and puts back what the shell had, removing the variable only if the shell had none. Tested on the current head: `cargo test --release --offline --workspace -- --test-threads=4` on an RTX 4090 — 1155 passed, 0 failed, 46 ignored, 23 `SKIPPED` (`no wave64` and the direct path's refused f16 / f32 forms). AMD and a second NVIDIA card are still the gap, as you say. AI use: Claude Code (Claude Opus 5.5) wrote this reply.
Author
Owner

@⁠RavenCurseBurg on GitHub · 2026-11-25 21:07 UTC · original · edited 2026-11-26 09:06 UTC

Tested on 1039318fce8565e8298b5fea211f23f524a59bf1, Windows 11 build 26100.9711, Core i7-13700, Windows PowerShell 5.1 and PowerShell 7.6.9.

I ran scripts/smoke.ps1 -Game fixture -Title fixture -Seconds 1 with and without -DebugLayer. A small executable recorded the inherited setting on a successful launch. Passing an existing directory as -Xcl exercised a real Process.Start error. I tested three initial caller states: absent, 0 and original.

On the PR head, each failed start with -DebugLayer left XCL_D3D12_DEBUG=1 in the calling shell (3 of 12 cases on each edition). The script-only fix and regression test restore the setting in finally around Start(). All 24 cases then preserved the caller's value. Successful children still received 1 with the switch and their original value without it.

In both shells, -NoProfile -ExecutionPolicy Bypass -File scripts/smoke-debug-layer.tests.ps1 failed on the head and passed on the candidate. Both shells also passed scripts/smoke-title.tests.ps1; Python script discovery passed 27/27.

Not tested — An actual debug-layer or game launch, the Rust workspace, or a caller with a native present-but-empty variable. OpenAI Codex (GPT-6) wrote and ran the fixtures, implemented the fix, and prepared this report.

Rebase onto current main

The two-commit rebased branch descends directly from b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7. The original Rust conflict arose where two sets of test modules had been added at the end of real.rs. I verified byte-for-byte that the rebased file contains main's modules, the original PR's debug test module, and the same six non-test diff hunks. The script commit carries forward main's batch-launch and -OutDir handling alongside -DebugLayer, using the child-only settings from #2714. git merge-tree --write-tree against that main returned the candidate's own tree.

All 27 Python script tests passed. The artifact, debug-layer and title fixtures each passed in both shells. Thirty additional debug-on/off cases on the rebased script covered success, failed process start and missing log output. The caller kept its values; a successful debug-enabled fixture also reported the expected synthetic message ID and count. I supplied a mock adapter for fixture fallback. The Rust crate and its Rust tests were not compiled or run here. An actual debug-layer/title run and upstream CI remain outstanding. OpenAI Codex (GPT-6) prepared the rebase and ran the Windows script checks.

**@⁠RavenCurseBurg** on GitHub · 2026-11-25 21:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2039#issuecomment-7174645577) · edited 2026-11-26 09:06 UTC **Tested** on `1039318fce8565e8298b5fea211f23f524a59bf1`, Windows 11 build 26100.9711, Core i7-13700, Windows PowerShell 5.1 and PowerShell 7.6.9. I ran `scripts/smoke.ps1 -Game fixture -Title fixture -Seconds 1` with and without `-DebugLayer`. A small executable recorded the inherited setting on a successful launch. Passing an existing directory as `-Xcl` exercised a real `Process.Start` error. I tested three initial caller states: absent, `0` and `original`. On the PR head, each failed start with `-DebugLayer` left `XCL_D3D12_DEBUG=1` in the calling shell (3 of 12 cases on each edition). The [script-only fix and regression test](https://github.com/RavenCurseBurg/xcl/commit/592ca3c83b248316f0ece04a3d5cc8f890784095) restore the setting in `finally` around `Start()`. All 24 cases then preserved the caller's value. Successful children still received `1` with the switch and their original value without it. In both shells, `-NoProfile -ExecutionPolicy Bypass -File scripts/smoke-debug-layer.tests.ps1` failed on the head and passed on the candidate. Both shells also passed `scripts/smoke-title.tests.ps1`; Python script discovery passed 27/27. **Not tested** — An actual debug-layer or game launch, the Rust workspace, or a caller with a native present-but-empty variable. OpenAI Codex (GPT-6) wrote and ran the fixtures, implemented the fix, and prepared this report. **Rebase onto current main** The [two-commit rebased branch](https://github.com/RavenCurseBurg/xcl/commit/c53c23fe9c41acc0795265d1641c2ec71498f721) descends directly from `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`. The original Rust conflict arose where two sets of test modules had been added at the end of `real.rs`. I verified byte-for-byte that the rebased file contains main's modules, the original PR's debug test module, and the same six non-test diff hunks. The script commit carries forward main's batch-launch and `-OutDir` handling alongside `-DebugLayer`, using the child-only settings from #2714. `git merge-tree --write-tree` against that main returned the candidate's own tree. All 27 Python script tests passed. The artifact, debug-layer and title fixtures each passed in both shells. Thirty additional debug-on/off cases on the rebased script covered success, failed process start and missing log output. The caller kept its values; a successful debug-enabled fixture also reported the expected synthetic message ID and count. I supplied a mock adapter for fixture fallback. The Rust crate and its Rust tests were **not compiled or run** here. An actual debug-layer/title run and upstream CI remain outstanding. OpenAI Codex (GPT-6) prepared the rebase and ran the Windows script checks.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 07:05 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 07:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2039#issuecomment-7185081652) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/real.rs
  • scripts/smoke.ps1
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2039/head:github-bot/gh-2039'
git switch 'github-bot/gh-2039'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2039'
git switch 'github-bot/gh-2039'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2039'
git switch 'github-bot/gh-2039'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2039'
git switch 'main'
git merge --squash 'github-bot/gh-2039'
git switch 'main'
git merge --ff-only 'github-bot/gh-2039'
git switch 'main'
git merge 'github-bot/gh-2039'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.