Skip to content

shader: lower more Ampere forms used by Pokemon Pokopia's compute shaders - #413

Merged
jojo-chaechae merged 1 commit into
Eglantine-Community:nx2from
protonnegativo:fix/ampere-const-lea-hi
Nov 4, 2026
Merged

jojo-chaechae merged 1 commit into
Eglantine-Community:nx2from
protonnegativo:fix/ampere-const-lea-hi

Conversation

@protonnegativo

@protonnegativo protonnegativo commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

I tested Pokopia on the Steam Deck and the game was rejecting several shaders, and photos came out black. I made the translator accept more forms of some instructions (LEA, SHF, UIADD3, DEPBAR and USHF). With this, almost all of Pokopia's shaders stopped being rejected and the tests pass. The photo is still black, but that should be a separate issue.

Assisted-by: Claude Opus 5.5 (debugging and code)

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of several Ampere compute-shader instructions, including predicated arithmetic and shifts, constant-based address calculations, and dependency barriers. This helps affected shaders compile and run more reliably.
  • Tests

    • Added coverage for the affected Ampere compute-shader operations.

…ders

I tested Pokopia on the Steam Deck and the game was rejecting several
shaders, and photos came out black. I made the translator accept more
forms of some instructions (LEA, SHF, UIADD3, DEPBAR and USHF). With
this, almost all of Pokopia's shaders stopped being rejected and the
tests pass. The photo is still black, but that should be a separate
issue.

Assisted-by: Claude Opus 5.5 (debugging and code)
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The Ampere-to-Maxwell lowering accepts additional guarded arithmetic and shift forms, dependency-barrier encodings, and constant-base LEA forms. Tests cover the new lowering cases.

Changes: Ampere instruction lowering

Layer / File(s) Summary
Guarded arithmetic and shifts
src/shader_recompiler/frontend/ampere/lower_to_maxwell.h, src/tests/video_core/ampere_compute_lowering.cpp, src/tests/CMakeLists.txt
Guarded UIADD3 and uniform shift forms use the existing lowering paths. Tests compare guarded output with unguarded output and check the configured predicate.
Constant-base LEA lowering
src/shader_recompiler/frontend/ampere/lower_to_maxwell.h, src/tests/video_core/ampere_compute_lowering.cpp
Constant-base LEA.HI supports the specified form without carry-out. The low-word path supports forms without carry-out and emits the carry comparison only when requested. Tests cover the accepted and rejected forms.
Immediate SHF and DEPBAR encodings
src/shader_recompiler/frontend/ampere/lower_to_maxwell.h, src/tests/video_core/ampere_compute_lowering.cpp
Immediate SHF.L high-word lowering accepts forms with or without .W. Dependency-barrier validation accepts the specified masked field values. Tests exercise these cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related issues

  • Djihads80/Eglantine#387 — The issue concerns rejected fullscreen shaders; this PR adds lowering support for guarded arithmetic and shift forms that may address part of the reported rendering behavior.

Possibly related PRs

Suggested reviewers: takoroka

Merge Risk: Minimal · up to 830a7

The change accepts additional shader forms. No merge-blocking regression was identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the Ampere shader lowering work and the game that needed it. The changeset adds lowering for LEA, SHF, UIADD3, DEPBAR, and USHF forms in lower_to_maxwell.h, plus tests for them. The ti…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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: Title check

Explanation

The title names the Ampere shader lowering work and the game that needed it. The changeset adds lowering for LEA, SHF, UIADD3, DEPBAR, and USHF forms in lower_to_maxwell.h, plus tests for them. The title is a real and specific description of the main change, though it does not list each instruction form.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd7ee9ea-2cc8-46c7-99fb-86ec71ffbd7b
Commits

Reviewing files that changed from the base of the PR and between 46967a1 and 830a7cc.

Files selected for processing: 3
  • src/shader_recompiler/frontend/ampere/lower_to_maxwell.h
  • src/tests/CMakeLists.txt
  • src/tests/video_core/ampere_compute_lowering.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@jojo-chaechae

Copy link
Copy Markdown
Collaborator

This PR is included in a test batch together with 34 other PRs, built for Linux and Windows (PGO). Game testing is underway; results will be posted here.

It conflicted with #456 and #443 in lower_to_maxwell.h and src/tests/CMakeLists.txt; both sides were kept for the batch. It will need a rebase once those land.

@jojo-chaechae
jojo-chaechae merged commit 201aacd into Eglantine-Community:nx2 Nov 4, 2026
1 check passed
jojo-chaechae added a commit that referenced this pull request Nov 4, 2026
ymatrix1 pushed a commit to ymatrix1/Eglantine that referenced this pull request Nov 4, 2026
…th async copies

The batch merge of Eglantine-Community#413 and Eglantine-Community#465 left uses_async_copy unused, which GCC's -Werror rejects
and broke the non-PGO Linux builds. The barrier is only needed when the program issues
LDGSTS copies, as in Eglantine-Community#465.
rdodoa pushed a commit to rdodoa/Eglantine that referenced this pull request Nov 7, 2026
…r-GPU-written pages (Eglantine-Community#413)

* vulkan: skip the buffer cache lock for dirty checks on pages the GPU never wrote

The split's front asks MustFlushRegion before each macro DMA read; it waited for the
buffer cache mutex the back holds through each draw (8% of the front in Ocarina).
Every GPU-modified range also marks its pages GPU-written (bits that never clear), so
pages without the bit are answered without the lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 6247fd5)

* video_core: answer the lock-free flush check from nx2.h and test it

Move the GPU-written page walk behind MustFlushRegion's lock-free answer into
Tegra::Nx2MayBeGpuWritten next to the bitmap it reads. A range past the bitmap,
or one that wraps, now answers true and takes the lock: Nx2MarkGpuWritten clamps
to the bitmap, so those pages were never marked. Test the page boundaries, the
bitmap end and clearing.

---------

Co-authored-by: Frizti <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
mollie2999 pushed a commit to mollie2999/Eglantine that referenced this pull request Nov 8, 2026
…r-GPU-written pages

The split's front asks MustFlushRegion before each macro DMA read and
waited for the buffer cache mutex the back holds through each draw (8% of
the front in Ocarina, Lichii's measurement; this tree's profile showed
~280 ms a second of front waits before macro DMA reads). Every range the
buffer cache adds to gpu_modified_ranges also marks its pages in
g_nx2_gpu_written_pages under the same lock (Switch 2 titles), so pages
without the bit are answered without the lock. Ranges past the bitmap
take the lock as before.

Ported from Lichii 2b70fc5 (Eglantine-Community#413, Frizti and Zortos) without its test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
godpow added a commit to godpow/Eglantine that referenced this pull request Nov 12, 2026
Taken from zortos293/Lichii Eglantine-Community#413 (2b70fc5, Zortos/Frizti), the helper only (not its
MustFlushRegion change): the stale-upload skip ported next (Lichii Eglantine-Community#463) uses it to keep the
upload of pages the buffer cache wrote on the GPU.

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants