Skip to content

feat(agc): accept samplers that force sRGB decoding of sRGB textures - #1487

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
Celegans12:feat/agc-forced-degamma-srgb
Oct 10, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
Celegans12:feat/agc-forced-degamma-srgb

Conversation

@Celegans12

@Celegans12 Celegans12 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

A sampler with FORCE_DEGAMMA (S# word 0 bit 20) throws guest sampler descriptor forces sRGB decoding which is not implemented at decode. This is the direct-sampler part of the earlier version, now on main without #757; the image table check follows once #757 lands.

  • DecodeSamplerResource records the bit as forceDegamma (host sampler unchanged) and accepts it only for callers that pair the sampler with its images (forceDegammaPaired, also on SamplerCache::Get).
  • The direct sampler binding pairs: RequireDegammaFormat lets only sRGB textures (8, 8_8, 8_8_8_8, BC1/2/3/7 SRGB; IsSrgbTextureFormat) through such a sampler, sampled as before, so decoded once.
  • Hardware: on RDNA2 (gfx1035), 8_SRGB, 8_8_SRGB and 8_8_8_8_SRGB sample bit for bit the same with and without FORCE_DEGAMMA, point and bilinear. Forcing UNORM 8, 8_8 and 8_8_8_8 decodes per texel before filtering, contrary to the older GPCS4/fpPS4 notes; this PR still throws for those formats. BC sRGB formats remain unmeasured (measurement).
  • Still throws: other textures through such a sampler, unpaired decodes and cache lookups.
  • PPSA26344 v1.008: compute shader 0x80003fca00 samples a 64x1 or 1024x1 BC1_SRGB T# (format 170) through a bilinear forcing S#; 202 dispatches were skipped in one run.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main f145139: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 489/489 tests pass (ctest --output-on-failure)
  • Linux (WSL Ubuntu 24.04, GCC 13.3, Mesa llvmpipe, upstream's job configuration), merged with main f145139: 498/498 pass; the sampler tests also pass on Windows lavapipe (Mesa 26.2.4)
  • New agc_driver_image_sample_force_degamma: a forcing S# samples 8_8_8_8_SRGB bit for bit as a plain one (point, bilinear); UNORM throws. It fails on main (guest sampler descriptor forces sRGB decoding which is not implemented).
  • agc_driver_graphics: decode, unpaired refusal on a cache miss and hit, IsSrgbTextureFormat.
  • PPSA26344 v1.008, with the version stacked on feat(agc): implement image and sampler tables indexed at runtime offsets #757 before perf(agc): baseline shader recompilation on registration #639: the "forces sRGB decoding" skips of 0x80003fca00 were gone. Not run again.
  • Not tested: PPSA21564, Dreaming Sarah, console behaviour.

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

@EdouardSence

Copy link
Copy Markdown
Contributor

Tested on AMD under Linux, since this PR wasn't: RX 9070 XT (RDNA4, GFX1201), RADV / Mesa 26.2.4, Linux 7.2.9 (CachyOS), GCC Release build.

AI-assisted: the runs and this write-up were done by Claude (Claude Code) on my machine.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@Celegans12
Celegans12 force-pushed the feat/agc-forced-degamma-srgb branch from dc182f2 to f6c5d4e Compare October 8, 2026 14:52
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@Celegans12
Celegans12 force-pushed the feat/agc-forced-degamma-srgb branch from f6c5d4e to e7d313b Compare October 9, 2026 02:10
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
Celegans12 and others added 2 commits October 10, 2026 01:38
A sampler with FORCE_DEGAMMA (S# word 0 bit 20) threw at decode, so
every dispatch or draw sampling through one was skipped.

DecodeSamplerResource now records the bit, but accepts it only for a
caller that pairs the sampler with its images. The direct sampler
binding does, and RequireDegammaFormat checks each sampled image
against its paired samplers: only already sRGB formats (8, 8_8 and
8_8_8_8 SRGB, BC1, BC2, BC3 and BC7 SRGB) pass, decoded once, as
shadPS4 (PS4) models it. Other textures and unpaired decodes still
throw; gfx10 behaviour is not measured.
Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto current main (only a TechnicalDebt adjacency conflict) and added one commit that updates the FORCE_DEGAMMA TechnicalDebt line with a hardware measurement.

  • Measured on RDNA2 (gfx1035) with image_sample_lz: 8_SRGB, 8_8_SRGB and 8_8_8_8_SRGB sample bit for bit the same with and without FORCE_DEGAMMA, point and bilinear, so passing them through unchanged is exact there.
  • For the follow-up: on the same hardware, UNORM 8, 8_8 and 8_8_8_8 through a forcing S# sample bit for bit as the matching sRGB format, i.e. decoded per texel before filtering, not after as the GPCS4/fpPS4 notes say. This PR still throws for them, which is right; the TechnicalDebt line now says so.
  • BC sRGB formats were not measured.
  • Checked: the libSceAgcDriver build and ctest pass after the rebase; the new execution test fails without the change; shadPS4#3420 skips sRGB images as described.

Merging once CI is green.

@adriadam10
adriadam10 force-pushed the feat/agc-forced-degamma-srgb branch from e7d313b to ec2df26 Compare October 9, 2026 23:52
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1415 core/libs/prx/libSceAgcDriver/Graphics/include/GuestSamplerResource.hpp L32
#1733 core/libs/prx/libSceAgcDriver/Graphics/include/Sampler.hpp L62
core/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cpp L94

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@adriadam10
adriadam10 merged commit ba6f1e5 into boykopovar:main Oct 10, 2026
9 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…gamma-srgb

feat(agc): accept samplers that force sRGB decoding of sRGB textures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants