startup: accept the structured-to-raw descriptor conversion for compute buffer stores (Part of #2274) #2538

Merged
Leyukaka merged 2 commits from upstream-pr/2546 into main 2026-11-25 21:02:32 +00:00
Leyukaka commented 2026-11-25 20:27:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T20:27:13Z.


Part of #2274, the composite form of "buffer store through a modified descriptor" (claim, building on #2320).

Captured compute programs convert a structured buffer descriptor to a raw one before a buffer_store_dword*. Shape of the sequence (register numbers illustrative):

s_bfe_u32  s16, s13, 0xe0010      ; stride = DW1[29:16]
s_max_u32  s16, s16, 1            ; at least 1 (optional)
s_and_b32  s15, s15, 0xcfffffff   ; clear OOB_SELECT (optional)
s_mul_i32  s14, s14, s16          ; NUM_RECORDS *= stride
s_or_b32   s15, s15, 0x30000000   ; OOB_SELECT = 3
s_and_b32  s13, s13, 0xc000ffff   ; stride = 0

This accepts exactly that conversion of the four words of one table descriptor, in any order the symbols allow, and translates the store as #2320 translates the stride-cleared store. The field positions are the ones in docs/pixel_mubuf_contract.md. Everything else stays refused with buffer store through a modified descriptor:

  • another OOB_SELECT;
  • NUM_RECORDS not scaled, or scaled by a constant or by another descriptor's stride;
  • another bit field in the s_bfe_u32;
  • a clamp other than 1;
  • the stride not cleared;
  • a conversion split across a branch, since derived words are not kept at joins.

Descriptor identity: the pointer symbol records neither an addend on the low word nor a rewritten high word, so this also tells compute loads apart when the pointer may differ. A load through an untouched root pointer pair keeps the plain symbol, a load through an untouched 32-bit table pointer with a known constant high word is tagged with that constant, and any other load with its own offset. So a second load through the same pointer names the same words, while a load after s_add_u32 on the pointer, after a new high word, or at another table offset cannot supply a word of the conversion. Equal loads on both arms of a branch are still kept at the join.

Limits. The fixture binds a root UAV and reads no descriptor, so the GPU run checks the translation, not the converted range. The manifest is the same as for the plain store, so sizing the view to NUM_RECORDS * stride is left to the runtime, as for the stride-only case of #2320.

Tests (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100), on main 780f3c0 plus the two commits of this PR:

  • python -B tests/startup_gfx2hlsl_compute_check.py: ok. New case I-raw gives the same HLSL and manifest as the plain store. The clamped form is accepted. The refusals above are each checked.
  • ... dispatch <dxc> <offscreen_check> warp and hardware: ok, including I-raw. WARP: Microsoft Basic Render Driver. Hardware: NVIDIA GeForce RTX 5080, driver 32.0.16.2101.
  • Also ok: startup_gfx2hlsl_join_symbols_check, startup_compute_translate_check, startup_compute_request_offline_check, compute_load_format_check, compute_heap_store_check, compute_desc_numeric_check, startup_translator_check, startup_compute_image_store_d16_check, startup_gfx2hlsl_loop_constants_check, startup_gfx2hlsl_refusals_check, startup_gfx2hlsl_sload_const_offset_check, startup_gfx2hlsl_smem_offset_check and compute_heap_view_check.

Mutation checks, run by hand. The controls fail on each:

  • OOB_SELECT 2 accepted;
  • the scale not required;
  • the scale from any descnum;
  • s_bfe_u32 with any field;
  • the stride clear with any mask;
  • the clamp with any constant;
  • the clamped form not accepted;
  • an addend on the pointer treated as untouched;
  • the high-word constant ignored.

Measured on a local capture (counts only, inputs private; requests re-keyed with shader_cache_rekey.py for the current revision): at main 396e7e2, 22 compute requests had buffer store through a modified descriptor as their first refusal. With this change, 16 of them translate and compile. The other 6 stop at unrelated refusals: buffer store without the offen address form (2), a 64-bit source, a descriptor used for both a load and a store (2), and an unproven v_readfirstlane_b32 source.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6613096173 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2546). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-25T20:27:13Z. --- Part of #2274, the composite form of "buffer store through a modified descriptor" ([claim](https://github.com/R0Y00/Xbox2Windows/issues/2274#issuecomment-7173242036), building on #2320). Captured compute programs convert a structured buffer descriptor to a raw one before a `buffer_store_dword*`. Shape of the sequence (register numbers illustrative): ``` s_bfe_u32 s16, s13, 0xe0010 ; stride = DW1[29:16] s_max_u32 s16, s16, 1 ; at least 1 (optional) s_and_b32 s15, s15, 0xcfffffff ; clear OOB_SELECT (optional) s_mul_i32 s14, s14, s16 ; NUM_RECORDS *= stride s_or_b32 s15, s15, 0x30000000 ; OOB_SELECT = 3 s_and_b32 s13, s13, 0xc000ffff ; stride = 0 ``` This accepts exactly that conversion of the four words of one table descriptor, in any order the symbols allow, and translates the store as #2320 translates the stride-cleared store. The field positions are the ones in `docs/pixel_mubuf_contract.md`. Everything else stays refused with `buffer store through a modified descriptor`: - another `OOB_SELECT`; - `NUM_RECORDS` not scaled, or scaled by a constant or by another descriptor's stride; - another bit field in the `s_bfe_u32`; - a clamp other than 1; - the stride not cleared; - a conversion split across a branch, since derived words are not kept at joins. Descriptor identity: the pointer symbol records neither an addend on the low word nor a rewritten high word, so this also tells compute loads apart when the pointer may differ. A load through an untouched root pointer pair keeps the plain symbol, a load through an untouched 32-bit table pointer with a known constant high word is tagged with that constant, and any other load with its own offset. So a second load through the same pointer names the same words, while a load after `s_add_u32` on the pointer, after a new high word, or at another table offset cannot supply a word of the conversion. Equal loads on both arms of a branch are still kept at the join. **Limits.** The fixture binds a root UAV and reads no descriptor, so the GPU run checks the translation, not the converted range. The manifest is the same as for the plain store, so sizing the view to `NUM_RECORDS * stride` is left to the runtime, as for the stride-only case of #2320. **Tests** (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100), on main `780f3c0` plus the two commits of this PR: - `python -B tests/startup_gfx2hlsl_compute_check.py`: ok. New case `I-raw` gives the same HLSL and manifest as the plain store. The clamped form is accepted. The refusals above are each checked. - `... dispatch <dxc> <offscreen_check> warp` and `hardware`: ok, including `I-raw`. WARP: Microsoft Basic Render Driver. Hardware: NVIDIA GeForce RTX 5080, driver 32.0.16.2101. - Also ok: `startup_gfx2hlsl_join_symbols_check`, `startup_compute_translate_check`, `startup_compute_request_offline_check`, `compute_load_format_check`, `compute_heap_store_check`, `compute_desc_numeric_check`, `startup_translator_check`, `startup_compute_image_store_d16_check`, `startup_gfx2hlsl_loop_constants_check`, `startup_gfx2hlsl_refusals_check`, `startup_gfx2hlsl_sload_const_offset_check`, `startup_gfx2hlsl_smem_offset_check` and `compute_heap_view_check`. **Mutation checks**, run by hand. The controls fail on each: - `OOB_SELECT` 2 accepted; - the scale not required; - the scale from any `descnum`; - `s_bfe_u32` with any field; - the stride clear with any mask; - the clamp with any constant; - the clamped form not accepted; - an addend on the pointer treated as untouched; - the high-word constant ignored. **Measured on a local capture** (counts only, inputs private; requests re-keyed with `shader_cache_rekey.py` for the current revision): at main `396e7e2`, 22 compute requests had `buffer store through a modified descriptor` as their first refusal. With this change, 16 of them translate and compile. The other 6 stop at unrelated refusals: `buffer store without the offen address form` (2), a 64-bit source, a descriptor used for both a load and a store (2), and an unproven `v_readfirstlane_b32` source. AI-assisted.
tedin7 commented 2026-11-25 21:01:23 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head eee2169a (comment only, code and fixture tests).

