Repository navigation
feat(agc): fold samples of views whose channels all select constants - #1417
Conversation
adriadam10
left a comment
There was a problem hiding this comment.
Measured on gfx1035 (HW oracle): with all four dst_sel constant, image_sample_lz returns 1.0f/0 for float and unorm formats and integer 1/0 for 32_UINT/32_SINT; image_gather4_lz returns the dst_sel of the dmask component in all four texels; dmask 0x6 packs channels 1 and 2; a 3D T# sampled with a 2D dim and an unnormalized sampler gives the same. That matches what the emitter produces. Build + ctest pass and the new case fails without the change. Three things before it can go in:
DescriptorBindingBuilder.cpp:221: theconstantSwizzleskip runs before theindirectRootcheck, butEmitSamplingOponly folds direct images (SpirvImageEmitter.cpp:1308,access.slot == 0). A bindless table root whose snapshot descriptor has a constant swizzle used to throw "samples an image selected at run time"; now it passes the proof and gets sampled through the table path with an unnormalized sampler, and the other entries of the table don't have to be constant. Skip only direct images (image.constantSwizzle != 0u && image.indirectRoot == ImageResource::NoIndirectImage), so tables keep throwing.- The test only covers float formats with dmask 0xf. The gather branch (
ImageGatherComponent(EffectiveDmask(...))), the uint/sint constants and a partial dmask aren't exercised. Please add cases pinning them, for exampleimage_gather4_lzwith dmask 0x2 and 0x4 ondst_sel(1, 0, 1, 0) (expected all 0 and all 1.0f), a32_UINTor32_SINTview (expected integer1, not0x3f800000), andimage_sample_lzwith dmask 0x6 (expected 0, 1.0f). These are the values measured on hardware above. - Conflicts with
main:ShaderDiskCache.hppis already atFormatVersion = 9, so this needs 10 after rebasing.
|
After #639, PPSA26344 (Ghost of Yōtei) hits the case this PR covers, at runtime image mode selection rather than in A compute program gathers (DIM 2D) through a 1D T# whose four Locally I treat a sampled, non-comparison T# whose This PR's base predates #639 and now conflicts with main in |
Lost track of this one. I'll get it rebased now. |
1dffbf1 to
829944a
Compare
|
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.
|
When every dst_sel of a sampled view selects constant 0 or 1, a sample or gather returns that constant whatever the texel, filter, LOD or coordinates. Such placeholder views can have a dimension the static runtime image interface has no mode for (a 3D view under a 2D sample, a 1D view under a 2D gather), and a 3D one paired with an unnormalized sampler fails the unnormalized proof. A direct sampled image whose accesses are all non-compare samples or gathers gets three constant runtime modes (float, uint, sint). The mode is selected when all four dst_sel are 0 or 1, unless the view is FMASK, depth bits, converted or sRGB-decoded. In it the emitter returns each channel's constant (the dmask channel's, in all four texels, for a gather) from the image's swizzle specialization constants, and the image is left unbound. ProveUnnormalized skips the mode after the run-time-selected check, so table roots still throw.
… fields The ImageResource layout change needs its own version: main is already at 21.
829944a to
995de0c
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the rebase. The three points from the earlier review are done: the constant-swizzle skip now runs after the indirectRoot check (table roots still throw), and the tests pin gather dmask 0x2/0x4, dmask 0x6 and the 32_UINT/32_SINT constants.
Checked on current main: build and ctest pass, and agc_shader_memory and agc_driver_image_sample_unnormalized fail without the change. The sample/gather results match what the gfx1035 hardware returns.
Added one commit on top: FormatVersion is 21 on main already, so the 20 → 21 bump disappeared in the rebase; it is now 22 since ImageResource gained two serialized fields.
Merging once CI is green.
…swizzle-samples feat(agc): fold samples of views whose channels all select constants
What
When every
dst_selof a sampled view selects constant 0 or 1, a sample or gather returns that constant whatever the texel, filter, LOD or coordinates. Titles sample such placeholders through views the static runtime image interface has no mode for: a 1x1x1 3D R8 texture under a 2D sample with an unnormalized sampler, or a 1D texture under a 2D gather. Both stop at runtime image mode selection ("image descriptor is incompatible with the static runtime image interface"), and the 3D one would then fail the unnormalized proof ("samples a 1D-array, 2D-array, 3D, cube or multisampled image").RuntimeImageModesappends three constant modes (float, uint, sint) to a direct sampled image whose accesses are all non-compare samples or gathers (constantSwizzleCompatible, tracked byResourceTracker). Storage, depth-compare, packed and table images get none.RuntimeImageModeselects the constant mode of the view's numeric class when all fourdst_selare 0 or 1, before dimensions are matched. FMASK, depth-bits, converted and sRGB-decoded views keep their existing modes.ProveUnnormalizedskips a constant mode only after the run-time-selected check, so bindless table roots still throw.ImageResourcefields are serialized andFormatVersiongoes from 20 to 21.Tested
agc_driver_image_sample_unnormalizedhas new cases, which fail without the change:dst_sel(1, 0, 1, 0) sampled withimage_sample_lz,image_sample_landimage_samplethrough all five unnormalized samplers returns exactly (1.0f, 0, 1.0f, 0);image_sample_lzdmask 0x6,image_gather4_lzdmask 0x2 andimage_gather4_lzdmask 0x4 under a 2D access return (0, 1.0f), all 0 and all 1.0f on a 3D UNORM view selecting (1, 0, 1, 0); (0, 1), all 0 and all 1 on 32_UINT and 32_SINT views; and zeros on a 1D view selecting (0, 0, 0, 0). These are the values measured on gfx1035.agc_shader_memory: a 3D view selecting constants passes the unnormalized proof and is not bound; a table root with the same descriptor still fails with "samples an image selected at run time".ctest: 507/507 pass (one skipped as usual).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)