Recompiler: pixel shaders run through execz skips with EXEC 0 on NVIDIA #3591

Open
Royalflamejlh wants to merge 1 commit from upstream-pr/3591 into main
Royalflamejlh commented 2026-12-01 17:29:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-01T17:29:52Z.


(Edited: head f4413ddb3, on main 078358a0: a region that writes an SGPR chosen by M0 (s_movrelsd_2_b32) keeps its branch, from @fromthemoonx's merge-check. The whole suite and the smoke pair below are of this head.)

On NVIDIA, a pixel wave whose pixels all skip a block by s_cbranch_execz can come out unwritten. Fixes #3574: there, the synthetic test below left 896 of 4,096 pixels at the clear colour on an RTX 4060 Ti under Wine + vkd3d-proton, and @imnicho saw the same 896 on an RTX 5080 on native Windows 10 (driver 610.47), and 784 with an explicit-level sample in the block. Waves with pixels on both sides of the branch draw right. This change goes around the fault on NVIDIA only; every other adapter keeps the skip, as the console takes it.

What is in it

  • gpu/recomp/ps_masks.rs: flat_skips, the forward s_cbranch_execz skips of a pixel shader that can run with every lane masked instead: the region ends where the branch goes and branches only forward inside, writes no EXEC, exports nothing, ends no program (any instruction without a successor: s_endpgm, s_endpgm_saved, s_endpgm_ordered_ps_done), changes no float mode (s_round_mode, s_denorm_mode, s_setreg), writes no SGPR chosen by M0 (s_movrelsd_2_b32), runs nothing EXEC does not mask, and writes no SGPR or SCC that is read after it before being written again (SCC read as a src_scc operand included, lane_masks::reads_scc).
  • gpu/dxil/kernel.rs, gpu/dxil/lower.rs: such a skip is not taken as a branch (its condition is false) when ps_skip_run_through() holds: on an NVIDIA adapter, by vendor id 0x10DE or by name, since DXVK's dxgi reports NVIDIA cards as AMD's (0x1002) under Wine unless dxgi.hideNvidiaGpu is off (gpu/adapter.rs is_nvidia; the adapter the device is made on, picked by the same rule, device_candidates), or forced by XCL_PS_SKIP_RUN_THROUGH=1 / 0. Every other skip is unchanged.
  • gpu/recomp/pso.rs, shaders.rs: the decision is part of the translated cache's identity, and the switch is one of the warm settings, so a cache made one way is not loaded the other.
  • Tests: gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values, a wave64 if / else on a disc, each block skipped by s_cbranch_execz, drawn with the second block sampling by IMAGE_SAMPLE and by IMAGE_SAMPLE_LZ; unit tests of the analysis (a region with a backward branch or a program end keeps its branch), of the vendor decision and of the cache identity.

In one retail pack's 12,101 pixel-shader programs, 125,815 of 255,127 such skips (in 7,984 programs) run through on NVIDIA (counted before program ends were refused). A region run through with EXEC 0 changes no result: every VGPR write and store is EXEC-guarded, implicit-LOD samples run with the heap index clamped and their results go unused, and other samples are not issued for inactive lanes. What it costs is those samples' fetches; a synthetic timing is under Tested. Its GPU time in the title is not measured.

Tested

  • At f4413ddb3, native Windows: RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, Rust 1.100.0, debug: cargo test --workspace -- --test-threads=4: 3,016 passed, 0 failed, 52 ignored; SKIPPED 29 (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 2 no D3D12 debug layer, 1 no GPU_UPLOAD heaps). The GPU test passed.
  • GPU time, at f4413ddb3 plus a timing test kept out of this PR, RTX 4060 Ti 16 GB (NVIDIA 615.71.09), Linux, Wine: a full-screen 2048×2048 draw of a wave64 pixel shader whose s_cbranch_execz region holds N implicit-LOD samples. With no lane in the region in any wave, the run-through cost 0.001, 0.050 and 0.230 ms over the kept skip for 8, 16 and 32 samples (0.134 to 0.135 ms with the skip kept). With every lane in it, the draw took 0.315, 0.323 and 0.424 ms either way. Medians of 5 processes of 20 draws each. This is an upper bound: every wave of these draws skips the region.
  • The switch changes 7,324 of 12,056 translated pixel shaders of the retail title, from a diff of the two translated caches after one offline pass each way.
  • At f4413ddb3, under Wine without a card (lavapipe): cargo test -p xcl --release --target x86_64-pc-windows-gnu --lib -- adapter ps_masks ps_skip lane_masks agility pso:: shaders:: d3d12x::real:: gpu::dxil: 706 passed, 8 failed, 5 ignored; the PR's base 078358a0 here: 697 passed, the same 8 failed, 5 ignored. execz_skips_over_a_relative_sgpr_move_keep_the_branch fails without the s_movrelsd_2_b32 refusal.
  • RTX 4060 Ti 16 GB, NVIDIA 615.71.09, AMD Ryzen 9 9950X3D, Linux, Wine 11.21 Staging, vkd3d-proton master with local patches, Rust 1.98.0, x86_64-pc-windows-gnu, release.
  • The GPU test, at ef570fa0a: passes; with lw.flat_skips = Default::default(); at gpu/dxil/kernel.rs:815 it fails, "IMAGE_SAMPLE: 896 pixels hold another branch's values, first (20, 16)", 1 run each. Not yet run at 79dbb7065 (the gate and switch).
  • At f6a07c872 (the vendor taken from the device's adapter), under Wine without a card: adapter ps_masks ps_skip pso:: shaders:: d3d12x::real::: 323 passed, 6 failed (the same 6 as main), with device_order_falls_back_to_every_adapter_when_none_matches red against the old rule. The GPU test at this head on the RTX 4060 Ti: passes; with XCL_PS_SKIP_RUN_THROUGH=0 it fails, "IMAGE_SAMPLE: 896 pixels hold another branch's values", 1 run each.
  • At 79dbb7065, under Wine without a card: cargo test -p xcl --release --lib -- ps_masks gpu::dxil pso:: shaders::: 454 passed, 1 failed (round_tests::directed_reference_basics, which fails on main here too), 4 ignored. The new program-end test fails at ef570fa0a's check (S_ENDPGM_SAVED runs through).
  • On a tree with other unmerged pull requests, in a retail title (1 run each): the black region over one shot that the fault draws was gone; 3 runs with the change, no device removal.

Regression run
RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, release builds by scripts/smoke.ps1, the same retail title for 60 s each.

main:

xcl-smoke v1
commit: 395405e4c0ed814afde0610a724dc96a3af329de
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1522 (PresentX 1522)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 16017 MB

this PR's head:

xcl-smoke v1
commit: f4413ddb3b5423acdefe02f3fdba2a2c9fc51c62
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1551 (PresentX 1551)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15203 MB

Not tested

  • AMD (where it is now off), GPU time in the title (the title runs here ran out of memory before any frame heavy enough to time), the synthetic timing on Windows. The cause in the driver is not known; this goes around it.

AI use

  • Claude Code, Claude Opus 5.5: found the shader, wrote the change, the tests and this description; Claude Fable 5.2 made the earlier card and title runs.
<!-- greyfinch-sync:ivall/xcl:issue:5590946425 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-01T17:29:52Z. --- (Edited: head `f4413ddb3`, on `main` 078358a0: a region that writes an SGPR chosen by M0 (`s_movrelsd_2_b32`) keeps its branch, from @fromthemoonx's merge-check. The whole suite and the smoke pair below are of this head.) On NVIDIA, a pixel wave whose pixels all skip a block by `s_cbranch_execz` can come out unwritten. Fixes #3574: there, the synthetic test below left 896 of 4,096 pixels at the clear colour on an RTX 4060 Ti under Wine + vkd3d-proton, and @imnicho saw the same 896 on an RTX 5080 on native Windows 10 (driver 610.47), and 784 with an explicit-level sample in the block. Waves with pixels on both sides of the branch draw right. This change goes around the fault on NVIDIA only; every other adapter keeps the skip, as the console takes it. **What is in it** - `gpu/recomp/ps_masks.rs`: `flat_skips`, the forward `s_cbranch_execz` skips of a pixel shader that can run with every lane masked instead: the region ends where the branch goes and branches only forward inside, writes no EXEC, exports nothing, ends no program (any instruction without a successor: `s_endpgm`, `s_endpgm_saved`, `s_endpgm_ordered_ps_done`), changes no float mode (`s_round_mode`, `s_denorm_mode`, `s_setreg`), writes no SGPR chosen by M0 (`s_movrelsd_2_b32`), runs nothing EXEC does not mask, and writes no SGPR or SCC that is read after it before being written again (SCC read as a `src_scc` operand included, `lane_masks::reads_scc`). - `gpu/dxil/kernel.rs`, `gpu/dxil/lower.rs`: such a skip is not taken as a branch (its condition is `false`) when `ps_skip_run_through()` holds: on an NVIDIA adapter, by vendor id `0x10DE` or by name, since DXVK's dxgi reports NVIDIA cards as AMD's (`0x1002`) under Wine unless `dxgi.hideNvidiaGpu` is off (`gpu/adapter.rs` `is_nvidia`; the adapter the device is made on, picked by the same rule, `device_candidates`), or forced by `XCL_PS_SKIP_RUN_THROUGH=1` / `0`. Every other skip is unchanged. - `gpu/recomp/pso.rs`, `shaders.rs`: the decision is part of the translated cache's identity, and the switch is one of the warm settings, so a cache made one way is not loaded the other. - Tests: `gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values`, a wave64 if / else on a disc, each block skipped by `s_cbranch_execz`, drawn with the second block sampling by `IMAGE_SAMPLE` and by `IMAGE_SAMPLE_LZ`; unit tests of the analysis (a region with a backward branch or a program end keeps its branch), of the vendor decision and of the cache identity. In one retail pack's 12,101 pixel-shader programs, 125,815 of 255,127 such skips (in 7,984 programs) run through on NVIDIA (counted before program ends were refused). A region run through with EXEC 0 changes no result: every VGPR write and store is EXEC-guarded, implicit-LOD samples run with the heap index clamped and their results go unused, and other samples are not issued for inactive lanes. What it costs is those samples' fetches; a synthetic timing is under **Tested**. Its GPU time in the title is not measured. **Tested** - At `f4413ddb3`, native Windows: RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, Rust 1.100.0, debug: `cargo test --workspace -- --test-threads=4`: 3,016 passed, 0 failed, 52 ignored; SKIPPED 29 (22 no wave64, 2 no heap windows, 2 no `d3d12SDKLayers.dll`, 2 no D3D12 debug layer, 1 no GPU_UPLOAD heaps). The GPU test passed. - GPU time, at `f4413ddb3` plus a timing test kept out of this PR, RTX 4060 Ti 16 GB (NVIDIA 615.71.09), Linux, Wine: a full-screen 2048×2048 draw of a wave64 pixel shader whose `s_cbranch_execz` region holds N implicit-LOD samples. With no lane in the region in any wave, the run-through cost 0.001, 0.050 and 0.230 ms over the kept skip for 8, 16 and 32 samples (0.134 to 0.135 ms with the skip kept). With every lane in it, the draw took 0.315, 0.323 and 0.424 ms either way. Medians of 5 processes of 20 draws each. This is an upper bound: every wave of these draws skips the region. - The switch changes 7,324 of 12,056 translated pixel shaders of the retail title, from a diff of the two translated caches after one offline pass each way. - At `f4413ddb3`, under Wine without a card (lavapipe): `cargo test -p xcl --release --target x86_64-pc-windows-gnu --lib -- adapter ps_masks ps_skip lane_masks agility pso:: shaders:: d3d12x::real:: gpu::dxil`: 706 passed, 8 failed, 5 ignored; the PR's base `078358a0` here: 697 passed, the same 8 failed, 5 ignored. `execz_skips_over_a_relative_sgpr_move_keep_the_branch` fails without the `s_movrelsd_2_b32` refusal. - RTX 4060 Ti 16 GB, NVIDIA 615.71.09, AMD Ryzen 9 9950X3D, Linux, Wine 11.21 Staging, vkd3d-proton `master` with local patches, Rust 1.98.0, `x86_64-pc-windows-gnu`, release. - The GPU test, at `ef570fa0a`: passes; with `lw.flat_skips = Default::default();` at `gpu/dxil/kernel.rs:815` it fails, "IMAGE_SAMPLE: 896 pixels hold another branch's values, first (20, 16)", 1 run each. Not yet run at `79dbb7065` (the gate and switch). - At `f6a07c872` (the vendor taken from the device's adapter), under Wine without a card: `adapter ps_masks ps_skip pso:: shaders:: d3d12x::real::`: 323 passed, 6 failed (the same 6 as `main`), with `device_order_falls_back_to_every_adapter_when_none_matches` red against the old rule. The GPU test at this head on the RTX 4060 Ti: passes; with `XCL_PS_SKIP_RUN_THROUGH=0` it fails, "IMAGE_SAMPLE: 896 pixels hold another branch's values", 1 run each. - At `79dbb7065`, under Wine without a card: `cargo test -p xcl --release --lib -- ps_masks gpu::dxil pso:: shaders::`: 454 passed, 1 failed (`round_tests::directed_reference_basics`, which fails on `main` here too), 4 ignored. The new program-end test fails at `ef570fa0a`'s check (`S_ENDPGM_SAVED` runs through). - On a tree with other unmerged pull requests, in a retail title (1 run each): the black region over one shot that the fault draws was gone; 3 runs with the change, no device removal. **Regression run** RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, release builds by `scripts/smoke.ps1`, the same retail title for 60 s each. `main`: ``` xcl-smoke v1 commit: 395405e4c0ed814afde0610a724dc96a3af329de gpu: NVIDIA GeForce RTX 2070 SUPER title: 5330474d seconds: 60 exit: 0x0 frames shown: 1522 (PresentX 1522) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 16017 MB ``` this PR's head: ``` xcl-smoke v1 commit: f4413ddb3b5423acdefe02f3fdba2a2c9fc51c62 gpu: NVIDIA GeForce RTX 2070 SUPER title: 5330474d seconds: 60 exit: 0x0 frames shown: 1551 (PresentX 1551) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 15203 MB ``` **Not tested** - AMD (where it is now off), GPU time in the title (the title runs here ran out of memory before any frame heavy enough to time), the synthetic timing on Windows. The cause in the driver is not known; this goes around it. **AI use** - Claude Code, Claude Opus 5.5: found the shader, wrote the change, the tests and this description; Claude Fable 5.2 made the earlier card and title runs.
Foniass commented 2026-12-01 20:38:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T20:38:45Z.


Review (head ef570fa0, diff read, not a merge-check; checks red):

  • On by default for every vendor, with no measurement. flat_skips is computed for every non-split pixel shader at gpu/dxil/kernel.rs ~815 with no vendor gate or switch, so AMD, which does not have the fault, changes too. By the description's own count, 125,815 skips in 7,984 of 12,101 programs now run their region in waves that used to jump over it, and implicit-LOD samples in a pixel shader stay unguarded for derivatives (gpu/dxil/lower_image.rs ~1271-1275), so those regions now fetch textures with no live lane. There are no smoke runs (the reason the PR description check is red) and no GPU-time numbers.
  • Other program-end instructions inside the region are not refused. The region check at gpu/recomp/ps_masks.rs ~488-490 excludes only S_ENDPGM by name. Terminators have no successors, so succ[k].iter().all(..) holds vacuously for S_ENDPGM_SAVED and S_ENDPGM_ORDERED_PS_DONE, which gpu/dxil/cfg.rs ~38 treats as program ends; a wave with EXEC 0 would end inside the region and skip the exports after it. Checking F_TERMINATOR (or an empty succ[k]) covers all three.

Fine: the analysis refuses EXEC writes, exports, backward branches and SGPR/SCC values live after the region; VGPR writes and stores stay EXEC-guarded in the lowering (write32, act()); unit tests cover accepted and refused shapes, and the GPU test reproduces the 896-pixel fault (it fails without the fix only on NVIDIA). #1834 also collapses forward s_cbranch_execz regions (in cfg.rs, for compute), so expect an interaction if both land.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7325035414 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7325035414). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T20:38:45Z. --- Review (head ef570fa0, diff read, not a merge-check; checks red): - **On by default for every vendor, with no measurement.** `flat_skips` is computed for every non-split pixel shader at `gpu/dxil/kernel.rs` ~815 with no vendor gate or switch, so AMD, which does not have the fault, changes too. By the description's own count, 125,815 skips in 7,984 of 12,101 programs now run their region in waves that used to jump over it, and implicit-LOD samples in a pixel shader stay unguarded for derivatives (`gpu/dxil/lower_image.rs` ~1271-1275), so those regions now fetch textures with no live lane. There are no smoke runs (the reason the `PR description` check is red) and no GPU-time numbers. - **Other program-end instructions inside the region are not refused.** The region check at `gpu/recomp/ps_masks.rs` ~488-490 excludes only `S_ENDPGM` by name. Terminators have no successors, so `succ[k].iter().all(..)` holds vacuously for `S_ENDPGM_SAVED` and `S_ENDPGM_ORDERED_PS_DONE`, which `gpu/dxil/cfg.rs` ~38 treats as program ends; a wave with EXEC 0 would end inside the region and skip the exports after it. Checking `F_TERMINATOR` (or an empty `succ[k]`) covers all three. Fine: the analysis refuses EXEC writes, exports, backward branches and SGPR/SCC values live after the region; VGPR writes and stores stay EXEC-guarded in the lowering (`write32`, `act()`); unit tests cover accepted and refused shapes, and the GPU test reproduces the 896-pixel fault (it fails without the fix only on NVIDIA). #1834 also collapses forward `s_cbranch_execz` regions (in `cfg.rs`, for compute), so expect an interaction if both land. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Royalflamejlh commented 2026-12-01 20:54:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-01T20:54:43Z.


@Foniass thank you; both points are fixed at 79dbb7065.

  • Program ends: a region now keeps its branch if any instruction in it has no successor, which covers s_endpgm_saved and s_endpgm_ordered_ps_done as well as s_endpgm. A unit test fails on S_ENDPGM_SAVED against ef570fa0's check.
  • Every vendor: the run-through is now taken only on NVIDIA adapters (vendor 0x10DE); XCL_PS_SKIP_RUN_THROUGH=1 or 0 forces it either way. The decision is part of the translated cache's identity and the switch is a warm setting. Every other adapter keeps the skip, as the console takes it.
  • Derivatives: a region run with EXEC 0 changes no result: VGPR writes and stores are EXEC-guarded, implicit-LOD samples clamp the heap index and their results go unused, and other samples are not issued for inactive lanes. What it costs is those fetches. GPU time and the smoke runs are still owed; the card here was busy, so the GPU test has not run at this head yet.
  • #1834: it collapses forward execz regions without image instructions in graphs of 128 blocks or more, on every vendor, so the sampling regions of #3574 stay with this change. If both land, kernel.rs / lower.rs will conflict as text and large pixel shaders change on AMD through #1834.

AI use: Claude Code (Claude Opus 5.5) checked both points, made the changes and drafted this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7325459324 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7325459324). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-01T20:54:43Z. --- @Foniass thank you; both points are fixed at `79dbb7065`. - **Program ends:** a region now keeps its branch if any instruction in it has no successor, which covers `s_endpgm_saved` and `s_endpgm_ordered_ps_done` as well as `s_endpgm`. A unit test fails on `S_ENDPGM_SAVED` against `ef570fa0`'s check. - **Every vendor:** the run-through is now taken only on NVIDIA adapters (vendor `0x10DE`); `XCL_PS_SKIP_RUN_THROUGH=1` or `0` forces it either way. The decision is part of the translated cache's identity and the switch is a warm setting. Every other adapter keeps the skip, as the console takes it. - **Derivatives:** a region run with EXEC 0 changes no result: VGPR writes and stores are EXEC-guarded, implicit-LOD samples clamp the heap index and their results go unused, and other samples are not issued for inactive lanes. What it costs is those fetches. GPU time and the smoke runs are still owed; the card here was busy, so the GPU test has not run at this head yet. - **#1834:** it collapses forward execz regions without image instructions in graphs of 128 blocks or more, on every vendor, so the sampling regions of #3574 stay with this change. If both land, `kernel.rs` / `lower.rs` will conflict as text and large pixel shaders change on AMD through #1834. AI use: Claude Code (Claude Opus 5.5) checked both points, made the changes and drafted this reply.
Foniass commented 2026-12-01 21:06:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T21:06:57Z.


Follow-up review (head 79dbb706, since ef570fa0, diff read, not a merge-check; checks red):

  • On by default for every vendor, with no measurement: partly fixed. flat_skips now runs only when ps_skip_run_through() holds (gpu/dxil/kernel.rs ~108-119, ~840): by default only on vendor 0x10DE, with XCL_PS_SKIP_RUN_THROUGH=0/1 to force it, so AMD and others keep the console's skip. It is still on by default on NVIDIA with no smoke runs (the reason PR description is red), no GPU-time numbers, and the GPU test not rerun at this head.
  • Other program-end instructions inside the region are not refused: fixed. ps_masks.rs ~488 now requires !succ[k].is_empty(), which refuses S_ENDPGM, S_ENDPGM_SAVED and S_ENDPGM_ORDERED_PS_DONE, and execz_skips_over_a_program_end_keep_the_branch covers all three.

New:

  • The vendor is picked differently from the device. adapter::vendor() (gpu/adapter.rs ~153-157) takes the first adapter that d3d12_adapter / XCL_ADAPTER matches and returns None when none does, while the device code (hle/d3d12x/real.rs ~989-1000) falls back to Selector::Auto and takes the first adapter that creates a device. An XCL_ADAPTER value that matches nothing on an NVIDIA machine still gets an NVIDIA device but leaves the workaround off, and if the first match fails device creation the decision is made for a different GPU than the one in use.

Fine: the decision is a process-wide OnceLock and part of the translated cache identity (pso.rs ~388, with a test); the switch is among the warm settings in shaders.rs; launch preparation passes the title's adapter to its child as XCL_ADAPTER, so the prepared cache and the runtime agree.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7325768486 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7325768486). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T21:06:57Z. --- Follow-up review (head 79dbb706, since ef570fa0, diff read, not a merge-check; checks red): - **On by default for every vendor, with no measurement:** partly fixed. `flat_skips` now runs only when `ps_skip_run_through()` holds (`gpu/dxil/kernel.rs` ~108-119, ~840): by default only on vendor `0x10DE`, with `XCL_PS_SKIP_RUN_THROUGH=0`/`1` to force it, so AMD and others keep the console's skip. It is still on by default on NVIDIA with no smoke runs (the reason `PR description` is red), no GPU-time numbers, and the GPU test not rerun at this head. - **Other program-end instructions inside the region are not refused:** fixed. `ps_masks.rs` ~488 now requires `!succ[k].is_empty()`, which refuses `S_ENDPGM`, `S_ENDPGM_SAVED` and `S_ENDPGM_ORDERED_PS_DONE`, and `execz_skips_over_a_program_end_keep_the_branch` covers all three. New: - **The vendor is picked differently from the device.** `adapter::vendor()` (`gpu/adapter.rs` ~153-157) takes the first adapter that `d3d12_adapter` / `XCL_ADAPTER` matches and returns `None` when none does, while the device code (`hle/d3d12x/real.rs` ~989-1000) falls back to `Selector::Auto` and takes the first adapter that creates a device. An `XCL_ADAPTER` value that matches nothing on an NVIDIA machine still gets an NVIDIA device but leaves the workaround off, and if the first match fails device creation the decision is made for a different GPU than the one in use. Fine: the decision is a process-wide `OnceLock` and part of the translated cache identity (`pso.rs` ~388, with a test); the switch is among the warm settings in `shaders.rs`; launch preparation passes the title's adapter to its child as `XCL_ADAPTER`, so the prepared cache and the runtime agree. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Royalflamejlh commented 2026-12-01 21:57:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-01T21:57:53Z.


@Foniass right; fixed at f6a07c872. adapter::vendor() now walks adapter::device_candidates, which the device code in real.rs uses too: the same match, the same fallback to every hardware adapter when XCL_ADAPTER matches nothing, and the first adapter that supports a device (asked with a null output pointer, so none is made). device_order_falls_back_to_every_adapter_when_none_matches fails against the old rule. Under Wine on the CPU, adapter ps_masks ps_skip pso:: shaders:: d3d12x::real::: 323 passed, 6 failed, the same 6 as main here.

Still owed at this head: the GPU test on a card (ours was busy), the smoke pair, and GPU time.

AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and drafted this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7327073037 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7327073037). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-01T21:57:53Z. --- @Foniass right; fixed at `f6a07c872`. `adapter::vendor()` now walks `adapter::device_candidates`, which the device code in `real.rs` uses too: the same match, the same fallback to every hardware adapter when `XCL_ADAPTER` matches nothing, and the first adapter that supports a device (asked with a null output pointer, so none is made). `device_order_falls_back_to_every_adapter_when_none_matches` fails against the old rule. Under Wine on the CPU, `adapter ps_masks ps_skip pso:: shaders:: d3d12x::real::`: 323 passed, 6 failed, the same 6 as `main` here. Still owed at this head: the GPU test on a card (ours was busy), the smoke pair, and GPU time. AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and drafted this reply.
Foniass commented 2026-12-01 21:59:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T21:59:08Z.


Follow-up review (head f6a07c87, since 79dbb706, diff read, not a merge-check; checks red):

  • On by default with no measurement: partly fixed, unchanged. The run-through is on only for vendor 0x10DE with XCL_PS_SKIP_RUN_THROUGH=0/1 to force it (gpu/dxil/kernel.rs ~106-119), but that NVIDIA default still has no xcl-smoke pair ("Owed"), no GPU-time numbers, and the GPU test has not been rerun at the gated heads.
  • Other program-end instructions inside the region: fixed, unchanged (ps_masks.rs ~488 and execz_skips_over_a_program_end_keep_the_branch).
  • The vendor is picked differently from the device: fixed. adapter::device_order / device_candidates (gpu/adapter.rs ~118-159) now hold the rule for both: the adapters XCL_ADAPTER / d3d12_adapter match, every hardware adapter when none matches, nothing for warp. real.rs ~989-992 builds the device from that list, and vendor() (~172-180) takes the first entry where agility::device_supported (gpu/agility.rs ~349-363) can make a device at the same feature level and path; device_order_falls_back_to_every_adapter_when_none_matches tests the fallback.

New: none.

Fine: real.rs still logs the no-match warning and falls back as before; the decision is still a process-wide OnceLock in the translated cache identity; with warp, or no hardware adapter that can make a device, vendor() returns None, matching the WARP device.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7327102734 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7327102734). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T21:59:08Z. --- Follow-up review (head f6a07c87, since 79dbb706, diff read, not a merge-check; checks red): - **On by default with no measurement:** partly fixed, unchanged. The run-through is on only for vendor `0x10DE` with `XCL_PS_SKIP_RUN_THROUGH=0`/`1` to force it (`gpu/dxil/kernel.rs` ~106-119), but that NVIDIA default still has no `xcl-smoke` pair ("Owed"), no GPU-time numbers, and the GPU test has not been rerun at the gated heads. - **Other program-end instructions inside the region:** fixed, unchanged (`ps_masks.rs` ~488 and `execz_skips_over_a_program_end_keep_the_branch`). - **The vendor is picked differently from the device:** fixed. `adapter::device_order` / `device_candidates` (`gpu/adapter.rs` ~118-159) now hold the rule for both: the adapters `XCL_ADAPTER` / `d3d12_adapter` match, every hardware adapter when none matches, nothing for `warp`. `real.rs` ~989-992 builds the device from that list, and `vendor()` (~172-180) takes the first entry where `agility::device_supported` (`gpu/agility.rs` ~349-363) can make a device at the same feature level and path; `device_order_falls_back_to_every_adapter_when_none_matches` tests the fallback. New: none. Fine: `real.rs` still logs the no-match warning and falls back as before; the decision is still a process-wide `OnceLock` in the translated cache identity; with `warp`, or no hardware adapter that can make a device, `vendor()` returns `None`, matching the WARP device. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Royalflamejlh commented 2026-12-01 22:04:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-01T22:04:30Z.


