startup: accept a stride-cleared descriptor for compute buffer stores #2312

Merged
NiiRoZz merged 1 commit from upstream-pr/2320 into main 2026-11-25 12:19:54 +00:00
NiiRoZz commented 2026-11-25 12:10:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T12:10:54Z.


Change

A compute buffer_store_dword through a descriptor whose dword 1 was ANDed with 0xc000ffff is now accepted. The
operation clears the stride field (bits 29:16) and keeps the base address bits 15:0 and bits 31:30, which is the raw
descriptor a byte-address store already assumes. Refs #2274, Refs #2302.

  • The clear is marked on its own (a stride0 word, compute stage only). Every other modification is recorded
    separately and still refuses the store: another mask, another dword, a repeated modification (clear twice, clear
    then s_or, s_or then clear) and the same clear on an image store.
  • Loads through the descriptor keep treating it as modified, so graphics output is unchanged.
  • SCC: the clear is a scalar ALU op on descriptor data, so the stale-SCC rule from #2305 already refuses any SCC
    read (s_cselect*, s_cmov*, s_cbranch_scc*) reachable before a fresh compare. No new check was added; the
    reproducer (clear, then s_cselect_b32/s_cbranch_scc1) is pinned as a refusal, and a compare in between is
    pinned as accepted with scc assigned.

Not covered, unchanged by this PR: gaps 1 and 2 of #2302 (a store at a loop head with later descriptor writes; a
branch-skipped reload) exist on main and stay.

AI-assisted (Claude Code).

Verification

Base 5e6563d9 (origin/main), head 6335767b. Windows 11 build 26300, Python 3.13.

  • python -B tests/startup_gfx2hlsl_*_check.py, tests/startup_translator_check.py, tests/docs_links_check.py,
    tests/bidi_controls_check.py: all pass. git diff --check origin/main...HEAD: clean.
  • ctest --preset release --no-tests=error -R "^startup_gfx2hlsl|^startup_translator|^startup_tools_lint|^startup_compute":
    121 passed, 0 skipped, 0 failed (WARP and an RTX 5090, driver 32.0.16.2135, debug layer on as in the execz run; adapter strings not re-read this run).
  • Fixture case I is case A with the clear before the store; its dispatch runs on WARP and hardware with the same
    expected words as A.

Negative controls (pure Python, tests/startup_gfx2hlsl_compute_check.py): another mask (0xc000fff0), the same mask
on dword 2, clear twice, clear then or, or then clear, the existing "off form is refused" assertion (untouched), and
the SCC readers after the clear.

Limits

  • The fixture binds a root UAV and reads no descriptor, so the effect of a cleared stride on the range check is not
    measured on hardware.
  • Pinned words are hand-encoded (no llvm-mc locally).
  • Fixtures are source-built gfx1013 programs; no game bytes. This does not show full-title startup.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6604171404 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2320). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T12:10:54Z. --- ## Change A compute `buffer_store_dword` through a descriptor whose dword 1 was ANDed with `0xc000ffff` is now accepted. The operation clears the stride field (bits 29:16) and keeps the base address bits 15:0 and bits 31:30, which is the raw descriptor a byte-address store already assumes. Refs #2274, Refs #2302. - The clear is marked on its own (a `stride0` word, compute stage only). Every other modification is recorded separately and still refuses the store: another mask, another dword, a repeated modification (clear twice, clear then `s_or`, `s_or` then clear) and the same clear on an image store. - Loads through the descriptor keep treating it as modified, so graphics output is unchanged. - SCC: the clear is a scalar ALU op on descriptor data, so the stale-SCC rule from #2305 already refuses any SCC read (`s_cselect*`, `s_cmov*`, `s_cbranch_scc*`) reachable before a fresh compare. No new check was added; the reproducer (clear, then `s_cselect_b32`/`s_cbranch_scc1`) is pinned as a refusal, and a compare in between is pinned as accepted with `scc` assigned. Not covered, unchanged by this PR: gaps 1 and 2 of #2302 (a store at a loop head with later descriptor writes; a branch-skipped reload) exist on main and stay. AI-assisted (Claude Code). ## Verification Base `5e6563d9` (origin/main), head `6335767b`. Windows 11 build 26300, Python 3.13. - `python -B tests/startup_gfx2hlsl_*_check.py`, `tests/startup_translator_check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`: all pass. `git diff --check origin/main...HEAD`: clean. - `ctest --preset release --no-tests=error -R "^startup_gfx2hlsl|^startup_translator|^startup_tools_lint|^startup_compute"`: 121 passed, 0 skipped, 0 failed (WARP and an RTX 5090, driver 32.0.16.2135, debug layer on as in the execz run; adapter strings not re-read this run). - Fixture case I is case A with the clear before the store; its dispatch runs on WARP and hardware with the same expected words as A. Negative controls (pure Python, `tests/startup_gfx2hlsl_compute_check.py`): another mask (`0xc000fff0`), the same mask on dword 2, clear twice, clear then or, or then clear, the existing "off form is refused" assertion (untouched), and the SCC readers after the clear. ## Limits - The fixture binds a root UAV and reads no descriptor, so the effect of a cleared stride on the range check is not measured on hardware. - Pinned words are hand-encoded (no `llvm-mc` locally). - Fixtures are source-built gfx1013 programs; no game bytes. This does not show full-title startup. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-25 13:00:46 +00:00
