feat(agc): accept texture BC swizzles that leave the sampled border unchanged #1733

Merged
TheAggie merged 1 commit from upstream-pr/1733 into main 2026-10-10 07:23:14 +00:00
TheAggie commented 2026-10-08 17:51:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T17:51:37Z.


What

DecodeTextureResource rejected any nonzero BC_SWIZZLE (T# word 3, bits 27:25). The field only reorders the border color, so the border lands in the right channels after DST_SEL. Mesa sets it from the format's channel order on every image descriptor (ac_border_color_swizzle in src/amd/common/ac_formats.c, used by RADV and radeonsi). So every texture whose format is not stored as XYZW was dropped, for example ccleste's (PPSA59322) under RADV.

Mesa's own comment there gives the rule: "For the pre-defined border color values (white, opaque black, transparent black), the only thing that matters is that the alpha channel winds up in the correct place."

  • BC_SWIZZLE values 0-5 decode into GuestTextureResource::bcSwizzle (enum SQ_IMG_RSRC_WORD3__BC_SWIZZLE in gfx10-rsrc.json). The reserved values 6 and 7 still throw.
  • RequireBorderSwizzle runs next to RequireFilterMinmax, for each sampled image and its paired samplers.
    • It throws only when the swizzle moves W (XWYZ, WZYX, WXYZ, YXWZ) and a paired sampler clamps to an opaque black border.
    • Transparent black and opaque white are the same under any channel order, as is any sampler that never reads its border. Border color tables already throw in DecodeSamplerResource.
    • With XYZW or ZYXW the sampled values are exactly those of the unswizzled case.
  • Tests:
    • agc_driver_graphics (GuestTextureResource): values 0-5 decode and keep their value; 6 and 7 are rejected.
    • agc_driver_graphics (GuestSamplerResource): ReadsOpaqueBlackBorder is true only for clamp-to-border with opaque black. Every swizzle passes with transparent black, opaque white, or no border addressing. The four alpha-moving swizzles throw with opaque black, and XYZW/ZYXW pass. An unbound sampler element throws.

Tested

Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti.

  • The full suite (458 tests) passes on this branch. It was run from the generated CTestTestfile.cmake commands because antivirus blocks ctest.exe on this machine.
  • ccleste's texture draws no longer stop at the BC swizzle check. Like #1732, this was tested on a local branch together with the other changes ccleste needs.

Not tested on AMD, Intel or Linux.

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 (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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4790744310 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1733). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-08T17:51:37Z. --- ### What `DecodeTextureResource` rejected any nonzero `BC_SWIZZLE` (T# word 3, bits 27:25). The field only reorders the border color, so the border lands in the right channels after `DST_SEL`. Mesa sets it from the format's channel order on every image descriptor (`ac_border_color_swizzle` in `src/amd/common/ac_formats.c`, used by RADV and radeonsi). So every texture whose format is not stored as XYZW was dropped, for example ccleste's (PPSA59322) under RADV. Mesa's own comment there gives the rule: "For the pre-defined border color values (white, opaque black, transparent black), the only thing that matters is that the alpha channel winds up in the correct place." - `BC_SWIZZLE` values 0-5 decode into `GuestTextureResource::bcSwizzle` (enum `SQ_IMG_RSRC_WORD3__BC_SWIZZLE` in `gfx10-rsrc.json`). The reserved values 6 and 7 still throw. - `RequireBorderSwizzle` runs next to `RequireFilterMinmax`, for each sampled image and its paired samplers. - It throws only when the swizzle moves W (`XWYZ`, `WZYX`, `WXYZ`, `YXWZ`) and a paired sampler clamps to an opaque black border. - Transparent black and opaque white are the same under any channel order, as is any sampler that never reads its border. Border color tables already throw in `DecodeSamplerResource`. - With `XYZW` or `ZYXW` the sampled values are exactly those of the unswizzled case. - Tests: - `agc_driver_graphics` (`GuestTextureResource`): values 0-5 decode and keep their value; 6 and 7 are rejected. - `agc_driver_graphics` (`GuestSamplerResource`): `ReadsOpaqueBlackBorder` is true only for clamp-to-border with opaque black. Every swizzle passes with transparent black, opaque white, or no border addressing. The four alpha-moving swizzles throw with opaque black, and `XYZW`/`ZYXW` pass. An unbound sampler element throws. ### Tested Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti. - The full suite (458 tests) passes on this branch. It was run from the generated `CTestTestfile.cmake` commands because antivirus blocks `ctest.exe` on this machine. - ccleste's texture draws no longer stop at the BC swizzle check. Like #1732, this was tested on a local branch together with the other changes ccleste needs. Not tested on AMD, Intel or Linux. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
johnmaia commented 2026-10-08 18:59:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-08T18:59:12Z.


Linux run, since the description lists AMD and Linux as not tested: Ubuntu 24.04.5 (kernel 6.8), GCC 13.3, Release, AMD Radeon RX 7600 (RADV NAVI33, Mesa 25.2.8). This PR's head 933bfe1d, merged onto main 6b56175a.

Full ctest: 479/479 pass, with the GPU tests running on the RX 7600 (none skipped). That includes agc_driver_graphics with the new GuestTextureResource and GuestSamplerResource cases.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6066957038 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1733#issuecomment-6066957038). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-08T18:59:12Z. --- Linux run, since the description lists AMD and Linux as not tested: Ubuntu 24.04.5 (kernel 6.8), GCC 13.3, Release, AMD Radeon RX 7600 (RADV NAVI33, Mesa 25.2.8). This PR's head `933bfe1d`, merged onto main `6b56175a`. Full ctest: 479/479 pass, with the GPU tests running on the RX 7600 (none skipped). That includes `agc_driver_graphics` with the new `GuestTextureResource` and `GuestSamplerResource` cases.
oneandonlydean commented 2026-10-10 03:18:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T03:18:51Z.


This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093231628 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1733#issuecomment-6093231628). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T03:18:51Z. --- This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready.
adriadam10 commented 2026-10-10 07:23:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:23:10Z.


Rebased head checked on top of current main: builds, ctest green (incl. agc_driver_graphics), no conflicts. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095082805 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1733#issuecomment-6095082805). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T07:23:10Z. --- Rebased head checked on top of current main: builds, ctest green (incl. `agc_driver_graphics`), no conflicts. Merging.
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!1733
No description provided.