The GPU test at f6a07c872, RTX 4060 Ti (NVIDIA 615.71.09) under Wine: passes; with XCL_PS_SKIP_RUN_THROUGH=0 it fails with "IMAGE_SAMPLE: 896 pixels hold another branch's values", 1 run each. So the vendor decision picks the NVIDIA adapter here and the switch forces it off. The description says so.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7327229476 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7327229476). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-01T22:04:30Z. --- The GPU test at `f6a07c872`, RTX 4060 Ti (NVIDIA 615.71.09) under Wine: passes; with `XCL_PS_SKIP_RUN_THROUGH=0` it fails with "IMAGE_SAMPLE: 896 pixels hold another branch's values", 1 run each. So the vendor decision picks the NVIDIA adapter here and the switch forces it off. The description says so. AI use: Claude Code (Claude Opus 5.5).
throny commented 2026-12-02 04:13:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T04:13:26Z.


merge-check claim
head: f6a07c8729

<!-- greyfinch-sync:ivall/xcl:comment:7334686811 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7334686811). Originally posted by [throny](https://github.com/throny) on 2026-12-02T04:13:26Z. --- merge-check claim head: f6a07c8729885abef3b3bfec4bcda36ec28d1223
throny commented 2026-12-02 04:50:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T04:50:20Z.


merge-check
base: 1c8b55147 (main)
head: f6a07c8729
merge: clean trial merge into main 1c8b55147 (merge_trial_suite.sh 3591).
build: cargo build --workspace passed.
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 on the merged tree: 2916 passed, 0 failed, 51 ignored; 25 SKIPPED notices (no wave64, no heap windows, driver cache); 0 binaries ended abnormally. Passing at this head: ps_skips_run_through_on_nvidia_unless_switched, execz_skips_over_a_program_end_keep_the_branch, execz_skips_over_a_loop_keep_the_branch, execz_skips_run_through_when_nothing_after_reads_what_they_skip, translated_identity_tracks_the_ps_skip_run_through. The PR's GPU test gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values was not found by name in the log lines I searched, so I do not claim it ran here.
review: diff read (10 files, +385/-16). All points of the earlier reviews are fixed at this head and re-checked in the diff: run-through only on vendor 0x10DE (or by XCL_PS_SKIP_RUN_THROUGH=1/0), program ends refused through !succ[k].is_empty(), the vendor picked by the same device_candidates rule as the device. The analysis refuses EXEC writes, exports, V_WRITELANE, S_SENDMSG, scalar stores/atomics, indirect and backward branches, and SGPR/SCC values read after the region; the unit tests cover accepted and refused shapes. Remaining, not blockers: implicit-LOD samples now run in regions with no live lane on NVIDIA (a cost, not a result change); a text conflict with #1834 in kernel.rs / lower.rs, as the author says.
performance: regression run in the description (retail title, 60 s, same title): main 1620 frames, this head 1628, 0 device removals, peak commit 15476 vs 15259 MB. The PR's GPU test, on an RTX 4060 Ti under Wine: passes; with XCL_PS_SKIP_RUN_THROUGH=0 it fails ("896 pixels hold another branch's values"), 1 run each. No GPU-time numbers; no in-world run of this head by us.
verdict: safe to merge (NVIDIA-only by default, switchable, other vendors unchanged); GPU-time numbers are still owed by the author and are not a blocker.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report

<!-- greyfinch-sync:ivall/xcl:comment:7335313188 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7335313188). Originally posted by [throny](https://github.com/throny) on 2026-12-02T04:50:20Z. --- merge-check base: 1c8b55147 (main) head: f6a07c8729885abef3b3bfec4bcda36ec28d1223 merge: clean trial merge into main 1c8b55147 (`merge_trial_suite.sh 3591`). build: `cargo build --workspace` passed. tests: `cargo test --workspace --no-fail-fast -- --test-threads=4` on the merged tree: 2916 passed, 0 failed, 51 ignored; 25 SKIPPED notices (no wave64, no heap windows, driver cache); 0 binaries ended abnormally. Passing at this head: `ps_skips_run_through_on_nvidia_unless_switched`, `execz_skips_over_a_program_end_keep_the_branch`, `execz_skips_over_a_loop_keep_the_branch`, `execz_skips_run_through_when_nothing_after_reads_what_they_skip`, `translated_identity_tracks_the_ps_skip_run_through`. The PR's GPU test `gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values` was not found by name in the log lines I searched, so I do not claim it ran here. review: diff read (10 files, +385/-16). All points of the earlier reviews are fixed at this head and re-checked in the diff: run-through only on vendor 0x10DE (or by `XCL_PS_SKIP_RUN_THROUGH=1/0`), program ends refused through `!succ[k].is_empty()`, the vendor picked by the same `device_candidates` rule as the device. The analysis refuses EXEC writes, exports, `V_WRITELANE`, `S_SENDMSG`, scalar stores/atomics, indirect and backward branches, and SGPR/SCC values read after the region; the unit tests cover accepted and refused shapes. Remaining, not blockers: implicit-LOD samples now run in regions with no live lane on NVIDIA (a cost, not a result change); a text conflict with #1834 in `kernel.rs` / `lower.rs`, as the author says. performance: regression run in the description (retail title, 60 s, same title): main 1620 frames, this head 1628, 0 device removals, peak commit 15476 vs 15259 MB. The PR's GPU test, on an RTX 4060 Ti under Wine: passes; with `XCL_PS_SKIP_RUN_THROUGH=0` it fails ("896 pixels hold another branch's values"), 1 run each. No GPU-time numbers; no in-world run of this head by us. verdict: safe to merge (NVIDIA-only by default, switchable, other vendors unchanged); GPU-time numbers are still owed by the author and are not a blocker. hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report
Decodere commented 2026-12-02 08:12:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T08:12:43Z.


merge-check
base: 1c8b551475
head: f6a07c8729
merge: clean
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2915 passed, 1 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache / Windows Developer Mode required); failing: tests/gpu_two_pass_cache_e2e.rs :: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (pre-existing on clean base 1c8b5514: 2908 passed, 1 failed, 51 ignored, identical 28 SKIPPED). All 7 new tests pass with 0 skips (+7 vs base), including explicit isolated runs of gpu::recomp::tests::gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values with both default NVIDIA run-through (0.37 s) and XCL_PS_SKIP_RUN_THROUGH=0 (0.34 s).
review: Full merged diff read (10 files, +385/-16). No blocking findings. ps_masks::flat_skips enforces strict forward-DAG bounds (no loops, no exits past t, no indirect jumps, !succ[k].is_empty() blocking all three S_ENDPGM* forms, no EXEC writes, no EXP/V_WRITELANE_B32/S_SENDMSG/SMEM store or atomic), and its forward liveness worklist conservatively rejects any region whose SGPR or SCC writes can be read after t before overwrite. adapter::device_candidates and adapter::vendor() match real::init_with_remap, ps_skip_tagged keys translated cache identity under Backend::DirectAll, and XCL_PS_SKIP_RUN_THROUGH is registered in semantic_pipeline_setting. Non-blocking observation: gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values also passed with XCL_PS_SKIP_RUN_THROUGH=0 on this RTX 4060 (driver 621.40), so the #3574 miscompile itself did not trigger on this driver/card, though the default run-through path and cache/override plumbing were verified clean. Untested: AMD/Intel/native wave64 GPUs, D3D12 debug layer, and visual inspection of affected retail title surfaces.
performance: Default-on for NVIDIA direct-DXIL pixel shaders (switchable via XCL_PS_SKIP_RUN_THROUGH=0); waves with EXEC 0 still execute skipped forward regions (including texture fetches) instead of branching over them. Paired 60 s retail smoke (title 29640639, release) on RTX 4060: 1597 frames / 15484 MB peak commit (0 removals, 0 crashes) vs base 1c8b5514 1462 frames / 16043 MB (+9.2% frames, -3.5% commit; no regression).
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)

