Skip to content

fix(shader): use guest lane for compute masks - #1227

Draft
Thimo188 wants to merge 4 commits into
mainfrom
upstream-pr/25404
Draft

Thimo188 wants to merge 4 commits into
mainfrom
upstream-pr/25404

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#25404, originally opened by DonRyuzaki.

Source commit: 446e5b0a132930dffcf8f311f517099ea926d479. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

For Wave32 compute shaders split across Vulkan subgroups, scalar VCC or EXEC bit tests can repeat the low mask bits in each host subgroup. The fix uses gl_LocalInvocationIndex % 32 when the mask comes from dependencies that provide a complete scalar word. Ballot-derived masks and masks with uncertain lane mapping keep host subgroup indexing.

The original literal-mask fixture and the two ballot and SCC regression fixtures are credited to mihiii1337. Original fixture · Regression fixtures

The separate 45-thread buffer-fed ReadFirstLane case still selects the wrong VCC bits with boykopovar#25660, including in the 13-lane partial wave. That case needs a follow-up that accounts for the workgroup exchange. Independent Windows results

Tested

Ubuntu 24.04 WSL2, GCC 13.3, Release, Mesa lavapipe (LLVM 20.1.2, subgroup size 8). Vulkan was required and shader and pipeline caches were disabled.

  • On main 7bf7d80bf9, the literal mask read back as 0xa5a5a5a5. With the previous PR head f432125076, the literal mask passed, but the ballot and SCC cases read back as 0x000000a9 and 0x000000ff.
  • On 446e5b0a132, the literal, ballot and SCC readbacks were 0x96a596a5, 0x7b36c4a9, and 0xffffffff. All three passed three times on the PR head and three times when merged onto 7bf7d80bf9. They also passed with SPIR-V optimization disabled. The user-data controls passed.
  • The Vulkan validation layer loaded and emitted zero VUID- diagnostics. Conventions and whitespace checks passed.

No PS5 title or physical GPU was run in the author’s test.

Checklist

  • Merges cleanly with current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Mesa llvmpipe LLVM 20.1.2, software Vulkan device, subgroup 8, Ubuntu 24.04 WSL2; no physical GPU
  • AI-assisted: yes

mihiii1337 and others added 4 commits November 22, 2026 00:29
Host subgroup IDs wrap at eight on llvmpipe, so scalar VCC writes alias guest lanes 8-31. Use the workgroup index only when one host invocation carries one guest compute lane.

Refs boykopovar#25298
Preserve the readback fixtures from a05bcb6.
Using the guest lane for every mask drops ballot-derived bits
above the first host subgroup. Use it for scalar mask bit tests
whose words do not depend on subgroup ballots.
@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants