startup: count null descriptor bindings by cause #1257

Manually merged
github merged 2 commits from gh-pr/1257/head into gh-pr/1257/base 2026-11-26 22:53:01 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 05:43 UTC · original
tedin7:x2w-c3-null-bindings → main · +186 −7 · 6 files · 2 commits · merged 2026-11-24 08:25 UTC

What

  • Splits the null bindings total in the translated draw path into five causes: null or unreadable table entry, unreadable buffer address or size (including a failed frame copy), unknown view token, missing or non-resource texture wrapper, view-dimension mismatch.
  • The existing total keeps its meaning and its null bindings %ld text in the x2w-render totals line. The per-cause counts follow it in parentheses.
  • Fixes an uncounted case: the dimension-mismatch path cleared the texture without counting it. It is now counted, in the total and in its cause.
  • Each binding is classified once by a pure function (src/startup_stubs/null_binding_cause.h), so the causes always sum to the total and a missing wrapper is not counted again as a mismatch.
  • startup_null_views_check now also runs pure cases for every cause, the sum equals the total, and valid bindings add nothing. The fixture cannot read the live counters (it never draws), so the classification is what is tested.
  • docs/startup-runtime.md describes the new figures.

Why

Refs #1146 (second done-when item only; the texture upload cache is not part of this change).

Tested

  • Run on Linux: the pure cause cases compiled with g++ -std=c++17 -Wall -Wextra and passed; python3 -B tests/docs_links_check.py and python3 -B tests/bidi_controls_check.py passed.
  • NOT run: any MSVC or D3D12 build, including the edits in d3d12_draw.inl and d3d12_xs_device.cpp and the updated fixture. No translated draw was run, so the live counts are unverified.
  • Windows commands to run:
    • ctest --preset dev --no-tests=error -R '^startup_null_views_warp$' -V
    • ctest --preset release --no-tests=error -R '^startup_null_views_warp$' -V
**@⁠tedin7** on GitHub · 2026-11-24 05:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257) `tedin7:x2w-c3-null-bindings` → `main` · +186 −7 · 6 files · 2 commits · merged 2026-11-24 08:25 UTC ## What - Splits the `null bindings` total in the translated draw path into five causes: null or unreadable table entry, unreadable buffer address or size (including a failed frame copy), unknown view token, missing or non-resource texture wrapper, view-dimension mismatch. - The existing total keeps its meaning and its `null bindings %ld` text in the `x2w-render totals` line. The per-cause counts follow it in parentheses. - Fixes an uncounted case: the dimension-mismatch path cleared the texture without counting it. It is now counted, in the total and in its cause. - Each binding is classified once by a pure function (`src/startup_stubs/null_binding_cause.h`), so the causes always sum to the total and a missing wrapper is not counted again as a mismatch. - `startup_null_views_check` now also runs pure cases for every cause, the sum equals the total, and valid bindings add nothing. The fixture cannot read the live counters (it never draws), so the classification is what is tested. - docs/startup-runtime.md describes the new figures. ## Why Refs #1146 (second done-when item only; the texture upload cache is not part of this change). ## Tested - Run on Linux: the pure cause cases compiled with g++ -std=c++17 -Wall -Wextra and passed; `python3 -B tests/docs_links_check.py` and `python3 -B tests/bidi_controls_check.py` passed. - NOT run: any MSVC or D3D12 build, including the edits in d3d12_draw.inl and d3d12_xs_device.cpp and the updated fixture. No translated draw was run, so the live counts are unverified. - Windows commands to run: - `ctest --preset dev --no-tests=error -R '^startup_null_views_warp$' -V` - `ctest --preset release --no-tests=error -R '^startup_null_views_warp$' -V`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:52:59 +00:00
github manually merged commit d9d8b46af9 into gh-pr/1257/base 2026-11-26 22:53:01 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 05:55 UTC · original

Verified on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 0012e8ea:

  • ctest --preset dev -R "^startup_null_views_warp$" — 1/1 PASS (0.14s)
  • ctest --preset release -R "^startup_null_views_warp$" (/O2) — 1/1 PASS (0.14s)
**@⁠tedin7** on GitHub · 2026-11-24 05:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#issuecomment-7123402280) Verified on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at `0012e8ea`: - `ctest --preset dev -R "^startup_null_views_warp$"` — **1/1 PASS** (`0.14s`) - `ctest --preset release -R "^startup_null_views_warp$"` (`/O2`) — **1/1 PASS** (`0.14s`)
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 05:55 UTC · original · edited 2026-11-24 06:00 UTC

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-24T06:00:15.542978Z 0012e8e 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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 05:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#issuecomment-7123406078) · edited 2026-11-24 06:00 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"0012e8ea1a735104547a1e4c521f11eac9d3e731","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T06:00:15.542978Z">2026-11-24T06:00:15.542978Z</relative-time> | `0012e8e` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). 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. </details> </details>
@ -0,0 +30,4 @@
// A buffer that ended up bound (also through the identity fallback) is not a null binding.
if (!f.texture && f.bound) return NullCause::none;
if (f.from_table && !f.entry_readable) return NullCause::table_entry;
if (f.from_table && f.token_magic && !f.token_known) return NullCause::unknown_token;
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 06:00 UTC · original

P2 Badge Exclude successful identity fallbacks from the null counts

With X2W_DRAW_NULL_IDENTITY=1 (enabled by the launcher at tools/startup/run.ps1:49), an unreadable table entry or unknown token can be replaced successfully by the identity upload, leaving buffer_facts.bound == true. These early returns nevertheless report a null cause, so the call after buffer_view increments null bindings and entry/token even though a non-null upload-ring SRV was bound; the old if (!have) counter did not. Check a buffer's final bound state before classifying its source failure so the existing total keeps its meaning.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 06:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#discussion_r4676108111) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Exclude successful identity fallbacks from the null counts** With `X2W_DRAW_NULL_IDENTITY=1` (enabled by the launcher at `tools/startup/run.ps1:49`), an unreadable table entry or unknown token can be replaced successfully by the identity upload, leaving `buffer_facts.bound == true`. These early returns nevertheless report a null cause, so the call after `buffer_view` increments `null bindings` and `entry`/`token` even though a non-null upload-ring SRV was bound; the old `if (!have)` counter did not. Check a buffer's final `bound` state before classifying its source failure so the existing total keeps its meaning. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 06:00 UTC · original

P2 Badge Read the total and cause counts from a synchronized snapshot

When queue_present logs while another thread records a translated draw, these arguments do not form a consistent snapshot: count_null_binding increments the total and its cause separately, and this logging block reads them without draw_lock. A present scheduled between those increments can therefore report a total of 1 with every cause still 0, violating the advertised sum invariant. Copy the total and all five cause counts while holding the same draw_lock used by draw_translated, then format the snapshot.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 06:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#discussion_r4676108122) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Read the total and cause counts from a synchronized snapshot** When `queue_present` logs while another thread records a translated draw, these arguments do not form a consistent snapshot: `count_null_binding` increments the total and its cause separately, and this logging block reads them without `draw_lock`. A present scheduled between those increments can therefore report a total of 1 with every cause still 0, violating the advertised sum invariant. Copy the total and all five cause counts while holding the same `draw_lock` used by `draw_translated`, then format the snapshot. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -0,0 +30,4 @@
// A buffer that ended up bound (also through the identity fallback) is not a null binding.
if (!f.texture && f.bound) return NullCause::none;
if (f.from_table && !f.entry_readable) return NullCause::table_entry;
if (f.from_table && f.token_magic && !f.token_known) return NullCause::unknown_token;
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 06:03 UTC · original

Fixed in 5579c35a: classify_null_binding returns none for any buffer whose final state is bound, so an identity-fallback upload is no longer counted in the total or in entry/token; the old if (!have) meaning is kept. The Linux-built cases now include an unreadable entry and an unknown token that end up bound (none), next to the unbound ones (counted). Without the change they fail. The draw path itself was not built or run by me.

