feat(agc): implement min and max sampler reduction modes #815
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/815"
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 Celegans12 on 2026-10-06T06:21:31Z.
What
An S# with
FILTER_MODE(word0 bits 29-30) set throws inDecodeSamplerResource.SQ_IMG_FILTER_TYPE, PALTexFilterMode); min and max chainVkSamplerReductionModeCreateInfoEXT(VK_EXT_sampler_filter_minmax, bothfilterMinmax*properties). Vulkan and D3D11.3 (5.9.4.5.6) reduce the texels of non-zero weight.DescriptorBinding::imageSamplers(disk cache format 5) carries the image-sampler pairs: only a texture sampled through a linear min/max S# needsSAMPLED_IMAGE_FILTER_MINMAX, else it throws.PointFilteredSamplerWordso #757's table point copy is covered once both land. TechnicalDebt gets two lines.20000092 00fff000 05500000 00000000(bilinear, point mip); the last alsoimage_loads two 8_8 SRGB textures.forcePointFilteringblock, #639 that block's condition. #757-#759, #799 and #822 addDescriptorBindingfields; they and #639 bump the disk cache format. #293, #426 and #805 editresolveImageBinding; #285buildPrepare.Tested
main5895ea72: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)VK_DRIVER_FILES): 357/357 pass;agc_driver_flat_storeis left out there because it takes several minutes on Windows llvmpipeagc_driver_image_sample_reduction: exact R32F min/max (bilinear or point, point or no mip), unreducedimage_gather4_lz, animage_loaded 8_8_8_8 texture beside a min-sampled one; min/max throws on 32_SINT, and on 8_8_8_8 on lavapipe (NVIDIA filters it).agc_driver_graphics(PointFilteredSamplerWordthrows for the min S# and a linear-mip max S#),agc_shader_disk_cacheandagc_driver_emulated_color_compare; these and the new test fail or do not build onmain.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)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T09:27:45Z.
Thanks, the mapping looks right to me: FILTER_MODE 1/2 go to
VK_SAMPLER_REDUCTION_MODE_MIN/MAX, 3 throws, and since the bits are in word 0 the sampler cache key already separates the modes. Compare samplers are refused, which Vulkan requires anyway (VUID-VkSamplerCreateInfo-compareEnable-01423). The format check is only applied with a linear filter, which matches when Vulkan requiresSAMPLED_IMAGE_FILTER_MINMAX_BIT.One thing for whichever of this and #757 lands second. Both change the
forcePointFilteringblock inDescriptorBindingBuilder::Populate, so they conflict there. #757 also adds a second place that point-filters a sampler: the point copy in theSamplerTablecase (copy == 1u && entry.point, throughPointFilteredSamplerWord). The min/max check in this PR only covers the direct path. After both are merged, a min/max sampler in a table with bilinear filtering, used on an image that needs point sampling, would quietly become a point sample instead of throwing. Moving the check into a helper that both paths call (or intoPointFilteredSamplerWorditself, with access to word 0) would cover both.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-06T10:57:20Z.
Thanks, good catch. The min/max check now lives in
PointFilteredSamplerWord(word0, filter), which this PR adds: it reads S# words 0 and 2, throws for a min or max S# that filters between texels or mips, and otherwise returns the point-filtered word 2. TheforcePointFilteringblock only calls it, so every caller gets the check, not just the direct path.For #757: whichever of the two lands second, I'll rebase it so that #757's one-word helper goes away and the table point copy (
copy == 1u && entry.point) callsPointFilteredSamplerWord(physical.guestDescriptor[first], physical.guestDescriptor[first + 2u]). Then a min/max sampler in a table with bilinear filtering, used on an image that needs point sampling, throws there too. This PR still has no dependency on #757.New rows in
agc_driver_graphicscallPointFilteredSamplerWorddirectly and require the throw for the bilinear min S#20000092 00fff000 05500000 00000000and for a max S# with a linear mip filter. With the check removed from the helper, that test fails. Updated: still one commit, rebased ontomain5895ea72.One more change since your review. The min/max format check was object-wide, and on PPSA26344 it rejected two
image_load-only 8_8 SRGB textures in 0x8000265d00 that are never sampled. It now applies only to textures actually sampled through a linear min/max S#.DescriptorBinding::imageSamplerscarries each sampled-image element's sampler pairs (disk cache format 5), andRequireFilterMinmaxchecks only those pairs.agc_driver_image_sample_reductioncovers animage_loaded RGBA8 texture next to a min-sampled R32F one. With this, 0x80003af600, 0x8000253100 and 0x8000265d00 dispatch in the title. CI: Windows ctest 358/358; lavapipe 357/357.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T07:23:19Z.
Measured on RDNA2 (gfx1035) with the HW oracle: bilinear blend/min/max, point min/max and
image_gather4_lzthrough min/max S#s over 24 coordinates (generic, exact texel centres and edges, 1/512 to 1/4096 texel from a centre, clamped). Point stays point and gathers return the four texels unreduced, as the PR does. Min/max reduce only the texels of non-zero weight, Vulkan's rule, after the weight is rounded to the 8-bit subtexel grid (a sample within 1/512 texel of a centre reduces that texel alone, the same rounding blend shows). RADV programs the sameSQ_IMG_FILTER_MODEvalues for Vulkan's reduction modes (radv_sampler.c), so on AMD this is the hardware filter.What we pushed:
ShaderDiskCache::FormatVersion6 (both PRs had moved it to 5),DescriptorBindingsize assert 408.subTexelPrecisionBitsreduces a different set near texel centres.Full ctest green on RADV, touched tests on CI's lavapipe (new test 0.4 s cold); the new tests don't build without the change. Merging once CI is green.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T07:27:03Z.
Thanks a lot for measuring this on gfx1035 and for doing the rebase. The note about the 8-bit subtexel rounding near texel centres is a good catch, and I hadn't been able to check it without hardware. I'll leave the branch as you pushed it.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T07:35:27Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/tests/execution/EmulatedColorCompare.cppL55core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL538-539docs/dev/TechnicalDebt.mdL224