startup: bind the resource-heap image record of a translated pixel draw #2755

Closed
tedin7 wants to merge 9 commits from upstream-pr/2763 into main
tedin7 commented 2026-11-26 06:40:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T06:40:52Z.


Part of #1723

What this unblocks: a translated pixel draw can now bind the image record a root constant indexes in the title's resource heap (the manifest line from #2761), so the heap-loaded image path works end to end instead of stopping at the manifest. Stacked on #2761 (translator and manifest); the diff shows only the runtime half once that merges.
Source: AMD "RDNA 2" Instruction Set Architecture reference guide, SMEM instruction S_LOAD_DWORDX8 (image resource descriptor load); Microsoft D3D12 documentation, descriptor heaps and CreateShaderResourceView.

What changed (src/startup_stubs/d3d12_draw.inl):

  • The graphics manifest reader accepts srv N tex* heap rootconst P W and heap word table T B at A [rootconst P W times S [mask M]]. Any other heap line, a non-texture kind, or a heap SRV next to a writable texture refuses the translation by name (the old reader silently skipped lines it could not parse).
  • heap_srvs_ready runs before the draw changes any state. It reads the index from the draw's root constants, or from the word the title wrote in the recording's upload memory (same bounds rules as the compute dispatch), takes the 32-byte record at index << 5 of the list's view heap, and requires it to be a shader-resource view the title created. Anything else refuses the whole draw with a logged reason; no texture is guessed. Indirect draws are refused.
  • The existing SRV binding loop then takes that record like a table entry.

Tests: startup_pixel_heap_srv (host controls, fixture words checked against assembly, and WARP/hardware draws with fxc and dxc). The draw uses a two-entry heap with two different textures, swaps them between two passes, and draws keys 0..3: keys 0 and 1 must show the texture at their record (so an index that is ignored or not re-read fails), keys 2 and 3 name records the heap does not hold and must be refused by name and leave the cleared target.

Verification (Linux only; no Win2025 run yet):

  • python3 -B tests/startup_pixel_heap_srv_check.py: host controls PASS
  • python3 -B tests/startup_pixel_heap_srv_check.py binary llvm-mc-19: fixture words match
  • startup_gfx2hlsl_pixel_heap_image, startup_gfx2hlsl_heap_record, startup_gfx2hlsl_heap_word: PASS
  • the runtime unit compiles only on Windows: not built locally

Draft until an independent review and a Win2025 WARP run of the draw tests.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6621078464 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:40:52Z. --- Part of #1723 What this unblocks: a translated pixel draw can now bind the image record a root constant indexes in the title's resource heap (the manifest line from #2761), so the heap-loaded image path works end to end instead of stopping at the manifest. Stacked on #2761 (translator and manifest); the diff shows only the runtime half once that merges. Source: AMD "RDNA 2" Instruction Set Architecture reference guide, SMEM instruction S_LOAD_DWORDX8 (image resource descriptor load); Microsoft D3D12 documentation, descriptor heaps and `CreateShaderResourceView`. What changed (`src/startup_stubs/d3d12_draw.inl`): - The graphics manifest reader accepts `srv N tex* heap rootconst P W` and `heap word table T B at A [rootconst P W times S [mask M]]`. Any other `heap` line, a non-texture kind, or a heap SRV next to a writable texture refuses the translation by name (the old reader silently skipped lines it could not parse). - `heap_srvs_ready` runs before the draw changes any state. It reads the index from the draw's root constants, or from the word the title wrote in the recording's upload memory (same bounds rules as the compute dispatch), takes the 32-byte record at `index << 5` of the list's view heap, and requires it to be a shader-resource view the title created. Anything else refuses the whole draw with a logged reason; no texture is guessed. Indirect draws are refused. - The existing SRV binding loop then takes that record like a table entry. Tests: `startup_pixel_heap_srv` (host controls, fixture words checked against assembly, and WARP/hardware draws with fxc and dxc). The draw uses a two-entry heap with two different textures, swaps them between two passes, and draws keys 0..3: keys 0 and 1 must show the texture at their record (so an index that is ignored or not re-read fails), keys 2 and 3 name records the heap does not hold and must be refused by name and leave the cleared target. Verification (Linux only; no Win2025 run yet): - `python3 -B tests/startup_pixel_heap_srv_check.py`: host controls PASS - `python3 -B tests/startup_pixel_heap_srv_check.py binary llvm-mc-19`: fixture words match - `startup_gfx2hlsl_pixel_heap_image`, `startup_gfx2hlsl_heap_record`, `startup_gfx2hlsl_heap_word`: PASS - the runtime unit compiles only on Windows: not built locally Draft until an independent review and a Win2025 WARP run of the draw tests. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-26 08:01:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T07:09:57Z.


Independent Windows Release review of 78cf80ff found two fixture issues. The four draw CTests originally returned 77. Their versioned serializer accepts only root CBV/SRV, while this fixture passes a descriptor table and a 32-bit root constant. Copy the table ranges and Constants into the 1.1 payload, and report serialization errors as fixture failures. Once the draw actually runs, WARP samples the second texture for key 2. On WARP the second native slot is at byte 64, which the fixture also presents as record 2 after memmove copies its token to the packed record at byte 32. Clear the bytes after the two packed records in the heap fixture after each move. The other joined-table test can keep its current bytes.

I made both fixture corrections in an isolated checkout. All four FXC/DXC × WARP/RTX 4060 Laptop draws pass, following the swapped first two records and refusing all four invalid draws across the two passes. All 10 CTests in ^(startup_pixel_heap_srv_.|startup_gfx2hlsl_(heap_record|heap_word|pixel_heap_image)|startup_root_cbv_.)$ pass, zero skips, Windows 11 build 26200. This is the source-built root-constant path. A source-built draw through the separate table-buffer word path is still needed to establish that runtime binding.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185164501 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#issuecomment-7185164501). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T07:09:57Z. --- Independent Windows Release review of 78cf80ff found two fixture issues. The four draw CTests originally returned 77. Their versioned serializer accepts only root CBV/SRV, while this fixture passes a descriptor table and a 32-bit root constant. Copy the table ranges and Constants into the 1.1 payload, and report serialization errors as fixture failures. Once the draw actually runs, WARP samples the second texture for key 2. On WARP the second native slot is at byte 64, which the fixture also presents as record 2 after memmove copies its token to the packed record at byte 32. Clear the bytes after the two packed records in the heap fixture after each move. The other joined-table test can keep its current bytes. I made both fixture corrections in an isolated checkout. All four FXC/DXC × WARP/RTX 4060 Laptop draws pass, following the swapped first two records and refusing all four invalid draws across the two passes. All 10 CTests in ^(startup_pixel_heap_srv_.*|startup_gfx2hlsl_(heap_record|heap_word|pixel_heap_image)|startup_root_cbv_.*)$ pass, zero skips, Windows 11 build 26200. This is the source-built root-constant path. A source-built draw through the separate table-buffer word path is still needed to establish that runtime binding.
tedin7 commented 2026-11-26 08:01:57 +00:00 (Migrated from github.com)

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


