startup: diagnose incomplete draw buffers and root SRV spans #3597

Merged
tedin7 merged 2 commits from upstream-pr/3597 into main 2026-11-30 17:18:53 +00:00
tedin7 commented 2026-11-30 12:27:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-30T12:27:01Z.


Add bounded per-key diagnostic logging (log_incomplete_buffer, capped per shader key) when indirect translated draws refuse due to an incomplete vertex, index, or buffer SRV range, reporting the requested address/size and the nearest registered desktop buffer span via a small header-only DiagnosticSpan helper (src/startup_stubs/diagnostic_span.h).

Read-only diagnostics on existing refusal paths — zero change to draw behavior.

Tests

  • Added tests/startup_diagnostic_span_check.cpp (registered via tests/cmake/startup_diagnostic_span.cmake as startup_diagnostic_span) covering containment, distance selection, and the 64 MiB span cutoff.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5565266076 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3597). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-30T12:27:01Z. --- Add bounded per-key diagnostic logging (`log_incomplete_buffer`, capped per shader key) when indirect translated draws refuse due to an incomplete vertex, index, or buffer SRV range, reporting the requested address/size and the nearest registered desktop buffer span via a small header-only `DiagnosticSpan` helper (`src/startup_stubs/diagnostic_span.h`). Read-only diagnostics on existing refusal paths — zero change to draw behavior. ## Tests - Added `tests/startup_diagnostic_span_check.cpp` (registered via `tests/cmake/startup_diagnostic_span.cmake` as `startup_diagnostic_span`) covering containment, distance selection, and the 64 MiB span cutoff.
chatgpt-codex-connector[bot] commented 2026-11-30 12:27:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-30T12:27:14Z.


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-30T12:31:44.286052Z 77e6891 PR opened
ℹ️ 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7278458386 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3597#issuecomment-7278458386). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-30T12:27:14Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"77e689167f71ad07c9c43122b77e36fdc07804bc","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-30T12:31:44.286052Z">2026-11-30T12:31:44.286052Z</relative-time> | `77e6891` | PR opened | <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>
chatgpt-codex-connector[bot] commented 2026-11-30 12:31:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-30T12:31:41Z.

Code review location: src/startup_stubs/d3d12_draw.inl; line 3825

@@ -3765,6 +3822,8 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI
                                     : "translated draw requires a complete GPU-backed table buffer range",
                     srv.source == 1 ? indirect_refusal_code::incomplete_vertex_stream
                                     : indirect_refusal_code::incomplete_table_buffer);
+                log_incomplete_buffer(tr->key, i, srv.source, srv.a, address, bytes, "incomplete GPU-backed buffer range");

P2 Badge Log the decoded table range on indirect-buffer refusals

For an indirect descriptor-table SRV (srv.source == 0), address and bytes are still zero here: only vertex/root bindings initialize these locals above, and the outer table-range decoding occurs below this early return. indirect_table_buffer decodes the descriptor internally but does not update those locals. Consequently, a non-null range that crosses its backing allocation is misleadingly logged as address 0x0 bytes 0, discarding the information this diagnostic is intended to expose. Populate the diagnostic fields from the descriptor or resolver before emitting both new early-refusal logs.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4739196822 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3597#discussion_r4739196822). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-30T12:31:41Z. **Code review location:** `src/startup_stubs/d3d12_draw.inl`; line 3825 ~~~~diff @@ -3765,6 +3822,8 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI : "translated draw requires a complete GPU-backed table buffer range", srv.source == 1 ? indirect_refusal_code::incomplete_vertex_stream : indirect_refusal_code::incomplete_table_buffer); + log_incomplete_buffer(tr->key, i, srv.source, srv.a, address, bytes, "incomplete GPU-backed buffer range"); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Log the decoded table range on indirect-buffer refusals** For an indirect descriptor-table SRV (`srv.source == 0`), `address` and `bytes` are still zero here: only vertex/root bindings initialize these locals above, and the outer table-range decoding occurs below this early return. `indirect_table_buffer` decodes the descriptor internally but does not update those locals. Consequently, a non-null range that crosses its backing allocation is misleadingly logged as `address 0x0 bytes 0`, discarding the information this diagnostic is intended to expose. Populate the diagnostic fields from the descriptor or resolver before emitting both new early-refusal logs. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-30 12:31:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-30T12:31:41Z.

Code review location: tests/startup_diagnostic_span_check.cpp; line 2

@@ -0,0 +1,22 @@
+#include "startup_stubs/diagnostic_span.h"
+#include <cassert>

P2 Badge Keep the diagnostic-span checks active in Release builds

With the release preset, NDEBUG disables every assertion in this test, so the new CTest reports success without checking any result in the Release suite run by .github/workflows/windows.yml. I verified this with a standalone build: changing diagnostic_span.h:11 from gap <= to gap < fails the Debug check but still exits successfully with -O2 -DNDEBUG. Undefine NDEBUG before including <cassert>, as the other assertion-based checks do, or use explicit failure checks so Release builds retain the regression coverage.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4739196834 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3597#discussion_r4739196834). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-30T12:31:41Z. **Code review location:** `tests/startup_diagnostic_span_check.cpp`; line 2 ~~~~diff @@ -0,0 +1,22 @@ +#include "startup_stubs/diagnostic_span.h" +#include <cassert> ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Keep the diagnostic-span checks active in Release builds** With the `release` preset, `NDEBUG` disables every assertion in this test, so the new CTest reports success without checking any result in the Release suite run by `.github/workflows/windows.yml`. I verified this with a standalone build: changing `diagnostic_span.h:11` from `gap <=` to `gap <` fails the Debug check but still exits successfully with `-O2 -DNDEBUG`. Undefine `NDEBUG` before including `<cassert>`, as the other assertion-based checks do, or use explicit failure checks so Release builds retain the regression coverage. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-30 12:31:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-30T12:31:41Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77e689167f

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6112207428 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3597#pullrequestreview-6112207428). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-30T12:31:41Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `77e689167f` <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>
R0Y00 commented 2026-11-30 17:17:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-30T17:17:57Z.

Review: APPROVED


Verified that the indirect-table decode now reports address and span back to the refusal log, including when backing lookup fails after decoding. The environment-gated root diagnostic uses the existing table and allocator locks. Built tests/startup_diagnostic_span_check.cpp with MSVC C++17 and ran it successfully on Windows, covering exact containment, both proximity bounds and overflow. This run covered the helper, not a live draw.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6116957950 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3597#pullrequestreview-6116957950). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-30T17:17:57Z. **Review:** APPROVED --- Verified that the indirect-table decode now reports address and span back to the refusal log, including when backing lookup fails after decoding. The environment-gated root diagnostic uses the existing table and allocator locks. Built `tests/startup_diagnostic_span_check.cpp` with MSVC C++17 and ran it successfully on Windows, covering exact containment, both proximity bounds and overflow. This run covered the helper, not a live draw.
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!3597
No description provided.