feat(agc): sample the base level through unnormalized samplers #1418
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1418"
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 gjonn on 2026-10-08T03:23:17Z.
What
An unnormalized sampler is refused when it is used by an implicit-LOD sample (in a pixel shader), a bias sample or a gradient sample. PPSA01317 stops there on current
main(#4782):The hardware ignores the LOD for unnormalized coordinates and samples the base level. On single-level views,
image_sample,_b,_cl,_dand_d_clthrough an unnormalized S# return the same bits asimage_sample_lz. Vulkan requires such samples to be explicit with LOD 0.SamplesBaseLevelIfUnnormalizedmarks a sampler used only by explicit-LOD, implicit-LOD, bias and gradient samples, with no offsets, comparison or gathers.DescriptorBindingBuilder::Preparesets a pipeline specialization constant for each such sampler (UnnormalizedBaseLevelBase + sampler) from the unnormalized bitProveUnnormalizedalready reads.ProveUnnormalizedaccepts these samplers.EmitSampleOpbranches on that constant. When it is set, the sample isOpImageSampleExplicitLodwith LOD 0, and derivatives, bias, LOD and LOD clamp are dropped. When it is clear, the sample keeps its own form. Specialization removes the other branch.image_get_lodthrough unnormalized samplers are still refused. The driver still accepts these samples only on single-level views.Tested
agc_driver_image_sample_unnormalized:image_sample_dwith derivatives of 4.0 samples the base level through each of the five samplers. A 4-level view read byimage_sample_dis still refused.agc_shader_memory: an unnormalized pixelimage_samplehas no implicit-LOD sample, and a normalized one keeps it. An unnormalizedimage_sample_ddrops its derivatives, and a normalized one keeps them in its own specialization of the same artifact.mainwith the refusal above.agc_shader_disk_cacheand the other 47agc_driver_image*,agc_driver_sampler*,agc_shader_*,agc_spirv_moduleandagc_driver_graphicstests pass.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 adriadam10 on 2026-10-11T08:22:02Z.
Review: CHANGES_REQUESTED
Thanks, the behaviour matches what we measured on hardware: on single-level views
image_sample,_b,_cl,_dand_d_clthrough an unnormalized S# return the same bits asimage_sample_lz.The PR no longer applies to
main, and the conflict is not mechanical:ResourceSpecialization(ResourceMaterializer.hpp) was removed when shader compilation moved to registration (#639), sounnormalizedSamplers, itsoperator==and theBuildKeyline have nowhere to go.ShaderDiskCache::FormatVersionis 25 onmain(the PR bumps 7 → 8).DescriptorBindingBuilder.cpp(ProveUnnormalized,samplerUnnormalizedin the physical binding). Please carry it toSamplerResource::unnormalized/EmitSampleOpfrom there instead of adding a second per-S# field to the specialization, and relax theunsupportedmask inProveUnnormalizedas you do now.FormatVersionto one abovemainat the time you push (check open PRs for the same bump), and keep the serialization of the newSamplerResourcefield inencodeInfo/decodeInfo.agc_driver_image_sample_unnormalizedandshader_disk_cacheon the merged tree; the first rebased push will also need fresh Linux CI.Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-13T02:59:47Z.
@adriadam10 Thanks. Rebased onto
main(c13dc7e6b) and reworked.The unnormalized bit can't reach
EmitSampleOpas aSamplerResourcefield onmain. The module is compiled at registration, before any S# is bound, and the bit is only known whenDescriptorBindingBuilder::Preparesees the snapshot. So this follows the texel-offset path from #822.Preparesets a per-sampler specialization constant from theProveUnnormalizedresult, andEmitSampleOpbranches on it: LOD 0 when it is set, the sample's own form when it is clear. The constant is always supplied (0 or 1), so every normalized draw of a shader shares one specialized module, and that is the module registration warms. Theunsupportedmask inProveUnnormalizedis relaxed for these samplers.Because of that, there is no new
SamplerResourcefield and nothing new is serialized, so I leftFormatVersionat 28. The cache key already includes the source version. I can bump it if you want one anyway.Multi-level views are left as
ac1c3b775set them: the driver still accepts these samples only on single-level views, which is what you measured. The execution test checks that a 4-level view read byimage_sample_dis still refused.agc_driver_image_sample_unnormalized,agc_shader_memoryandagc_shader_disk_cachepass on the merged tree, as do the other 47 image, sampler and shader tests. The first two fail onmain. This push will need fresh Linux CI.@dawid-swiecicki ported the same idea to a specialization constant in #4782. Thanks for confirming it gets PPSA01317 past this point.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-13T05:33:27Z.
Another data point: High on Life (PPSA15388) stops on this error when loading a later save (the home base):
With this PR cherry-picked onto my stack (
main3377986aplus #1077, #425 and #3202), it gets past that stop and reaches gameplay. #4487 is also needed for that. Theagc_suite has no new failures (Linux, RTX 4090). The next sampler stops in that area are listed on #4736.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:25:05Z.
Review: APPROVED
Checked the rework on top of current
main: the per-sampler specialization constant set inDescriptorBindingBuilder::PreparefromProveUnnormalizedand the branch inEmitSampleOp(LOD 0 when set, own form otherwise) follow the texel-offset path, and no new serialized field is needed, so leavingFormatVersionis right. Hardware: on single-level viewsimage_sample,_b,_cl,_dand_d_clthrough an unnormalized S# matchimage_sample_lzbit for bit.agc_shader_memory,agc_shader_disk_cache,agc_driver_image_sample_unnormalizedand the otherimage_sample_*/sampler tests pass on the merged tree; confirmed by @Tamalero on an RTX 4090 (High on Life reaches gameplay). Merging once the full Build is green.