startup: copy descriptor words into vcc as the upper half of s[104:107] (Part of #2023) #2661

Merged
Leyukaka merged 3 commits from upstream-pr/2669 into main 2026-11-26 05:14:49 +00:00
Leyukaka commented 2026-11-26 01:36:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T01:36:42Z.


Part of #2023, Item L (takeover). Builds on #2057's descriptor s_load into s[104:107].

What the requests do. On a local capture (counts and instruction shape only), 41 of the 43 mask from descriptor data hits are

s_mov_b64 vcc, s[n+2:n+3]                  ; s[n:n+3] is a buffer descriptor
s_buffer_load_dwordx8 s[n:n+7], s[n:n+3], <off>   ; overwrites s[n:n+3]
s_buffer_load_dwordx2 s[m:m+1], s[104:107], <off> ; s104, s105 + vcc (s106/s107)

vcc is used only as s106/s107, the upper half of a descriptor read through s[104:107].

Change (tools/startup/gfx2hlsl.py):

  • s_mov_b64 vcc, s[n:n+1], with n even and both registers holding descriptor words, records the two words as the symbols of s106/s107 and emits no code. It marks vcc lost the way the #2057 path does (now shared as mark_vcc_descriptor), so a later read of vcc as a mask before it is redefined raises vcc read after a descriptor load into s106/s107, on straight-line code and on branch paths.
  • Some operand handlers refuse a mask as data before reading their operands. Stage.one now checks vcc/vcc_hi reads up front while vcc is lost, and on the error path of a branchy program it runs check_vcc_paths, so the refusal is the vcc one (a lost vcc read, or a descriptor without a matching load on every path) rather than the handler's.
  • A descriptor operand s[104:107] whose s104 holds a descriptor word must hold four consecutive words of the same descriptor. This also applies to the #2057 path; its tests are unchanged and pass.
  • exec from descriptor data, s_mov_b32 vcc_lo / s_and_b64 vcc from descriptor data, and an odd or partly non-descriptor pair stay refused. exec_hi/vcc_hi destinations now get the same mask from descriptor data refusal; before, a descriptor source there reached reg_range(dname)[1] on None.

Tests (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100), on main 7287979 plus this commit:

  • New tests/startup_gfx2hlsl_desc_vcc_check.py: ok. It checks:
    • Symbol copy: the words reach s106/s107 after the source registers are overwritten, no vcc = is emitted, and the last four HLSL lines match the direct load.
    • Refused reads of the lost vcc: v_cndmask, the carry-in of v_add_co_ci/v_sub_co_ci/v_subrev_co_ci, v_div_fmas, VOPC e32/e64/SDWA sources, a VOP3 source, s_and_saveexec_b64, s_mov_b32 s, vcc_lo, and s_cbranch_vccz/vccnz.
    • Branch paths: a v_cndmask after a branch that skips the redefinition and a v_div_fmas at a branch target are refused; a redefinition by a compare is accepted.
    • Other refusal controls: the refusals above that stay in place, and three malformed s[104:107] descriptors.
  • draw <dxc> <offscreen_check> warp and hardware: ok on WARP (Microsoft Basic Render Driver) and an NVIDIA GeForce RTX 5080. The direct and aliased pixel shaders are compiled with DXC and both read back the same four words.
    • The flat-parameter runner binds only b0, so the fixture replaces the SRV with an HLSL function over the same bytes, after checking the translated resource key and the load count.
  • Also ok: startup_gfx2hlsl_sload_s104_check (controls and WARP draw), startup_gfx2hlsl_join_symbols_check, startup_translator_check, startup_gfx2hlsl_refusals_check, startup_gfx2hlsl_mask_data_check, startup_mesh57_skeleton_check, docs_links_check, bidi_controls_check.

Mutation checks, run by hand. Each fails the controls, which the draw variants run first (a refusal or a wrong symbol, not a pixel change):

  • dropping the symbol copy;
  • skipping the four-word check;
  • dropping the vcc lost marking.

Measured on the same capture with this branch on 7287979: of the 42 requests that stopped at mask from descriptor data, 41 now pass it. They stop at later, unrelated refusals: 64-bit literal sources, s_lshl*_add_u32 and s_nand_b64 on a lane mask, v_ldexp_f32, s_bfm_b32, and another descriptor operand without a symbol. So none of them translates fully yet. One stays refused for exec from descriptor data.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6617519189 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2669). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-26T01:36:42Z. --- Part of #2023, Item L ([takeover](https://github.com/R0Y00/Xbox2Windows/issues/2023#issuecomment-7179678759)). Builds on #2057's descriptor `s_load` into `s[104:107]`. **What the requests do.** On a local capture (counts and instruction shape only), 41 of the 43 `mask from descriptor data` hits are ``` s_mov_b64 vcc, s[n+2:n+3] ; s[n:n+3] is a buffer descriptor s_buffer_load_dwordx8 s[n:n+7], s[n:n+3], <off> ; overwrites s[n:n+3] s_buffer_load_dwordx2 s[m:m+1], s[104:107], <off> ; s104, s105 + vcc (s106/s107) ``` `vcc` is used only as `s106`/`s107`, the upper half of a descriptor read through `s[104:107]`. **Change** (`tools/startup/gfx2hlsl.py`): - `s_mov_b64 vcc, s[n:n+1]`, with `n` even and both registers holding descriptor words, records the two words as the symbols of `s106`/`s107` and emits no code. It marks `vcc` lost the way the #2057 path does (now shared as `mark_vcc_descriptor`), so a later read of `vcc` as a mask before it is redefined raises `vcc read after a descriptor load into s106/s107`, on straight-line code and on branch paths. - Some operand handlers refuse a mask as data before reading their operands. `Stage.one` now checks `vcc`/`vcc_hi` reads up front while `vcc` is lost, and on the error path of a branchy program it runs `check_vcc_paths`, so the refusal is the `vcc` one (a lost `vcc` read, or a descriptor without a matching load on every path) rather than the handler's. - A descriptor operand `s[104:107]` whose `s104` holds a descriptor word must hold four consecutive words of the same descriptor. This also applies to the #2057 path; its tests are unchanged and pass. - `exec` from descriptor data, `s_mov_b32 vcc_lo` / `s_and_b64 vcc` from descriptor data, and an odd or partly non-descriptor pair stay refused. `exec_hi`/`vcc_hi` destinations now get the same `mask from descriptor data` refusal; before, a descriptor source there reached `reg_range(dname)[1]` on `None`. **Tests** (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100), on main `7287979` plus this commit: - New `tests/startup_gfx2hlsl_desc_vcc_check.py`: ok. It checks: - **Symbol copy:** the words reach `s106`/`s107` after the source registers are overwritten, no `vcc =` is emitted, and the last four HLSL lines match the direct load. - **Refused reads of the lost `vcc`:** `v_cndmask`, the carry-in of `v_add_co_ci`/`v_sub_co_ci`/`v_subrev_co_ci`, `v_div_fmas`, VOPC e32/e64/SDWA sources, a VOP3 source, `s_and_saveexec_b64`, `s_mov_b32 s, vcc_lo`, and `s_cbranch_vccz`/`vccnz`. - **Branch paths:** a `v_cndmask` after a branch that skips the redefinition and a `v_div_fmas` at a branch target are refused; a redefinition by a compare is accepted. - **Other refusal controls:** the refusals above that stay in place, and three malformed `s[104:107]` descriptors. - `draw <dxc> <offscreen_check> warp` and `hardware`: ok on WARP (Microsoft Basic Render Driver) and an NVIDIA GeForce RTX 5080. The direct and aliased pixel shaders are compiled with DXC and both read back the same four words. - The flat-parameter runner binds only `b0`, so the fixture replaces the SRV with an HLSL function over the same bytes, after checking the translated resource key and the load count. - Also ok: `startup_gfx2hlsl_sload_s104_check` (controls and WARP draw), `startup_gfx2hlsl_join_symbols_check`, `startup_translator_check`, `startup_gfx2hlsl_refusals_check`, `startup_gfx2hlsl_mask_data_check`, `startup_mesh57_skeleton_check`, `docs_links_check`, `bidi_controls_check`. **Mutation checks**, run by hand. Each fails the controls, which the draw variants run first (a refusal or a wrong symbol, not a pixel change): - dropping the symbol copy; - skipping the four-word check; - dropping the `vcc` lost marking. **Measured** on the same capture with this branch on `7287979`: of the 42 requests that stopped at `mask from descriptor data`, 41 now pass it. They stop at later, unrelated refusals: 64-bit literal sources, `s_lshl*_add_u32` and `s_nand_b64` on a lane mask, `v_ldexp_f32`, `s_bfm_b32`, and another descriptor operand without a symbol. So none of them translates fully yet. One stays refused for `exec` from descriptor data. AI-assisted.
tedin7 commented 2026-11-26 03:03:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:54:58Z.