Thank you, both findings are right and are fixed in the next push.

  • serialize_root (tests/startup_stream_setup.cpp) now copies descriptor-table ranges and 32-bit constants into the 1.1 payload. A serializer failure now returns a fixture failure (6), not a capability skip.
  • The heap fixture clears every byte after the two packed records after each move (heap case only), so key 2 and key 3 name records that do not exist. The other joined-table test keeps its bytes.

Still open, as you noted: a source-built draw through the table-buffer word form (heap word table ... at ...). The runtime path for it is written but has no draw proof yet; I will add that case next and say here when it is pushed. This stays a Draft until then.

Verification: Linux host controls (startup_pixel_heap_srv_cpu, startup_gfx2hlsl_heap_record, startup_gfx2hlsl_heap_word, startup_gfx2hlsl_pixel_heap_image) rerun after the change. The two edits are C++ fixture code; I rely on your Windows run for them and will rerun after pushing.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185875600 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#issuecomment-7185875600). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T07:49:33Z. --- Thank you, both findings are right and are fixed in the next push. - `serialize_root` (tests/startup_stream_setup.cpp) now copies descriptor-table ranges and 32-bit constants into the 1.1 payload. A serializer failure now returns a fixture failure (6), not a capability skip. - The heap fixture clears every byte after the two packed records after each move (heap case only), so key 2 and key 3 name records that do not exist. The other joined-table test keeps its bytes. Still open, as you noted: a source-built draw through the table-buffer word form (`heap word table ... at ...`). The runtime path for it is written but has no draw proof yet; I will add that case next and say here when it is pushed. This stays a Draft until then. Verification: Linux host controls (`startup_pixel_heap_srv_cpu`, `startup_gfx2hlsl_heap_record`, `startup_gfx2hlsl_heap_word`, `startup_gfx2hlsl_pixel_heap_image`) rerun after the change. The two edits are C++ fixture code; I rely on your Windows run for them and will rerun after pushing. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 09:04:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T08:51:22Z.


Pushed the table-buffer word draw case the review asked for (head 5989abe7).

  • New fixture mode in tests/startup_address_srv.cpp (X2W_TEST_HEAP_SRV=word): the heap index is a word of a buffer in the recording's upload memory, whose hardware descriptor sits at table byte 64. Keys 0 and 1 name records 1 and 0 (so a draw that ignored the word, or read the root constant as the index, shows the wrong texture); keys 2 and 3 name records 5 and 7, past the heap, and must be refused. The manifest line is srv 1 tex2d heap word table 0 64 at 0 rootconst 1 0 times 4.
  • A real bug surfaced while writing it: the graphics manifest builder evaluated its lookup table eagerly and crashed on a heap word source (%d of the string word). Fixed in tools/startup/gfx2hlsl.py.
  • Registered as startup_pixel_heap_srv_word_{fxc,dxc}_{warp,hardware}.

Verification (self-check, not the independent run): bash runpod_test.sh 2763 --regex startup_pixel_heap_srv on the pod, 9 of 9 passed (cpu, plus root-constant and word cases for fxc and dxc on WARP and on the GPU), tested on RTX 3090 through vkd3d-proton (Linux). Host controls and startup_gfx2hlsl_{heap_record,heap_word,pixel_heap_image} pass; 173 translation shapes unchanged against origin/main.

Still a Draft until the independent Windows run of this head.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7187103447 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#issuecomment-7187103447). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T08:51:22Z. --- Pushed the table-buffer word draw case the review asked for (head `5989abe7`). - New fixture mode in `tests/startup_address_srv.cpp` (`X2W_TEST_HEAP_SRV=word`): the heap index is a word of a buffer in the recording's upload memory, whose hardware descriptor sits at table byte 64. Keys 0 and 1 name records 1 and 0 (so a draw that ignored the word, or read the root constant as the index, shows the wrong texture); keys 2 and 3 name records 5 and 7, past the heap, and must be refused. The manifest line is `srv 1 tex2d heap word table 0 64 at 0 rootconst 1 0 times 4`. - A real bug surfaced while writing it: the graphics manifest builder evaluated its lookup table eagerly and crashed on a `heap word` source (`%d` of the string `word`). Fixed in `tools/startup/gfx2hlsl.py`. - Registered as `startup_pixel_heap_srv_word_{fxc,dxc}_{warp,hardware}`. Verification (self-check, not the independent run): `bash runpod_test.sh 2763 --regex startup_pixel_heap_srv` on the pod, 9 of 9 passed (cpu, plus root-constant and word cases for fxc and dxc on WARP and on the GPU), tested on RTX 3090 through vkd3d-proton (Linux). Host controls and `startup_gfx2hlsl_{heap_record,heap_word,pixel_heap_image}` pass; 173 translation shapes unchanged against `origin/main`. Still a Draft until the independent Windows run of this head. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 10:03:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T09:16:04Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5989abe792

ℹ️ 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:6071354859 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#pullrequestreview-6071354859). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T09:16:04Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `5989abe792` <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>
tedin7 commented 2026-11-26 10:04:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:04:56Z.


