shader: support V_CMPX_EQ_U16 #816

Manually merged
github merged 2 commits from gh-pr/816/head into gh-pr/816/base 2026-11-26 09:33:41 +00:00
Owner

@⁠theantipopau on GitHub · 2026-09-24 22:05 UTC · original
theantipopau:fix-vcmpx-eq-u16-clean → main · +80 −1 · 4 files · 2 commits · merged 2026-09-24 22:27 UTC

Summary

  • decode gfx11 VOPC 0xba as V_CMPX_EQ_U16 in compact, VOP3, and SDWA forms
  • lower the instruction as an unsigned 16-bit equality compare with CMPX EXEC-mask semantics
  • reject the currently unsupported DPP encoding consistently with the neighboring 16-bit CMPX instruction
  • add decoder, CFG, IR, SPIR-V, and runtime regression coverage

Related to #281 and its VOPC 0xba report.

Validation

  • shader_cfg: passed on a branch based directly on upstream main
  • shader_recompiler_compute_tests: builds successfully
  • new runtime case is registered in the compute suite and via --cmpx-eq-u16-only
  • local runtime execution is blocked by the AMD driver lacking the harness's required production rasterization features
  • git diff --check: passed
**@⁠theantipopau** on GitHub · 2026-09-24 22:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/816) `theantipopau:fix-vcmpx-eq-u16-clean` → `main` · +80 −1 · 4 files · 2 commits · merged 2026-09-24 22:27 UTC ## Summary - decode gfx11 VOPC `0xba` as `V_CMPX_EQ_U16` in compact, VOP3, and SDWA forms - lower the instruction as an unsigned 16-bit equality compare with CMPX EXEC-mask semantics - reject the currently unsupported DPP encoding consistently with the neighboring 16-bit CMPX instruction - add decoder, CFG, IR, SPIR-V, and runtime regression coverage Related to #281 and its VOPC `0xba` report. ## Validation - `shader_cfg`: passed on a branch based directly on upstream `main` - `shader_recompiler_compute_tests`: builds successfully - new runtime case is registered in the compute suite and via `--cmpx-eq-u16-only` - local runtime execution is blocked by the AMD driver lacking the harness's required production rasterization features - `git diff --check`: passed
Decode gfx11 VOPC 0xba and lower it as an unsigned 16-bit equality
compare with CMPX EXEC-mask semantics.

🤖 Generated with Codebuff 🤖
Co-Authored-By: Codebuff <[email protected]>
Remove the added CFG tests and correct two EXEC expectations in the compute regression case.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:33:39 +00:00
github manually merged commit 1addc173e3 into gh-pr/816/base 2026-11-26 09:33:41 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-24 22:21 UTC · original

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The decoder adds V_CMPX_EQ_U16 for VOPC encoding 0xba and classifies it as an EXEC-destination comparison. The translator emits an unsigned 16-bit equality comparison with execute-mask updates. Tests cover compact, SDWA, and VOP3 encodings, including EXEC and VCC results; DPP remains unsupported. A compute test covers 12 equality cases and can run on its own.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Feature

Merge Risk: 🟡 Moderate · up to aa4b0

The new compute regression test is expected to fail when run on supported hardware. Correct its test case before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: support for V_CMPX_EQ_U16.
Description check ✅ Passed The description directly explains decoding, lowering, unsupported DPP handling, test coverage, and validation for V_CMPX_EQ_U16.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (2 skipped: 2 too large.)


Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-24 22:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/816#issuecomment-5823191862) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/816"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The decoder adds V_CMPX_EQ_U16 for VOPC encoding 0xba and classifies it as an EXEC-destination comparison. The translator emits an unsigned 16-bit equality comparison with execute-mask updates. Tests cover compact, SDWA, and VOP3 encodings, including EXEC and VCC results; DPP remains unsupported. A compute test covers 12 equality cases and can run on its own. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"aa4b03d168a9e248925c69371575daed77445889" --> **Change:** Feature <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _🟡 Moderate_ · up to `aa4b0` <!-- final_review_risk_coverage:{"sourceCommitId":"aa4b03d168a9e248925c69371575daed77445889","coveredCommitId":"aa4b03d168a9e248925c69371575daed77445889","kind":"reviewed"} --> The new compute regression test is expected to fail when run on supported hardware. Correct its test case before merging. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :----------------: | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ❓ Inconclusive | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (2 skipped: 2 … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly and concisely identifies the main change: support for V_CMPX_EQ_U16. | | Description check | ✅ Passed | The description directly explains decoding, lowering, unsupported DPP handling, test coverage, and validation for V_CMPX_EQ_U16. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (2 skipped: 2 too large.) </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-24 22:21 UTC · original · edited 2026-09-24 22:27 UTC
On tests/ShaderRecompilerComputeTests.cpp line 22511 (outdated):

@@ -22492,6 +22492,74 @@ TestCase VectorVopcCmpxLtU16CapturedSdwaExecMask() {
   return test;
 }
 
