fix(shader): decode image_sample_cd as a derivative sample #395

Closed
MichonGoddijn231849 wants to merge 1 commit from upstream-pr/395 into main
MichonGoddijn231849 commented 2026-10-02 17:53:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-02T17:53:23Z.


What

The image decoder refused image_sample_cd with "unsupported image coarse derivative (_cd) address layout", although the opcode table already describes it as a derivative sample.

  • image_sample_cd passes its derivatives in the image_sample_d address layout. Only the hardware LOD selection differs: one LOD per quad instead of one per pixel.
  • It now samples with the given gradients for each lane, as image_sample_d does. The result is the same whenever the lanes of a quad pass equal derivatives, which is what coarse derivatives normally are.

GTA V uses image_sample_cd in G-buffer shaders of the Prologue. Their draws were skipped.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • GTA V (PPSA04264), with #373–#377, #394 and the other fixes still in progress: the _cd refusals are gone from the Prologue's skip report and those draws render.
  • Other titles were not re-run. The change only affects shaders that use image_sample_cd, which were refused before.
  • ctest: all tests pass.

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
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4719651766 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/395). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-02T17:53:23Z. --- ### What The image decoder refused `image_sample_cd` with "unsupported image coarse derivative (_cd) address layout", although the opcode table already describes it as a derivative sample. - `image_sample_cd` passes its derivatives in the `image_sample_d` address layout. Only the hardware LOD selection differs: one LOD per quad instead of one per pixel. - It now samples with the given gradients for each lane, as `image_sample_d` does. The result is the same whenever the lanes of a quad pass equal derivatives, which is what coarse derivatives normally are. GTA V uses `image_sample_cd` in G-buffer shaders of the Prologue. Their draws were skipped. ### Tested Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0. - GTA V (PPSA04264), with #373–#377, #394 and the other fixes still in progress: the `_cd` refusals are gone from the Prologue's skip report and those draws render. - Other titles were not re-run. The change only affects shaders that use `image_sample_cd`, which were refused before. - `ctest`: all tests pass. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MichonGoddijn231849 commented 2026-10-05 15:17:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-05T15:17:10Z.


Closing in favour of #475 (adriadam10, merged), which implements image_sample_cd and its variants. It's also more exact than this PR: it reads each quad's gradients from its first active lane, as the hardware does, where this one sampled every lane with its own gradients.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5997406513 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/395#issuecomment-5997406513). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-05T15:17:10Z. --- Closing in favour of #475 (adriadam10, merged), which implements `image_sample_cd` and its variants. It's also more exact than this PR: it reads each quad's gradients from its first active lane, as the hardware does, where this one sampled every lane with its own gradients.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!395
No description provided.