<!-- greyfinch-sync:ivall/xcl:comment:7339146644 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7339146644). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T08:12:43Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: f6a07c8729885abef3b3bfec4bcda36ec28d1223 merge: clean build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2915 passed, 1 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache / Windows Developer Mode required); failing: tests/gpu_two_pass_cache_e2e.rs :: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (pre-existing on clean base 1c8b5514: 2908 passed, 1 failed, 51 ignored, identical 28 SKIPPED). All 7 new tests pass with 0 skips (+7 vs base), including explicit isolated runs of gpu::recomp::tests::gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values with both default NVIDIA run-through (0.37 s) and XCL_PS_SKIP_RUN_THROUGH=0 (0.34 s). review: Full merged diff read (10 files, +385/-16). No blocking findings. ps_masks::flat_skips enforces strict forward-DAG bounds (no loops, no exits past t, no indirect jumps, !succ[k].is_empty() blocking all three S_ENDPGM* forms, no EXEC writes, no EXP/V_WRITELANE_B32/S_SENDMSG/SMEM store or atomic), and its forward liveness worklist conservatively rejects any region whose SGPR or SCC writes can be read after t before overwrite. adapter::device_candidates and adapter::vendor() match real::init_with_remap, ps_skip_tagged keys translated cache identity under Backend::DirectAll, and XCL_PS_SKIP_RUN_THROUGH is registered in semantic_pipeline_setting. Non-blocking observation: gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values also passed with XCL_PS_SKIP_RUN_THROUGH=0 on this RTX 4060 (driver 621.40), so the #3574 miscompile itself did not trigger on this driver/card, though the default run-through path and cache/override plumbing were verified clean. Untested: AMD/Intel/native wave64 GPUs, D3D12 debug layer, and visual inspection of affected retail title surfaces. performance: Default-on for NVIDIA direct-DXIL pixel shaders (switchable via XCL_PS_SKIP_RUN_THROUGH=0); waves with EXEC 0 still execute skipped forward regions (including texture fetches) instead of branching over them. Paired 60 s retail smoke (title 29640639, release) on RTX 4060: 1597 frames / 15484 MB peak commit (0 removals, 0 crashes) vs base 1c8b5514 1462 frames / 16043 MB (+9.2% frames, -3.5% commit; no regression). verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
Foniass commented 2026-12-02 13:48:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T13:48:29Z.


Follow-up review (head 8ca2df9d, since f6a07c87, diff read, not a merge-check; checks red):

  • Earlier points: unchanged. git range-diff shows the own commit changed only where main moved under it (the XCL_WAVE64_IDIOMS warm setting and cache tag now sit next to this PR's own in shaders.rs / kernel.rs); this push is a rebase.

New: none.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7347492803 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7347492803). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T13:48:29Z. --- Follow-up review (head 8ca2df9d, since f6a07c87, diff read, not a merge-check; checks red): - **Earlier points:** unchanged. `git range-diff` shows the own commit changed only where `main` moved under it (the `XCL_WAVE64_IDIOMS` warm setting and cache tag now sit next to this PR's own in `shaders.rs` / `kernel.rs`); this push is a rebase. New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
bmjask commented 2026-12-02 15:19:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:19:00Z.

Review: COMMENTED


Review of 8ca2df9d: 5 finding(s) (2 high, 3 medium), most severe first.

  1. High crates/xcl/src/gpu/recomp/ps_masks.rs:492: flat_skips doesn't refuse a region that changes the float mode (s_round_mode, s_denorm_mode, s_setreg_b32 / s_setreg_imm32_b32 on HW_REG_MODE). (inline)
  2. High crates/xcl/src/gpu/dxil/kernel.rs:890: The workaround exists only in the direct DXIL pixel path, so pixel shaders that go through the HLSL translator keep the plain execz branch NVIDIA miscompiles: direct DXIL's direct_fallback on error, ps_debug, and XCL_DIRECT_DXIL=0/1. (inline)
  3. Medium crates/xcl/src/gpu/recomp/ps_masks.rs:511: Reads of SCC after the region are found by instruction name only (reads_scc / S_CBRANCH_SCC*), so a read through the src_scc operand (code 253) is missed: scalar_code maps 253 to no register and sgpr_uses drops codes above 127, y.... (inline)
  4. Medium crates/xcl/src/gpu/recomp/ps_masks.rs:517: Not certain about this one: the forward pending-read walk from the join follows only CFG successors and ignores the emitter's loop-budget (LOOP_GUARD) exits, which x64_masks liveness models (what's live after a loop is live before each.... (inline)
  5. Medium crates/xcl/src/gpu/adapter.rs:173: Not certain about this one: vendor() repeats the device-selection loop of real.rs init (new DXGI factory, adapter enumeration, a D3D12CreateDevice probe per candidate) instead of using the vendor init already stores in ADAPTER_VENDOR /.... (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6153703944 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#pullrequestreview-6153703944). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:19:00Z. **Review:** COMMENTED --- Review of `8ca2df9d`: 5 finding(s) (2 high, 3 medium), most severe first. 1. **High** `crates/xcl/src/gpu/recomp/ps_masks.rs:492`: `flat_skips` doesn't refuse a region that changes the float mode (s_round_mode, s_denorm_mode, s_setreg_b32 / s_setreg_imm32_b32 on HW_REG_MODE). (inline) 2. **High** `crates/xcl/src/gpu/dxil/kernel.rs:890`: The workaround exists only in the direct DXIL pixel path, so pixel shaders that go through the HLSL translator keep the plain execz branch NVIDIA miscompiles: direct DXIL's `direct_fallback` on error, `ps_debug`, and XCL_DIRECT_DXIL=0/1. (inline) 3. **Medium** `crates/xcl/src/gpu/recomp/ps_masks.rs:511`: Reads of SCC after the region are found by instruction name only (`reads_scc` / S_CBRANCH_SCC*), so a read through the `src_scc` operand (code 253) is missed: `scalar_code` maps 253 to no register and `sgpr_uses` drops codes above 127, y.... (inline) 4. **Medium** `crates/xcl/src/gpu/recomp/ps_masks.rs:517`: Not certain about this one: the forward pending-read walk from the join follows only CFG successors and ignores the emitter's loop-budget (LOOP_GUARD) exits, which `x64_masks` liveness models (what's live after a loop is live before each.... (inline) 5. **Medium** `crates/xcl/src/gpu/adapter.rs:173`: Not certain about this one: `vendor()` repeats the device-selection loop of real.rs init (new DXGI factory, adapter enumeration, a D3D12CreateDevice probe per candidate) instead of using the vendor init already stores in ADAPTER_VENDOR /.... (inline) --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 15:19:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:19:01Z.

Code review location: crates/xcl/src/gpu/recomp/ps_masks.rs; line 492

@@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re
     Ok(())
 }
 
+/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the
+/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward
+/// and is left only at its end, and no SGPR or SCC it writes is read after it before being
+/// written again.
+pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> {
+    let exec = exec_mask(wave64);
+    let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect();
+    let (succ, indirect) = successors(insts, &pcs);
+    let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r);
+    let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64);
+    let mut out = BTreeSet::new();
+    for (b, d) in insts.iter().enumerate() {
+        if d.inst.name != "S_CBRANCH_EXECZ" {
+            continue;
+        }
+        let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue };
+        let (mut w, mut scc) = (0u128, false);
+        let ok = (b + 1..t).all(|k| {
+            let dk = &insts[k];
+            let nk = dk.inst.name;
+            w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1);
+            scc |= writes_scc(nk);
+            !indirect[k]
+                && !succ[k].is_empty()
+                && succ[k].iter().all(|&s| s > k && s <= t)
+                && writes(dk, wave64) & exec == 0
+                && !matches!(nk, "EXP" | "V_WRITELANE_B32")
+                && !nk.starts_with("S_SENDMSG")

High: flat_skips doesn't refuse a region that changes the float mode (s_round_mode, s_denorm_mode, s_setreg_b32 / s_setreg_imm32_b32 on HW_REG_MODE). The lowering keeps that mode in runtime state (mode_write, VAR_FP16_RM, denorm_mode), so running the region with EXEC 0 now changes rounding and denormal handling for everything after the join. Take a PS region guarded by s_cbranch_execz that holds s_round_mode 0x3 or s_setreg_imm32_b32 hwreg(HW_REG_MODE,...) with no restore before the join. On NVIDIA (run-through on), a wave with EXEC 0 runs the setreg. The region writes no SGPR read later, so the skip is accepted, and every f32/f16 op after the join uses the wrong mode, where the console (branch taken) left it unchanged. Treating mode writes as region writes that block the run-through would fix it.

<!-- greyfinch-sync:ivall/xcl:review-comment:4771821644 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4771821644). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:19:01Z. **Code review location:** `crates/xcl/src/gpu/recomp/ps_masks.rs`; line 492 ~~~~diff @@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re Ok(()) } +/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the +/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward +/// and is left only at its end, and no SGPR or SCC it writes is read after it before being +/// written again. +pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> { + let exec = exec_mask(wave64); + let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect(); + let (succ, indirect) = successors(insts, &pcs); + let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r); + let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64); + let mut out = BTreeSet::new(); + for (b, d) in insts.iter().enumerate() { + if d.inst.name != "S_CBRANCH_EXECZ" { + continue; + } + let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue }; + let (mut w, mut scc) = (0u128, false); + let ok = (b + 1..t).all(|k| { + let dk = &insts[k]; + let nk = dk.inst.name; + w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1); + scc |= writes_scc(nk); + !indirect[k] + && !succ[k].is_empty() + && succ[k].iter().all(|&s| s > k && s <= t) + && writes(dk, wave64) & exec == 0 + && !matches!(nk, "EXP" | "V_WRITELANE_B32") + && !nk.starts_with("S_SENDMSG") ~~~~ --- **High**: `flat_skips` doesn't refuse a region that changes the float mode (s_round_mode, s_denorm_mode, s_setreg_b32 / s_setreg_imm32_b32 on HW_REG_MODE). The lowering keeps that mode in runtime state (`mode_write`, VAR_FP16_RM, `denorm_mode`), so running the region with EXEC 0 now changes rounding and denormal handling for everything after the join. Take a PS region guarded by s_cbranch_execz that holds `s_round_mode 0x3` or `s_setreg_imm32_b32 hwreg(HW_REG_MODE,...)` with no restore before the join. On NVIDIA (run-through on), a wave with EXEC 0 runs the setreg. The region writes no SGPR read later, so the skip is accepted, and every f32/f16 op after the join uses the wrong mode, where the console (branch taken) left it unchanged. Treating mode writes as region writes that block the run-through would fix it.
bmjask commented 2026-12-02 15:19:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:19:01Z.

Code review location: crates/xcl/src/gpu/dxil/kernel.rs; line 890

@@ -862,6 +888,9 @@ impl Lw {
         }
         if matches!(entry, Entry::Pixel(_)) && !split {
             lw.ps_masks = crate::gpu::recomp::ps_masks::forms(insts, o.wave64);

High: The workaround exists only in the direct DXIL pixel path, so pixel shaders that go through the HLSL translator keep the plain execz branch NVIDIA miscompiles: direct DXIL's direct_fallback on error, ps_debug, and XCL_DIRECT_DXIL=0/1. On NVIDIA, any PS that direct DXIL rejects falls back to HLSL (pso.rs ~840), as does every PS with XCL_DIRECT_DXIL=1. A wave where every pixel skips a block still drops writes (the 896-pixel corruption from #3574), because the HLSL emitter lowers s_cbranch_execz unchanged. Applying the same flat_skips decision in the HLSL emitter would cover the fallback too.

<!-- greyfinch-sync:ivall/xcl:review-comment:4771821654 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4771821654). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:19:01Z. **Code review location:** `crates/xcl/src/gpu/dxil/kernel.rs`; line 890 ~~~~diff @@ -862,6 +888,9 @@ impl Lw { } if matches!(entry, Entry::Pixel(_)) && !split { lw.ps_masks = crate::gpu::recomp::ps_masks::forms(insts, o.wave64); ~~~~ --- **High**: The workaround exists only in the direct DXIL pixel path, so pixel shaders that go through the HLSL translator keep the plain execz branch NVIDIA miscompiles: direct DXIL's `direct_fallback` on error, `ps_debug`, and XCL_DIRECT_DXIL=0/1. On NVIDIA, any PS that direct DXIL rejects falls back to HLSL (pso.rs ~840), as does every PS with XCL_DIRECT_DXIL=1. A wave where every pixel skips a block still drops writes (the 896-pixel corruption from #3574), because the HLSL emitter lowers s_cbranch_execz unchanged. Applying the same `flat_skips` decision in the HLSL emitter would cover the fallback too.
bmjask commented 2026-12-02 15:19:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:19:01Z.

Code review location: crates/xcl/src/gpu/recomp/ps_masks.rs; line 511

@@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re
     Ok(())
 }
 
+/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the
+/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward
+/// and is left only at its end, and no SGPR or SCC it writes is read after it before being
+/// written again.
+pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> {
+    let exec = exec_mask(wave64);
+    let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect();
+    let (succ, indirect) = successors(insts, &pcs);
+    let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r);
+    let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64);
+    let mut out = BTreeSet::new();
+    for (b, d) in insts.iter().enumerate() {
+        if d.inst.name != "S_CBRANCH_EXECZ" {
+            continue;
+        }
+        let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue };
+        let (mut w, mut scc) = (0u128, false);
+        let ok = (b + 1..t).all(|k| {
+            let dk = &insts[k];
+            let nk = dk.inst.name;
+            w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1);
+            scc |= writes_scc(nk);
+            !indirect[k]
+                && !succ[k].is_empty()
+                && succ[k].iter().all(|&s| s > k && s <= t)
+                && writes(dk, wave64) & exec == 0
+                && !matches!(nk, "EXP" | "V_WRITELANE_B32")
+                && !nk.starts_with("S_SENDMSG")
+                && !(dk.enc.name == "ENC_SMEM" && (nk.contains("STORE") || nk.contains("ATOMIC")))
+        });
+        if !ok {
+            continue;
+        }
+        // what the region writes, followed from its end until written again
+        let mut pending: Vec<Option<(u128, bool)>> = vec![None; insts.len()];
+        let mut work = vec![(t, w, scc)];
+        let mut read = false;
+        while let Some((j, r, c)) = work.pop() {
+            let (r, c) = match pending[j] {
+                Some((pr, pc)) if r & !pr == 0 && (!c || pc) => continue,
+                Some((pr, pc)) => (r | pr, c || pc),
+                None => (r, c),
+            };
+            pending[j] = Some((r, c));
+            let dj = &insts[j];
+            let nj = dj.inst.name;
+            if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] {

Medium: Reads of SCC after the region are found by instruction name only (reads_scc / S_CBRANCH_SCC*), so a read through the src_scc operand (code 253) is missed: scalar_code maps 253 to no register and sgpr_uses drops codes above 127, yet the lowering supports src_scc as an operand (lower.rs:872). If the region ends with s_cmp_eq_u32 s4, 0 and after the join v_mov_b32 v1, src_scc reads the pre-branch SCC, the skip is accepted, the region's s_cmp overwrites SCC with EXEC 0, and v1 gets the wrong value.

<!-- greyfinch-sync:ivall/xcl:review-comment:4771821670 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4771821670). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:19:01Z. **Code review location:** `crates/xcl/src/gpu/recomp/ps_masks.rs`; line 511 ~~~~diff @@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re Ok(()) } +/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the +/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward +/// and is left only at its end, and no SGPR or SCC it writes is read after it before being +/// written again. +pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> { + let exec = exec_mask(wave64); + let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect(); + let (succ, indirect) = successors(insts, &pcs); + let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r); + let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64); + let mut out = BTreeSet::new(); + for (b, d) in insts.iter().enumerate() { + if d.inst.name != "S_CBRANCH_EXECZ" { + continue; + } + let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue }; + let (mut w, mut scc) = (0u128, false); + let ok = (b + 1..t).all(|k| { + let dk = &insts[k]; + let nk = dk.inst.name; + w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1); + scc |= writes_scc(nk); + !indirect[k] + && !succ[k].is_empty() + && succ[k].iter().all(|&s| s > k && s <= t) + && writes(dk, wave64) & exec == 0 + && !matches!(nk, "EXP" | "V_WRITELANE_B32") + && !nk.starts_with("S_SENDMSG") + && !(dk.enc.name == "ENC_SMEM" && (nk.contains("STORE") || nk.contains("ATOMIC"))) + }); + if !ok { + continue; + } + // what the region writes, followed from its end until written again + let mut pending: Vec<Option<(u128, bool)>> = vec![None; insts.len()]; + let mut work = vec![(t, w, scc)]; + let mut read = false; + while let Some((j, r, c)) = work.pop() { + let (r, c) = match pending[j] { + Some((pr, pc)) if r & !pr == 0 && (!c || pc) => continue, + Some((pr, pc)) => (r | pr, c || pc), + None => (r, c), + }; + pending[j] = Some((r, c)); + let dj = &insts[j]; + let nj = dj.inst.name; + if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] { ~~~~ --- **Medium**: Reads of SCC after the region are found by instruction name only (`reads_scc` / S_CBRANCH_SCC*), so a read through the `src_scc` operand (code 253) is missed: `scalar_code` maps 253 to no register and `sgpr_uses` drops codes above 127, yet the lowering supports src_scc as an operand (lower.rs:872). If the region ends with `s_cmp_eq_u32 s4, 0` and after the join `v_mov_b32 v1, src_scc` reads the pre-branch SCC, the skip is accepted, the region's s_cmp overwrites SCC with EXEC 0, and v1 gets the wrong value.
bmjask commented 2026-12-02 15:19:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:19:01Z.

Code review location: crates/xcl/src/gpu/recomp/ps_masks.rs; line 517

@@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re
     Ok(())
 }
 
+/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the
+/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward
+/// and is left only at its end, and no SGPR or SCC it writes is read after it before being
+/// written again.
+pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> {
+    let exec = exec_mask(wave64);
+    let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect();
+    let (succ, indirect) = successors(insts, &pcs);
+    let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r);
+    let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64);
+    let mut out = BTreeSet::new();
+    for (b, d) in insts.iter().enumerate() {
+        if d.inst.name != "S_CBRANCH_EXECZ" {
+            continue;
+        }
+        let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue };
+        let (mut w, mut scc) = (0u128, false);
+        let ok = (b + 1..t).all(|k| {
+            let dk = &insts[k];
+            let nk = dk.inst.name;
+            w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1);
+            scc |= writes_scc(nk);
+            !indirect[k]
+                && !succ[k].is_empty()
+                && succ[k].iter().all(|&s| s > k && s <= t)
+                && writes(dk, wave64) & exec == 0
+                && !matches!(nk, "EXP" | "V_WRITELANE_B32")
+                && !nk.starts_with("S_SENDMSG")
+                && !(dk.enc.name == "ENC_SMEM" && (nk.contains("STORE") || nk.contains("ATOMIC")))
+        });
+        if !ok {
+            continue;
+        }
+        // what the region writes, followed from its end until written again
+        let mut pending: Vec<Option<(u128, bool)>> = vec![None; insts.len()];
+        let mut work = vec![(t, w, scc)];
+        let mut read = false;
+        while let Some((j, r, c)) = work.pop() {
+            let (r, c) = match pending[j] {
+                Some((pr, pc)) if r & !pr == 0 && (!c || pc) => continue,
+                Some((pr, pc)) => (r | pr, c || pc),
+                None => (r, c),
+            };
+            pending[j] = Some((r, c));
+            let dj = &insts[j];
+            let nj = dj.inst.name;
+            if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] {
+                read = true;
+                break;
+            }
+            let (r, c) = (r & !x64_masks::uses_for_width(dj, wave64).1, c && !writes_scc(nj));
+            if r != 0 || c {
+                work.extend(succ[j].iter().map(|&s| (s, r, c)));

Medium: Not certain about this one: the forward pending-read walk from the join follows only CFG successors and ignores the emitter's loop-budget (LOOP_GUARD) exits, which x64_masks liveness models (what's live after a loop is live before each of its instructions). If the execz region sits inside a loop and writes s4, and on the normal CFG s4 is rewritten at the top of the body before any exit, the walk accepts the skip. When the iteration budget fires at the loop head, control goes straight to the exit, where code reads s4 holding the value the region computed with EXEC 0.

