Recompiler: match all VOP3 encoding names in ps_masks #2605

Open
github-bot wants to merge 1 commit from github-bot/gh-2605 into amd-dev AGit
Owner

@⁠AlpPesen on GitHub · 2026-11-26 01:27 UTC · original
AlpPesen:amd-dev/fix-ps-masks-vop3 → amd-dev · +44 −2 · 1 files · 1 commits · open

Fixes VOP3 encoding detection in crates/xcl/src/gpu/recomp/ps_masks.rs:

per_lane and forms checked d.enc.name.starts_with("ENC_VOP3"), which misses VOP3_SDST_ENC, VOP3_SDST_ENC_INST_LITERAL, and VOP3_INST_LITERAL. As a result, V_ADD_CO_CI_U32, V_SUB_CO_CI_U32, and V_SUBREV_CO_CI_U32 in VOP3_SDST_ENC fell through to VCC instead of checking their SRC2 carry-in SGPR pair in per_lane(d), allowing diverged SRC2 reads to slip past ps_masks::run.

What is in it

  • Replace d.enc.name.starts_with("ENC_VOP3") with d.enc.name.contains("VOP3") in per_lane and forms (crates/xcl/src/gpu/recomp/ps_masks.rs).
  • Add unit test vop3_sdst_and_literal_encodings_are_recognized verifying VOP3_SDST_ENC (V_ADD_CO_CI_U32 / V_SUB_CO_CI_U32) SRC2 extraction and scalar-vs-literal Form::Uniform.

Tested

  • Hardware: Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (16337 MiB VRAM, RDNA2, driver 32.0.21045.29003), Windows 11 Pro build 26300, rustc 1.100.0, DXC 1.9.2602.17.
  • cargo test -p xcl --lib gpu::recomp::ps_masks: 4 passed, 0 failed, 0 ignored, 0 skipped.

Not tested

  • NVIDIA or Intel GPUs or Linux/Wine.

Regression run

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1499 (PresentX 1499)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13951 MB
xcl-smoke v1
commit: 6a0bb5b4f294b0729771ed457af1f96c01f5c06b
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14734 MB
xcl-smoke v1
commit: 5b4437eea9af0775547529e6e34574992a6a5f7f
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1458 (PresentX 1458)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14766 MB

AI use

  • Antigravity (Gemini 4 Neon): audited amd-dev ps_masks.rs, implemented the fix and unit test, ran the tests and paired scripts/smoke.ps1 runs, and drafted this PR description.
**@⁠AlpPesen** on GitHub · 2026-11-26 01:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/2605) `AlpPesen:amd-dev/fix-ps-masks-vop3` → `amd-dev` · +44 −2 · 1 files · 1 commits · open Fixes VOP3 encoding detection in `crates/xcl/src/gpu/recomp/ps_masks.rs`: `per_lane` and `forms` checked `d.enc.name.starts_with("ENC_VOP3")`, which misses `VOP3_SDST_ENC`, `VOP3_SDST_ENC_INST_LITERAL`, and `VOP3_INST_LITERAL`. As a result, `V_ADD_CO_CI_U32`, `V_SUB_CO_CI_U32`, and `V_SUBREV_CO_CI_U32` in `VOP3_SDST_ENC` fell through to `VCC` instead of checking their `SRC2` carry-in SGPR pair in `per_lane(d)`, allowing diverged `SRC2` reads to slip past `ps_masks::run`. **What is in it** - Replace `d.enc.name.starts_with("ENC_VOP3")` with `d.enc.name.contains("VOP3")` in `per_lane` and `forms` (`crates/xcl/src/gpu/recomp/ps_masks.rs`). - Add unit test `vop3_sdst_and_literal_encodings_are_recognized` verifying `VOP3_SDST_ENC` (`V_ADD_CO_CI_U32` / `V_SUB_CO_CI_U32`) `SRC2` extraction and scalar-vs-literal `Form::Uniform`. **Tested** - Hardware: Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (16337 MiB VRAM, RDNA2, driver 32.0.21045.29003), Windows 11 Pro build 26300, `rustc 1.100.0`, DXC `1.9.2602.17`. - `cargo test -p xcl --lib gpu::recomp::ps_masks`: 4 passed, 0 failed, 0 ignored, 0 skipped. **Not tested** - NVIDIA or Intel GPUs or Linux/Wine. **Regression run** ``` xcl-smoke v1 commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea gpu: AMD Radeon RX 6800 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1499 (PresentX 1499) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13951 MB ``` ``` xcl-smoke v1 commit: 6a0bb5b4f294b0729771ed457af1f96c01f5c06b gpu: AMD Radeon RX 6800 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1540 (PresentX 1540) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14734 MB ``` ``` xcl-smoke v1 commit: 5b4437eea9af0775547529e6e34574992a6a5f7f gpu: AMD Radeon RX 6800 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1458 (PresentX 1458) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14766 MB ``` **AI use** - Antigravity (Gemini 4 Neon): audited `amd-dev` `ps_masks.rs`, implemented the fix and unit test, ran the tests and paired `scripts/smoke.ps1` runs, and drafted this PR description.
Use contains(VOP3) instead of starts_with(ENC_VOP3) in ps_masks so VOP3_SDST_ENC and VOP3*_INST_LITERAL instructions inspect SRC2 properly and scalar-vs-literal compares recognize Form::Uniform.

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:34:45 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 01:57 UTC · original