tedin7 commented 2026-11-25 13:00:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:15:32Z.

Review: COMMENTED


Review of head 6335767b1fad0637c28bb8b3616cdbf685e2cd99 (base origin/main).

Result: no P1, no P2. Two nits.

Semantics: for an offen store the index is 0, so the stride (bits 29:16 of dword 1) does not enter the address. Clearing it with mask 0xc000ffff keeps base bits 15:0 and bits 31:30, so accepting it as the raw byte-address descriptor is consistent. Marking it as its own stride0 word and recording every other change in other_modified keeps the refusals for other masks, other dwords, repeated edits, and image stores. Loads still see the descriptor as modified through pipe.modified. SCC is covered by the existing stale-SCC rule, and the new controls pin both the refusal and the accepted-after-compare case.

Commands run locally in the PR worktree:

  • git diff --stat origin/main...HEAD: 3 files, +68/-14
  • python3 -B tests/startup_gfx2hlsl_*_check.py (all), tests/startup_translator_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py: all rc=0
  • git diff --check origin/main...HEAD: clean
  • CI at review time: Linux Python checks pass; Windows jobs still pending. I did not run Win2025: the change is a Python-side acceptance rule, and the GPU case I only checks that the translation runs, as the PR itself states.

Mutations (both reverted with git checkout -- .):

  1. Removed the key in self.pipe.modified and not stride0_ok clause (replaced by False): tests still pass. The only caller always passes stride0_ok=True, so the clause is unreachable.
  2. Removed the own[3] % 4 == 1 dword-1 guard when marking stride0: tests still pass. The store check (k == 1 in word_ok) already refuses other dwords, so the guard is redundant defense.

Nits:

  • tools/startup/gfx2hlsl.py store_descriptor: the stride0_ok=False path and its pipe.modified clause have no caller and no test. Drop the parameter or add a test for it.
  • tools/startup/gfx2hlsl.py (stride0 marking): getattr(self.pipe, 'other_modified', set()) silently discards the add for a pipeline without the attribute. ComputePipeline defines it, so a plain attribute access would fail loudly instead.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6057421206 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2320#pullrequestreview-6057421206). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:15:32Z. **Review:** COMMENTED --- Review of head `6335767b1fad0637c28bb8b3616cdbf685e2cd99` (base origin/main). **Result: no P1, no P2. Two nits.** Semantics: for an offen store the index is 0, so the stride (bits 29:16 of dword 1) does not enter the address. Clearing it with mask `0xc000ffff` keeps base bits 15:0 and bits 31:30, so accepting it as the raw byte-address descriptor is consistent. Marking it as its own `stride0` word and recording every other change in `other_modified` keeps the refusals for other masks, other dwords, repeated edits, and image stores. Loads still see the descriptor as modified through `pipe.modified`. SCC is covered by the existing stale-SCC rule, and the new controls pin both the refusal and the accepted-after-compare case. Commands run locally in the PR worktree: - `git diff --stat origin/main...HEAD`: 3 files, +68/-14 - `python3 -B tests/startup_gfx2hlsl_*_check.py` (all), `tests/startup_translator_check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`: all rc=0 - `git diff --check origin/main...HEAD`: clean - CI at review time: Linux Python checks pass; Windows jobs still pending. I did not run Win2025: the change is a Python-side acceptance rule, and the GPU case I only checks that the translation runs, as the PR itself states. Mutations (both reverted with `git checkout -- .`): 1. Removed the `key in self.pipe.modified and not stride0_ok` clause (replaced by `False`): tests still pass. The only caller always passes `stride0_ok=True`, so the clause is unreachable. 2. Removed the `own[3] % 4 == 1` dword-1 guard when marking `stride0`: tests still pass. The store check (`k == 1` in `word_ok`) already refuses other dwords, so the guard is redundant defense. Nits: - `tools/startup/gfx2hlsl.py` `store_descriptor`: the `stride0_ok=False` path and its `pipe.modified` clause have no caller and no test. Drop the parameter or add a test for it. - `tools/startup/gfx2hlsl.py` (stride0 marking): `getattr(self.pipe, 'other_modified', set())` silently discards the add for a pipeline without the attribute. `ComputePipeline` defines it, so a plain attribute access would fail loudly instead. AI-assisted; commands listed were executed locally.
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!2312
No description provided.