<!-- greyfinch-sync:ivall/xcl:review-comment:4771821679 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4771821679). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:19:01Z. **Code review location:** `crates/xcl/src/gpu/recomp/ps_masks.rs`; line 517 ~~~~diff @@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re Ok(()) } +/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the +/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward +/// and is left only at its end, and no SGPR or SCC it writes is read after it before being +/// written again. +pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> { + let exec = exec_mask(wave64); + let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect(); + let (succ, indirect) = successors(insts, &pcs); + let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r); + let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64); + let mut out = BTreeSet::new(); + for (b, d) in insts.iter().enumerate() { + if d.inst.name != "S_CBRANCH_EXECZ" { + continue; + } + let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue }; + let (mut w, mut scc) = (0u128, false); + let ok = (b + 1..t).all(|k| { + let dk = &insts[k]; + let nk = dk.inst.name; + w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1); + scc |= writes_scc(nk); + !indirect[k] + && !succ[k].is_empty() + && succ[k].iter().all(|&s| s > k && s <= t) + && writes(dk, wave64) & exec == 0 + && !matches!(nk, "EXP" | "V_WRITELANE_B32") + && !nk.starts_with("S_SENDMSG") + && !(dk.enc.name == "ENC_SMEM" && (nk.contains("STORE") || nk.contains("ATOMIC"))) + }); + if !ok { + continue; + } + // what the region writes, followed from its end until written again + let mut pending: Vec<Option<(u128, bool)>> = vec![None; insts.len()]; + let mut work = vec![(t, w, scc)]; + let mut read = false; + while let Some((j, r, c)) = work.pop() { + let (r, c) = match pending[j] { + Some((pr, pc)) if r & !pr == 0 && (!c || pc) => continue, + Some((pr, pc)) => (r | pr, c || pc), + None => (r, c), + }; + pending[j] = Some((r, c)); + let dj = &insts[j]; + let nj = dj.inst.name; + if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] { + read = true; + break; + } + let (r, c) = (r & !x64_masks::uses_for_width(dj, wave64).1, c && !writes_scc(nj)); + if r != 0 || c { + work.extend(succ[j].iter().map(|&s| (s, r, c))); ~~~~ --- **Medium**: Not certain about this one: the forward pending-read walk from the join follows only CFG successors and ignores the emitter's loop-budget (LOOP_GUARD) exits, which `x64_masks` liveness models (what's live after a loop is live before each of its instructions). If the execz region sits inside a loop and writes s4, and on the normal CFG s4 is rewritten at the top of the body before any exit, the walk accepts the skip. When the iteration budget fires at the loop head, control goes straight to the exit, where code reads s4 holding the value the region computed with EXEC 0.
bmjask commented 2026-12-02 15:19:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:19:01Z.

Code review location: crates/xcl/src/gpu/adapter.rs; line 173

@@ -140,15 +150,35 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES
 
 /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`).
 pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| select_indices(names, sel))
+}
+
+/// The hardware adapters the device is tried on in turn ([`device_order`]).
+pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| device_order(names, sel))
+}
+
+fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
     let hw = hardware(factory);
     let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect();
     let mut keep = vec![false; hw.len()];
-    for i in select_indices(&names, sel) {
+    for i in indices(&names) {
         keep[i] = true;
     }
     hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect()
 }
 
+/// PCI vendor id of the adapter the title's device is made on (`hle::d3d12x::real::init`):
+/// the first of [`device_candidates`] that supports a device; `None` for WARP.
+pub fn vendor() -> Option<u32> {

Medium: Not certain about this one: vendor() repeats the device-selection loop of real.rs init (new DXGI factory, adapter enumeration, a D3D12CreateDevice probe per candidate) instead of using the vendor init already stores in ADAPTER_VENDOR / driver_cache::note_vendor, and the two can disagree. ps_skip_run_through() is a OnceLock, so if it's first evaluated before state::set_boot (a worker or tool computing translation_cache_identity early), state::config() gives the default config and the first adapter's vendor is used. Init later picks the configured adapter (e.g. d3d12_adapter=radeon on an NVIDIA+AMD box), so the run-through decision and cache identity follow the wrong GPU.

<!-- greyfinch-sync:ivall/xcl:review-comment:4771821688 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4771821688). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:19:01Z. **Code review location:** `crates/xcl/src/gpu/adapter.rs`; line 173 ~~~~diff @@ -140,15 +150,35 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`). pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| select_indices(names, sel)) +} + +/// The hardware adapters the device is tried on in turn ([`device_order`]). +pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| device_order(names, sel)) +} + +fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { let hw = hardware(factory); let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect(); let mut keep = vec![false; hw.len()]; - for i in select_indices(&names, sel) { + for i in indices(&names) { keep[i] = true; } hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect() } +/// PCI vendor id of the adapter the title's device is made on (`hle::d3d12x::real::init`): +/// the first of [`device_candidates`] that supports a device; `None` for WARP. +pub fn vendor() -> Option<u32> { ~~~~ --- **Medium**: Not certain about this one: `vendor()` repeats the device-selection loop of real.rs init (new DXGI factory, adapter enumeration, a D3D12CreateDevice probe per candidate) instead of using the vendor init already stores in ADAPTER_VENDOR / `driver_cache::note_vendor`, and the two can disagree. `ps_skip_run_through()` is a OnceLock, so if it's first evaluated before `state::set_boot` (a worker or tool computing `translation_cache_identity` early), `state::config()` gives the default config and the first adapter's vendor is used. Init later picks the configured adapter (e.g. d3d12_adapter=radeon on an NVIDIA+AMD box), so the run-through decision and cache identity follow the wrong GPU.
bmjask commented 2026-12-02 15:19:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:19:05Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7350118684 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7350118684). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:19:05Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
fromthemoonx commented 2026-12-02 18:18:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-02T18:18:42Z.


merge-check
base: 16c2fd082a
head: f4413ddb3b
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3022 passed, 0 failed, 56 ignored (base: 3012 passed, 0 failed, 56 ignored, counted on 395405e4; only docs and scripts changed since); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. An earlier run ended with 0xc0000005 during the thread-dump test (#3586, on main too)
review: rerun on the new head. Since 3632bfa6 only S_MOVRELSD_2_B32 was added to the refused instructions, with a test (read that change; the whole diff was read before). No open finding from my side.

  1. The last case is fixed: the shader that had 5 in s31 and got 7 from its skipped region now keeps 5 with XCL_PS_SKIP_RUN_THROUGH unset, 0 and 1. The SCC and s_round_mode cases are still right. All were drawn on the RTX 3060.
  2. The new test fails when I take the added name out.
  3. The PR's GPU test passes 3 of 3 by default. With XCL_PS_SKIP_RUN_THROUGH=0 it fails 3 of 3 (IMAGE_SAMPLE_LZ: 784 pixels), so it still goes around a fault this card has.
  4. The smoke pair is now of this head, and scripts/pr_check.py accepts the description.
  5. Not tested: a retail title (none on this machine), AMD, Wine.
    performance: on NVIDIA, waves that skipped a region now run it, texture fetches included. The GPU time of that is not measured, here or in the description. The smoke pair (RTX 2070 SUPER) shows no loss: 1551 frames against 1522.
    verdict: safe to merge
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
Earlier report on 3632bfa6

merge-check
base: 395405e4c0
head: 3632bfa692
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3021 passed, 0 failed, 56 ignored (base: 3012 passed, 0 failed, 56 ignored); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. The red CI job on this head (143838507638) is one of those #3743 lists for the thread-dump crash (#3586), not this PR
review: rerun on the new head; read the whole diff (11 files, +427 -17).

  1. Both problems from my last report are fixed. I drew the same shaders again on the RTX 3060. With the skips run through, SCC read as an operand is 1 and the sum after a region with s_round_mode 3 is 0x3F800001, the same as with the skip kept. Each fix has a test that fails when I take the fix out.
  2. The PR's GPU test passes 3 of 3 by default. With XCL_PS_SKIP_RUN_THROUGH=0 it fails 3 of 3 (IMAGE_SAMPLE_LZ: 784 pixels), so the NVIDIA fault is still there and this still goes around it.
  3. One more case, small: S_MOVRELSD_2_B32 in the region. It writes s[SDST + M0[25:16]], but writes() treats only S_MOVRELD* as writing any SGPR. The shader below has 5 in s31, and its skipped region would write 7 there:
XCL_PS_SKIP_RUN_THROUGH s31 after the region
0 (skip kept, right) 5
unset on NVIDIA, or 1 7

Adding "S_MOVRELSD_2_B32" to the matches! list in flat_skips gives 5 again; the ps_masks tests and the PR's GPU test still pass with it. I have not seen a shader that uses this instruction here, so I would not hold the PR for it.
4) Not tested: a retail title (none on this machine), AMD, Wine.
performance: on NVIDIA, waves that skipped a region now run it, texture fetches included. Not measured here.
verdict: not yet: the PR's smoke block is of 8ca2df9d, not of this head (PR description is red for it). Nothing in the code blocks it from my side
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)

Earlier report on 8ca2df9d

merge-check
base: 817eb1fc9f
head: 8ca2df9d1d
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3011 passed, 0 failed, 52 ignored (base: 3004 passed, 0 failed, 52 ignored); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. An earlier run of the same build ended with 0xc0000005 in the library tests while eh::tests::thread_dumps_while_threads_run_and_exit was running. Plain main did the same here once, so I do not count it against this PR.
review: read the whole diff (10 files, +385 -16).

  1. The fix works on native Windows here: the PR's GPU test passes 3 of 3 by default, and with XCL_PS_SKIP_RUN_THROUGH=0 it fails 3 of 3 (IMAGE_SAMPLE_LZ: 784 pixels, the number in the description).
  2. Blocking: two of bmjask's points are real, and they change pixels. I drew a wave64 pixel shader whose region is skipped by every pixel, and read SCC and 1.0 + 0.75 ulp after it:
region skip kept (right) run through (the default on NVIDIA)
v_mov only SCC 1, sum 0x3F800001 the same
with s_cmp, SCC read later as an operand (src_scc) SCC 1 SCC 0
with s_round_mode 3 sum 0x3F800001 sum 0x3F800000 (rounded toward zero)

flat_skips also accepts regions with s_denorm_mode and s_setreg_b32 of MODE. M0 and VCC written in the region and read after it are refused correctly. I do not know how often real shaders do this.
3) This closes both; with it the table's last column is right, the PR's GPU test and the ps_masks tests still pass (I did not rerun the whole suite with it):

                 && !nk.starts_with("S_SENDMSG")
+                && !nk.starts_with("S_SETREG")
+                && !matches!(nk, "S_ROUND_MODE" | "S_DENORM_MODE")
@@
-            if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] {
+            if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC") || scc_source(dj)) || indirect[j] {
@@
+/// SCC read as an operand (`src_scc`)
+fn scc_source(d: &Decoded) -> bool {
+    ["SRC0", "SRC1", "SRC2", "SSRC0", "SSRC1"].iter().any(|f| fv(d, f) == Some(253))
+}
  1. Not tested: bmjask's other points (the HLSL path, loop budget, vendor choice), AMD, a retail title (none on this machine).
    performance: on NVIDIA, waves that skipped a region now run it, texture fetches included. Not measured here; the smoke pair in the description shows no loss.
    verdict: not yet: a skipped region that changes the rounding mode, or an SCC later read as an operand, gives wrong pixels on NVIDIA by default; the small fix above closes both
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
<!-- greyfinch-sync:ivall/xcl:comment:7354344974 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7354344974). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-02T18:18:42Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: f4413ddb3b5423acdefe02f3fdba2a2c9fc51c62 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3022 passed, 0 failed, 56 ignored (base: 3012 passed, 0 failed, 56 ignored, counted on 395405e4; only docs and scripts changed since); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. An earlier run ended with 0xc0000005 during the thread-dump test (#3586, on main too) review: rerun on the new head. Since `3632bfa6` only `S_MOVRELSD_2_B32` was added to the refused instructions, with a test (read that change; the whole diff was read before). No open finding from my side. 1) The last case is fixed: the shader that had 5 in s31 and got 7 from its skipped region now keeps 5 with `XCL_PS_SKIP_RUN_THROUGH` unset, 0 and 1. The SCC and `s_round_mode` cases are still right. All were drawn on the RTX 3060. 2) The new test fails when I take the added name out. 3) The PR's GPU test passes 3 of 3 by default. With `XCL_PS_SKIP_RUN_THROUGH=0` it fails 3 of 3 (`IMAGE_SAMPLE_LZ`: 784 pixels), so it still goes around a fault this card has. 4) The smoke pair is now of this head, and `scripts/pr_check.py` accepts the description. 5) Not tested: a retail title (none on this machine), AMD, Wine. performance: on NVIDIA, waves that skipped a region now run it, texture fetches included. The GPU time of that is not measured, here or in the description. The smoke pair (RTX 2070 SUPER) shows no loss: 1551 frames against 1522. verdict: safe to merge hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5) <details><summary>Earlier report on 3632bfa6</summary> merge-check base: 395405e4c0ed814afde0610a724dc96a3af329de head: 3632bfa692731549172a8dc55cc9eb93063ea0e5 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3021 passed, 0 failed, 56 ignored (base: 3012 passed, 0 failed, 56 ignored); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. The red CI job on this head (143838507638) is one of those #3743 lists for the thread-dump crash (#3586), not this PR review: rerun on the new head; read the whole diff (11 files, +427 -17). 1) Both problems from my last report are fixed. I drew the same shaders again on the RTX 3060. With the skips run through, SCC read as an operand is 1 and the sum after a region with `s_round_mode 3` is 0x3F800001, the same as with the skip kept. Each fix has a test that fails when I take the fix out. 2) The PR's GPU test passes 3 of 3 by default. With `XCL_PS_SKIP_RUN_THROUGH=0` it fails 3 of 3 (`IMAGE_SAMPLE_LZ`: 784 pixels), so the NVIDIA fault is still there and this still goes around it. 3) One more case, small: `S_MOVRELSD_2_B32` in the region. It writes `s[SDST + M0[25:16]]`, but `writes()` treats only `S_MOVRELD*` as writing any SGPR. The shader below has 5 in s31, and its skipped region would write 7 there: | `XCL_PS_SKIP_RUN_THROUGH` | s31 after the region | |---|---| | 0 (skip kept, right) | 5 | | unset on NVIDIA, or 1 | **7** | Adding `"S_MOVRELSD_2_B32"` to the `matches!` list in `flat_skips` gives 5 again; the `ps_masks` tests and the PR's GPU test still pass with it. I have not seen a shader that uses this instruction here, so I would not hold the PR for it. 4) Not tested: a retail title (none on this machine), AMD, Wine. performance: on NVIDIA, waves that skipped a region now run it, texture fetches included. Not measured here. verdict: not yet: the PR's smoke block is of `8ca2df9d`, not of this head (`PR description` is red for it). Nothing in the code blocks it from my side hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5) </details> <details><summary>Earlier report on 8ca2df9d</summary> merge-check base: 817eb1fc9fb0763008ae5d8de1f7f586f442b51d head: 8ca2df9d1df03d4c373d6ad5783d73681dfcb557 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3011 passed, 0 failed, 52 ignored (base: 3004 passed, 0 failed, 52 ignored); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. An earlier run of the same build ended with 0xc0000005 in the library tests while `eh::tests::thread_dumps_while_threads_run_and_exit` was running. Plain main did the same here once, so I do not count it against this PR. review: read the whole diff (10 files, +385 -16). 1) The fix works on native Windows here: the PR's GPU test passes 3 of 3 by default, and with `XCL_PS_SKIP_RUN_THROUGH=0` it fails 3 of 3 (`IMAGE_SAMPLE_LZ`: 784 pixels, the number in the description). 2) Blocking: two of bmjask's points are real, and they change pixels. I drew a wave64 pixel shader whose region is skipped by every pixel, and read SCC and 1.0 + 0.75 ulp after it: | region | skip kept (right) | run through (the default on NVIDIA) | |---|---|---| | `v_mov` only | SCC 1, sum 0x3F800001 | the same | | with `s_cmp`, SCC read later as an operand (`src_scc`) | SCC 1 | **SCC 0** | | with `s_round_mode 3` | sum 0x3F800001 | **sum 0x3F800000** (rounded toward zero) | `flat_skips` also accepts regions with `s_denorm_mode` and `s_setreg_b32` of MODE. M0 and VCC written in the region and read after it are refused correctly. I do not know how often real shaders do this. 3) This closes both; with it the table's last column is right, the PR's GPU test and the `ps_masks` tests still pass (I did not rerun the whole suite with it): ```diff && !nk.starts_with("S_SENDMSG") + && !nk.starts_with("S_SETREG") + && !matches!(nk, "S_ROUND_MODE" | "S_DENORM_MODE") @@ - if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] { + if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC") || scc_source(dj)) || indirect[j] { @@ +/// SCC read as an operand (`src_scc`) +fn scc_source(d: &Decoded) -> bool { + ["SRC0", "SRC1", "SRC2", "SSRC0", "SSRC1"].iter().any(|f| fv(d, f) == Some(253)) +} ``` 4) Not tested: bmjask's other points (the HLSL path, loop budget, vendor choice), AMD, a retail title (none on this machine). performance: on NVIDIA, waves that skipped a region now run it, texture fetches included. Not measured here; the smoke pair in the description shows no loss. verdict: not yet: a skipped region that changes the rounding mode, or an SCC later read as an operand, gives wrong pixels on NVIDIA by default; the small fix above closes both hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5) </details>
Royalflamejlh commented 2026-12-02 22:01:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:50Z.

Code review location: crates/xcl/src/gpu/recomp/ps_masks.rs; line 492

@@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re
     Ok(())
 }
 
