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

Manually merged
github merged 1 commit from gh-pr/2320/head into gh-pr/2320/base 2026-11-27 00:15:40 +00:00
Owner

@⁠NiiRoZz on GitHub · 2026-11-25 12:10 UTC · original
NiiRoZz:startup/gfx2hlsl-compute-stride-clear → main · +68 −14 · 3 files · 1 commits · merged 2026-11-25 12:19 UTC

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

**@⁠NiiRoZz** on GitHub · 2026-11-25 12:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2320) `NiiRoZz:startup/gfx2hlsl-compute-stride-clear` → `main` · +68 −14 · 3 files · 1 commits · merged 2026-11-25 12:19 UTC ## 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)
A compute buffer store 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. The result
is the raw descriptor a byte-address store already assumes.
- The clear is marked on its own (a 'stride0' word, compute only). Every other modification is recorded
  separately and still refuses the store: another mask, another dword, a repeated modification, and the same
  clear on an image store.
- Loads through the descriptor keep treating it as modified, so graphics output is unchanged.
- The clear is a scalar ALU op on descriptor data, so the stale-SCC rule refuses an SCC read before a fresh
  compare; pinned for s_cselect and s_cbranch_scc.

Fixture case I is case A with the clear before the store. The runner binds a root UAV and reads no descriptor,
so the GPU run checks the translation only. The pure-Python controls pin the accepted mask (either operand
order) and the refused neighbours.

Refs #2274
Refs #2302

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:15:37 +00:00
github manually merged commit 6335767b1f into gh-pr/2320/base 2026-11-27 00:15:40 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 12:15 UTC · original · reviewed

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.

**@⁠tedin7** on GitHub · 2026-11-25 12:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2320#pullrequestreview-6057421206) · **reviewed** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.