textures: honor the Scarlett copy-out signature for BC mip chains #2249

Merged
RavenCurseBurg merged 2 commits from upstream-pr/2257 into main 2026-11-25 08:44:47 +00:00
RavenCurseBurg commented 2026-11-25 08:20:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T08:20:36Z.


Microsoft's Scarlett detile call passes a zero-valued UINT after the subresource index. The existing 64 KiB BC5/BC7 texture computer uses the six-argument copy-in prototype for slot 9 as well. A caller following that example gets E_INVALIDARG because the zero occupies the position where the stand-in expects its source pointer. The copy-in call already matches slot 8.

Give slot 9 its own entry point and pass its arguments to the existing detiler. The extra option's nonzero values have no established meaning here, so they return E_NOTIMPL before touching the destination. Both native Python fixtures now call the published Scarlett signature. The single-slice case supplies a zero slice pitch and the array case supplies an explicit pitch.

On Windows, ctest -V -R '^startup_xg_(bc7_layout|bc_(chain|array)_warp)$' passed all three tests on e640e28a. For each of BC5 and BC7, the six-mip case checked 87,360 block addresses and 12,288 WARP pixels. At both array heights, each format checked 18 subresources and 12,288 pixels against the slice reference. Restoring only the old slot-9 registration made the valid copy-out call fail in the same WARP test. Build and positive/negative test logs

Refs #1140.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6600242688 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2257). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T08:20:36Z. --- Microsoft's Scarlett [detile call](https://github.com/microsoft/DirectXTex/blob/a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379/Auxiliary/DirectXTexXboxDetile.cpp#L229-L238) passes a zero-valued `UINT` after the subresource index. The existing 64 KiB BC5/BC7 texture computer uses the six-argument copy-in prototype for slot 9 as well. A caller following that example gets `E_INVALIDARG` because the zero occupies the position where the stand-in expects its source pointer. The [copy-in call](https://github.com/microsoft/DirectXTex/blob/a8e5dbf42909aeeb9fcf9c2ae399ae3c06737379/Auxiliary/DirectXTexXboxTile.cpp#L357-L363) already matches slot 8. Give slot 9 its own entry point and pass its arguments to the existing detiler. The extra option's nonzero values have no established meaning here, so they return `E_NOTIMPL` before touching the destination. Both native Python fixtures now call the published Scarlett signature. The single-slice case supplies a zero slice pitch and the array case supplies an explicit pitch. On Windows, `ctest -V -R '^startup_xg_(bc7_layout|bc_(chain|array)_warp)$'` passed all three tests on `e640e28a`. For each of BC5 and BC7, the six-mip case checked 87,360 block addresses and 12,288 WARP pixels. At both array heights, each format checked 18 subresources and 12,288 pixels against the slice reference. Restoring only the old slot-9 registration made the valid copy-out call fail in the same WARP test. [Build and positive/negative test logs](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45574916739) Refs #1140.
upstream-sync closed this pull request 2026-11-25 09:04:04 +00:00
tedin7 commented 2026-11-25 09:04:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T08:25:57Z.

Review: COMMENTED


Review of head e640e28a83ecd1e4f067e3348c2e5287bd761cf1.

Summary: The change is small and coherent. Slot 9 of the BC-chain stand-in now takes the extra UINT between the subresource and the tiled source. It rejects any non-zero value with E_NOTIMPL and forwards zero to the existing copy-out path. The tests and docs follow the new signature.

Checked

  • Diff: 6 files, +25/-5. The title is neutral and the PR is MERGEABLE.
  • CI: Linux Python checks, gfx1013 fixtures and Windows build+test are all pass. The /O2 job and the chart publish were skipped.
  • The new bc64_copy_from is the only slot-9 user in xg_xs.cpp. Slot 8 (copy in) is unchanged. The other slots[9] hit is the unrelated GameInput table.
  • The non-zero option returns before any arguments are touched, so the destination is not written. The new sentinel assertion in startup_xg_bc_chain_check.py guards this.
  • The chain check passes slice pitch 0 and the array check passes len(linear). This covers both branches of the slice_pitch && guard in bc64_copy.
  • The doc paragraph cites DirectXTex permalinks pinned to a commit.

Findings

  • P1: none.
  • P2: none.
  • nit tests/startup_xg_bc_chain_check.py (new sentinel block, after the for level loop): it reuses the loop variables level, row_pitch and result from the last iteration. This works, but it breaks if the loop is ever reordered or emptied. Binding explicit locals would be sturdier.
  • nit src/startup_stubs/xg_bc64.inl:76: an unsupported option gives E_NOTIMPL even when the other arguments are invalid. That is fine, but a one-line comment on the ordering would help.