+/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the
+/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward
+/// and is left only at its end, and no SGPR or SCC it writes is read after it before being
+/// written again.
+pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> {
+    let exec = exec_mask(wave64);
+    let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect();
+    let (succ, indirect) = successors(insts, &pcs);
+    let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r);
+    let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64);
+    let mut out = BTreeSet::new();
+    for (b, d) in insts.iter().enumerate() {
+        if d.inst.name != "S_CBRANCH_EXECZ" {
+            continue;
+        }
+        let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue };
+        let (mut w, mut scc) = (0u128, false);
+        let ok = (b + 1..t).all(|k| {
+            let dk = &insts[k];
+            let nk = dk.inst.name;
+            w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1);
+            scc |= writes_scc(nk);
+            !indirect[k]
+                && !succ[k].is_empty()
+                && succ[k].iter().all(|&s| s > k && s <= t)
+                && writes(dk, wave64) & exec == 0
+                && !matches!(nk, "EXP" | "V_WRITELANE_B32")
+                && !nk.starts_with("S_SENDMSG")

Right; fixed at b33985709. A region with s_round_mode, s_denorm_mode or any s_setreg now keeps its branch (ps_masks.rs:491-493). The new test execz_skips_over_a_float_mode_change_keep_the_branch fails without it. @fromthemoonx measured the wrong rounding on an RTX 3060 in his merge-check, and this is the fix he gave there.

AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776711018 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4776711018). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:01:50Z. **Code review location:** `crates/xcl/src/gpu/recomp/ps_masks.rs`; line 492 ~~~~diff @@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re Ok(()) } +/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the +/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward +/// and is left only at its end, and no SGPR or SCC it writes is read after it before being +/// written again. +pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> { + let exec = exec_mask(wave64); + let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect(); + let (succ, indirect) = successors(insts, &pcs); + let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r); + let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64); + let mut out = BTreeSet::new(); + for (b, d) in insts.iter().enumerate() { + if d.inst.name != "S_CBRANCH_EXECZ" { + continue; + } + let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue }; + let (mut w, mut scc) = (0u128, false); + let ok = (b + 1..t).all(|k| { + let dk = &insts[k]; + let nk = dk.inst.name; + w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1); + scc |= writes_scc(nk); + !indirect[k] + && !succ[k].is_empty() + && succ[k].iter().all(|&s| s > k && s <= t) + && writes(dk, wave64) & exec == 0 + && !matches!(nk, "EXP" | "V_WRITELANE_B32") + && !nk.starts_with("S_SENDMSG") ~~~~ --- Right; fixed at `b33985709`. A region with `s_round_mode`, `s_denorm_mode` or any `s_setreg` now keeps its branch (`ps_masks.rs:491-493`). The new test `execz_skips_over_a_float_mode_change_keep_the_branch` fails without it. @fromthemoonx measured the wrong rounding on an RTX 3060 in his merge-check, and this is the fix he gave there. AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.
Royalflamejlh commented 2026-12-02 22:01:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:52Z.

Code review location: crates/xcl/src/gpu/dxil/kernel.rs; line 890

@@ -862,6 +888,9 @@ impl Lw {
         }
         if matches!(entry, Entry::Pixel(_)) && !split {
             lw.ps_masks = crate::gpu::recomp::ps_masks::forms(insts, o.wave64);

Not changed: a run showed the HLSL path draws this shader right on NVIDIA. I ran the PR's disc shader through the HLSL translator and DXC on an RTX 2070 SUPER (driver 621.01, Windows 11), as a test kept out of the PR, 1 run each way. With the run-through off (XCL_PS_SKIP_RUN_THROUGH=0, which the HLSL path does not read), the HLSL draw passed and the direct DXIL draw failed, with 868 pixels holding the other branch's values. With the run-through on, both passed. So the fault comes from the direct path's DXIL, and the HLSL emitter's s_cbranch_execz needs no change.

AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776711419 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4776711419). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:01:52Z. **Code review location:** `crates/xcl/src/gpu/dxil/kernel.rs`; line 890 ~~~~diff @@ -862,6 +888,9 @@ impl Lw { } if matches!(entry, Entry::Pixel(_)) && !split { lw.ps_masks = crate::gpu::recomp::ps_masks::forms(insts, o.wave64); ~~~~ --- Not changed: a run showed the HLSL path draws this shader right on NVIDIA. I ran the PR's disc shader through the HLSL translator and DXC on an RTX 2070 SUPER (driver 621.01, Windows 11), as a test kept out of the PR, 1 run each way. With the run-through off (`XCL_PS_SKIP_RUN_THROUGH=0`, which the HLSL path does not read), the HLSL draw passed and the direct DXIL draw failed, with 868 pixels holding the other branch's values. With the run-through on, both passed. So the fault comes from the direct path's DXIL, and the HLSL emitter's `s_cbranch_execz` needs no change. AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.
Royalflamejlh commented 2026-12-02 22:01:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:54Z.

Code review location: crates/xcl/src/gpu/recomp/ps_masks.rs; line 511

@@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re
     Ok(())
 }
 
+/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the
+/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward
+/// and is left only at its end, and no SGPR or SCC it writes is read after it before being
+/// written again.
+pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> {
+    let exec = exec_mask(wave64);
+    let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect();
+    let (succ, indirect) = successors(insts, &pcs);
+    let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r);
+    let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64);
+    let mut out = BTreeSet::new();
+    for (b, d) in insts.iter().enumerate() {
+        if d.inst.name != "S_CBRANCH_EXECZ" {
+            continue;
+        }
+        let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue };
+        let (mut w, mut scc) = (0u128, false);
+        let ok = (b + 1..t).all(|k| {
+            let dk = &insts[k];
+            let nk = dk.inst.name;
+            w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1);
+            scc |= writes_scc(nk);
+            !indirect[k]
+                && !succ[k].is_empty()
+                && succ[k].iter().all(|&s| s > k && s <= t)
+                && writes(dk, wave64) & exec == 0
+                && !matches!(nk, "EXP" | "V_WRITELANE_B32")
+                && !nk.starts_with("S_SENDMSG")
+                && !(dk.enc.name == "ENC_SMEM" && (nk.contains("STORE") || nk.contains("ATOMIC")))
+        });
+        if !ok {
+            continue;
+        }
+        // what the region writes, followed from its end until written again
+        let mut pending: Vec<Option<(u128, bool)>> = vec![None; insts.len()];
+        let mut work = vec![(t, w, scc)];
+        let mut read = false;
+        while let Some((j, r, c)) = work.pop() {
+            let (r, c) = match pending[j] {
+                Some((pr, pc)) if r & !pr == 0 && (!c || pc) => continue,
+                Some((pr, pc)) => (r | pr, c || pc),
+                None => (r, c),
+            };
+            pending[j] = Some((r, c));
+            let dj = &insts[j];
+            let nj = dj.inst.name;
+            if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] {

Right; fixed at b33985709. After the region, the walk now also stops at any instruction that reads SCC as an operand: lane_masks::reads_scc (253 in SSRC0/1, SRC0-2 or SOFFSET, or an implicit SCC input), now pub(super), used at ps_masks.rs:512. A new case in execz_skips_run_through_when_nothing_after_reads_what_they_skip (v_mov_b32 v1, src_scc after a region with s_cmp) fails without it. @fromthemoonx showed SCC 0 instead of 1 on an RTX 3060.

AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776711744 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4776711744). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:01:54Z. **Code review location:** `crates/xcl/src/gpu/recomp/ps_masks.rs`; line 511 ~~~~diff @@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re Ok(()) } +/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the +/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward +/// and is left only at its end, and no SGPR or SCC it writes is read after it before being +/// written again. +pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> { + let exec = exec_mask(wave64); + let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect(); + let (succ, indirect) = successors(insts, &pcs); + let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r); + let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64); + let mut out = BTreeSet::new(); + for (b, d) in insts.iter().enumerate() { + if d.inst.name != "S_CBRANCH_EXECZ" { + continue; + } + let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue }; + let (mut w, mut scc) = (0u128, false); + let ok = (b + 1..t).all(|k| { + let dk = &insts[k]; + let nk = dk.inst.name; + w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1); + scc |= writes_scc(nk); + !indirect[k] + && !succ[k].is_empty() + && succ[k].iter().all(|&s| s > k && s <= t) + && writes(dk, wave64) & exec == 0 + && !matches!(nk, "EXP" | "V_WRITELANE_B32") + && !nk.starts_with("S_SENDMSG") + && !(dk.enc.name == "ENC_SMEM" && (nk.contains("STORE") || nk.contains("ATOMIC"))) + }); + if !ok { + continue; + } + // what the region writes, followed from its end until written again + let mut pending: Vec<Option<(u128, bool)>> = vec![None; insts.len()]; + let mut work = vec![(t, w, scc)]; + let mut read = false; + while let Some((j, r, c)) = work.pop() { + let (r, c) = match pending[j] { + Some((pr, pc)) if r & !pr == 0 && (!c || pc) => continue, + Some((pr, pc)) => (r | pr, c || pc), + None => (r, c), + }; + pending[j] = Some((r, c)); + let dj = &insts[j]; + let nj = dj.inst.name; + if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] { ~~~~ --- Right; fixed at `b33985709`. After the region, the walk now also stops at any instruction that reads SCC as an operand: `lane_masks::reads_scc` (253 in SSRC0/1, SRC0-2 or SOFFSET, or an implicit SCC input), now `pub(super)`, used at `ps_masks.rs:512`. A new case in `execz_skips_run_through_when_nothing_after_reads_what_they_skip` (`v_mov_b32 v1, src_scc` after a region with `s_cmp`) fails without it. @fromthemoonx showed SCC 0 instead of 1 on an RTX 3060. AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.
Royalflamejlh commented 2026-12-02 22:01:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:56Z.

Code review location: crates/xcl/src/gpu/recomp/ps_masks.rs; line 517

@@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re
     Ok(())
 }
 
+/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the
+/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward
+/// and is left only at its end, and no SGPR or SCC it writes is read after it before being
+/// written again.
+pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> {
+    let exec = exec_mask(wave64);
+    let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect();
+    let (succ, indirect) = successors(insts, &pcs);
+    let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r);
+    let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64);
+    let mut out = BTreeSet::new();
+    for (b, d) in insts.iter().enumerate() {
+        if d.inst.name != "S_CBRANCH_EXECZ" {
+            continue;
+        }
+        let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue };
+        let (mut w, mut scc) = (0u128, false);
+        let ok = (b + 1..t).all(|k| {
+            let dk = &insts[k];
+            let nk = dk.inst.name;
+            w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1);
+            scc |= writes_scc(nk);
+            !indirect[k]
+                && !succ[k].is_empty()
+                && succ[k].iter().all(|&s| s > k && s <= t)
+                && writes(dk, wave64) & exec == 0
+                && !matches!(nk, "EXP" | "V_WRITELANE_B32")
+                && !nk.starts_with("S_SENDMSG")
+                && !(dk.enc.name == "ENC_SMEM" && (nk.contains("STORE") || nk.contains("ATOMIC")))
+        });
+        if !ok {
+            continue;
+        }
+        // what the region writes, followed from its end until written again
+        let mut pending: Vec<Option<(u128, bool)>> = vec![None; insts.len()];
+        let mut work = vec![(t, w, scc)];
+        let mut read = false;
+        while let Some((j, r, c)) = work.pop() {
+            let (r, c) = match pending[j] {
+                Some((pr, pc)) if r & !pr == 0 && (!c || pc) => continue,
+                Some((pr, pc)) => (r | pr, c || pc),
+                None => (r, c),
+            };
+            pending[j] = Some((r, c));
+            let dj = &insts[j];
+            let nj = dj.inst.name;
+            if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] {
+                read = true;
+                break;
+            }
+            let (r, c) = (r & !x64_masks::uses_for_width(dj, wave64).1, c && !writes_scc(nj));
+            if r != 0 || c {
+                work.extend(succ[j].iter().map(|&s| (s, r, c)));

Not changed: that exit does not happen in the path that uses flat_skips. In the direct DXIL path, a loop that runs out of its budget does not branch to the loop's exit. It branches to end (gpu/dxil/kernel.rs:583, :596, :609), which is the program's exit block (:533) and ends the lane's program. No instruction after the loop runs, so nothing reads s4 there. The HLSL path's break does go on after the loop, but that path does not use flat_skips.

AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776712118 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4776712118). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:01:56Z. **Code review location:** `crates/xcl/src/gpu/recomp/ps_masks.rs`; line 517 ~~~~diff @@ -455,6 +462,68 @@ fn run(insts: &[Decoded], succ: &[Vec<usize>], indirect: &[bool], z: &[u128], re Ok(()) } +/// The forward `s_cbranch_execz` skips that a pixel shader runs through with EXEC 0 instead: the +/// region writes no EXEC, exports nothing, runs nothing EXEC does not mask, branches only forward +/// and is left only at its end, and no SGPR or SCC it writes is read after it before being +/// written again. +pub fn flat_skips(insts: &[Decoded], wave64: bool) -> BTreeSet<u64> { + let exec = exec_mask(wave64); + let pcs: BTreeMap<u64, usize> = insts.iter().enumerate().map(|(i, d)| (d.pc, i)).collect(); + let (succ, indirect) = successors(insts, &pcs); + let bits = |v: Vec<u64>| v.into_iter().fold(0u128, |m, r| m | 1 << r); + let reads = |d: &Decoded| x64_masks::uses_for_width(d, wave64).0 | bits(rdna2::sgpr_uses(d).0) | per_lane(d, wave64); + let mut out = BTreeSet::new(); + for (b, d) in insts.iter().enumerate() { + if d.inst.name != "S_CBRANCH_EXECZ" { + continue; + } + let Some(t) = rdna2::branch_target(d).and_then(|t| pcs.get(&t).copied()).filter(|&t| t > b + 1) else { continue }; + let (mut w, mut scc) = (0u128, false); + let ok = (b + 1..t).all(|k| { + let dk = &insts[k]; + let nk = dk.inst.name; + w |= writes(dk, wave64) | bits(rdna2::sgpr_uses(dk).1); + scc |= writes_scc(nk); + !indirect[k] + && !succ[k].is_empty() + && succ[k].iter().all(|&s| s > k && s <= t) + && writes(dk, wave64) & exec == 0 + && !matches!(nk, "EXP" | "V_WRITELANE_B32") + && !nk.starts_with("S_SENDMSG") + && !(dk.enc.name == "ENC_SMEM" && (nk.contains("STORE") || nk.contains("ATOMIC"))) + }); + if !ok { + continue; + } + // what the region writes, followed from its end until written again + let mut pending: Vec<Option<(u128, bool)>> = vec![None; insts.len()]; + let mut work = vec![(t, w, scc)]; + let mut read = false; + while let Some((j, r, c)) = work.pop() { + let (r, c) = match pending[j] { + Some((pr, pc)) if r & !pr == 0 && (!c || pc) => continue, + Some((pr, pc)) => (r | pr, c || pc), + None => (r, c), + }; + pending[j] = Some((r, c)); + let dj = &insts[j]; + let nj = dj.inst.name; + if reads(dj) & r != 0 || c && (reads_scc(nj) || nj.starts_with("S_CBRANCH_SCC")) || indirect[j] { + read = true; + break; + } + let (r, c) = (r & !x64_masks::uses_for_width(dj, wave64).1, c && !writes_scc(nj)); + if r != 0 || c { + work.extend(succ[j].iter().map(|&s| (s, r, c))); ~~~~ --- Not changed: that exit does not happen in the path that uses `flat_skips`. In the direct DXIL path, a loop that runs out of its budget does not branch to the loop's exit. It branches to `end` (`gpu/dxil/kernel.rs:583`, `:596`, `:609`), which is the program's `exit` block (`:533`) and ends the lane's program. No instruction after the loop runs, so nothing reads s4 there. The HLSL path's `break` does go on after the loop, but that path does not use `flat_skips`. AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.
Royalflamejlh commented 2026-12-02 22:01:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:58Z.

Code review location: crates/xcl/src/gpu/adapter.rs; line 173

@@ -140,15 +150,35 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES
 
 /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`).
 pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| select_indices(names, sel))
+}
+
+/// The hardware adapters the device is tried on in turn ([`device_order`]).
+pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| device_order(names, sel))
+}
+
+fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
     let hw = hardware(factory);
     let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect();
     let mut keep = vec![false; hw.len()];
-    for i in select_indices(&names, sel) {
+    for i in indices(&names) {
         keep[i] = true;
     }
     hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect()
 }
 
+/// PCI vendor id of the adapter the title's device is made on (`hle::d3d12x::real::init`):
+/// the first of [`device_candidates`] that supports a device; `None` for WARP.
+pub fn vendor() -> Option<u32> {

Not changed: both choices see the same setting. In the title's process host_main calls state::set_boot (host.rs:89) before shader preparation and before the device is made, and nothing is translated before then. The launch preparation also passes the configured adapter to its own device (shaders.rs:4135). The offline tools (xcl shaders, pso-precompile) set no boot record, so config().d3d12_adapter is the default auto there, and auto is also what their own device uses (shaders.rs:2498). Reading the vendor off the title's device would leave those tools without an answer, and they need one, since the decision is part of the cache key they write.

AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776712417 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4776712417). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:01:58Z. **Code review location:** `crates/xcl/src/gpu/adapter.rs`; line 173 ~~~~diff @@ -140,15 +150,35 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`). pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| select_indices(names, sel)) +} + +/// The hardware adapters the device is tried on in turn ([`device_order`]). +pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| device_order(names, sel)) +} + +fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { let hw = hardware(factory); let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect(); let mut keep = vec![false; hw.len()]; - for i in select_indices(&names, sel) { + for i in indices(&names) { keep[i] = true; } hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect() } +/// PCI vendor id of the adapter the title's device is made on (`hle::d3d12x::real::init`): +/// the first of [`device_candidates`] that supports a device; `None` for WARP. +pub fn vendor() -> Option<u32> { ~~~~ --- Not changed: both choices see the same setting. In the title's process `host_main` calls `state::set_boot` (`host.rs:89`) before shader preparation and before the device is made, and nothing is translated before then. The launch preparation also passes the configured adapter to its own device (`shaders.rs:4135`). The offline tools (`xcl shaders`, `pso-precompile`) set no boot record, so `config().d3d12_adapter` is the default `auto` there, and `auto` is also what their own device uses (`shaders.rs:2498`). Reading the vendor off the title's device would leave those tools without an answer, and they need one, since the decision is part of the cache key they write. AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.
Royalflamejlh commented 2026-12-02 22:02:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:02:07Z.