Independent Stage-2 review of head 5989abe792: PASS (round 2; the first round failed because all four draw tests skipped).

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 5989abe792454b9f896deb061ce1cffecb84446b:

  • Debug (--preset dev):

    • Build (cmake --build --preset dev --target startup_stream_consumer d3d12_xs_shim -- -j 2): 23.37s (configure 1.90s)
    • Test (ctest --preset dev -R '^(startup_pixel_heap_srv|startup_gfx2hlsl_pixel_heap_image|startup_gfx2hlsl_heap_record|startup_gfx2hlsl_heap_word|startup_address_srv|startup_stream|startup_shader_cache)' --parallel 3 --no-tests=error --output-on-failure): 34/34 passed (12.24s: startup_stream_draw_warp 2.82s, startup_stream_depth_warp 3.69s, startup_stream_depth_hardware 3.69s, startup_stream_fetch_hardware 1.12s, startup_stream_fetch_warp 1.30s, startup_stream_draw_hardware 2.75s, startup_stream_request_warp 0.84s, startup_stream_viewport_warp 0.76s, startup_shader_cache_key 0.48s, startup_address_srv_warp 0.60s, startup_stream_viewport_hardware 0.84s, startup_stream_interface_warp 0.65s, startup_stream_rasterizer_hardware 0.77s, startup_stream_interface_hardware 0.63s, startup_stream_rasterizer_warp 0.75s, `startup_st
  • Release /O2 (--preset release):

    • Build (cmake --build --preset release --target startup_stream_consumer d3d12_xs_shim -- -j 2): 38.49s (configure 1.91s)
    • Test (ctest --preset release -R '^(startup_pixel_heap_srv|startup_gfx2hlsl_pixel_heap_image|startup_gfx2hlsl_heap_record|startup_gfx2hlsl_heap_word|startup_address_srv|startup_stream|startup_shader_cache)' --parallel 3 --no-tests=error --output-on-failure): 34/34 passed (10.89s: startup_stream_draw_warp 2.41s, startup_stream_depth_hardware 3.04s, startup_stream_depth_warp 3.09s, startup_stream_request_warp 0.80s, startup_stream_fetch_warp 1.05s, startup_stream_viewport_warp 0.64s, startup_stream_fetch_hardware 1.01s, startup_stream_draw_hardware 2.46s, startup_stream_interface_warp 0.56s, startup_address_srv_warp 0.58s, startup_stream_viewport_hardware 0.73s, startup_shader_cache_key 0.47s, startup_stream_rasterizer_warp 0.71s, startup_stream_rasterizer_hardware 0.72s, startup_stream_rasterizer_ignore_hardware 0.65s,
  • sccache: 0/8 hits; wall 183.2s

  • The PR's own tests all ran and passed (no skips): startup_pixel_heap_srv_cpu and the eight draws startup_pixel_heap_srv_{fxc,dxc}_{warp,hardware} and startup_pixel_heap_srv_word_{fxc,dxc}_{warp,hardware}; the author reports RTX 3090 through vkd3d-proton 9/9.

  • Linux: python3 -B tests/startup_pixel_heap_srv_check.py (+ binary llvm-mc-19), startup_gfx2hlsl_pixel_heap_image, heap_record, heap_word: pass; 173 existing translation shapes unchanged against origin/main; the workflow's Python check list shows only the failures origin/main has in the same environment.

  • Not blocking: the word path reads the index word when the draw is recorded, like the compute dispatch, so a title that writes the upload word after recording but before submit would be read stale; worth one sentence in the body.

Marked Ready. @MasterDomino

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7187390837 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#issuecomment-7187390837). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T09:04:56Z. --- Independent Stage-2 review of head 5989abe792454b9f896deb061ce1cffecb84446b: PASS (round 2; the first round failed because all four draw tests skipped). Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `5989abe792454b9f896deb061ce1cffecb84446b`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target startup_stream_consumer d3d12_xs_shim -- -j 2`): `23.37s` (configure `1.90s`) - Test (`ctest --preset dev -R '^(startup_pixel_heap_srv|startup_gfx2hlsl_pixel_heap_image|startup_gfx2hlsl_heap_record|startup_gfx2hlsl_heap_word|startup_address_srv|startup_stream|startup_shader_cache)' --parallel 3 --no-tests=error --output-on-failure`): **34/34 passed** (`12.24s`: `startup_stream_draw_warp` `2.82s`, `startup_stream_depth_warp` `3.69s`, `startup_stream_depth_hardware` `3.69s`, `startup_stream_fetch_hardware` `1.12s`, `startup_stream_fetch_warp` `1.30s`, `startup_stream_draw_hardware` `2.75s`, `startup_stream_request_warp` `0.84s`, `startup_stream_viewport_warp` `0.76s`, `startup_shader_cache_key` `0.48s`, `startup_address_srv_warp` `0.60s`, `startup_stream_viewport_hardware` `0.84s`, `startup_stream_interface_warp` `0.65s`, `startup_stream_rasterizer_hardware` `0.77s`, `startup_stream_interface_hardware` `0.63s`, `startup_stream_rasterizer_warp` `0.75s`, `startup_st - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target startup_stream_consumer d3d12_xs_shim -- -j 2`): `38.49s` (configure `1.91s`) - Test (`ctest --preset release -R '^(startup_pixel_heap_srv|startup_gfx2hlsl_pixel_heap_image|startup_gfx2hlsl_heap_record|startup_gfx2hlsl_heap_word|startup_address_srv|startup_stream|startup_shader_cache)' --parallel 3 --no-tests=error --output-on-failure`): **34/34 passed** (`10.89s`: `startup_stream_draw_warp` `2.41s`, `startup_stream_depth_hardware` `3.04s`, `startup_stream_depth_warp` `3.09s`, `startup_stream_request_warp` `0.80s`, `startup_stream_fetch_warp` `1.05s`, `startup_stream_viewport_warp` `0.64s`, `startup_stream_fetch_hardware` `1.01s`, `startup_stream_draw_hardware` `2.46s`, `startup_stream_interface_warp` `0.56s`, `startup_address_srv_warp` `0.58s`, `startup_stream_viewport_hardware` `0.73s`, `startup_shader_cache_key` `0.47s`, `startup_stream_rasterizer_warp` `0.71s`, `startup_stream_rasterizer_hardware` `0.72s`, `startup_stream_rasterizer_ignore_hardware` `0.65s`, - `sccache`: 0/8 hits; wall `183.2s` - The PR's own tests all ran and passed (no skips): `startup_pixel_heap_srv_cpu` and the eight draws `startup_pixel_heap_srv_{fxc,dxc}_{warp,hardware}` and `startup_pixel_heap_srv_word_{fxc,dxc}_{warp,hardware}`; the author reports RTX 3090 through vkd3d-proton 9/9. - Linux: `python3 -B tests/startup_pixel_heap_srv_check.py` (+ `binary llvm-mc-19`), `startup_gfx2hlsl_pixel_heap_image`, `heap_record`, `heap_word`: pass; 173 existing translation shapes unchanged against `origin/main`; the workflow's Python check list shows only the failures `origin/main` has in the same environment. - Not blocking: the word path reads the index word when the draw is recorded, like the compute dispatch, so a title that writes the upload word after recording but before submit would be read stale; worth one sentence in the body. Marked Ready. @MasterDomino AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 10:04:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T09:05:06Z.


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-26T09:16:07.895032Z 5989abe 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7187395015 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#issuecomment-7187395015). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T09:05:06Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5989abe792454b9f896deb061ce1cffecb84446b","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-26T09:16:07.895032Z">2026-11-26T09:16:07.895032Z</relative-time> | `5989abe` | 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>
chatgpt-codex-connector[bot commented 2026-11-26 10:04:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T09:16:04Z.

Code review location: tools/startup/gfx2hlsl.py; line 5336

@@ -5316,10 +5316,25 @@ def mark_heap_index(self, base, d, srcs, syms):
                 k = lit[1 - i]
                 offset = self.heap_word_offset(srcs[i], syms[i]) if k is not None else None
                 if offset:
-                    p, w, scale, add = offset
+                    p, w, scale, add, *mask = offset
+                    if mask:
+                        # (word & mask) plus a literal: the add keeps the mask, a multiply would need a scale of the masked word.
+                        if base != 's_mul_i32':
+                            self.heap_index[d] = ('rc', p, w, scale, add + k & 0xffffffff, mask[0])
+                        break
                     self.heap_index[d] = (('rc', p, w, scale * k & 0xffffffff, add * k & 0xffffffff) if base == 's_mul_i32'
                                           else ('rc', p, w, scale, add + k & 0xffffffff))
                     break
+        elif base == 's_and_b32' and len(srcs) == 2 and getattr(self, 'kind', None) == 'ps':
+            # root constant word AND a literal: the draw's own constant, read when the draw is bound (pixel stage only: the
+            # compute dispatch does not read a mask).
+            for i in (0, 1):
+                # an inline constant such as -16 is a negative decimal
+                k = int(srcs[1 - i], 0) & 0xffffffff if re.fullmatch(r'-?(0x[0-9a-f]+|[0-9]+)', srcs[1 - i]) else None
+                offset = self.heap_word_offset(srcs[i], syms[i]) if k is not None else None
+                if offset and len(offset) == 4 and offset[2:] == (1, 0):
+                    self.heap_index[d] = ('rc', offset[0], offset[1], 1, 0, k)

P1 Badge Handle masked offsets in the SOPK tracking consumer

For a pixel shader that masks a root constant and then applies s_addk_i32 or s_mulk_i32 to that SGPR, this new mark makes heap_word_offset() return five values, but scalar_accumulate() still unpacks exactly four at line 5437. A synthetic binary containing s_and_b32 s28, s9, -16 followed by s_addk_i32 s28, 0x10 translates on the parent commit but raises ValueError: too many values to unpack (expected 4) here; the multiply form fails identically. Tracking runs on every pixel shader, so this also breaks previously supported shaders without heap indexing enabled. Update the SOPK consumer to handle the new masked shape.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4706113060 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#discussion_r4706113060). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T09:16:04Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 5336 ~~~~diff @@ -5316,10 +5316,25 @@ def mark_heap_index(self, base, d, srcs, syms): k = lit[1 - i] offset = self.heap_word_offset(srcs[i], syms[i]) if k is not None else None if offset: - p, w, scale, add = offset + p, w, scale, add, *mask = offset + if mask: + # (word & mask) plus a literal: the add keeps the mask, a multiply would need a scale of the masked word. + if base != 's_mul_i32': + self.heap_index[d] = ('rc', p, w, scale, add + k & 0xffffffff, mask[0]) + break self.heap_index[d] = (('rc', p, w, scale * k & 0xffffffff, add * k & 0xffffffff) if base == 's_mul_i32' else ('rc', p, w, scale, add + k & 0xffffffff)) break + elif base == 's_and_b32' and len(srcs) == 2 and getattr(self, 'kind', None) == 'ps': + # root constant word AND a literal: the draw's own constant, read when the draw is bound (pixel stage only: the + # compute dispatch does not read a mask). + for i in (0, 1): + # an inline constant such as -16 is a negative decimal + k = int(srcs[1 - i], 0) & 0xffffffff if re.fullmatch(r'-?(0x[0-9a-f]+|[0-9]+)', srcs[1 - i]) else None + offset = self.heap_word_offset(srcs[i], syms[i]) if k is not None else None + if offset and len(offset) == 4 and offset[2:] == (1, 0): + self.heap_index[d] = ('rc', offset[0], offset[1], 1, 0, k) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Handle masked offsets in the SOPK tracking consumer** For a pixel shader that masks a root constant and then applies `s_addk_i32` or `s_mulk_i32` to that SGPR, this new mark makes `heap_word_offset()` return five values, but `scalar_accumulate()` still unpacks exactly four at line 5437. A synthetic binary containing `s_and_b32 s28, s9, -16` followed by `s_addk_i32 s28, 0x10` translates on the parent commit but raises `ValueError: too many values to unpack (expected 4)` here; the multiply form fails identically. Tracking runs on every pixel shader, so this also breaks previously supported shaders without heap indexing enabled. Update the SOPK consumer to handle the new masked shape. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 10:04:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T09:16:05Z.

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

@@ -1574,6 +1614,69 @@ void draw_dump_flush()
     log("x2w-draw per-draw dump: %d of %zu completed target copies written to %s", written, completed.size(), folder);
 }
 
+// The heap records a translation's `heap` SRVs name, found now: the index is read from the draw's root constants or from the
+// word the title wrote in the recording's upload memory, and the 32-byte record at index << 5 of the list's view heap must be
+// a view the title created for a texture. Anything else refuses the whole draw (it is not translated), never a guessed texture.
+bool heap_srvs_ready(Wrapper* self, const Translation& tr, const Pass& pass, bool indirect, u64 (&entries)[32])
+{
+    const auto refuse = [&](UINT slot, const char* reason, u64 detail) {
+        static LONG refused;
+        if (first_calls(refused, 8))
+            log("x2w-draw %016llx srv %u: heap record refused (%s %llx); draw not translated", tr.key, slot, reason, detail);
+        return false;
+    };
+    for (UINT i = 0; i < tr.srvs.size() && i < 32; ++i) {
+        const Translation::Srv& srv = tr.srvs[i];
+        if (srv.source != 3) continue;
+        if (indirect) return refuse(i, "indirect draw", 0);
+        const auto constant = [&]() -> std::uint64_t {
+            return srv.a >= 0 && srv.a < 16 && srv.b >= 0 && srv.b < 8 ? pass.constants[srv.a][srv.b] : ~u64{0};
+        };
+        std::uint32_t index = 0;
+        if (srv.word_param < 0) {
+            const std::uint64_t value = constant();
+            if (value == ~u64{0}) return refuse(i, "root constant out of range", srv.a);
+            index = static_cast<std::uint32_t>(value);
+        } else {
+            std::uint64_t extra = 0;
+            if (srv.a >= 0) {
+                const std::uint64_t value = constant();
+                if (value == ~u64{0}) return refuse(i, "root constant out of range", srv.a);
+                extra = u64{static_cast<std::uint32_t>(value) & srv.mask} * srv.times;
+            }
+            if (srv.word_param >= 16 || srv.word_byte < 0) return refuse(i, "table out of range", srv.word_param);
+            const u64 table_entry = pass.view_tables[srv.word_param].record(static_cast<u64>(srv.word_byte), 16);
+            std::uint32_t table_words[4] = {};
+            if (!table_entry || !x2w_local::readable(reinterpret_cast<const void*>(table_entry), 16))
+                return refuse(i, "table buffer descriptor is not bound", srv.word_param);
+            std::memcpy(table_words, reinterpret_cast<const void*>(table_entry), 16);
+            const u64 at = u64{srv.at} + extra;

P2 Badge Preserve DWORD wraparound when resolving heap offsets

When a table-word offset wraps 32-bit arithmetic, this 64-bit reconstruction disagrees with the translated shader. The added word fixture computes s28 = ud1 * 4u: with ud1 == 0x40000000, the guest and HLSL read byte zero of the buffer, but heap_srvs_ready() computes an offset of 4 GiB and refuses the valid draw. The compute resolver already uses std::uint32_t at for the same manifest form. Apply DWORD wraparound before checking the upload and buffer bounds; likewise, the later index > (0xffffffffu >> 5) guard rejects valid wrapped record addresses whose high bits the shader's index << 5 discards.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4706113072 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#discussion_r4706113072). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T09:16:05Z. **Code review location:** `src/startup_stubs/d3d12_draw.inl`; line 1653 ~~~~diff @@ -1574,6 +1614,69 @@ void draw_dump_flush() log("x2w-draw per-draw dump: %d of %zu completed target copies written to %s", written, completed.size(), folder); } +// The heap records a translation's `heap` SRVs name, found now: the index is read from the draw's root constants or from the +// word the title wrote in the recording's upload memory, and the 32-byte record at index << 5 of the list's view heap must be +// a view the title created for a texture. Anything else refuses the whole draw (it is not translated), never a guessed texture. +bool heap_srvs_ready(Wrapper* self, const Translation& tr, const Pass& pass, bool indirect, u64 (&entries)[32]) +{ + const auto refuse = [&](UINT slot, const char* reason, u64 detail) { + static LONG refused; + if (first_calls(refused, 8)) + log("x2w-draw %016llx srv %u: heap record refused (%s %llx); draw not translated", tr.key, slot, reason, detail); + return false; + }; + for (UINT i = 0; i < tr.srvs.size() && i < 32; ++i) { + const Translation::Srv& srv = tr.srvs[i]; + if (srv.source != 3) continue; + if (indirect) return refuse(i, "indirect draw", 0); + const auto constant = [&]() -> std::uint64_t { + return srv.a >= 0 && srv.a < 16 && srv.b >= 0 && srv.b < 8 ? pass.constants[srv.a][srv.b] : ~u64{0}; + }; + std::uint32_t index = 0; + if (srv.word_param < 0) { + const std::uint64_t value = constant(); + if (value == ~u64{0}) return refuse(i, "root constant out of range", srv.a); + index = static_cast<std::uint32_t>(value); + } else { + std::uint64_t extra = 0; + if (srv.a >= 0) { + const std::uint64_t value = constant(); + if (value == ~u64{0}) return refuse(i, "root constant out of range", srv.a); + extra = u64{static_cast<std::uint32_t>(value) & srv.mask} * srv.times; + } + if (srv.word_param >= 16 || srv.word_byte < 0) return refuse(i, "table out of range", srv.word_param); + const u64 table_entry = pass.view_tables[srv.word_param].record(static_cast<u64>(srv.word_byte), 16); + std::uint32_t table_words[4] = {}; + if (!table_entry || !x2w_local::readable(reinterpret_cast<const void*>(table_entry), 16)) + return refuse(i, "table buffer descriptor is not bound", srv.word_param); + std::memcpy(table_words, reinterpret_cast<const void*>(table_entry), 16); + const u64 at = u64{srv.at} + extra; ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Preserve DWORD wraparound when resolving heap offsets** When a table-word offset wraps 32-bit arithmetic, this 64-bit reconstruction disagrees with the translated shader. The added word fixture computes `s28 = ud1 * 4u`: with `ud1 == 0x40000000`, the guest and HLSL read byte zero of the buffer, but `heap_srvs_ready()` computes an offset of 4 GiB and refuses the valid draw. The compute resolver already uses `std::uint32_t at` for the same manifest form. Apply DWORD wraparound before checking the upload and buffer bounds; likewise, the later `index > (0xffffffffu >> 5)` guard rejects valid wrapped record addresses whose high bits the shader's `index << 5` discards. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
upstream-sync closed this pull request 2026-11-26 11:02:45 +00:00
thepatrickworld commented 2026-11-26 11:02:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T10:04:12Z.


Independent AMD RDNA 4 result on 80a17a3d: both heap-record draw forms pass on a real GPU, with fxc and dxc

Not a code change; measurements only. The word case arrived at 5989abe7; the independent Windows review in this thread is on 78cf80ff, before it, and the author's own run of it is the RunPod one. This adds one more independent run of the current head, on an AMD adapter instead of the RTX 4060.

Environment

Captured on the machine at run time:

Microsoft Windows [version 10.0.26200.9974]  build 26200
Compilateur d'optimisation Microsoft (R) C/C++ version 19.44.35230 pour x64
toolset directory: 14.44.35207
dxc.exe 1.9.2602.17   fxc.exe 10.0.26100.9457 (Windows Kits 10.0.26100.0)
AMD Radeon RX 9070 XT driver=32.0.32029.2010 date=11/18/2026
  • git rev-parse HEAD printed 80a17a3d289e2df8f6ca7482c935d6a6328fe4fa. git status --porcelain printed nothing: it is the first thing the run log and the neighbour log record, and it is empty again in the environment capture taken after the runs.
  • Preset dev. ctest --preset dev -N reports Total Tests: 2405, and ctest --preset dev -N -R startup_pixel_heap_srv lists the nine entries (Total Tests: 9 for that filter), so they were built rather than dropped for a missing interpreter.
  • Adapter selection (pick_stream_adapter, in tests/startup_stream_setup.cpp, code this pull request does not touch): by GPU preference, software-flagged adapters skipped, then the name filter and a D3D12 device at feature level 12_0. The draw's own printed line below says which adapter won.
  • Validation layer: Test-Path C:\Windows\System32\d3d12SDKLayers.dll is False (d3d12.dll is 10.0.26100.9818) and X2W_TEST_DEBUG_LAYER was not set, so no validation-layer output was captured and none is claimed.

Commands

cd /d C:\Users\walde\Downloads\x2w-2741
git fetch origin +pull/2763/head:panam2763
git checkout -f panam2763
git rev-parse HEAD                        :: 80a17a3d289e2df8f6ca7482c935d6a6328fe4fa
git status --porcelain                    :: empty
cmake --build --preset dev --target startup_stream_consumer d3d12_xs_shim
set "XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT"
ctest --preset dev --no-tests=error -R "^startup_pixel_heap_srv" -V

For whoever repeats this: the build directory was configured earlier with -DINTAKE_PYTHON=C:/Users/walde/Downloads/x2w-pr641/out/pe-env/Scripts/python.exe, a virtual environment in another checkout of this repository (without it no Python entry is registered); and the tree is x2w-2741, a worktree directory of this repository, so the sha its log prints is what identifies it.

Observed

100% tests passed out of 9, Total Test time (real) = 7.61 sec, no ***Skipped, no stop at 77:

1/9 Test  #746: startup_pixel_heap_srv_cpu .................   Passed    0.31 sec
2/9 Test #1282: startup_pixel_heap_srv_fxc_warp ............   Passed    1.02 sec
3/9 Test #1283: startup_pixel_heap_srv_word_fxc_warp .......   Passed    0.83 sec
4/9 Test #1286: startup_pixel_heap_srv_dxc_warp ............   Passed    0.80 sec
5/9 Test #1287: startup_pixel_heap_srv_word_dxc_warp .......   Passed    0.80 sec
6/9 Test #1332: startup_pixel_heap_srv_fxc_hardware ........   Passed    0.97 sec
7/9 Test #1333: startup_pixel_heap_srv_word_fxc_hardware ...   Passed    0.96 sec
8/9 Test #1336: startup_pixel_heap_srv_dxc_hardware ........   Passed    0.93 sec
9/9 Test #1337: startup_pixel_heap_srv_word_dxc_hardware ...   Passed    0.93 sec

The fixture captures the consumer's stdout, so a green ctest log carries no adapter line. I ran the same draw() from the same file in a probe that prints what it captures; the recording call (no backend argument) and the drawing call print different devices, and only the second is the card:

adapter=Microsoft Basic Render Driver driver=10.0.26100.9818   <- first call, recording pass
adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010           <- second call, backend=hardware

Readback is 128 bytes per case; the four 32-byte rows are equal (rows differ is not raised) and the eight columns are, root constant case, identical with fxc and with dxc:

100000ff 902000ff 0000ffff 0000ffff | 900000ff 102000ff 0000ffff 0000ffff
pass 0, keys 0..3                   | pass 1, keys 0..3

100000ff and 902000ff are the two textures at records 0 and 1 (red 0x10 / 0x90, green = key x 32); 0000ffff is the cleared target the refused keys leave. On the second pass the two views are swapped and the same keys show the other texture (900000ff, 102000ff).

Word case, same shape:

900000ff 102000ff 0000ffff 10ff00ff | 100000ff 902000ff 0000ffff 90ff00ff

Keys 0 and 1 name records 1 and 0 (the index buffer holds {1, 0, 5, 7}), key 2 names record 5 and is refused, and key 3's 0x40000001 root constant gives a byte offset of 4 after the 32-bit wrap, so it reads word 1 and is drawn with record 0 (green 255).

The refused indices differ between the two cases, from the draw's stderr:

x2w-draw 47d6cbf5a28e260a srv 0: heap record refused (record is outside the list's view heap 2); draw not translated
x2w-draw 47d6cbf5a28e260a srv 0: heap record refused (record is outside the list's view heap 3); draw not translated
x2w-draw 33c79287699a3d5e srv 1: heap record refused (record is outside the list's view heap 5); draw not translated

Two per pass in the root constant case (indices 2 and 3), one per pass in the word case (index 5); index 7 is never requested. The fixture asserts the total, 4 or 2, not which index each key named.

Negative control on the fixture

The docstring says a shim that ignored the index would fail one of these cases. Measured on the same tree, by changing the record the runtime resolves in heap_srvs_ready:

before:  const u64 entry = pass.title_view_heap.record(std::uint32_t{index << 5}, 32);  // s_lshl_b32 discards the high bits
after:   const u64 entry = pass.title_view_heap.record(std::uint32_t{0} /* MUTANT: index ignored */, 32);  // s_lshl_b32 discards the high bits

Rebuild d3d12_xs_shim, then ctest --preset dev --no-tests=error -R "^startup_pixel_heap_srv_(fxc|dxc)_hardware$" -V:

1332: AssertionError: ('100000ff102000ff104000ff106000ff900000ff902000ff904000ff906000ff',
                       '100000ff902000ff0000ffff0000ffff900000ff102000ff0000ffff0000ffff')
0% tests passed, 2 tests failed out of 2

ctest exits 8. The first divergence is key 1 of pass 0: 102000ff, where the record-1 texture 902000ff is expected. Then git checkout -- of the file, rebuild, same regex: 100% tests passed out of 2, exit 0, git status --porcelain empty and no marker left in the file.

Scope: the two root constant hardware entries only, and the mutant is not single-variable — once every key resolves to record 0, keys 2 and 3 are drawn instead of refused, so it removes the refusal as well as the index read.

Regression

  • ^startup_gfx2hlsl_(heap_record|heap_word|pixel_heap_image)$ — 3/3, with their own controls (19 refused controls, 10 refused controls, x4 and compute refusals, mask marks).
  • ^(startup_stream_|startup_address_srv|startup_joined_table_pointer|startup_root_cbv) — 27/27, 58.31 s, no skip. The first attempt failed five of these in FileNotFoundError because startup_stream_rasterizer.exe and startup_stream_depth.exe had not been built; those are harness binaries, not a result, and the same regex is 27/27 once they exist.

Conclusion

On this adapter, with both compilers, the shim draws the record the draw's index names (two different textures for keys 0 and 1), re-resolves it on the second pass when the views are swapped, and refuses a draw whose index is outside the heap — 2 and 3 in the root constant case, 5 in the word case — leaving the cleared target. A shim that always bound record 0 fails both root constant hardware entries at key 1.

Limits

  • One hardware adapter (RDNA 4), one driver, one Windows build; WARP ran the same entries against the Basic Render Driver. dev preset only. No validation-layer output, so nothing here is API-layer validation.
  • tex2d only: a heap record naming a buffer SRV or a 1D/3D/array texture, and the heap word table ... mask M manifest form, are parsed but never drawn here.
  • One refusal reason is reached, record is outside the list's view heap. Not exercised: record is not a shader-resource view (record.slot != 18), index word is outside its table buffer, root constant out of range, table out of range, table buffer descriptor is not bound, the unsupported/invalid manifest-line refusals, the heap SRV beside a writable texture refusal, the indirect-draw refusal, and the serialize_root change (a serialization error returning 6 instead of 77).
  • A refused draw and a draw with no effect leave the same cleared target, so the refusal branch is proven by the stderr count and the draw log, not by the pixels alone.
  • The index is constant across the two passes (unchanging root constant, index buffer written once), so the readback separates "re-resolves the record on the second pass" from "keeps the first pass's binding". It does not separate "reads the index once": the docstring's "did not re-read it" is not what this fixture measures.
  • Fixtures only, no title and no game data.

Notes (non-blocking)

  • tests/startup_pixel_heap_srv_check.py:13: the inserted (Word case: ...) parenthetical splits the sentence ("A draw that ... ignored the index").
  • tests/startup_address_srv.cpp: the comment "keys 2 and 3 name records the two-entry heap does not hold" is exact for the root constant case; in word mode the index buffer holds {1, 0, 5, 7}, key 2 names record 5 and is refused, and key 3 wraps to word 1 — record 7 is never requested.
  • The refusal log is capped at eight lines per process (first_calls(refused, 8)), so a case producing more refusals would stop logging rather than fail; and the stderr line already names the refused record, so asserting the set of refused indices would pin the per-key mapping that the count alone leaves open.

AI-assisted; runs executed on the machine above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7188866655 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#issuecomment-7188866655). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-26T10:04:12Z. --- **Independent AMD RDNA 4 result on `80a17a3d`: both heap-record draw forms pass on a real GPU, with fxc and dxc** Not a code change; measurements only. The `word` case arrived at `5989abe7`; the independent Windows review in this thread is on `78cf80ff`, before it, and the author's own run of it is the RunPod one. This adds one more independent run of the current head, on an AMD adapter instead of the RTX 4060. ### Environment Captured on the machine at run time: ``` Microsoft Windows [version 10.0.26200.9974] build 26200 Compilateur d'optimisation Microsoft (R) C/C++ version 19.44.35230 pour x64 toolset directory: 14.44.35207 dxc.exe 1.9.2602.17 fxc.exe 10.0.26100.9457 (Windows Kits 10.0.26100.0) AMD Radeon RX 9070 XT driver=32.0.32029.2010 date=11/18/2026 ``` - `git rev-parse HEAD` printed `80a17a3d289e2df8f6ca7482c935d6a6328fe4fa`. `git status --porcelain` printed nothing: it is the first thing the run log and the neighbour log record, and it is empty again in the environment capture taken after the runs. - Preset `dev`. `ctest --preset dev -N` reports `Total Tests: 2405`, and `ctest --preset dev -N -R startup_pixel_heap_srv` lists the nine entries (`Total Tests: 9` for that filter), so they were built rather than dropped for a missing interpreter. - Adapter selection (`pick_stream_adapter`, in `tests/startup_stream_setup.cpp`, code this pull request does not touch): by GPU preference, software-flagged adapters skipped, then the name filter and a D3D12 device at feature level 12_0. The draw's own printed line below says which adapter won. - Validation layer: `Test-Path C:\Windows\System32\d3d12SDKLayers.dll` is `False` (`d3d12.dll` is 10.0.26100.9818) and `X2W_TEST_DEBUG_LAYER` was not set, so no validation-layer output was captured and none is claimed. ### Commands ```bat cd /d C:\Users\walde\Downloads\x2w-2741 git fetch origin +pull/2763/head:panam2763 git checkout -f panam2763 git rev-parse HEAD :: 80a17a3d289e2df8f6ca7482c935d6a6328fe4fa git status --porcelain :: empty cmake --build --preset dev --target startup_stream_consumer d3d12_xs_shim set "XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT" ctest --preset dev --no-tests=error -R "^startup_pixel_heap_srv" -V ``` For whoever repeats this: the build directory was configured earlier with `-DINTAKE_PYTHON=C:/Users/walde/Downloads/x2w-pr641/out/pe-env/Scripts/python.exe`, a virtual environment in another checkout of this repository (without it no Python entry is registered); and the tree is `x2w-2741`, a worktree directory of this repository, so the sha its log prints is what identifies it. ### Observed `100% tests passed out of 9`, `Total Test time (real) = 7.61 sec`, no `***Skipped`, no stop at 77: ``` 1/9 Test #746: startup_pixel_heap_srv_cpu ................. Passed 0.31 sec 2/9 Test #1282: startup_pixel_heap_srv_fxc_warp ............ Passed 1.02 sec 3/9 Test #1283: startup_pixel_heap_srv_word_fxc_warp ....... Passed 0.83 sec 4/9 Test #1286: startup_pixel_heap_srv_dxc_warp ............ Passed 0.80 sec 5/9 Test #1287: startup_pixel_heap_srv_word_dxc_warp ....... Passed 0.80 sec 6/9 Test #1332: startup_pixel_heap_srv_fxc_hardware ........ Passed 0.97 sec 7/9 Test #1333: startup_pixel_heap_srv_word_fxc_hardware ... Passed 0.96 sec 8/9 Test #1336: startup_pixel_heap_srv_dxc_hardware ........ Passed 0.93 sec 9/9 Test #1337: startup_pixel_heap_srv_word_dxc_hardware ... Passed 0.93 sec ``` The fixture captures the consumer's stdout, so a green `ctest` log carries no adapter line. I ran the same `draw()` from the same file in a probe that prints what it captures; the recording call (no backend argument) and the drawing call print different devices, and only the second is the card: ``` adapter=Microsoft Basic Render Driver driver=10.0.26100.9818 <- first call, recording pass adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010 <- second call, backend=hardware ``` Readback is 128 bytes per case; the four 32-byte rows are equal (`rows differ` is not raised) and the eight columns are, root constant case, identical with fxc and with dxc: ``` 100000ff 902000ff 0000ffff 0000ffff | 900000ff 102000ff 0000ffff 0000ffff pass 0, keys 0..3 | pass 1, keys 0..3 ``` `100000ff` and `902000ff` are the two textures at records 0 and 1 (red 0x10 / 0x90, green = key x 32); `0000ffff` is the cleared target the refused keys leave. On the second pass the two views are swapped and the same keys show the other texture (`900000ff`, `102000ff`). Word case, same shape: ``` 900000ff 102000ff 0000ffff 10ff00ff | 100000ff 902000ff 0000ffff 90ff00ff ``` Keys 0 and 1 name records 1 and 0 (the index buffer holds `{1, 0, 5, 7}`), key 2 names record 5 and is refused, and key 3's `0x40000001` root constant gives a byte offset of 4 after the 32-bit wrap, so it reads word 1 and is drawn with record 0 (green 255). The refused indices differ between the two cases, from the draw's stderr: ``` x2w-draw 47d6cbf5a28e260a srv 0: heap record refused (record is outside the list's view heap 2); draw not translated x2w-draw 47d6cbf5a28e260a srv 0: heap record refused (record is outside the list's view heap 3); draw not translated x2w-draw 33c79287699a3d5e srv 1: heap record refused (record is outside the list's view heap 5); draw not translated ``` Two per pass in the root constant case (indices 2 and 3), one per pass in the word case (index 5); index 7 is never requested. The fixture asserts the total, `4` or `2`, not which index each key named. ### Negative control on the fixture The docstring says a shim that ignored the index would fail one of these cases. Measured on the same tree, by changing the record the runtime resolves in `heap_srvs_ready`: ```cpp before: const u64 entry = pass.title_view_heap.record(std::uint32_t{index << 5}, 32); // s_lshl_b32 discards the high bits after: const u64 entry = pass.title_view_heap.record(std::uint32_t{0} /* MUTANT: index ignored */, 32); // s_lshl_b32 discards the high bits ``` Rebuild `d3d12_xs_shim`, then `ctest --preset dev --no-tests=error -R "^startup_pixel_heap_srv_(fxc|dxc)_hardware$" -V`: ``` 1332: AssertionError: ('100000ff102000ff104000ff106000ff900000ff902000ff904000ff906000ff', '100000ff902000ff0000ffff0000ffff900000ff102000ff0000ffff0000ffff') 0% tests passed, 2 tests failed out of 2 ``` `ctest` exits 8. The first divergence is key 1 of pass 0: `102000ff`, where the record-1 texture `902000ff` is expected. Then `git checkout --` of the file, rebuild, same regex: `100% tests passed out of 2`, exit 0, `git status --porcelain` empty and no marker left in the file. Scope: the two root constant hardware entries only, and the mutant is not single-variable — once every key resolves to record 0, keys 2 and 3 are drawn instead of refused, so it removes the refusal as well as the index read. ### Regression - `^startup_gfx2hlsl_(heap_record|heap_word|pixel_heap_image)$` — 3/3, with their own controls (`19 refused controls`, `10 refused controls`, `x4 and compute refusals, mask marks`). - `^(startup_stream_|startup_address_srv|startup_joined_table_pointer|startup_root_cbv)` — 27/27, 58.31 s, no skip. The first attempt failed five of these in `FileNotFoundError` because `startup_stream_rasterizer.exe` and `startup_stream_depth.exe` had not been built; those are harness binaries, not a result, and the same regex is 27/27 once they exist. ### Conclusion On this adapter, with both compilers, the shim draws the record the draw's index names (two different textures for keys 0 and 1), re-resolves it on the second pass when the views are swapped, and refuses a draw whose index is outside the heap — 2 and 3 in the root constant case, 5 in the word case — leaving the cleared target. A shim that always bound record 0 fails both root constant hardware entries at key 1. ### Limits - One hardware adapter (RDNA 4), one driver, one Windows build; WARP ran the same entries against the Basic Render Driver. `dev` preset only. No validation-layer output, so nothing here is API-layer validation. - `tex2d` only: a heap record naming a buffer SRV or a 1D/3D/array texture, and the `heap word table ... mask M` manifest form, are parsed but never drawn here. - One refusal reason is reached, `record is outside the list's view heap`. Not exercised: `record is not a shader-resource view` (`record.slot != 18`), `index word is outside its table buffer`, `root constant out of range`, `table out of range`, `table buffer descriptor is not bound`, the unsupported/invalid manifest-line refusals, the heap SRV beside a writable texture refusal, the indirect-draw refusal, and the `serialize_root` change (a serialization error returning 6 instead of 77). - A refused draw and a draw with no effect leave the same cleared target, so the refusal branch is proven by the stderr count and the draw log, not by the pixels alone. - The index is constant across the two passes (unchanging root constant, index buffer written once), so the readback separates "re-resolves the record on the second pass" from "keeps the first pass's binding". It does not separate "reads the index once": the docstring's "did not re-read it" is not what this fixture measures. - Fixtures only, no title and no game data. ### Notes (non-blocking) - `tests/startup_pixel_heap_srv_check.py:13`: the inserted `(Word case: ...)` parenthetical splits the sentence ("A draw that ... ignored the index"). - `tests/startup_address_srv.cpp`: the comment "keys 2 and 3 name records the two-entry heap does not hold" is exact for the root constant case; in `word` mode the index buffer holds `{1, 0, 5, 7}`, key 2 names record 5 and is refused, and key 3 wraps to word 1 — record 7 is never requested. - The refusal log is capped at eight lines per process (`first_calls(refused, 8)`), so a case producing more refusals would stop logging rather than fail; and the stderr line already names the refused record, so asserting the set of refused indices would pin the per-key mapping that the count alone leaves open. _AI-assisted; runs executed on the machine above._
tedin7 commented 2026-11-26 11:02:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:12:45Z.


Withdrawn: shader translation is moving to the native C++ frontend (see #870), so we are not continuing this change to the Python translator. The branch stays available if any part is useful later. Thank you to everyone who reviewed and tested it.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189058656 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#issuecomment-7189058656). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:12:45Z. --- Withdrawn: shader translation is moving to the native C++ frontend (see #870), so we are not continuing this change to the Python translator. The branch stays available if any part is useful later. Thank you to everyone who reviewed and tested it.
tedin7 commented 2026-11-26 11:02:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:13:51Z.


Both automated-review findings are fixed in head 80a17a3d (pushed).

  • P1 (masked offsets in the SOPK consumer): scalar_accumulate now accepts the five-value masked mark. s_addk_i32 keeps the mask; s_mulk_i32 of a masked word is not named. startup_gfx2hlsl_pixel_heap_image_check.py has controls for both forms, and putting the old four-value unpack back makes it fail with ValueError: too many values to unpack.
  • P2 (DWORD wraparound): heap_srvs_ready now does the offset arithmetic in 32 bits ((word & mask) * times, at, and index << 5), checks the bounds on the wrapped value, and no longer rejects an index whose high bits the shader's index << 5 discards. The word-case draw fixture's key 3 is root constant 0x40000001, whose byte offset x 4 wraps to 4, so it must be drawn with record 0 (the old 64-bit code would have refused it).

Verification: Linux host controls, startup_gfx2hlsl_{heap_record,heap_word,pixel_heap_image}, binary mode and the 173 shape comparison pass on 80a17a3d. The C++ wraparound case has not been run yet: my pod run picked up the previous head, so it needs the independent Windows run.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189082932 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2763#issuecomment-7189082932). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:13:51Z. --- Both automated-review findings are fixed in head `80a17a3d` (pushed). - P1 (masked offsets in the SOPK consumer): `scalar_accumulate` now accepts the five-value masked mark. `s_addk_i32` keeps the mask; `s_mulk_i32` of a masked word is not named. `startup_gfx2hlsl_pixel_heap_image_check.py` has controls for both forms, and putting the old four-value unpack back makes it fail with `ValueError: too many values to unpack`. - P2 (DWORD wraparound): `heap_srvs_ready` now does the offset arithmetic in 32 bits (`(word & mask) * times`, `at`, and `index << 5`), checks the bounds on the wrapped value, and no longer rejects an index whose high bits the shader's `index << 5` discards. The word-case draw fixture's key 3 is root constant `0x40000001`, whose byte offset x 4 wraps to 4, so it must be drawn with record 0 (the old 64-bit code would have refused it). Verification: Linux host controls, `startup_gfx2hlsl_{heap_record,heap_word,pixel_heap_image}`, binary mode and the 173 shape comparison pass on `80a17a3d`. The C++ wraparound case has not been run yet: my pod run picked up the previous head, so it needs the independent Windows run. AI-assisted; commands listed were executed locally.

Pull request closed

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!2755
No description provided.