Commands executed locally (in a worktree at the head SHA)

  • git diff --stat origin/main...HEAD
  • git diff --check origin/main...HEAD -> clean
  • python3 tests/docs_links_check.py -> self-test passed, 18 Markdown files and 428 links OK
  • python3 tests/bidi_controls_check.py -> 1538 files, no bidi controls
  • python3 -m py_compile tests/startup_xg_bc*_check.py -> OK
  • gh pr checks 2257

Not run: the touched tests use ctypes.WINFUNCTYPE against the Windows stub, so they can't run on Linux. That means I did not do a local mutation run. I relied on the green Windows CI job. A useful mutation for the author or the Windows stage: flip scarlett_option != 0 to == 0, or call bc64_copy<true> in bc64_copy_from. Both should fail the chain and array checks. I did not run a Win2025 pass because this change has no shader or HLSL part.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054101577 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2257#pullrequestreview-6054101577). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T08:25:57Z. **Review:** COMMENTED --- Review of head `e640e28a83ecd1e4f067e3348c2e5287bd761cf1`. **Summary:** The change is small and coherent. Slot 9 of the BC-chain stand-in now takes the extra `UINT` between the subresource and the tiled source. It rejects any non-zero value with `E_NOTIMPL` and forwards zero to the existing copy-out path. The tests and docs follow the new signature. **Checked** - Diff: 6 files, +25/-5. The title is neutral and the PR is MERGEABLE. - CI: Linux Python checks, gfx1013 fixtures and Windows build+test are all pass. The /O2 job and the chart publish were skipped. - The new `bc64_copy_from` is the only slot-9 user in `xg_xs.cpp`. Slot 8 (copy in) is unchanged. The other `slots[9]` hit is the unrelated GameInput table. - The non-zero option returns before any arguments are touched, so the destination is not written. The new sentinel assertion in `startup_xg_bc_chain_check.py` guards this. - The chain check passes slice pitch 0 and the array check passes `len(linear)`. This covers both branches of the `slice_pitch &&` guard in `bc64_copy`. - The doc paragraph cites DirectXTex permalinks pinned to a commit. **Findings** - P1: none. - P2: none. - nit `tests/startup_xg_bc_chain_check.py` (new sentinel block, after the `for level` loop): it reuses the loop variables `level`, `row_pitch` and `result` from the last iteration. This works, but it breaks if the loop is ever reordered or emptied. Binding explicit locals would be sturdier. - nit `src/startup_stubs/xg_bc64.inl:76`: an unsupported option gives `E_NOTIMPL` even when the other arguments are invalid. That is fine, but a one-line comment on the ordering would help. **Commands executed locally** (in a worktree at the head SHA) - `git diff --stat origin/main...HEAD` - `git diff --check origin/main...HEAD` -> clean - `python3 tests/docs_links_check.py` -> self-test passed, 18 Markdown files and 428 links OK - `python3 tests/bidi_controls_check.py` -> 1538 files, no bidi controls - `python3 -m py_compile tests/startup_xg_bc*_check.py` -> OK - `gh pr checks 2257` **Not run:** the touched tests use `ctypes.WINFUNCTYPE` against the Windows stub, so they can't run on Linux. That means I did not do a local mutation run. I relied on the green Windows CI job. A useful mutation for the author or the Windows stage: flip `scarlett_option != 0` to `== 0`, or call `bc64_copy<true>` in `bc64_copy_from`. Both should fail the chain and array checks. I did not run a Win2025 pass because this change has no shader or HLSL part. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 09:04:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T08:35:30Z.

Review: COMMENTED


Re-review of head af63f0dcf208f2cdaaa1d0e4c547ceebbd428d1a (delta since e640e28: xg_bc64.inl +1 comment, startup_xg_bc_chain_check.py +8/-4).

Delta checked

  • xg_bc64.inl: comment only. The scarlett_option != 0 -> E_NOTIMPL guard still runs before bc64_copy, so neither buffer is touched on refusal. No behavior change.
  • startup_xg_bc_chain_check.py: the refusal control now uses its own destination buffer. It is exact-sized for mip 5 (blocks = 256 >> 5 = 8, pitch = 128, from the 1024x1024 BC base, i.e. 256 blocks at mip 0). It no longer reuses result or the per-mip padded row_pitch, so the sentinel check cannot be masked by the copy-out loop above. Sizes agree with the mip-5 layout (OFFSETS[5]). Good isolation.
  • A removed guard would write 1024 bytes over the 0xad sentinel, so the assert would fail. I confirmed this by reading the code. I did not run it, because the test needs ctypes.WINFUNCTYPE.