@fromthemoonx thank you; both are fixed at b33985709, rebased onto main 5ad98adb. Your change went in, except that SCC read as an operand is found by lane_masks::reads_scc, which also checks SOFFSET and implicit SCC inputs. Each fix has a unit test that fails without it (execz_skips_over_a_float_mode_change_keep_the_branch, and a src_scc case in execz_skips_run_through_when_nothing_after_reads_what_they_skip). bmjask's other three points are answered inline: on an RTX 2070 SUPER the HLSL path draws the disc shader right with the run-through off. The whole suite and a smoke pair at the new head are running; the description will carry them.

AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7360131541 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7360131541). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:02:07Z. --- @fromthemoonx thank you; both are fixed at `b33985709`, rebased onto `main` `5ad98adb`. Your change went in, except that SCC read as an operand is found by `lane_masks::reads_scc`, which also checks SOFFSET and implicit SCC inputs. Each fix has a unit test that fails without it (`execz_skips_over_a_float_mode_change_keep_the_branch`, and a `src_scc` case in `execz_skips_run_through_when_nothing_after_reads_what_they_skip`). bmjask's other three points are answered inline: on an RTX 2070 SUPER the HLSL path draws the disc shader right with the run-through off. The whole suite and a smoke pair at the new head are running; the description will carry them. AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Foniass commented 2026-12-02 22:03:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T22:03:40Z.


Follow-up review of b3398570, since 8ca2df9d (code reading only, not a merge-check; PR description red) · 1 medium

In short: This push refuses two more things inside a region that a wave with EXEC 0 runs through: float-mode changes (s_round_mode, s_denorm_mode, s_setreg*), and SCC read as a src_scc operand after the region. Both have tests. The earlier measurement point is narrower now: a smoke pair is in, for the previous head 8ca2df9d, but the GPU time of the run-through regions is still not measured.

Medium

  1. On by default on NVIDIA without a GPU-time measurement (partly open). The run-through is on by default only for vendor 0x10DE (kernel.rs ~106-119), and the smoke pair shows no regression (1575 → 1612 frames, previous head). The description still says the GPU time of the forms it changes is not measured, and a region run through still fetches its implicit-LOD samples. A frame-time comparison on a scene with many such skips would settle it.
Checked and fine
  • Float modes: run (ps_masks.rs) now stops a region at S_ROUND_MODE, S_DENORM_MODE and any S_SETREG*, so a wave with EXEC 0 never changes the float mode its live lanes later use. execz_skips_over_a_float_mode_change_keep_the_branch covers all three.
  • src_scc: the liveness check after the region now also uses lane_masks::reads_scc, made pub(super). It covers OPR_SSRC_SPECIAL_SCC inputs and encoding 253 in the scalar and vector source fields. The new assertion refuses a region followed by v_mov_b32 v1, src_scc.
  • Earlier fixes still hold: program ends inside a region are refused (!succ[k].is_empty()), and the vendor comes from the same adapter list as the device.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7360167606 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7360167606). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T22:03:40Z. --- **Follow-up review** of `b3398570`, since `8ca2df9d` (code reading only, not a merge-check; `PR description` red) · 1 medium **In short:** This push refuses two more things inside a region that a wave with EXEC 0 runs through: float-mode changes (`s_round_mode`, `s_denorm_mode`, `s_setreg*`), and SCC read as a `src_scc` operand after the region. Both have tests. The earlier measurement point is narrower now: a smoke pair is in, for the previous head `8ca2df9d`, but the GPU time of the run-through regions is still not measured. #### Medium 1. **On by default on NVIDIA without a GPU-time measurement (partly open).** The run-through is on by default only for vendor `0x10DE` (`kernel.rs` ~106-119), and the smoke pair shows no regression (1575 → 1612 frames, previous head). The description still says the GPU time of the forms it changes is not measured, and a region run through still fetches its implicit-LOD samples. A frame-time comparison on a scene with many such skips would settle it. <details><summary>Checked and fine</summary> - Float modes: `run` (`ps_masks.rs`) now stops a region at `S_ROUND_MODE`, `S_DENORM_MODE` and any `S_SETREG*`, so a wave with EXEC 0 never changes the float mode its live lanes later use. `execz_skips_over_a_float_mode_change_keep_the_branch` covers all three. - `src_scc`: the liveness check after the region now also uses `lane_masks::reads_scc`, made `pub(super)`. It covers `OPR_SSRC_SPECIAL_SCC` inputs and encoding 253 in the scalar and vector source fields. The new assertion refuses a region followed by `v_mov_b32 v1, src_scc`. - Earlier fixes still hold: program ends inside a region are refused (`!succ[k].is_empty()`), and the vendor comes from the same adapter list as the device. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
bmjask commented 2026-12-02 22:21:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:21:40Z.

Code review location: crates/xcl/src/gpu/adapter.rs; line 179

@@ -140,15 +150,35 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES
 
 /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`).
 pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| select_indices(names, sel))
+}
+
+/// The hardware adapters the device is tried on in turn ([`device_order`]).
+pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| device_order(names, sel))
+}
+
+fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
     let hw = hardware(factory);
     let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect();
     let mut keep = vec![false; hw.len()];
-    for i in select_indices(&names, sel) {
+    for i in indices(&names) {
         keep[i] = true;
     }
     hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect()
 }
 
+/// PCI vendor id of the adapter the title's device is made on (`hle::d3d12x::real::init`):
+/// the first of [`device_candidates`] that supports a device; `None` for WARP.
+pub fn vendor() -> Option<u32> {
+    let factory: IDXGIFactory6 = unsafe { CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)) }.ok()?;
+    let sel = Selector::from_env_or(&crate::state::config().d3d12_adapter);
+    device_candidates(&factory, &sel)
+        .into_iter()
+        .find(|(a, _)| crate::gpu::agility::device_supported(a, windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0))
+        .map(|(_, d)| d.VendorId)

High: The gate relies on DXGI's VendorId == 0x10DE, but under Proton/DXVK's dxgi NVIDIA GPUs are reported as AMD (0x1002) by default when NVAPI isn't enabled (dxgi.hideNvidiaGpu), so the workaround silently turns off on exactly the Wine/Proton NVIDIA setups where the bug was reported. On a Proton setup with an RTX card and no PROTON_ENABLE_NVAPI, vendor() returns Some(0x1002), ps_skip_run_through() is false, flat_skips stays empty, and the black region from #3574 comes back with nothing logged. Detecting the vendor from the D3D12 device (or the Vulkan driver vkd3d-proton reports) rather than DXGI, and logging the decision, would make it reliable.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776930734 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4776930734). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:21:40Z. **Code review location:** `crates/xcl/src/gpu/adapter.rs`; line 179 ~~~~diff @@ -140,15 +150,35 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`). pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| select_indices(names, sel)) +} + +/// The hardware adapters the device is tried on in turn ([`device_order`]). +pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| device_order(names, sel)) +} + +fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { let hw = hardware(factory); let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect(); let mut keep = vec![false; hw.len()]; - for i in select_indices(&names, sel) { + for i in indices(&names) { keep[i] = true; } hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect() } +/// PCI vendor id of the adapter the title's device is made on (`hle::d3d12x::real::init`): +/// the first of [`device_candidates`] that supports a device; `None` for WARP. +pub fn vendor() -> Option<u32> { + let factory: IDXGIFactory6 = unsafe { CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)) }.ok()?; + let sel = Selector::from_env_or(&crate::state::config().d3d12_adapter); + device_candidates(&factory, &sel) + .into_iter() + .find(|(a, _)| crate::gpu::agility::device_supported(a, windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0)) + .map(|(_, d)| d.VendorId) ~~~~ --- **High**: The gate relies on DXGI's `VendorId == 0x10DE`, but under Proton/DXVK's dxgi NVIDIA GPUs are reported as AMD (0x1002) by default when NVAPI isn't enabled (`dxgi.hideNvidiaGpu`), so the workaround silently turns off on exactly the Wine/Proton NVIDIA setups where the bug was reported. On a Proton setup with an RTX card and no PROTON_ENABLE_NVAPI, `vendor()` returns Some(0x1002), `ps_skip_run_through()` is false, `flat_skips` stays empty, and the black region from #3574 comes back with nothing logged. Detecting the vendor from the D3D12 device (or the Vulkan driver vkd3d-proton reports) rather than DXGI, and logging the decision, would make it reliable.
bmjask commented 2026-12-02 22:21:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:21:40Z.

Code review location: crates/xcl/src/gpu/agility.rs; line 350

@@ -346,6 +346,22 @@ where
     device.ok_or_else(|| windows::core::Error::from(windows::Win32::Foundation::E_FAIL))
 }
 
+/// Whether a device at `feature_level` can be made on `adapter`, without making one.
+pub fn device_supported<P>(adapter: P, feature_level: D3D_FEATURE_LEVEL) -> bool

Medium: Not certain about this one, because it depends on when vendor() is first reached: device_supported calls D3D12CreateDevice / factory.CreateDevice without enable_dred_once(), unlike create_device, and vendor() reaches it lazily from the translated::identity() / ps_skip_run_through OnceLocks, which can run before real::init has set up DRED and the debug layer. warm_replay/warm_library compute translation_cache_identity() during launch preparation, before the first real device, so the probe creates devices before the DRED settings that create_device's comment says must come before the process's first device. The DRED_LATE guard is skipped, so XCL_DRED=1 or debug-layer setup can silently end up out of order. Calling enable_dred_once() before probing, or using the vendor real::init already records, would avoid it.

<!-- greyfinch-sync:ivall/xcl:review-comment:4776930744 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4776930744). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:21:40Z. **Code review location:** `crates/xcl/src/gpu/agility.rs`; line 350 ~~~~diff @@ -346,6 +346,22 @@ where device.ok_or_else(|| windows::core::Error::from(windows::Win32::Foundation::E_FAIL)) } +/// Whether a device at `feature_level` can be made on `adapter`, without making one. +pub fn device_supported<P>(adapter: P, feature_level: D3D_FEATURE_LEVEL) -> bool ~~~~ --- **Medium**: Not certain about this one, because it depends on when `vendor()` is first reached: `device_supported` calls `D3D12CreateDevice` / `factory.CreateDevice` without `enable_dred_once()`, unlike `create_device`, and `vendor()` reaches it lazily from the `translated::identity()` / `ps_skip_run_through` OnceLocks, which can run before `real::init` has set up DRED and the debug layer. `warm_replay`/`warm_library` compute `translation_cache_identity()` during launch preparation, before the first real device, so the probe creates devices before the DRED settings that `create_device`'s comment says must come before the process's first device. The `DRED_LATE` guard is skipped, so XCL_DRED=1 or debug-layer setup can silently end up out of order. Calling `enable_dred_once()` before probing, or using the vendor `real::init` already records, would avoid it.
bmjask commented 2026-12-02 22:21:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:21:40Z.

Review: COMMENTED


Review of b3398570: 3 finding(s) (1 high, 2 medium), most severe first.

  1. High crates/xcl/src/gpu/adapter.rs:179: The gate relies on DXGI's VendorId == 0x10DE, but under Proton/DXVK's dxgi NVIDIA GPUs are reported as AMD (0x1002) by default when NVAPI isn't enabled (dxgi.hideNvidiaGpu), so the workaround silently turns off on exactly the Wine/Pr.... (inline)
  2. Medium crates/xcl/src/gpu/recomp/emit.rs:1419: see below.
  3. Medium crates/xcl/src/gpu/agility.rs:350: Not certain about this one, because it depends on when vendor() is first reached: device_supported calls D3D12CreateDevice / factory.CreateDevice without enable_dred_once(), unlike create_device, and vendor() reaches it laz.... (inline)

On lines outside the diff:

  1. Medium crates/xcl/src/gpu/recomp/emit.rs:1419: The run-through exists only in the direct DXIL lowering (lower.rs branch_cond). The HLSL emitter still lowers every s_cbranch_execz as a real mask_zero(126) branch, so NVIDIA pixel shaders that take the HLSL path still hit the #3574 fault. That includes a pixel shader whose direct translation fails (direct_fallback in pso.rs ~838), and any PS run with XCL_DEBUG_LOD0 / XCL_DEBUG_PS_SUB / XCL_DEBUG_PS_EXPR, a debug colour, or XCL_DIRECT_DXIL=1. Their all-skipping waves still come out unwritten, while the cache identity is tagged as if the fix applied. Applying the same run-through in emit.rs (or tagging only direct translations) would keep them consistent.

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6160070745 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#pullrequestreview-6160070745). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:21:40Z. **Review:** COMMENTED --- Review of `b3398570`: 3 finding(s) (1 high, 2 medium), most severe first. 1. **High** `crates/xcl/src/gpu/adapter.rs:179`: The gate relies on DXGI's `VendorId == 0x10DE`, but under Proton/DXVK's dxgi NVIDIA GPUs are reported as AMD (0x1002) by default when NVAPI isn't enabled (`dxgi.hideNvidiaGpu`), so the workaround silently turns off on exactly the Wine/Pr.... (inline) 2. **Medium** `crates/xcl/src/gpu/recomp/emit.rs:1419`: see below. 3. **Medium** `crates/xcl/src/gpu/agility.rs:350`: Not certain about this one, because it depends on when `vendor()` is first reached: `device_supported` calls `D3D12CreateDevice` / `factory.CreateDevice` without `enable_dred_once()`, unlike `create_device`, and `vendor()` reaches it laz.... (inline) **On lines outside the diff:** 2. **Medium** `crates/xcl/src/gpu/recomp/emit.rs:1419`: The run-through exists only in the direct DXIL lowering (`lower.rs` `branch_cond`). The HLSL emitter still lowers every `s_cbranch_execz` as a real `mask_zero(126)` branch, so NVIDIA pixel shaders that take the HLSL path still hit the #3574 fault. That includes a pixel shader whose direct translation fails (`direct_fallback` in pso.rs ~838), and any PS run with XCL_DEBUG_LOD0 / XCL_DEBUG_PS_SUB / XCL_DEBUG_PS_EXPR, a debug colour, or XCL_DIRECT_DXIL=1. Their all-skipping waves still come out unwritten, while the cache identity is tagged as if the fix applied. Applying the same run-through in emit.rs (or tagging only direct translations) would keep them consistent. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
Royalflamejlh commented 2026-12-02 22:30:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:30:47Z.

Code review location: crates/xcl/src/gpu/adapter.rs; line 179

@@ -140,15 +150,35 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES
 
 /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`).
 pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| select_indices(names, sel))
+}
+
+/// The hardware adapters the device is tried on in turn ([`device_order`]).
+pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| device_order(names, sel))
+}
+
+fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
     let hw = hardware(factory);
     let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect();
     let mut keep = vec![false; hw.len()];
-    for i in select_indices(&names, sel) {
+    for i in indices(&names) {
         keep[i] = true;
     }
     hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect()
 }
 
+/// PCI vendor id of the adapter the title's device is made on (`hle::d3d12x::real::init`):
+/// the first of [`device_candidates`] that supports a device; `None` for WARP.
+pub fn vendor() -> Option<u32> {
+    let factory: IDXGIFactory6 = unsafe { CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)) }.ok()?;
+    let sel = Selector::from_env_or(&crate::state::config().d3d12_adapter);
+    device_candidates(&factory, &sel)
+        .into_iter()
+        .find(|(a, _)| crate::gpu::agility::device_supported(a, windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0))
+        .map(|(_, d)| d.VendorId)

Right, and it is the setup this was first seen on. Fixed at 3632bfa69. On an RTX 4060 Ti under Wine with DXVK's dxgi.dll and dxgi.hideNvidiaGpu left at its default, DXGI reports vendor 0x1002 and device 0x73df, and the name stays "NVIDIA GeForce RTX 4060 Ti 8GB". adapter::is_nvidia now takes either the vendor id or a name containing "NVIDIA", and the decision is logged once ("pixel shaders' execz skips: run through / kept"). There, 1 run each: the PR's GPU test failed at b33985709 (896 pixels) and passed at 3632bfa69. With XCL_PS_SKIP_RUN_THROUGH=0 it failed again, as it should. ps_skips_run_through_on_nvidia_unless_switched has the spoofed case and fails against the old rule.

AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:review-comment:4777035355 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4777035355). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:30:47Z. **Code review location:** `crates/xcl/src/gpu/adapter.rs`; line 179 ~~~~diff @@ -140,15 +150,35 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`). pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| select_indices(names, sel)) +} + +/// The hardware adapters the device is tried on in turn ([`device_order`]). +pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| device_order(names, sel)) +} + +fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { let hw = hardware(factory); let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect(); let mut keep = vec![false; hw.len()]; - for i in select_indices(&names, sel) { + for i in indices(&names) { keep[i] = true; } hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect() } +/// PCI vendor id of the adapter the title's device is made on (`hle::d3d12x::real::init`): +/// the first of [`device_candidates`] that supports a device; `None` for WARP. +pub fn vendor() -> Option<u32> { + let factory: IDXGIFactory6 = unsafe { CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)) }.ok()?; + let sel = Selector::from_env_or(&crate::state::config().d3d12_adapter); + device_candidates(&factory, &sel) + .into_iter() + .find(|(a, _)| crate::gpu::agility::device_supported(a, windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0)) + .map(|(_, d)| d.VendorId) ~~~~ --- Right, and it is the setup this was first seen on. Fixed at `3632bfa69`. On an RTX 4060 Ti under Wine with DXVK's `dxgi.dll` and `dxgi.hideNvidiaGpu` left at its default, DXGI reports vendor `0x1002` and device `0x73df`, and the name stays "NVIDIA GeForce RTX 4060 Ti 8GB". `adapter::is_nvidia` now takes either the vendor id or a name containing "NVIDIA", and the decision is logged once ("pixel shaders' execz skips: run through / kept"). There, 1 run each: the PR's GPU test failed at `b33985709` (896 pixels) and passed at `3632bfa69`. With `XCL_PS_SKIP_RUN_THROUGH=0` it failed again, as it should. `ps_skips_run_through_on_nvidia_unless_switched` has the spoofed case and fails against the old rule. AI use: Claude Code (Claude Opus 5.5) checked the code, made the change and the runs, and wrote this reply.
Royalflamejlh commented 2026-12-02 22:30:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:30:49Z.

