AGC: hardware behaviour of anisotropic filtering with unnormalized S# coordinates (measured) #27644

Open
opened 2026-11-26 21:12:48 +00:00 by JJenkx · 0 comments
JJenkx commented 2026-11-26 21:12:48 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-26T21:12:48Z.


GuestSamplerResource.cpp refuses an S# with FORCE_UNNORMALIZED and an anisotropic XY filter ("guest sampler descriptor uses unnormalized coordinates with anisotropic filtering, which is not implemented"). In my runs it stops PPSA02630 (Destruction AllStars), PPSA22102 and PPSA05213. Vulkan forbids anisotropy with unnormalizedCoordinates, so a fix has to reproduce the hardware behaviour. Here is a measurement of that behaviour, so nobody maps it to plain linear filtering.

Probe: tools/hw-oracle on an RX 6650 XT (gfx1032, Linux, HSA), main 97319cf0b9.

  • Image: an 8-dword T# for a 4×1 32_FLOAT image with texels 0, 10, 20, 30 and identity selects. It's one row high, so pitch doesn't matter.
  • Sampler: an S# with FORCE_UNNORMALIZED, clamp to last texel, max aniso ratio 4×, MIN = MAG filter.
  • Instruction: image_sample with dmask 0xf at y = 0.5 and these unnormalized x values in six lanes: 0.5, 1.0, 1.5, 2.0, 2.25, 3.5. Implicit derivatives come from the quads: x steps of 0.5 in the first quad, then 1.25.
XY filter x = 0.5 1.0 1.5 2.0 2.25 3.5
point (0) 0 10 10 20 20 30
linear (1) 0 5 10 15 17.5 30
aniso point (2) 0 5 10 15 17.5 27.5
aniso linear (3) 0.625 5 10 15 17.5 26.77

All four components were equal in every case.

What this shows: the hardware does not ignore the anisotropic filter with unnormalized coordinates. Aniso point already behaves like linear inside the image. Near the clamped edges both aniso modes differ from linear: 0.625 instead of 0 at x = 0.5, and 27.5 / 26.77 instead of 30 at x = 3.5. That fits a multi-tap footprint driven by the derivatives. Treating these samplers as linear would therefore be wrong at edges and wherever derivatives are large. A correct implementation needs the anisotropic taps emulated in the shader, so the refusal is right until that exists.

Not measured: other ratios, filter combinations with a mip filter, 2D footprints, and wave64.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6635168054 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/27644). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-26T21:12:48Z. --- `GuestSamplerResource.cpp` refuses an S# with `FORCE_UNNORMALIZED` and an anisotropic XY filter ("guest sampler descriptor uses unnormalized coordinates with anisotropic filtering, which is not implemented"). In my runs it stops PPSA02630 (Destruction AllStars), PPSA22102 and PPSA05213. Vulkan forbids anisotropy with `unnormalizedCoordinates`, so a fix has to reproduce the hardware behaviour. Here is a measurement of that behaviour, so nobody maps it to plain linear filtering. **Probe:** `tools/hw-oracle` on an RX 6650 XT (gfx1032, Linux, HSA), main `97319cf0b9`. - **Image:** an 8-dword T# for a 4×1 `32_FLOAT` image with texels 0, 10, 20, 30 and identity selects. It's one row high, so pitch doesn't matter. - **Sampler:** an S# with `FORCE_UNNORMALIZED`, clamp to last texel, max aniso ratio 4×, MIN = MAG filter. - **Instruction:** `image_sample` with dmask 0xf at y = 0.5 and these unnormalized x values in six lanes: 0.5, 1.0, 1.5, 2.0, 2.25, 3.5. Implicit derivatives come from the quads: x steps of 0.5 in the first quad, then 1.25. | XY filter | x = 0.5 | 1.0 | 1.5 | 2.0 | 2.25 | 3.5 | | --- | --- | --- | --- | --- | --- | --- | | point (0) | 0 | 10 | 10 | 20 | 20 | 30 | | linear (1) | 0 | 5 | 10 | 15 | 17.5 | 30 | | aniso point (2) | 0 | 5 | 10 | 15 | 17.5 | **27.5** | | aniso linear (3) | **0.625** | 5 | 10 | 15 | 17.5 | **26.77** | All four components were equal in every case. **What this shows:** the hardware does not ignore the anisotropic filter with unnormalized coordinates. Aniso point already behaves like linear inside the image. Near the clamped edges both aniso modes differ from linear: 0.625 instead of 0 at x = 0.5, and 27.5 / 26.77 instead of 30 at x = 3.5. That fits a multi-tap footprint driven by the derivatives. Treating these samplers as linear would therefore be wrong at edges and wherever derivatives are large. A correct implementation needs the anisotropic taps emulated in the shader, so the refusal is right until that exists. **Not measured:** other ratios, filter combinations with a mip filter, 2D footprints, and wave64. AI-assisted: yes
Sign in to join this conversation.
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#27644
No description provided.