Commands run locally (Linux)

  • gh pr checks 2257: Linux Python checks, Windows build+test and gfx1013 fixtures all pass. The /O2 job and the chart publish were skipped.
  • python3 tests/docs_links_check.py: 18 files, 428 links OK.
  • python3 tests/bidi_controls_check.py: 1538 files, no bidi controls.
  • git diff --check origin/main...HEAD: clean.
  • python3 tests/startup_xg_bc_chain_check.py: not runnable on Linux (ctypes.WINFUNCTYPE is missing). The Windows CI job covers it. I did not queue Win2025, since the delta is a comment plus a test-only change and CI is green on this head.

Findings: P1=0, P2=0.

  • nit: the new comment on the guard repeats what the line below already says. Optional.

Title is neutral and the PR is mergeable. Nothing blocks this.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054225334 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2257#pullrequestreview-6054225334). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T08:35:30Z. **Review:** COMMENTED --- Re-review of head `af63f0dcf208f2cdaaa1d0e4c547ceebbd428d1a` (delta since `e640e28`: `xg_bc64.inl` +1 comment, `startup_xg_bc_chain_check.py` +8/-4). **Delta checked** - `xg_bc64.inl`: comment only. The `scarlett_option != 0 -> E_NOTIMPL` guard still runs before `bc64_copy`, so neither buffer is touched on refusal. No behavior change. - `startup_xg_bc_chain_check.py`: the refusal control now uses its own destination buffer. It is exact-sized for mip 5 (`blocks = 256 >> 5 = 8`, `pitch = 128`, from the 1024x1024 BC base, i.e. 256 blocks at mip 0). It no longer reuses `result` or the per-mip padded `row_pitch`, so the sentinel check cannot be masked by the copy-out loop above. Sizes agree with the mip-5 layout (`OFFSETS[5]`). Good isolation. - A removed guard would write 1024 bytes over the `0xad` sentinel, so the assert would fail. I confirmed this by reading the code. I did not run it, because the test needs `ctypes.WINFUNCTYPE`. **Commands run locally (Linux)** - `gh pr checks 2257`: Linux Python checks, Windows build+test and gfx1013 fixtures all pass. The /O2 job and the chart publish were skipped. - `python3 tests/docs_links_check.py`: 18 files, 428 links OK. - `python3 tests/bidi_controls_check.py`: 1538 files, no bidi controls. - `git diff --check origin/main...HEAD`: clean. - `python3 tests/startup_xg_bc_chain_check.py`: not runnable on Linux (`ctypes.WINFUNCTYPE` is missing). The Windows CI job covers it. I did not queue Win2025, since the delta is a comment plus a test-only change and CI is green on this head. **Findings:** P1=0, P2=0. - nit: the new comment on the guard repeats what the line below already says. Optional. Title is neutral and the PR is mergeable. Nothing blocks this. AI-assisted; commands listed were executed locally.
RavenCurseBurg commented 2026-11-25 09:04:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T08:26:30Z.


I also reran both updated fixtures on an independent Windows machine with Microsoft FXC. All six native CPU byte/guard checks passed, and the local WARP run passed both formats at both array heights as well as both six-mip chains. On the physical adapter, the first BC5 draw reached the queue signal and the consumer process exited with 0xC0000005 before returning a pixel buffer. I have no physical-adapter pixel result for that run. The native slot-9 checks had already completed successfully. The Windows CI and the separate hosted WARP run are green.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7157028762 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2257#issuecomment-7157028762). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T08:26:30Z. --- I also reran both updated fixtures on an independent Windows machine with Microsoft FXC. All six native CPU byte/guard checks passed, and the local WARP run passed both formats at both array heights as well as both six-mip chains. On the physical adapter, the first BC5 draw reached the queue signal and the consumer process exited with 0xC0000005 before returning a pixel buffer. I have no physical-adapter pixel result for that run. The native slot-9 checks had already completed successfully. The Windows CI and the separate hosted WARP run are green.
RavenCurseBurg commented 2026-11-25 09:04:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T08:34:03Z.


Addressed both review notes in af63f0dc. The nonzero-option test now owns its mip, pitch and sentinel buffer. The entry point documents why option validation happens before interpreting the other arguments.

On this exact commit all three positive Windows CTests passed. Restoring the old registration broke the documented zero-option call. Inverting scarlett_option != 0 to == 0 also made both the chain and array fixtures fail at their first valid copy-out call. Windows results, including both controls

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7157194196 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2257#issuecomment-7157194196). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T08:34:03Z. --- Addressed both review notes in `af63f0dc`. The nonzero-option test now owns its mip, pitch and sentinel buffer. The entry point documents why option validation happens before interpreting the other arguments. On this exact commit all three positive Windows CTests passed. Restoring the old registration broke the documented zero-option call. Inverting `scarlett_option != 0` to `== 0` also made both the chain and array fixtures fail at their first valid copy-out call. [Windows results, including both controls](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45576825456)
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!2249
No description provided.