Code review location: crates/xcl/src/gpu/agility.rs; line 350

@@ -346,6 +346,22 @@ where
     device.ok_or_else(|| windows::core::Error::from(windows::Win32::Foundation::E_FAIL))
 }
 
+/// Whether a device at `feature_level` can be made on `adapter`, without making one.
+pub fn device_supported<P>(adapter: P, feature_level: D3D_FEATURE_LEVEL) -> bool

Done at 3632bfa69: device_supported calls enable_dred_once() first, as create_device does. A probe with a null out-pointer leaves no device behind, but whether D3D12 counts it as the process's first device is not documented, so it now keeps the same order either way.

AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:review-comment:4777035750 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4777035750). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:30:49Z. **Code review location:** `crates/xcl/src/gpu/agility.rs`; line 350 ~~~~diff @@ -346,6 +346,22 @@ where device.ok_or_else(|| windows::core::Error::from(windows::Win32::Foundation::E_FAIL)) } +/// Whether a device at `feature_level` can be made on `adapter`, without making one. +pub fn device_supported<P>(adapter: P, feature_level: D3D_FEATURE_LEVEL) -> bool ~~~~ --- Done at `3632bfa69`: `device_supported` calls `enable_dred_once()` first, as `create_device` does. A probe with a null out-pointer leaves no device behind, but whether D3D12 counts it as the process's first device is not documented, so it now keeps the same order either way. AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Royalflamejlh commented 2026-12-02 22:30:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:30:51Z.


@bmjask on your second point (emit.rs:1419, the HLSL path): answered in the thread on kernel.rs:890 with a run. The disc shader drawn through the HLSL translator was right on an RTX 2070 SUPER with the run-through off, while the direct DXIL draw lost 868 pixels, so the HLSL emitter is not affected. The cache tag is applied only when Backend::current() == Backend::DirectAll (pso.rs:388). A shader that falls back to HLSL there gets a tag for a change that does not touch it, which costs nothing. The other two points are fixed at 3632bfa69 (inline replies), rebased onto main 078358a0.

AI use: Claude Code (Claude Opus 5.5) checked the code and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7360795684 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7360795684). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:30:51Z. --- @bmjask on your second point (`emit.rs:1419`, the HLSL path): answered in the thread on `kernel.rs:890` with a run. The disc shader drawn through the HLSL translator was right on an RTX 2070 SUPER with the run-through off, while the direct DXIL draw lost 868 pixels, so the HLSL emitter is not affected. The cache tag is applied only when `Backend::current() == Backend::DirectAll` (`pso.rs:388`). A shader that falls back to HLSL there gets a tag for a change that does not touch it, which costs nothing. The other two points are fixed at `3632bfa69` (inline replies), rebased onto `main` `078358a0`. AI use: Claude Code (Claude Opus 5.5) checked the code and wrote this reply.
Foniass commented 2026-12-02 22:34:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T22:34:23Z.


Follow-up review of 3632bfa6, since b3398570 (code reading only, not a merge-check; PR description red) · 1 medium

In short: This push recognises an NVIDIA card by its name as well as its vendor id, because under Wine DXVK's dxgi reports an NVIDIA card as AMD's (0x1002) unless dxgi.hideNvidiaGpu is off. The decision is logged once. device_supported now sets up DRED before its probe, so XCL_DRED still applies to the title's device. The GPU-time point is unchanged. The smoke pair names 8ca2df9d.

Medium

  1. On by default on NVIDIA without a GPU-time measurement (partly open). The smoke pair shows no regression on the previous head, but the description still says the GPU time of the regions run through is not measured. A region run through still fetches its implicit-LOD samples.
Checked and fine
  • adapter::is_nvidia (adapter.rs) is true for vendor 0x10DE or a name containing "nvidia", in any case. device_adapter returns the vendor and name from the same device_candidates list as before. The test covers NVIDIA reported as NVIDIA and as AMD, a real AMD card and an Intel card.
  • ps_skip_run_through logs "pixel shaders' execz skips: run through / kept" once, inside the OnceLock. XCL_PS_SKIP_RUN_THROUGH=0 / 1 still force it either way.
  • device_supported (agility.rs ~350) calls enable_dred_once() before its probe, as create_device does. The probe can run before the title's device is made, and DRED settings apply only to devices made after them.
  • The earlier fixes (float-mode changes, src_scc reads, program ends refused) are unchanged.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7360875030 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7360875030). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T22:34:23Z. --- **Follow-up review** of `3632bfa6`, since `b3398570` (code reading only, not a merge-check; `PR description` red) · 1 medium **In short:** This push recognises an NVIDIA card by its name as well as its vendor id, because under Wine DXVK's dxgi reports an NVIDIA card as AMD's (`0x1002`) unless `dxgi.hideNvidiaGpu` is off. The decision is logged once. `device_supported` now sets up DRED before its probe, so `XCL_DRED` still applies to the title's device. The GPU-time point is unchanged. The smoke pair names `8ca2df9d`. #### Medium 1. **On by default on NVIDIA without a GPU-time measurement (partly open).** The smoke pair shows no regression on the previous head, but the description still says the GPU time of the regions run through is not measured. A region run through still fetches its implicit-LOD samples. <details><summary>Checked and fine</summary> - `adapter::is_nvidia` (`adapter.rs`) is true for vendor `0x10DE` or a name containing "nvidia", in any case. `device_adapter` returns the vendor and name from the same `device_candidates` list as before. The test covers NVIDIA reported as NVIDIA and as AMD, a real AMD card and an Intel card. - `ps_skip_run_through` logs "pixel shaders' execz skips: run through / kept" once, inside the `OnceLock`. `XCL_PS_SKIP_RUN_THROUGH=0` / `1` still force it either way. - `device_supported` (`agility.rs` ~350) calls `enable_dred_once()` before its probe, as `create_device` does. The probe can run before the title's device is made, and DRED settings apply only to devices made after them. - The earlier fixes (float-mode changes, `src_scc` reads, program ends refused) are unchanged. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
bmjask commented 2026-12-02 22:46:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:46:54Z.

Code review location: crates/xcl/src/gpu/adapter.rs; line 174

@@ -140,15 +150,42 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES
 
 /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`).
 pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| select_indices(names, sel))
+}
+
+/// The hardware adapters the device is tried on in turn ([`device_order`]).
+pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| device_order(names, sel))
+}
+
+fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
     let hw = hardware(factory);
     let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect();
     let mut keep = vec![false; hw.len()];
-    for i in select_indices(&names, sel) {
+    for i in indices(&names) {
         keep[i] = true;
     }
     hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect()
 }
 
+/// PCI vendor id and name of the adapter the title's device is made on
+/// (`hle::d3d12x::real::init`): the first of [`device_candidates`] that supports a device;
+/// `None` for WARP.
+pub fn device_adapter() -> Option<(u32, String)> {

Medium: device_adapter works out the title's adapter again with a second enumeration and a device probe, instead of using the vendor real::init already records in ADAPTER_VENDOR, so the translation decision can disagree with the device actually used. If the NULL-pointer probe succeeds on the NVIDIA adapter but create_device fails in init, the title falls back to another adapter or WARP while every PS was translated with skips run through, or the reverse. With the new name match, a DXVK-hidden NVIDIA card (VendorId 0x1002) is NVIDIA for the ps-skip gate but AMD for the ADAPTER_VENDOR-based paths (medium_compute_compile, driver_cache reference vendor), so one process makes contradictory vendor decisions. Deciding from the vendor recorded at device creation, and keying only pixel-shader cache entries on it, would keep them consistent.

<!-- greyfinch-sync:ivall/xcl:review-comment:4777202013 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4777202013). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:46:54Z. **Code review location:** `crates/xcl/src/gpu/adapter.rs`; line 174 ~~~~diff @@ -140,15 +150,42 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`). pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| select_indices(names, sel)) +} + +/// The hardware adapters the device is tried on in turn ([`device_order`]). +pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| device_order(names, sel)) +} + +fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { let hw = hardware(factory); let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect(); let mut keep = vec![false; hw.len()]; - for i in select_indices(&names, sel) { + for i in indices(&names) { keep[i] = true; } hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect() } +/// PCI vendor id and name of the adapter the title's device is made on +/// (`hle::d3d12x::real::init`): the first of [`device_candidates`] that supports a device; +/// `None` for WARP. +pub fn device_adapter() -> Option<(u32, String)> { ~~~~ --- **Medium**: `device_adapter` works out the title's adapter again with a second enumeration and a device probe, instead of using the vendor `real::init` already records in ADAPTER_VENDOR, so the translation decision can disagree with the device actually used. If the NULL-pointer probe succeeds on the NVIDIA adapter but `create_device` fails in init, the title falls back to another adapter or WARP while every PS was translated with skips run through, or the reverse. With the new name match, a DXVK-hidden NVIDIA card (VendorId 0x1002) is NVIDIA for the ps-skip gate but AMD for the ADAPTER_VENDOR-based paths (`medium_compute_compile`, `driver_cache` reference vendor), so one process makes contradictory vendor decisions. Deciding from the vendor recorded at device creation, and keying only pixel-shader cache entries on it, would keep them consistent.
bmjask commented 2026-12-02 22:46:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T22:46:54Z.

Review: COMMENTED


Review of 3632bfa6: 1 finding(s) (1 medium), most severe first.

Re-review at 3632bfa6. The Proton vendor-ID issue from the b3398570 review is partly addressed: the adapter name now matches 'nvidia' too. Still open: the HLSL path keeps real execz branches, and the early device probe can run before the DRED/debug-layer setup. One new item below.

  1. Medium crates/xcl/src/gpu/adapter.rs:174: device_adapter works out the title's adapter again with a second enumeration and a device probe, instead of using the vendor real::init already records in ADAPTER_VENDOR, so the translation decision can disagree with the device actua.... (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6160396736 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#pullrequestreview-6160396736). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T22:46:54Z. **Review:** COMMENTED --- Review of `3632bfa6`: 1 finding(s) (1 medium), most severe first. Re-review at `3632bfa6`. The Proton vendor-ID issue from the `b3398570` review is partly addressed: the adapter name now matches 'nvidia' too. Still open: the HLSL path keeps real execz branches, and the early device probe can run before the DRED/debug-layer setup. One new item below. 1. **Medium** `crates/xcl/src/gpu/adapter.rs:174`: `device_adapter` works out the title's adapter again with a second enumeration and a device probe, instead of using the vendor `real::init` already records in ADAPTER_VENDOR, so the translation decision can disagree with the device actua.... (inline) --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
Royalflamejlh commented 2026-12-02 22:55:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:55:19Z.

Code review location: crates/xcl/src/gpu/adapter.rs; line 174

