feat(agc): accept texel offsets, LOD biases and LOD clamps in color comparison sampling #934

Merged
CnRJay merged 1 commit from upstream-pr/934 into main 2026-10-07 09:41:51 +00:00
CnRJay commented 2026-10-06 18:47:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-06T18:47:01Z.


What

Comparison sampling of a color texture threw on the _o, _b and _cl forms and on a sampler LOD bias.

  • Offsets: the emulation fetches the texels itself, so the 6-bit offsets from the address are added to the point or bilinear texel indices, as on the hardware and in Vulkan.
  • LOD bias and clamp: the emulation runs only at level zero or on a single-level view, where a bias or clamp cannot select another level. They are therefore accepted and have no effect. The TechnicalDebt entry is updated to match.

#907 also edits the color compare emulation, but it is a review follow-up to #668 and doesn't add these forms.

Tested

Windows 11, MinGW GCC Release build, ctest agc_driver_emulated_color_compare passes (on the GPU). The test now also runs with point and bilinear filtering for:

  • a sampler LOD bias alone (point, clamp to edge);
  • a shader with offsets, an LOD bias and an LOD clamp, with point clamp-to-edge, bilinear wrap and bilinear white-border sampling. The x offsets range from -3 to +3 and the y offsets from -2 to +2, and every third thread also sets the unused z bits.

Each result is compared with a CPU reference that applies the same offsets.

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:4763206424 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/934). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-06T18:47:01Z. --- ### What Comparison sampling of a color texture threw on the `_o`, `_b` and `_cl` forms and on a sampler LOD bias. - **Offsets:** the emulation fetches the texels itself, so the 6-bit offsets from the address are added to the point or bilinear texel indices, as on the hardware and in Vulkan. - **LOD bias and clamp:** the emulation runs only at level zero or on a single-level view, where a bias or clamp cannot select another level. They are therefore accepted and have no effect. The TechnicalDebt entry is updated to match. #907 also edits the color compare emulation, but it is a review follow-up to #668 and doesn't add these forms. ### Tested Windows 11, MinGW GCC Release build, ctest `agc_driver_emulated_color_compare` passes (on the GPU). The test now also runs with point and bilinear filtering for: - a sampler LOD bias alone (point, clamp to edge); - a shader with offsets, an LOD bias and an LOD clamp, with point clamp-to-edge, bilinear wrap and bilinear white-border sampling. The x offsets range from -3 to +3 and the y offsets from -2 to +2, and every third thread also sets the unused z bits. Each result is compared with a CPU reference that applies the same offsets. ### 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)
adriadam10 commented 2026-10-07 09:31:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T09:31:41Z.


Measured image_sample_c_b_cl_o on RDNA2 (gfx1035) with a single-level 2D view: 992 rows × point/bilinear × wrap/clamp-to-edge/white and black border, with offsets from -32 to 31 (z bits set on some rows), shader and sampler LOD biases of both signs and an LOD clamp. Adding the offsets to the texel indices and ignoring the bias and clamp matches the hardware on every row. The new cases fail without the change.

I rebased onto main to resolve the conflict with #815: lodBias is now the fifth Sampler field, after reduction. I also dropped the merge commit. Full ctest passes (390/390). Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6035111389 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/934#issuecomment-6035111389). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T09:31:41Z. --- Measured `image_sample_c_b_cl_o` on RDNA2 (gfx1035) with a single-level 2D view: 992 rows × point/bilinear × wrap/clamp-to-edge/white and black border, with offsets from -32 to 31 (z bits set on some rows), shader and sampler LOD biases of both signs and an LOD clamp. Adding the offsets to the texel indices and ignoring the bias and clamp matches the hardware on every row. The new cases fail without the change. I rebased onto `main` to resolve the conflict with #815: `lodBias` is now the fifth `Sampler` field, after `reduction`. I also dropped the merge commit. Full ctest passes (390/390). Merging once CI is green.
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!934
No description provided.