Verification on RTX 3060 Ti (Windows 11), head merged with current main:

  • cargo test -p xcl --lib -- --test-threads=1: aborts with 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN) partway through, deterministically:
thread 'xcl-pso-5' panicked at crates\xcl\src\hle\d3d12x\pso_async.rs:1219:43:
a build that panics (test)

thread 'xcl-pso-22' panicked at windows-core-0.62.2\src\interface.rs:41:18:
misaligned pointer dereference: address must be a multiple of 0x8 but is 0xffffffffffffffff
thread caused non-unwinding panic. aborting.

During hle::d3d12x::pso_async::used_tests::a_released_queued_pipeline_is_not_built_by_normal_workers. An injected worker panic is followed by a 0xffffffffffffffff COM-pointer dereference on another worker — the poisoned pointer is not being checked during teardown. Real bug in the merged state.

Note: the branch is a ~212-commit stack on main, so this may belong to an earlier layer (the pso_async frame-wait-window work looks related).

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 01:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2605#issuecomment-7180324405) Verification on RTX 3060 Ti (Windows 11), head merged with current `main`: - `cargo test -p xcl --lib -- --test-threads=1`: **aborts with 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN)** partway through, deterministically: ``` thread 'xcl-pso-5' panicked at crates\xcl\src\hle\d3d12x\pso_async.rs:1219:43: a build that panics (test) thread 'xcl-pso-22' panicked at windows-core-0.62.2\src\interface.rs:41:18: misaligned pointer dereference: address must be a multiple of 0x8 but is 0xffffffffffffffff thread caused non-unwinding panic. aborting. ``` During `hle::d3d12x::pso_async::used_tests::a_released_queued_pipeline_is_not_built_by_normal_workers`. An injected worker panic is followed by a `0xffffffffffffffff` COM-pointer dereference on another worker — the poisoned pointer is not being checked during teardown. Real bug in the merged state. Note: the branch is a ~212-commit stack on `main`, so this may belong to an earlier layer (the pso_async frame-wait-window work looks related). — Devin
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-26 02:01 UTC · original

NVIDIA run (listed as untested), plus an RX 9070 XT: the new test passes on both, and nothing else changes against amd-dev in the GPU suite.

Head 5b4437e applied on amd-dev b5c0275, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4 (default HLSL path) on amd-dev and with the PR, card chosen with XCL_ADAPTER:

amd-dev this PR
RTX 3060 (Ampere, 32-lane waves only, 32.0.16.1088) 749 passed, 3 failed, 20 SKIPPED 750 passed, 3 failed, 20 SKIPPED
RX 9070 XT (RDNA4, 32.0.32029.2010) 748 passed, 4 failed, 4 SKIPPED 749 passed, 4 failed, 4 SKIPPED

On both cards, the only result change is the new vop3_sdst_and_literal_encodings_are_recognized (ok), with no new skips. All the failures are the same on amd-dev without this PR:

  • both cards: dispatch_chain_native_wave64_builds_whole, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, f32_programs_on_the_gpu;
  • RX 9070 XT only: fuzz_validate_and_gpu_1 (#2115).

Not tested: Intel, Linux / Wine, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-26 02:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/2605#issuecomment-7180376289) NVIDIA run (listed as untested), plus an RX 9070 XT: the new test passes on both, and nothing else changes against `amd-dev` in the GPU suite. Head `5b4437e` applied on `amd-dev` `b5c0275`, debug, Windows 11 Pro 26200, `cargo test -p xcl --lib -- gpu:: --test-threads=4` (default HLSL path) on `amd-dev` and with the PR, card chosen with `XCL_ADAPTER`: | | `amd-dev` | this PR | |---|---|---| | RTX 3060 (Ampere, 32-lane waves only, 32.0.16.1088) | 749 passed, 3 failed, 20 SKIPPED | 750 passed, 3 failed, 20 SKIPPED | | RX 9070 XT (RDNA4, 32.0.32029.2010) | 748 passed, 4 failed, 4 SKIPPED | 749 passed, 4 failed, 4 SKIPPED | On both cards, the only result change is the new `vop3_sdst_and_literal_encodings_are_recognized` (ok), with no new skips. All the failures are the same on `amd-dev` without this PR: - both cards: `dispatch_chain_native_wave64_builds_whole`, `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, `f32_programs_on_the_gpu`; - RX 9070 XT only: `fuzz_validate_and_gpu_1` (#2115). Not tested: Intel, Linux / Wine, a title. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2605/head:github-bot/gh-2605'
git switch 'github-bot/gh-2605'

Merge

Merge the changes and update on Forgejo.
git switch 'amd-dev'
git merge --no-ff 'github-bot/gh-2605'
git switch 'github-bot/gh-2605'
git rebase 'amd-dev'
git switch 'amd-dev'
git merge --ff-only 'github-bot/gh-2605'
git switch 'github-bot/gh-2605'
git rebase 'amd-dev'
git switch 'amd-dev'
git merge --no-ff 'github-bot/gh-2605'
git switch 'amd-dev'
git merge --squash 'github-bot/gh-2605'
git switch 'amd-dev'
git merge --ff-only 'github-bot/gh-2605'
git switch 'amd-dev'
git merge 'github-bot/gh-2605'
git push origin 'amd-dev'
This discussion has been locked. Commenting is limited to contributors.
No description provided.