Skip to content

fix(shader): preserve adjusted sampler table reads during Windows loading - #1681

Open
Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/27779
Open

Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/27779

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#27779, originally opened by lgqdaxia.

Source commit: 1aab4aaada5e642ab2caacd4691198b459c90500. 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

A Windows loading draw failed with GetSamplerResource dword 0 is not a valid runtime value. The shader read a sampler from an indexed table and ORed a lane mask into bits 12–29 of its fourth word before an adjusted image sample. The table recognizer lost the underlying read and sent the descriptor down the runtime-value path.

The table recognizer now uses the existing sample-adjust rule. It removes an OR operand only when its possible bits are confined to the reserved field and every consumer of the handle uses adjusted sampling. The selected entry still supplies its filter, LOD and border settings. Original sample-adjust rule

Tested

On Windows, the image-table regression dispatches six workgroups across float, unsigned and signed texture records. The control on main at 30cb03d5d47 reproduced the loading error. With the change, its complete GPU readback matched the unmodified table fixture. The Khronos validation layer was active in both runs, with zero validation errors and zero skipped cases.

A separate pixel-draw fixture on the bindless development branch selects two different LOD biases from one sampler table. Both the descriptor-set and bindless controls reproduced the error. With the change, both modes produced the expected mip stripe at all 2,048 pixels. In the Windows loading draw that previously failed, the planner recovered a four-word sampler column with 128 records and reported zero malformed records. Bindless development branch

On Linux with RADV and a Radeon RX Vega 56, agc_driver_image_table passed 3/3 runs at 1aab4aaa with no validation errors reported. Restoring the base ResourceTracker.cpp with the same test reproduced the runtime-value error. Independent verification by tablefrogpillow

Checklist

  • Based on 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: The Game
  • GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, NVIDIA 621.14, Windows 11 Pro build 26300 and AMD Radeon RX Vega 56, RADV on Linux
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved image-sampling consistency when adjusted sampler settings are used, helping ensure results match the expected output.
  • Tests
    • Added coverage verifying that adjusted sampler cases complete without faults and produce the same results as the reference case.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Sampler dword 3 canonicalization

Layer / File(s) Summary
Conditional canonicalization and execution check
core/shader/recompiler/Optimization/src/ResourceTracker.cpp, core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
TryMakeTableColumn checks sampler dword 3 through tableSamplerDword3. The helper canonicalizes an OR-valued word only when the handle uses and memory metadata meet the specified conditions. The execution test checks that the modified shader variant does not fault and produces the reference output.

Change: Bug fix

Merge Risk: Minimal · up to 1aab4

This change keeps adjusted sampler-table reads recognizable during shader loading, and the tracker only rewrites the word when every use of the handle is an adjusted sample. The added execution test checks that the adjusted shader runs without a fault and matches the reference output. No merge-blocking risk was found.

Security architecture risk: Minimal · up to 1aab4

The shader recompiler now recognizes adjusted sampler reads without changing which table entry is selected or bypassing the existing descriptor checks.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

⏳ This installation's GitHub REST API quota is critically low (2.9% remaining as of 2026-12-02T23:03:45Z). This hourly window resets at 2026-12-02T23:40:00Z; reviews may be slow or delayed until then.

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 2
  • Waived: $0.50 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 51d64fa2-c37f-489a-b661-b3b2df6f91e5
Commits

Reviewing files that changed from the base of the PR and between 4131f51 and 1aab4aa.

Files selected for processing: 2

  • core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
  • core/shader/recompiler/Optimization/src/ResourceTracker.cpp

Limit details: You’ve used all 10 included reviews currently available.

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.

2 participants