Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
CnRJay:feat/agc-color-compare-offsets
Oct 7, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
CnRJay:feat/agc-color-compare-offsets

Conversation

@CnRJay

@CnRJay CnRJay commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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

…omparison sampling

Comparison sampling of a color texture threw on the _o, _b and _cl
forms and on a sampler LOD bias. The emulation fetches the texels
itself, so the 6-bit offsets of the address are added to the point or
bilinear texel indices, as on the hardware and in Vulkan. The emulation
runs only at level zero or on a single-level view, where an LOD bias or
clamp cannot select another level, so they are accepted with no effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs needs rebase Conflicts with main, rebase needed shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants