fix(agc): accept the sampler ANISO_OVERRIDE bit #1415
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1415"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T03:12:46Z.
What
A guest sampler with
ANISO_OVERRIDE(S# word 2, bit 29) was rejected (guest sampler descriptor uses an anisotropy override which is not implemented). Mesa sets this bit on every GFX10+ sampler unless itsaniso_single_leveloption is on:ac_descriptors.cusesS_008F38_ANISO_OVERRIDE_GFX10(!state->aniso_single_level). With the bit, the texture unit turns anisotropic filtering off when the sampled view has a single mip level (BASE_LEVEL == LAST_LEVEL). The RADV comment inradv_nir_lower_descriptors.cdescribes it as the TA-side replacement for the shader workaround GFX6–7 needed.DecodeSamplerResourceaccepts the bit.ShaderResourcesrecords, for each sampler of a draw, whether the images paired with it (DescriptorBinding::imageSamplers) are single-level or mipmapped (Texture::SampledViewRange().levels).SingleLevelSamplerWords).... paired with both single-level and mipmapped images in one draw, which is not implemented).GuestSamplerResourcetest:SingleLevelSamplerWordskeeps samplers of mipmapped images, samplers without the bit and samplers without anisotropy unchanged. For a single-level image it gives a non-anisotropic sampler with the same filters and other words, and it throws for the mixed case.Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti.
agc_*tests pass. They were run from the generatedCTestTestfile.cmakecommands, because antivirus blocksctest.exeon this machine.Not tested on AMD, Intel or Linux.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T03:25:13Z.
Showcase before/after on the combined local branch: without this change the instanced scene's draws are skipped; with it (together with #1414) the scene renders.


Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T05:12:58Z.
Ignoring the bit makes single-level views filter anisotropically where the hardware turns anisotropy off, so this isn't exact yet (
GuestSamplerResource.cpp:115). Each sampled image's sampler is already known when the binding is resolved (binding.imageSamplers[element],ShaderResources.cpp:2550-2571). Please either bind a sampler without anisotropy there for single-level views when the bit is set, or accept the bit only when the sampler has no anisotropy and keep the throw otherwise.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T14:29:52Z.
Thanks, done: the first option, decided per draw. Rebased on current
main(which also drops the TechnicalDebt entry).The bound sampler is shared by every image the shader pairs with it, so the choice is made per sampler in
ShaderResourcesonce the draw's images are resolved:The variant comes from the sampler cache keyed by the rewritten S#, so it's created once.
The Showcase's instanced scene (anisotropic samplers with the bit) renders with no skipped draw and never takes the mixed case.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:24:03Z.
Review: CHANGES_REQUESTED
Measured on the HW oracle (
image_sample_dwith anisotropic gradients, S# in SGPRs): with ANISO_OVERRIDE and BASE_LEVEL == LAST_LEVEL the result is bit-identical to the non-anisotropic filter (aniso-point → point, aniso-linear → linear; Z/mip filter and mixed mag/min don't matter), and mipmapped views are unaffected. SoSingleLevelSamplerWordsmatches the hardware. One gap and two smaller points:ShaderResources.cpp:2905: the hardware decides on the T#'s raw BASE_LEVEL == LAST_LEVEL, butSampledViewRange().levelscomes from the view afterLAST_LEVELis clamped toMAX_MIP(GuestTextureResource.cpp:142). Measured: BASE=0, LAST=3, MAX_MIP=0 and BASE=1, LAST=2 or 3, MAX_MIP=1 keep anisotropic filtering with the override set (same values as without it, different from point/bilinear), while this PR seeslevels == 1and turns it off. Deciding from the T# fields (e.g. keep the unclamped last level inGuestTextureResource, or compare word 3's BASE_LEVEL/LAST_LEVEL directly) would make it exact.GuestSamplerResourceonly coversSingleLevelSamplerWords. The per-draw part (samplerSourcesindexing, the reset inbuildComplete,applyAnisoOverrideswapping the sampler, the mixed-case throw) has no test. A draw-level test next toagc_driver_image_sample_shared_samplerwith one override sampler paired with a single-level image, a mipmapped image, and both, plus a T# with LAST_LEVEL > MAX_MIP, would cover it.applyAnisoOverridecallsstd::getenv("APS5_NO_SAMPLER_CACHE")for every sampler on every draw;addImageBindingalready caches it in astatic, so reuse that.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T03:18:38Z.
This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready.
Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T06:34:22Z.
@adriadam10 thanks for measuring this on the hardware oracle. All three points are addressed in 824ec269:
LAST_LEVEL vs MAX_MIP: the single-level decision now reads BASE_LEVEL and LAST_LEVEL from the T#'s word 3 (
DescriptorSingleLevel) instead of the view's level count, which is taken after LAST_LEVEL is clamped to MAX_MIP. Your BASE=0, LAST=3, MAX_MIP=0 case now counts as mipmapped, so anisotropic filtering stays on.Draw-level test: new
agc_driver_image_sample_aniso_override, next toagc_driver_image_sample_shared_samplerand using its two-texture program. One ANISO_OVERRIDE sampler is shared by two images in one dispatch:Each case that runs also checks its samples. With the old view-based check, the LAST_LEVEL > MAX_MIP + mipmapped case is refused, so the test catches the gap you described. The test checks the pairing rules, not filtered values: the program samples at LOD 0 without gradients, where anisotropic and plain filtering agree.
Nit:
applyAnisoOverridenow uses the same cachedAPS5_NO_SAMPLER_CACHEflag asaddImageBinding.The branch was rebased onto
main001124896first, as @oneandonlydean asked. On Windows 11 (MinGW-w64 GCC 15.2, NVIDIA GeForce RTX 5070 Ti), 227 of 228 related tests pass (agc_driver,image_sample,guest_sampler, texture). The one failure,agc_driver_prepared_shaders_debug_failure, also fails on cleanmainon this machine.tools/check_conventions.pypasses.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T08:06:17Z.
Conflicts with main again in
ShaderResources.cppafter #1607 and #1733; please rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:59:37Z.
Review: APPROVED
Rebased onto current
mainas requested (conflict inShaderResources.cppnext toRequireBorderSwizzle; both blocks kept, no logic change). Build and the libSceAgcDriver tests pass, includingguest_sampler_resourceandagc_driver_image_sample_aniso_override; merging on green CI.