Review: COMMENTED


Update for #2669 (head 9bba71f3).

What I added: only a merge of origin/main into the branch (no rebase, no force-push). One conflict in tools/startup/gfx2hlsl.py, in Stage's scalar handler: kept both the new s_mov_b64 vcc descriptor copy and main's TG_SIZE refusal block. No other change to the author's code.

Review of the code (fixtures only):

  • The vcc copy, the mark_vcc_descriptor sharing, the up-front vcc check in Stage.one and the malformed s[104:107] refusals match the PR description.
  • A real D3D12 WARP draw test exists (startup_gfx2hlsl_desc_vcc_<adapter>, registered in CMakeLists.txt), next to the offline check. Mutation: renaming the mark_vcc_descriptor() call makes the offline check fail with an AttributeError.

Commands executed:

  • Linux: python3 -B tests/startup_gfx2hlsl_desc_vcc_check.py ok, startup_gfx2hlsl_sload_s104_check.py ok, startup_gfx2hlsl_desc_ptr_prop_check.py ok, startup_compute_tg_size_check.py ok.
  • Win2025 WARP with the merge applied as a patch on the old head: x2w_pipe.py win2025 2669 --patch <merge diff> --regex 'startup_gfx2hlsl_desc_vcc|startup_gfx2hlsl_sload|tg_size|startup_gfx2hlsl_desc_ptr': dev 15/15 passed, release /O2 15/15 passed, Windows Python checks ok.