Code: the recognizer raw_descriptor_alu accepts only the listed word expressions (stride bfe 0xe0010, optional max with 1, OOB clear 0xcfffffff, NUM_RECORDS times stride, OOB set 0x30000000, stride clear 0xc000ffff) on words of one table descriptor, and store_descriptor requires the exact four-word shape. Everything else still lands on buffer store through a modified descriptor. Field positions match docs/pixel_mubuf_contract.md. The stricter names_one_value check keeps a derived word from being treated as a loaded value. I found no sibling table that needs the same change.

Tests: the new I-raw case checks HLSL and manifest against the plain store and the refusal list. The PR also reports a WARP and hardware dispatch run of the same test.

Commands run locally (Linux, 6 commits behind main, own diff unaffected):

  • python3 -B tests/startup_gfx2hlsl_compute_check.py passed
  • python3 tests/docs_links_check.py and python3 tests/bidi_controls_check.py passed
  • git diff --check origin/main...HEAD clean
  • Mutation 1: OOB_SELECT constant 0x30000000 changed to 0x20000000: the test fails with a refusal.
  • Mutation 2: the s_max_u32 clamp accepts any constant: the test fails (accepted, expected a refusal).

Not verified by me: I did not run the D3D12 dispatch step, and the "16 of 22 translate" count comes from a private capture that I cannot reproduce. The PR is tied to startup progress under #2274, so the merge decision and any check on the real game stay with MasterDomino or @R0Y00.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064599896 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2546#pullrequestreview-6064599896). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:35:10Z. **Review:** COMMENTED --- Review of head eee2169a (comment only, code and fixture tests). Code: the recognizer `raw_descriptor_alu` accepts only the listed word expressions (stride bfe 0xe0010, optional max with 1, OOB clear 0xcfffffff, NUM_RECORDS times stride, OOB set 0x30000000, stride clear 0xc000ffff) on words of one table descriptor, and `store_descriptor` requires the exact four-word shape. Everything else still lands on `buffer store through a modified descriptor`. Field positions match `docs/pixel_mubuf_contract.md`. The stricter `names_one_value` check keeps a derived word from being treated as a loaded value. I found no sibling table that needs the same change. Tests: the new `I-raw` case checks HLSL and manifest against the plain store and the refusal list. The PR also reports a WARP and hardware dispatch run of the same test. Commands run locally (Linux, 6 commits behind main, own diff unaffected): - `python3 -B tests/startup_gfx2hlsl_compute_check.py` passed - `python3 tests/docs_links_check.py` and `python3 tests/bidi_controls_check.py` passed - `git diff --check origin/main...HEAD` clean - Mutation 1: OOB_SELECT constant 0x30000000 changed to 0x20000000: the test fails with a refusal. - Mutation 2: the `s_max_u32` clamp accepts any constant: the test fails (accepted, expected a refusal). Not verified by me: I did not run the D3D12 dispatch step, and the "16 of 22 translate" count comes from a private capture that I cannot reproduce. The PR is tied to startup progress under #2274, so the merge decision and any check on the real game stay with MasterDomino or @R0Y00. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 22:02:00 +00:00
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!2538
No description provided.