+TestCase VectorVopcCmpxEqU16SdwaCompactVop3ExecMask() {
+  using O = ShaderOpcode;
+  struct CompareCase {
+    u32 lhs;
+    u32 rhs;
+    u32 incoming_exec;
+    u32 expected_exec;
+    u32 encoding = 0; // 0: SDWA, 1: compact, 2: VOP3, 3: SDWA sign-extend.
+  };
+  const std::array<CompareCase, 12> cases{{
+      {0x12340000u, 0x56780000u, 1, 1}, // Equal low half; ignore high half.
+      {0xffff0001u, 0xabcd0001u, 1, 1},
+      {0x00000000u, 0x12340000u, 1, 1},
+      {0xaaaa5555u, 0xbbbb5555u, 1, 1},
+      {0x00000000u, 0x00000001u, 1, 0},
+      {0x0000ffffu, 0x00000000u, 1, 0},
+      {0x7fff8000u, 0x00018000u, 1, 0}, // Sign bit alone does not make these equal.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fix the wrong expected value for the V_CMPX_EQ_U16 "sign bit" case.

This case uses the default SDWA encoding (encoding=0). Case 1 in the same array documents the rule for this encoding: the comparison uses only the low 16 bits and ignores the high 16 bits. Seven other cases in this test confirm the rule.

Apply the rule to this case: 0x7fff8000u & 0xffff equals 0x8000. 0x00018000u & 0xffff also equals 0x8000. The two low halves are identical, so V_CMPX_EQ_U16 must report equality here. The test hardcodes expected_exec = 0, which contradicts the rule that the other seven cases establish.

Equality does not depend on sign interpretation. If the compared 16 bits are bit-identical, the values are equal regardless of the "sign bit" framing in the comment. As written, this case will fail at runtime: the GPU produces EXEC = 1, CompareWords receives 0 as the expected value, and the test process aborts.

Change one operand so the low 16 bits differ while both keep bit 15 set, to preserve the apparent intent of testing two negative-looking values that are not equal.

🐛 Proposed fix for the test data
-      {0x7fff8000u, 0x00018000u, 1, 0}, // Sign bit alone does not make these equal.
+      {0x7fff8000u, 0x00019000u, 1, 0}, // Sign bit alone does not make these equal.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      {0x7fff8000u, 0x00019000u, 1, 0}, // Sign bit alone does not make these equal.

✅ Addressed in commit 1addc17

**@⁠coderabbitai[bot]** on GitHub · 2026-09-24 22:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/816#discussion_r4099061031) · edited 2026-09-24 22:27 UTC On `tests/ShaderRecompilerComputeTests.cpp` line 22511 (outdated): ```diff @@ -22492,6 +22492,74 @@ TestCase VectorVopcCmpxLtU16CapturedSdwaExecMask() { return test; } +TestCase VectorVopcCmpxEqU16SdwaCompactVop3ExecMask() { + using O = ShaderOpcode; + struct CompareCase { + u32 lhs; + u32 rhs; + u32 incoming_exec; + u32 expected_exec; + u32 encoding = 0; // 0: SDWA, 1: compact, 2: VOP3, 3: SDWA sign-extend. + }; + const std::array<CompareCase, 12> cases{{ + {0x12340000u, 0x56780000u, 1, 1}, // Equal low half; ignore high half. + {0xffff0001u, 0xabcd0001u, 1, 1}, + {0x00000000u, 0x12340000u, 1, 1}, + {0xaaaa5555u, 0xbbbb5555u, 1, 1}, + {0x00000000u, 0x00000001u, 1, 0}, + {0x0000ffffu, 0x00000000u, 1, 0}, + {0x7fff8000u, 0x00018000u, 1, 0}, // Sign bit alone does not make these equal. ``` _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_ **Fix the wrong expected value for the V_CMPX_EQ_U16 "sign bit" case.** This case uses the default SDWA encoding (encoding=0). Case 1 in the same array documents the rule for this encoding: the comparison uses only the low 16 bits and ignores the high 16 bits. Seven other cases in this test confirm the rule. Apply the rule to this case: `0x7fff8000u & 0xffff` equals `0x8000`. `0x00018000u & 0xffff` also equals `0x8000`. The two low halves are identical, so V_CMPX_EQ_U16 must report equality here. The test hardcodes `expected_exec = 0`, which contradicts the rule that the other seven cases establish. Equality does not depend on sign interpretation. If the compared 16 bits are bit-identical, the values are equal regardless of the "sign bit" framing in the comment. As written, this case will fail at runtime: the GPU produces `EXEC = 1`, `CompareWords` receives `0` as the expected value, and the test process aborts. Change one operand so the low 16 bits differ while both keep bit 15 set, to preserve the apparent intent of testing two negative-looking values that are not equal. <details> <summary>🐛 Proposed fix for the test data</summary> ```diff - {0x7fff8000u, 0x00018000u, 1, 0}, // Sign bit alone does not make these equal. + {0x7fff8000u, 0x00019000u, 1, 0}, // Sign bit alone does not make these equal. ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion {0x7fff8000u, 0x00019000u, 1, 0}, // Sign bit alone does not make these equal. ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:poseidon:beignet --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:69050dc190e9db3deed05e7c --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 1addc17
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-24 22:21 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 0a123846-872b-4183-8c00-7ec38092340d

📥 Commits

Reviewing files that changed from the base of the PR and between a20fb7f9f8 and aa4b03d168.

📒 Files selected for processing (5)
  • src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.h
  • src/graphics/shader/recompiler/frontend/decode/VectorAluOps.cpp
  • src/graphics/shader/recompiler/frontend/translate/Vector.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/shaderCfgTests.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-24 22:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/816#pullrequestreview-5310909651) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `0a123846-872b-4183-8c00-7ec38092340d` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between a20fb7f9f894f199fd678301356af1bbe030885e and aa4b03d168a9e248925c69371575daed77445889. </details> <details> <summary>📒 Files selected for processing (5)</summary> * `src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.h` * `src/graphics/shader/recompiler/frontend/decode/VectorAluOps.cpp` * `src/graphics/shader/recompiler/frontend/translate/Vector.cpp` * `tests/ShaderRecompilerComputeTests.cpp` * `tests/shaderCfgTests.cpp` </details> **Included review availability:** Your plan provides up to 10 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.