Repository navigation
feat(agc): sample the base level through unnormalized samplers - #1418
Conversation
adriadam10
left a comment
There was a problem hiding this comment.
Thanks, the behaviour matches what we measured on hardware: on single-level views image_sample, _b, _cl, _d and _d_cl through an unnormalized S# return the same bits as image_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).- The unnormalized bit is already read from the sampler descriptor in
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. - Bump
FormatVersionto one abovemainat the time you push (check open PRs for the same bump), and keep the serialization of the newSamplerResourcefield inencodeInfo/decodeInfo. - Rebase and rerun
agc_driver_image_sample_unnormalizedandshader_disk_cacheon the merged tree; the first rebased push will also need fresh Linux CI.
The hardware ignores the LOD for unnormalized coordinates and samples the base level. A sampler used only by explicit-LOD, implicit-LOD, bias and gradient samples gets a pipeline specialization constant set from its unnormalized bit when the binding plan is prepared. When the constant is set, each of its samples is emitted as OpImageSampleExplicitLod with LOD 0, which is what Vulkan requires of unnormalized samplers. Otherwise the sample keeps its own form. Such shaders are no longer refused.
3d68c36 to
63ed0ff
Compare
|
@adriadam10 Thanks. Rebased onto The unnormalized bit can't reach Because of that, there is no new Multi-level views are left as
@dawid-swiecicki ported the same idea to a specialization constant in #4782. Thanks for confirming it gets PPSA01317 past this point. |
|
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 ( Tested and written by Claude (AI assistant) on a contributor's machine. |
adriadam10
left a comment
There was a problem hiding this comment.
Checked the rework on top of current main: the per-sampler specialization constant set in DescriptorBindingBuilder::Prepare from ProveUnnormalized and the branch in EmitSampleOp (LOD 0 when set, own form otherwise) follow the texel-offset path, and no new serialized field is needed, so leaving FormatVersion is right. Hardware: on single-level views image_sample, _b, _cl, _d and _d_cl through an unnormalized S# match image_sample_lz bit for bit. agc_shader_memory, agc_shader_disk_cache, agc_driver_image_sample_unnormalized and the other image_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.
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)