docs(debt): measure normalized S# clamp modes 4, 5 and 7 against RDNA2 #22729

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/22729 into main 2026-11-18 06:18:30 +00:00
MichonGoddijn231849 commented 2026-11-18 05:40:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-11-18T05:40:39Z.


What

A debt entry records that a normalized S# with clamp mode 4 (clamp, half border), 5 (mirror once, half border) or 7 (mirror once, border) does not sample like RDNA2.

toVkAddressMode maps mode 4 to VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER and modes 5 and 7 to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE. Vulkan has no half-border or mirror-once-border mode, and these choices give different texels past the edges. #14964 handles modes 4 and 5 for unnormalized samplers in the shader. Its measured rule (point: mode 4 like mode 2; bilinear: clamp the coordinate to the edges and blend half the border) agrees with what I measured here for normalized coordinates, which nothing handles yet.

Only docs/dev/debt/changes/docs-normalized-border-clamp-modes.md is added; no code changes.

Measurement: tools/hw-oracle, hardware against agc_oracle_runner on both GPUs. An 8×1 32_FLOAT texture (texel x = 8 + x) was read by image_sample_lz at 16 normalized x from -2.3 to 2.6, with CLAMP_X 0 to 7, border colour types 0, 1 and 2, and point and bilinear XY filters. The hardware values with opaque black border (border = 0):

x -1.2 -1.0 -0.03 0.0 0.97 1.0 1.03 1.2
mode 4, point 8 8 8 8 15 15 15 15
mode 4, bilinear 4 4 4 4 11.07 7.5 7.5 7.5
mode 5, bilinear 7.5 7.5 8 8 11.07 7.5 7.5 7.5
mode 7, point 0 15 8 8 15 0 0 0
mode 7, bilinear 0 7.5 8 8 11.07 7.5 3.93 0

AnyPS5 on both GPUs gives:

  • mode 4: the border colour wherever the hardware shows the edge texel or the half blend (point: 13 of 16 x differ);
  • modes 5 and 7: the edge texel (15) wherever the hardware blends or reads the border (bilinear: 8 of 16 x differ; mode 7 point: 8).

Modes 0, 1, 2, 3 and 6, and mode 5 with a point filter, match on both GPUs for every x and border type.

Tested

Windows 11 Pro 10.0.26200; NVIDIA GeForce RTX 5080 (driver 610.74) and AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036, driver 32.0.21045.16010), AnyPS5 at main. The fragment passes tools/debt_fold.py --check and tools/check_conventions.py. Not tested on a PS5.

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: none
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 610.74, Windows 11 Pro 10.0.26200; AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036), driver 32.0.21045.16010, Windows 11 Pro 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5370612379 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22729). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-11-18T05:40:39Z. --- ### What A debt entry records that a *normalized* S# with clamp mode 4 (clamp, half border), 5 (mirror once, half border) or 7 (mirror once, border) does not sample like RDNA2. `toVkAddressMode` maps mode 4 to `VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER` and modes 5 and 7 to `VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE`. Vulkan has no half-border or mirror-once-border mode, and these choices give different texels past the edges. #14964 handles modes 4 and 5 for *unnormalized* samplers in the shader. Its measured rule (point: mode 4 like mode 2; bilinear: clamp the coordinate to the edges and blend half the border) agrees with what I measured here for normalized coordinates, which nothing handles yet. Only `docs/dev/debt/changes/docs-normalized-border-clamp-modes.md` is added; no code changes. **Measurement:** `tools/hw-oracle`, hardware against `agc_oracle_runner` on both GPUs. An 8×1 32_FLOAT texture (texel x = 8 + x) was read by `image_sample_lz` at 16 normalized x from -2.3 to 2.6, with CLAMP_X 0 to 7, border colour types 0, 1 and 2, and point and bilinear XY filters. The hardware values with opaque black border (border = 0): | x | -1.2 | -1.0 | -0.03 | 0.0 | 0.97 | 1.0 | 1.03 | 1.2 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | mode 4, point | 8 | 8 | 8 | 8 | 15 | 15 | 15 | 15 | | mode 4, bilinear | 4 | 4 | 4 | 4 | 11.07 | 7.5 | 7.5 | 7.5 | | mode 5, bilinear | 7.5 | 7.5 | 8 | 8 | 11.07 | 7.5 | 7.5 | 7.5 | | mode 7, point | 0 | 15 | 8 | 8 | 15 | 0 | 0 | 0 | | mode 7, bilinear | 0 | 7.5 | 8 | 8 | 11.07 | 7.5 | 3.93 | 0 | AnyPS5 on both GPUs gives: - mode 4: the border colour wherever the hardware shows the edge texel or the half blend (point: 13 of 16 x differ); - modes 5 and 7: the edge texel (15) wherever the hardware blends or reads the border (bilinear: 8 of 16 x differ; mode 7 point: 8). Modes 0, 1, 2, 3 and 6, and mode 5 with a point filter, match on both GPUs for every x and border type. ### Tested Windows 11 Pro 10.0.26200; NVIDIA GeForce RTX 5080 (driver 610.74) and AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036, driver 32.0.21045.16010), AnyPS5 at `main`. The fragment passes `tools/debt_fold.py --check` and `tools/check_conventions.py`. Not tested on a PS5. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 5080, driver 610.74, Windows 11 Pro 10.0.26200; AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036), driver 32.0.21045.16010, Windows 11 Pro 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!22729
No description provided.