gpu: sample slot 62 root bindings at dispatch #2238

Merged
R0Y00 merged 2 commits from upstream-pr/2246 into main 2026-11-25 07:54:17 +00:00
R0Y00 commented 2026-11-25 07:31:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T07:31:18Z.


Refs #1412, #1803, #1954 and #1974.

Add an opt-in trace that pairs slot 62 PSO creation with the root state observed at command-list slot 14. It reports the matching root, desktop PSO/root availability, constant write mask, and upload or placed-resource classification from the current recording. Set X2W_D3D12_COMPUTE_BINDINGS=1 with render mode, or pass a comma-separated list of lowercase container hashes. Sampling leaves dispatch behavior unchanged and logs classifications without buffer payloads, constant values, or addresses. Resource classifications describe the first byte and need separate range and state validation before use for dispatch.

The source-built WARP control validates a legal compute PSO and then drives the shim through root binds, split constant setters, aligned and unaligned uploads, a placed buffer, a root switch, and a fresh recording. Disabled and unmatched-filter processes must emit no trace records.

Verification on Windows build 26200, WARP and GeForce RTX 4060 Laptop driver 616.56, with X2W_D3D12_DEBUG=1:

cmake --build --preset release --target startup_compute_binding_trace startup_indirect_dispatch
ctest --preset release --no-tests=error -R '^(startup_compute_binding_trace_warp|startup_indirect_(dispatch|root_constants|count)_(warp|hardware))$' --output-on-failure

7 passed, zero skipped. git diff --check, the documentation link check, and the bidirectional controls check passed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6599516067 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2246). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T07:31:18Z. --- Refs #1412, #1803, #1954 and #1974. Add an opt-in trace that pairs slot 62 PSO creation with the root state observed at command-list slot 14. It reports the matching root, desktop PSO/root availability, constant write mask, and upload or placed-resource classification from the current recording. Set `X2W_D3D12_COMPUTE_BINDINGS=1` with render mode, or pass a comma-separated list of lowercase container hashes. Sampling leaves dispatch behavior unchanged and logs classifications without buffer payloads, constant values, or addresses. Resource classifications describe the first byte and need separate range and state validation before use for dispatch. The source-built WARP control validates a legal compute PSO and then drives the shim through root binds, split constant setters, aligned and unaligned uploads, a placed buffer, a root switch, and a fresh recording. Disabled and unmatched-filter processes must emit no trace records. Verification on Windows build 26200, WARP and GeForce RTX 4060 Laptop driver 616.56, with `X2W_D3D12_DEBUG=1`: ```powershell cmake --build --preset release --target startup_compute_binding_trace startup_indirect_dispatch ctest --preset release --no-tests=error -R '^(startup_compute_binding_trace_warp|startup_indirect_(dispatch|root_constants|count)_(warp|hardware))$' --output-on-failure ``` 7 passed, zero skipped. `git diff --check`, the documentation link check, and the bidirectional controls check passed. AI-assisted.
tedin7 commented 2026-11-25 07:33:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:33:48Z.

Review: COMMENTED


Review of head 766ab152f05eedaba48d64e60c3c4d57c1bc1854 (comment only, no approval).

Scope read: git diff --stat origin/main...HEAD shows 6 files, +353/-1. I read d3d12_compute_binding_trace.inl, the d3d12_xs_device.cpp hunks (WrapperOwn fields, noop_slot hook, RootParameter.constants_count, Pass::compute_trace, list_compute_root) and the CMake and Python check.

Commands run locally (Linux):

  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 418 links OK.
  • python3 tests/bidi_controls_check.py: self-test passed, 1524 files, no bidirectional controls.
  • git diff --check origin/main...HEAD: clean, rc=0.
  • python3 -I -m py_compile tests/startup_compute_binding_trace_check.py: OK.
  • gh pr checks: Linux Python checks pass. Windows build/test and gfx1013 fixtures were still pending when I looked, and the /O2 job was skipped.

Not done: the C++ is Windows-only, so I could not run the new CTest or do a real logic mutation on Linux. I did not queue Win2025, because the PR body already reports a WARP and hardware run and CI is building it. The mutation check is therefore open. Suggested mutations for the Windows side: change offset >= 64 to offset > 64, drop the slot == 35 special case in compute_binding_source, or compare compute_trace_root against nullptr. The exact-line assertions in startup_compute_binding_trace_check.py look tight enough to kill all three.