**@⁠tedin7** on GitHub · 2026-11-24 06:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#discussion_r4676130524) Fixed in 5579c35a: `classify_null_binding` returns none for any buffer whose final state is bound, so an identity-fallback upload is no longer counted in the total or in `entry`/`token`; the old `if (!have)` meaning is kept. The Linux-built cases now include an unreadable entry and an unknown token that end up bound (none), next to the unbound ones (counted). Without the change they fail. The draw path itself was not built or run by me.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 06:03 UTC · original

Fixed in 5579c35a: queue_present copies the total and the five causes while holding draw_lock, which draw_translated holds while it counts, and formats the copy. Only the null counters are snapshotted; the other counters on that line are unchanged. Not compiled by me (Windows headers).

**@⁠tedin7** on GitHub · 2026-11-24 06:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#discussion_r4676130789) Fixed in 5579c35a: `queue_present` copies the total and the five causes while holding `draw_lock`, which `draw_translated` holds while it counts, and formats the copy. Only the null counters are snapshotted; the other counters on that line are unchanged. Not compiled by me (Windows headers).
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 06:07 UTC · original

Verified on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 5579c35a:

  • cmake --preset dev + cmake --build --preset dev --target startup_null_views_check + ctest --preset dev -R "^startup_null_views_warp$" — 1/1 PASS (0.07s)
  • cmake --preset release + cmake --build --preset release --target startup_null_views_check (/O2) + ctest --preset release -R "^startup_null_views_warp$" — 1/1 PASS (0.10s)
**@⁠tedin7** on GitHub · 2026-11-24 06:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#issuecomment-7123616735) Verified on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at `5579c35a`: - `cmake --preset dev` + `cmake --build --preset dev --target startup_null_views_check` + `ctest --preset dev -R "^startup_null_views_warp$"` — **1/1 PASS** (`0.07s`) - `cmake --preset release` + `cmake --build --preset release --target startup_null_views_check` (`/O2`) + `ctest --preset release -R "^startup_null_views_warp$"` — **1/1 PASS** (`0.10s`)
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 08:09 UTC · original

Re-verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) after rebase at 291eb28e:

  • Debug (--preset dev): ctest --preset dev -R "^startup_null_views_warp$" — 1/1 PASS (0.06s)
  • Release /O2 (--preset release): ctest --preset release -R "^startup_null_views_warp$" — 1/1 PASS (0.06s)
**@⁠tedin7** on GitHub · 2026-11-24 08:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#issuecomment-7125791426) Re-verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) after rebase at `291eb28e`: - Debug (`--preset dev`): `ctest --preset dev -R "^startup_null_views_warp$"` — **1/1 PASS** (`0.06s`) - Release `/O2` (`--preset release`): `ctest --preset release -R "^startup_null_views_warp$"` — **1/1 PASS** (`0.06s`)
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 08:23 UTC · original

Re-verified after rebase onto main on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit d9d8b46af94a8306e1398a42ae7512c9af98a018:

  • Debug (--preset dev): startup_null_views_check build 26.00s; ctest --preset dev -R '^startup_null_views_warp$' --no-tests=error --output-on-failure: 1/1 passed (0.06s)
  • Release /O2 (--preset release): startup_null_views_check build 38.28s; ctest --preset release -R '^startup_null_views_warp$' --no-tests=error --output-on-failure: 1/1 passed (0.06s)
**@⁠tedin7** on GitHub · 2026-11-24 08:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#issuecomment-7126066745) Re-verified after rebase onto `main` on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `d9d8b46af94a8306e1398a42ae7512c9af98a018`: - **Debug (`--preset dev`)**: `startup_null_views_check` build `26.00s`; `ctest --preset dev -R '^startup_null_views_warp$' --no-tests=error --output-on-failure`: **1/1 passed** (`0.06s`) - **Release `/O2` (`--preset release`)**: `startup_null_views_check` build `38.28s`; `ctest --preset release -R '^startup_null_views_warp$' --no-tests=error --output-on-failure`: **1/1 passed** (`0.06s`)
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 06:00 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0012e8ea1a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 06:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1257#pullrequestreview-6034416307) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `0012e8ea1a` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
This discussion has been locked. Commenting is limited to contributors.
No description provided.