@@ -140,15 +150,42 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES
 
 /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`).
 pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| select_indices(names, sel))
+}
+
+/// The hardware adapters the device is tried on in turn ([`device_order`]).
+pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
+    pick(factory, |names| device_order(names, sel))
+}
+
+fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> {
     let hw = hardware(factory);
     let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect();
     let mut keep = vec![false; hw.len()];
-    for i in select_indices(&names, sel) {
+    for i in indices(&names) {
         keep[i] = true;
     }
     hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect()
 }
 
+/// PCI vendor id and name of the adapter the title's device is made on
+/// (`hle::d3d12x::real::init`): the first of [`device_candidates`] that supports a device;
+/// `None` for WARP.
+pub fn device_adapter() -> Option<(u32, String)> {

Not changed, for two reasons.

  • The decision is needed before there is a device. The launch preparation computes translation_cache_identity() (shaders/warm_replay.rs:117, warm_library.rs:74) before real::init stores ADAPTER_VENDOR (real.rs:1013), and the offline tools never make a title device. If the decision came from ADAPTER_VENDOR, the preparation would key its cache one way and the title the other. The probe follows the rule init uses (device_candidates, first adapter that supports a device). The case where they part (the probe passes on the NVIDIA card and create_device then fails there) leaves a run-through on another adapter, which costs fetches but changes no result.
  • The two vendor uses ask different questions. medium_compute_compile (real.rs:5566) and the driver cache want the id DXGI reports. This gate wants the driver underneath, which under DXVK's spoof is still NVIDIA's. It is the NVIDIA driver that drops the writes: the GPU test fails under the spoof at b33985709. Making the gate agree with a spoofed 0x1002 would bring #3574 back on Wine. Whether those AMD-only paths should run on a hidden NVIDIA card is a question about main, outside this PR.

Also, on the summary: the DRED order is fixed at 3632bfa69 (agility.rs, device_supported calls enable_dred_once()). The HLSL path was answered with a run in the kernel.rs:890 thread: with the run-through off, it drew the disc shader right on an RTX 2070 SUPER, where the direct path lost 868 pixels.

AI use: Claude Code (Claude Opus 5.5) checked the code and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:review-comment:4777288161 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#discussion_r4777288161). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T22:55:19Z. **Code review location:** `crates/xcl/src/gpu/adapter.rs`; line 174 ~~~~diff @@ -140,15 +150,42 @@ pub fn hardware(factory: &IDXGIFactory6) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DES /// The hardware adapters `sel` allows, in high-performance order (empty for `warp`). pub fn candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| select_indices(names, sel)) +} + +/// The hardware adapters the device is tried on in turn ([`device_order`]). +pub fn device_candidates(factory: &IDXGIFactory6, sel: &Selector) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { + pick(factory, |names| device_order(names, sel)) +} + +fn pick(factory: &IDXGIFactory6, indices: impl FnOnce(&[String]) -> Vec<usize>) -> Vec<(IDXGIAdapter1, DXGI_ADAPTER_DESC1)> { let hw = hardware(factory); let names: Vec<String> = hw.iter().map(|(_, d)| name(d)).collect(); let mut keep = vec![false; hw.len()]; - for i in select_indices(&names, sel) { + for i in indices(&names) { keep[i] = true; } hw.into_iter().enumerate().filter(|(i, _)| keep[*i]).map(|(_, a)| a).collect() } +/// PCI vendor id and name of the adapter the title's device is made on +/// (`hle::d3d12x::real::init`): the first of [`device_candidates`] that supports a device; +/// `None` for WARP. +pub fn device_adapter() -> Option<(u32, String)> { ~~~~ --- Not changed, for two reasons. - **The decision is needed before there is a device.** The launch preparation computes `translation_cache_identity()` (`shaders/warm_replay.rs:117`, `warm_library.rs:74`) before `real::init` stores `ADAPTER_VENDOR` (`real.rs:1013`), and the offline tools never make a title device. If the decision came from `ADAPTER_VENDOR`, the preparation would key its cache one way and the title the other. The probe follows the rule `init` uses (`device_candidates`, first adapter that supports a device). The case where they part (the probe passes on the NVIDIA card and `create_device` then fails there) leaves a run-through on another adapter, which costs fetches but changes no result. - **The two vendor uses ask different questions.** `medium_compute_compile` (`real.rs:5566`) and the driver cache want the id DXGI reports. This gate wants the driver underneath, which under DXVK's spoof is still NVIDIA's. It is the NVIDIA driver that drops the writes: the GPU test fails under the spoof at `b33985709`. Making the gate agree with a spoofed `0x1002` would bring #3574 back on Wine. Whether those AMD-only paths should run on a hidden NVIDIA card is a question about `main`, outside this PR. Also, on the summary: the DRED order is fixed at `3632bfa69` (`agility.rs`, `device_supported` calls `enable_dred_once()`). The HLSL path was answered with a run in the `kernel.rs:890` thread: with the run-through off, it drew the disc shader right on an RTX 2070 SUPER, where the direct path lost 868 pixels. AI use: Claude Code (Claude Opus 5.5) checked the code and wrote this reply.
fromthemoonx commented 2026-12-03 03:33:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T03:33:52Z.


@Royalflamejlh reran on 3632bfa6: both fixes hold on the RTX 3060, and the suite is clean. What is left is the smoke pair on this head, plus one small case in flat_skips (S_MOVRELSD_2_B32, a one-word fix): https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7354344974

<!-- greyfinch-sync:ivall/xcl:comment:7366699919 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7366699919). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-03T03:33:52Z. --- @Royalflamejlh reran on `3632bfa6`: both fixes hold on the RTX 3060, and the suite is clean. What is left is the smoke pair on this head, plus one small case in `flat_skips` (`S_MOVRELSD_2_B32`, a one-word fix): https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7354344974
CharlyRien commented 2026-12-03 07:38:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T07:38:08Z.


Test report from Windows with an RTX 3090 24 GB (driver 616.56), Ryzen 9 5950X, Windows 11 22631, release builds. Not a merge-check. This fixes a visible defect in the retail title, and a sweep over the title's pixel shaders shows what it fixes and what is left. Everything below was measured with this PR at 8ca2df9d; see the end for the current head.

1. In game: the halo is gone

During a cinematic, an elliptic disc stayed frozen at the centre of the screen, covered by a regular dot grid, in every run (3 to 6 recorded frames per run). The pixel shader at fault is an edge-blur pre-pass with a vignette. Inside the ellipse, every lane of a wave takes the copy branch, so the wave skips the other block by s_cbranch_execz. That is the shape of #3574. Bisected in game with XCL_HLSL_PS: the halo is gone when only this program goes through HLSL + DXC, and stays when the two other programs of the effect do.

With this PR the detector counts 0 halo frames in two runs (469 and 306 recorded frames), against 3 to 6 per run before. There were no device removals, and the pace was 0.86 and 0.92 presents/s, against 0.77 to 0.98 for the same settings without the PR. In those two runs only this one program was translated again, though; the other pixel shaders came from an earlier cache. So this does not measure the GPU cost Foniass asks about.

2. Offline: three GPU tests

Each test draws both backends and counts the pixels left at the clear value (main 1c8b5514 + 8ca2df9d):

test without this PR with this PR
hand-written wave64 PS: divergent copy branch, sample, export (128²) direct DXIL 3,248 / 16,384 unwritten, HLSL 0 0 / 0
the halo's program, synthetic descriptors and constants (256²) direct 12,877 wrong in the copy region, HLSL 0 0 / 0
the same at 2560² direct 1,431,768 unwritten 0
XCL_PS_SKIP_RUN_THROUGH=0 with this PR direct 3,248 unwritten again —

Your own tests and four existing PS mask / helper-lane GPU tests pass on that tree. The unwritten pixels come in whole waves: only the waves that straddle the ellipse's edge get written.

3. Sweep over the title's programs

A local offline probe (not upstream) translates each console program both ways, draws it with one triangle covering a 128×128 target on 3 synthetic input sets, and compares the direct DXIL output with the HLSL one. A first sweep without this PR found 119 programs (117 PS, 2 CS) where the direct path leaves pixels unwritten that HLSL writes. On those 119, XCL_PS_SKIP_RUN_THROUGH=1 against =0:

  • 4 PS become identical (the halo's program, a lens-distortion pass, another edge-blur pre-pass and a decal). Their holes were whole waves.
  • The total of unwritten pixels drops from 6.53 M to 3.28 M. No program gets worse.
  • The 2 CS do not change, as expected (flat_skips is only used for pixel shaders).

What is left is not a bug in this PR. A CPU probe that calls flat_skips the way dxil/kernel.rs does, then replays its rules, shows that every skip it keeps in the remaining families is kept for one reason: the region writes EXEC (s_and_saveexec, v_cmpx, s_andn2 exec). No skip was refused for an export, a program end or a read after the region.

  • A family of 95 programs: 1 of its 2 skips is taken; the other region narrows EXEC and also holds the kill path. Its unwritten pixels halve (×0.49 for each of the 95).
  • A family of 17 programs: each has 32 skips, all nested EXEC masks like a switch, so none is taken.
  • One blur program: both skips write EXEC, one of them heading a waterfall loop.

With EXEC 0 at the region's start, these writes leave EXEC at 0. As a local test, not for this PR as is, I widened the rule so that a region may write EXEC when each write can only narrow a zero EXEC (v_cmpx, s_and_saveexec, s_andn1_saveexec, s_and, s_andn2 or s_mov of a zero mask; s_or_saveexec is still refused), and EXEC is zero at the region's end. The 17-program family then takes all 32 skips of each program and loses the whole-wave part of its holes (most go from 12,704 to 8,514 unwritten pixels). The other two families need more than that: a backward branch whose condition comes from a zero mask, and a kill branch that the rule cannot prove locally. That rule has had no independent review yet; I can share the patch if it is useful.

The 8,514 pixels the 17-program family still loses are not #3574. They are single lanes, they depend on the input values, and they stay when every skip is run through. They are a separate NVIDIA problem, reported in #3772 (the same DXIL is right on WARP).

Current head

I have not run 3632bfa6. Since 8ca2df9d the PR refuses more regions (float-mode changes, src_scc read after the region) and also recognises NVIDIA by name. None of the 4 programs fixed above has s_setreg*, s_round_mode, s_denorm_mode or s_movrel* (checked in an opcode census of the title's programs), so I expect the same result there. That is an inference, not a run.

Setup

  • In game: main 493dbd3d + #3528 + #3517 + local commits, with 8ca2df9d cherry-picked.
  • Offline tests (section 2): main 1c8b5514 + 8ca2df9d + our three GPU tests.
  • Sweep (section 3): main 817eb1fc + the local probe commits (tests only) + 8ca2df9d cherry-picked, with XCL_PS_SKIP_RUN_THROUGH=1 against =0; the direct path splits wave64 pixel shaders into two 32-lane halves. The widened rule is one more local commit on top.
  • RTX 3090, NVIDIA 616.56, Windows 11 22631.

AI use: Claude Code (Claude Opus 5.5) wrote the tests and the probe, ran the bisection, the runs and the sweep, and wrote this comment; checked and posted by me.

<!-- greyfinch-sync:ivall/xcl:comment:7371235707 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7371235707). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-03T07:38:08Z. --- Test report from Windows with an RTX 3090 24 GB (driver 616.56), Ryzen 9 5950X, Windows 11 22631, release builds. Not a merge-check. This fixes a visible defect in the retail title, and a sweep over the title's pixel shaders shows what it fixes and what is left. Everything below was measured with this PR at `8ca2df9d`; see the end for the current head. ### 1. In game: the halo is gone During a cinematic, an elliptic disc stayed frozen at the centre of the screen, covered by a regular dot grid, in every run (3 to 6 recorded frames per run). The pixel shader at fault is an edge-blur pre-pass with a vignette. Inside the ellipse, every lane of a wave takes the copy branch, so the wave skips the other block by `s_cbranch_execz`. That is the shape of #3574. Bisected in game with `XCL_HLSL_PS`: the halo is gone when only this program goes through HLSL + DXC, and stays when the two other programs of the effect do. With this PR the detector counts 0 halo frames in two runs (469 and 306 recorded frames), against 3 to 6 per run before. There were no device removals, and the pace was 0.86 and 0.92 presents/s, against 0.77 to 0.98 for the same settings without the PR. In those two runs only this one program was translated again, though; the other pixel shaders came from an earlier cache. So this does not measure the GPU cost Foniass asks about. ### 2. Offline: three GPU tests Each test draws both backends and counts the pixels left at the clear value (`main` `1c8b5514` + `8ca2df9d`): | test | without this PR | with this PR | |---|---|---| | hand-written wave64 PS: divergent copy branch, sample, export (128²) | direct DXIL 3,248 / 16,384 unwritten, HLSL 0 | 0 / 0 | | the halo's program, synthetic descriptors and constants (256²) | direct 12,877 wrong in the copy region, HLSL 0 | 0 / 0 | | the same at 2560² | direct 1,431,768 unwritten | 0 | | `XCL_PS_SKIP_RUN_THROUGH=0` with this PR | direct 3,248 unwritten again | — | Your own tests and four existing PS mask / helper-lane GPU tests pass on that tree. The unwritten pixels come in whole waves: only the waves that straddle the ellipse's edge get written. ### 3. Sweep over the title's programs A local offline probe (not upstream) translates each console program both ways, draws it with one triangle covering a 128×128 target on 3 synthetic input sets, and compares the direct DXIL output with the HLSL one. A first sweep without this PR found 119 programs (117 PS, 2 CS) where the direct path leaves pixels unwritten that HLSL writes. On those 119, `XCL_PS_SKIP_RUN_THROUGH=1` against `=0`: - 4 PS become identical (the halo's program, a lens-distortion pass, another edge-blur pre-pass and a decal). Their holes were whole waves. - The total of unwritten pixels drops from 6.53 M to 3.28 M. No program gets worse. - The 2 CS do not change, as expected (`flat_skips` is only used for pixel shaders). **What is left is not a bug in this PR.** A CPU probe that calls `flat_skips` the way `dxil/kernel.rs` does, then replays its rules, shows that every skip it keeps in the remaining families is kept for one reason: **the region writes EXEC** (`s_and_saveexec`, `v_cmpx`, `s_andn2 exec`). No skip was refused for an export, a program end or a read after the region. - A family of 95 programs: 1 of its 2 skips is taken; the other region narrows EXEC and also holds the kill path. Its unwritten pixels halve (×0.49 for each of the 95). - A family of 17 programs: each has 32 skips, all nested EXEC masks like a `switch`, so none is taken. - One blur program: both skips write EXEC, one of them heading a waterfall loop. With EXEC 0 at the region's start, these writes leave EXEC at 0. As a local test, not for this PR as is, I widened the rule so that a region may write EXEC when each write can only narrow a zero EXEC (`v_cmpx`, `s_and_saveexec`, `s_andn1_saveexec`, `s_and`, `s_andn2` or `s_mov` of a zero mask; `s_or_saveexec` is still refused), and EXEC is zero at the region's end. The 17-program family then takes all 32 skips of each program and loses the whole-wave part of its holes (most go from 12,704 to 8,514 unwritten pixels). The other two families need more than that: a backward branch whose condition comes from a zero mask, and a kill branch that the rule cannot prove locally. That rule has had no independent review yet; I can share the patch if it is useful. The 8,514 pixels the 17-program family still loses are not #3574. They are single lanes, they depend on the input values, and they stay when every skip is run through. They are a separate NVIDIA problem, reported in #3772 (the same DXIL is right on WARP). ### Current head I have not run `3632bfa6`. Since `8ca2df9d` the PR refuses more regions (float-mode changes, `src_scc` read after the region) and also recognises NVIDIA by name. None of the 4 programs fixed above has `s_setreg*`, `s_round_mode`, `s_denorm_mode` or `s_movrel*` (checked in an opcode census of the title's programs), so I expect the same result there. That is an inference, not a run. ### Setup - In game: `main` `493dbd3d` + #3528 + #3517 + local commits, with `8ca2df9d` cherry-picked. - Offline tests (section 2): `main` `1c8b5514` + `8ca2df9d` + our three GPU tests. - Sweep (section 3): `main` `817eb1fc` + the local probe commits (tests only) + `8ca2df9d` cherry-picked, with `XCL_PS_SKIP_RUN_THROUGH=1` against `=0`; the direct path splits wave64 pixel shaders into two 32-lane halves. The widened rule is one more local commit on top. - RTX 3090, NVIDIA 616.56, Windows 11 22631. AI use: Claude Code (Claude Opus 5.5) wrote the tests and the probe, ran the bisection, the runs and the sweep, and wrote this comment; checked and posted by me.
Royalflamejlh commented 2026-12-03 07:46:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-03T07:46:16Z.


(Edited: the census sentence now says what it covered.)

@fromthemoonx thank you; point 3 is fixed at f4413ddb3: a region with s_movrelsd_2_b32 now keeps its branch, the way you suggested. execz_skips_over_a_relative_sgpr_move_keep_the_branch fails without it: it puts the move in the region and reads s31 after it. The smoke pair is of this head, on an RTX 2070 SUPER 8 GB (driver 621.01), the same title for 60 s: main 395405e4 1,522 frames, peak commit 16,017 MB; this head 1,551 frames, 15,203 MB, 0 device removals, 0 crashes. The whole suite at this head on that card, debug: 3,016 passed, 0 failed, 52 ignored, 29 SKIPPED (22 no wave64); the PR's GPU test passed.

@CharlyRien thank you for the runs and the sweep. Yes, please share the widened EXEC rule. We would take it as a follow-up pull request after this one rather than widen this one. This head refuses more regions than 8ca2df9d (float-mode changes, src_scc reads after the region, and now s_movrelsd_2_b32), and your census found no float-mode change and no s_movrel* in the 4 programs it fixed (src_scc reads were not in it). So I expect your result to hold at this head, but that is an inference, not a run.

AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7371404911 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7371404911). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-03T07:46:16Z. --- (Edited: the census sentence now says what it covered.) @fromthemoonx thank you; point 3 is fixed at `f4413ddb3`: a region with `s_movrelsd_2_b32` now keeps its branch, the way you suggested. `execz_skips_over_a_relative_sgpr_move_keep_the_branch` fails without it: it puts the move in the region and reads s31 after it. The smoke pair is of this head, on an RTX 2070 SUPER 8 GB (driver 621.01), the same title for 60 s: `main` `395405e4` 1,522 frames, peak commit 16,017 MB; this head 1,551 frames, 15,203 MB, 0 device removals, 0 crashes. The whole suite at this head on that card, debug: 3,016 passed, 0 failed, 52 ignored, 29 SKIPPED (22 no wave64); the PR's GPU test passed. @CharlyRien thank you for the runs and the sweep. Yes, please share the widened EXEC rule. We would take it as a follow-up pull request after this one rather than widen this one. This head refuses more regions than `8ca2df9d` (float-mode changes, `src_scc` reads after the region, and now `s_movrelsd_2_b32`), and your census found no float-mode change and no `s_movrel*` in the 4 programs it fixed (`src_scc` reads were not in it). So I expect your result to hold at this head, but that is an inference, not a run. AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply.
Foniass commented 2026-12-03 07:48:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T07:48:49Z.


Follow-up review of f4413ddb, since 3632bfa6 (code reading only, not a merge-check) · 1 medium

In short: This push refuses one more instruction inside a region that a wave with EXEC 0 runs through: s_movrelsd_2_b32, whose destination SGPR is chosen by M0. A test covers it. The GPU-time point is unchanged.

Medium

  1. On by default on NVIDIA without a GPU-time measurement (partly open). The smoke pair shows no regression, but the description still says the GPU time of the regions run through is not measured, and such a region still fetches its implicit-LOD samples.
Checked and fine
  • s_movrelsd_2_b32 writes an SGPR that uses cannot name statically, so refusing it by name in run (ps_masks.rs ~491) keeps a region from writing an SGPR that is live after it. execz_skips_over_a_relative_sgpr_move_keep_the_branch covers it.
  • S_MOVRELD_* was already counted as writing every SGPR (writes, ~70), so the M0-relative moves are now all covered.
  • The earlier refusals (float-mode changes, src_scc reads, program ends) and the NVIDIA detection by name are unchanged.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7371459927 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7371459927). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T07:48:49Z. --- **Follow-up review** of `f4413ddb`, since `3632bfa6` (code reading only, not a merge-check) · 1 medium **In short:** This push refuses one more instruction inside a region that a wave with EXEC 0 runs through: `s_movrelsd_2_b32`, whose destination SGPR is chosen by M0. A test covers it. The GPU-time point is unchanged. #### Medium 1. **On by default on NVIDIA without a GPU-time measurement (partly open).** The smoke pair shows no regression, but the description still says the GPU time of the regions run through is not measured, and such a region still fetches its implicit-LOD samples. <details><summary>Checked and fine</summary> - `s_movrelsd_2_b32` writes an SGPR that `uses` cannot name statically, so refusing it by name in `run` (`ps_masks.rs` ~491) keeps a region from writing an SGPR that is live after it. `execz_skips_over_a_relative_sgpr_move_keep_the_branch` covers it. - `S_MOVRELD_*` was already counted as writing every SGPR (`writes`, ~70), so the M0-relative moves are now all covered. - The earlier refusals (float-mode changes, `src_scc` reads, program ends) and the NVIDIA detection by name are unchanged. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Royalflamejlh commented 2026-12-03 14:40:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-03T14:40:30Z.


@Foniass I measured the run-through's GPU cost with a synthetic draw, not in the title. On an RTX 4060 Ti, a skipped region run with EXEC 0 cost nothing measurable with 8 implicit-LOD samples in it, and up to 80 % of the same region's cost with every lane active when it held 32.

Setup: f4413ddb3 plus a timing test kept out of this PR. It is a full-screen 2048×2048 draw (65,536 64-pixel waves) of a wave64 pixel shader, translated as the PR's GPU test translates it. Its s_cbranch_execz region holds N image_sample (implicit LOD, 1024² RGBA32F texture), summed into the exported colour. The region has no lane in any wave, or every lane in every wave. XCL_PS_SKIP_RUN_THROUGH=1 and 0 ran in separate processes, 5 processes each. Each process gives the median of 20 timed draws; the table gives the median of those 5. The spread across processes was 0.001 ms or less, except one empty run-through at 8 samples (0.008 ms). RTX 4060 Ti 16 GB, NVIDIA 615.71.09, Linux, Wine, vkd3d-proton.

samples in the region no lane, skip kept no lane, run through every lane, either setting
8 0.134 ms 0.135 ms 0.315 ms
16 0.135 ms 0.185 ms 0.323 to 0.325 ms
32 0.135 ms 0.366 ms 0.424 ms
  • Every wave of these draws skips the region, so the extra time is an upper bound for a draw of this size. In a real draw only the waves with no lane in the region pay it: 0, 0.8 and 3.5 ns for each such wave here.
  • The switch changes 7,324 of 12,056 translated pixel shaders of the retail title. This is a diff of the two translated caches after one offline pass each way. How many waves skip at run time is not known.
  • GPU time in the title was not measured. The title runs here (RTX 4060 Ti, Linux) ran out of system memory before any frame heavy enough to time. The 8 GB card on Windows ran out of video memory first.

Not tested: AMD (off there), other NVIDIA cards, this timing on Windows, and regions with explicit-LOD samples or loads.

AI use: Claude Code (Claude Opus 5.5) wrote the timing test, ran it and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7381840812 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3591#issuecomment-7381840812). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-03T14:40:30Z. --- @Foniass I measured the run-through's GPU cost with a synthetic draw, not in the title. On an RTX 4060 Ti, a skipped region run with EXEC 0 cost nothing measurable with 8 implicit-LOD samples in it, and up to 80 % of the same region's cost with every lane active when it held 32. Setup: `f4413ddb3` plus a timing test kept out of this PR. It is a full-screen 2048×2048 draw (65,536 64-pixel waves) of a wave64 pixel shader, translated as the PR's GPU test translates it. Its `s_cbranch_execz` region holds N `image_sample` (implicit LOD, 1024² RGBA32F texture), summed into the exported colour. The region has no lane in any wave, or every lane in every wave. `XCL_PS_SKIP_RUN_THROUGH=1` and `0` ran in separate processes, 5 processes each. Each process gives the median of 20 timed draws; the table gives the median of those 5. The spread across processes was 0.001 ms or less, except one empty run-through at 8 samples (0.008 ms). RTX 4060 Ti 16 GB, NVIDIA 615.71.09, Linux, Wine, vkd3d-proton. | samples in the region | no lane, skip kept | no lane, run through | every lane, either setting | |---|---|---|---| | 8 | 0.134 ms | 0.135 ms | 0.315 ms | | 16 | 0.135 ms | 0.185 ms | 0.323 to 0.325 ms | | 32 | 0.135 ms | 0.366 ms | 0.424 ms | - Every wave of these draws skips the region, so the extra time is an upper bound for a draw of this size. In a real draw only the waves with no lane in the region pay it: 0, 0.8 and 3.5 ns for each such wave here. - The switch changes 7,324 of 12,056 translated pixel shaders of the retail title. This is a diff of the two translated caches after one offline pass each way. How many waves skip at run time is not known. - GPU time in the title was not measured. The title runs here (RTX 4060 Ti, Linux) ran out of system memory before any frame heavy enough to time. The 8 GB card on Windows ran out of video memory first. Not tested: AMD (off there), other NVIDIA cards, this timing on Windows, and regions with explicit-LOD samples or loads. AI use: Claude Code (Claude Opus 5.5) wrote the timing test, ran it and wrote this reply.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3591:upstream-pr/3591'
git switch 'upstream-pr/3591'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3591'
git switch 'upstream-pr/3591'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3591'
git switch 'upstream-pr/3591'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3591'
git switch 'main'
git merge --squash 'upstream-pr/3591'
git switch 'main'
git merge --ff-only 'upstream-pr/3591'
git switch 'main'
git merge 'upstream-pr/3591'
git push origin 'main'
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
xcl-dev/xcl!3591
No description provided.