Findings

  • P1: none.
  • P2: none.
  • nit, d3d12_compute_binding_trace.inl (compute_binding_filter): if X2W_D3D12_COMPUTE_BINDINGS is 192 bytes or longer, GetEnvironmentVariableA returns the required size, size < sizeof(value) fails, and the trace turns off with no message. A long hash list therefore looks like "nothing matched". Log one line when the value is truncated, or document the limit (about 11 hashes) in docs/startup-runtime.md.
  • nit, mask semantics: constants only tracks dwords 0..63 and ignores writes at offset >= 64. The 64-dword bound matches the D3D12 root signature limit, so this is correct, but a one-line comment on that would help later readers.
  • nit, trace_compute_binding: slot 39 reads third as a pointer and probes it with readable() before counting the dwords. That is safe, and values are never logged, which is the intent. A short comment saying so would stop a future change from printing them.

Checked and found fine

  • The shift (~u64{} >> (64 - count)) << offset is only reached with 0 < count <= 64 and offset < 64, so there is no undefined shift.
  • A filter of exactly 1 or a comma list is parsed without overrun (substr(0, npos) and remove_prefix are both guarded).
  • The trace state is rebuilt only when the compute root signature changes, which matches D3D12 root-binding invalidation. Re-setting the same root keeps the bindings.
  • The disabled path costs one static-string check per hooked list call and forwards the call unchanged.
  • Title and body are neutral, and the body has the Refs line and a Verification block.

Open item before Ready: a green Windows CI run (WARP and hardware) on this exact head.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053518814 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2246#pullrequestreview-6053518814). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T07:33:48Z. **Review:** COMMENTED --- Review of head `766ab152f05eedaba48d64e60c3c4d57c1bc1854` (comment only, no approval). **Scope read:** `git diff --stat origin/main...HEAD` shows 6 files, +353/-1. I read `d3d12_compute_binding_trace.inl`, the `d3d12_xs_device.cpp` hunks (WrapperOwn fields, `noop_slot` hook, `RootParameter.constants_count`, `Pass::compute_trace`, `list_compute_root`) and the CMake and Python check. **Commands run locally (Linux):** - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files, 418 links OK. - `python3 tests/bidi_controls_check.py`: self-test passed, 1524 files, no bidirectional controls. - `git diff --check origin/main...HEAD`: clean, rc=0. - `python3 -I -m py_compile tests/startup_compute_binding_trace_check.py`: OK. - `gh pr checks`: Linux Python checks pass. Windows build/test and gfx1013 fixtures were still pending when I looked, and the /O2 job was skipped. **Not done:** the C++ is Windows-only, so I could not run the new CTest or do a real logic mutation on Linux. I did not queue Win2025, because the PR body already reports a WARP and hardware run and CI is building it. The mutation check is therefore open. Suggested mutations for the Windows side: change `offset >= 64` to `offset > 64`, drop the `slot == 35` special case in `compute_binding_source`, or compare `compute_trace_root` against `nullptr`. The exact-line assertions in `startup_compute_binding_trace_check.py` look tight enough to kill all three. **Findings** - P1: none. - P2: none. - nit, `d3d12_compute_binding_trace.inl` (`compute_binding_filter`): if `X2W_D3D12_COMPUTE_BINDINGS` is 192 bytes or longer, `GetEnvironmentVariableA` returns the required size, `size < sizeof(value)` fails, and the trace turns off with no message. A long hash list therefore looks like "nothing matched". Log one line when the value is truncated, or document the limit (about 11 hashes) in `docs/startup-runtime.md`. - nit, mask semantics: `constants` only tracks dwords 0..63 and ignores writes at `offset >= 64`. The 64-dword bound matches the D3D12 root signature limit, so this is correct, but a one-line comment on that would help later readers. - nit, `trace_compute_binding`: slot 39 reads `third` as a pointer and probes it with `readable()` before counting the dwords. That is safe, and values are never logged, which is the intent. A short comment saying so would stop a future change from printing them. **Checked and found fine** - The shift `(~u64{} >> (64 - count)) << offset` is only reached with `0 < count <= 64` and `offset < 64`, so there is no undefined shift. - A filter of exactly `1` or a comma list is parsed without overrun (`substr(0, npos)` and `remove_prefix` are both guarded). - The trace state is rebuilt only when the compute root signature changes, which matches D3D12 root-binding invalidation. Re-setting the same root keeps the bindings. - The disabled path costs one static-string check per hooked list call and forwards the call unchanged. - Title and body are neutral, and the body has the `Refs` line and a Verification block. Open item before Ready: a green Windows CI run (WARP and hardware) on this exact head. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 08:04:59 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2238
No description provided.