The description says it is motivated by a capture of the title. We have no way to check that claim, so the merge is left to @R0Y00 or MasterDomino, who can verify it. CI needs to run on the new head.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067929912 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2669#pullrequestreview-6067929912). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T02:54:58Z. **Review:** COMMENTED --- Update for #2669 (head 9bba71f3). What I added: only a merge of origin/main into the branch (no rebase, no force-push). One conflict in tools/startup/gfx2hlsl.py, in Stage's scalar handler: kept both the new `s_mov_b64 vcc` descriptor copy and main's TG_SIZE refusal block. No other change to the author's code. Review of the code (fixtures only): - The vcc copy, the `mark_vcc_descriptor` sharing, the up-front vcc check in `Stage.one` and the malformed `s[104:107]` refusals match the PR description. - A real D3D12 WARP draw test exists (`startup_gfx2hlsl_desc_vcc_<adapter>`, registered in CMakeLists.txt), next to the offline check. Mutation: renaming the `mark_vcc_descriptor()` call makes the offline check fail with an AttributeError. Commands executed: - Linux: `python3 -B tests/startup_gfx2hlsl_desc_vcc_check.py` ok, `startup_gfx2hlsl_sload_s104_check.py` ok, `startup_gfx2hlsl_desc_ptr_prop_check.py` ok, `startup_compute_tg_size_check.py` ok. - Win2025 WARP with the merge applied as a patch on the old head: `x2w_pipe.py win2025 2669 --patch <merge diff> --regex 'startup_gfx2hlsl_desc_vcc|startup_gfx2hlsl_sload|tg_size|startup_gfx2hlsl_desc_ptr'`: dev 15/15 passed, release /O2 15/15 passed, Windows Python checks ok. The description says it is motivated by a capture of the title. We have no way to check that claim, so the merge is left to @R0Y00 or MasterDomino, who can verify it. CI needs to run on the new head. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 06:01:49 +00:00
R0Y00 commented 2026-11-26 06:01:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T05:13:25Z.

Review: APPROVED


The previous Windows failure came from duplicated Pass fields on the old main. This synchronization retains the VCC descriptor-word tracking and the lost-mask, malformed-range and branch refusals. The Python controls and the direct versus VCC-aliased FXC/DXC shader readbacks passed on WARP and RTX 4060 Laptop using synthetic buffer data in the shader helper.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068877541 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2669#pullrequestreview-6068877541). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T05:13:25Z. **Review:** APPROVED --- The previous Windows failure came from duplicated Pass fields on the old main. This synchronization retains the VCC descriptor-word tracking and the lost-mask, malformed-range and branch refusals. The Python controls and the direct versus VCC-aliased FXC/DXC shader readbacks passed on WARP and RTX 4060 Laptop using synthetic buffer data in the shader helper.
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!2661
No description provided.