Repository navigation
compute: allow implicit-derivative image sampling in direct compute - #3255
Conversation
There was a problem hiding this comment.
Reviewed 0dc6383 on main f9286e7 (trial eebea2902a6b8194315ce5c4b7d17e8e6b36830a). Release /O2 compiler controls and the RTX readback passed. Inbox WARP returned 77. Extra source-built 4- and 12-thread single-wave groups also produced identical implicit/explicit readback. A 36-thread wave32 group still refuses at the existing partial-final-wave guard, before the complete-quad check.
Please document the accepted group shapes and lane-mapping assumption in the experiment notes. The SM 6.6 spec guarantees the matching position within each 1D quad. The current reconstruction also uses the wave rank and host lane for the full guest index. Please pin at least one sub-wave and one group with multiple guest waves, and keep the 36-thread refusal distinct from the incomplete-quad refusal.
The GPU fixture tests image_sample against explicit LOD. Separate compile probes for image_sample_b, image_sample_c and image_get_lod produced DXIL, but they do not prove the selected mip/compare/query result. Gather still refused with the test's sampler because it requires mip zero. Please either scope this PR to the readback-tested operation or add corresponding readbacks for the other paths it enables, using a mip-zero sampler for Gather and keeping a negative for an unsupported sampler.
ctest --test-dir <release-build> --no-tests=error --output-on-failure -j 1 -R "^native_compute_implicit_lod_(controls|hardware|warp)$"
Windows 11 26200.9974, RTX 4060 Laptop 32.0.16.1656, inbox WARP 10.0.26100.9818, D3D12 debug layer enabled on both adapters.
Additional RTX readback: 96-thread wave32 and 128-thread wave64 also matched in both the implicit and explicit cases.
image_sample, image_sample_b, image_sample_c, image_gather4 and image_get_lod no longer refuse in direct compute when the guest group has a multiple of four threads. The guest model treats a compute quad as four consecutive lanes (ddx from lane ^ 1, ddy from lane ^ 2), so a module that uses implicit derivatives declares numthreads(X*Y*Z, 1, 1), where SM 6.6 forms quads from four consecutive threads; the guest x/y/z IDs are still rebuilt from the logical lane index (wave rank * 32 + host lane) with the original shape. Such a module also declares DXIL validator 1.8, which accepts derivative operations in compute; every other module keeps 1.6. Groups that are not a multiple of four stay refused. New test native_compute_implicit_lod (controls, WARP, hardware): (32,1,1), (8,4,1), (64,1,1) and (8,4,2) groups sample a three-mip texture with implicit LOD and with image_sample_l, and compare against the mip the guest quad selects. native_direct_container keeps its refusal check on a six-thread group.
…ation Document the accepted group shapes and the lane-mapping assumption in docs/experiments/native-compute-implicit-derivatives.md. native_compute_implicit_lod adds (4,1,1) and (12,1,1) sub-wave groups and (96,1,1) wave32 and (128,1,1) wave64 multi-wave groups, and keeps the 36-thread "partial final wave in multi-wave group" refusal distinct from the 6-thread incomplete-quad refusal. It now reads back image_sample_b (bias +1 selects the next mip, matching image_sample_l at that LOD), image_sample_c (LESS against a depth mip chain at the implicit LOD), image_get_lod (clamped and unclamped LOD) and image_gather4 with a sampler fixed to mip zero (matching image_gather4_l at LOD 0), and keeps the refusal for implicit gather with a sampler that is not fixed to mip zero. compute_check gains a scalar R32_FLOAT comparison case and a mip-zero static sampler for those cases.
0dc6383 to
346da2b
Compare
|
Thanks for the review and the extra readbacks. Pushed
Results:
AI-assisted. |
|
I checked the distinction in your experiment note. Swapping two intact four-thread quads within one host wave keeps each lane's within-quad position but changes eight reconstructed guest indices. That is a CPU counterexample to the weaker assumption, independent of whether a specific GPU ever uses that layout. I opened a pinned AMD replay in PortBridge for your new |
R0Y00
left a comment
There was a problem hiding this comment.
The changes at 346da2ba answer the earlier review. The docs now spell out the desktop quad-lane ordering assumption. The launch bounds and shape controls cover partial and multiple waves, and the fixture checks sample, bias, comparison, clamped/unclamped LOD queries, and gather separately. The deliberately distinct values make the output controls sensitive to selecting the wrong mip.
I built the integration tree 8178cd9f on main 0637fced. Debug and Release /O2 each had 3 passes and one WARP capability skip:
ctest --test-dir out/b/<configuration> --no-tests=error --output-on-failure -j 1 -R '^(native_compute_implicit_lod_(controls|warp|hardware)|native_direct_container)$'I then rebuilt against main 9872074a (tree 3ae3518f). Release /O2 passed the derivative controls and hardware value checks plus both adjacent MIMG cache-flag hardware cases. WARP still returned a capability skip.
ctest --test-dir out/b/release --no-tests=error --output-on-failure -j 1 -R '^(native_compute_implicit_lod_(controls|warp|hardware)|native_image_cache_flags_(ps_hardware|cs_hardware))$'Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, WARP 10.0.26100.9818 and DXC 10.0.26100.0. Hosted Windows CI is green. Hardware readbacks verify the tested adapter.
|
There is now a physical AMD result for the lane-order assumption. The RX 9060 XT report on #3241 reproduces the same failure on unmodified main This gives the existing AMD replay a pinned main failure to compare against. Please preserve the |
|
I recorded lambirou’s AMD result in the existing PortBridge replay. The old fixture can stop on the first mismatch before it runs explicit LOD. This test-only patch applies to If you or your agent are already rerunning the AMD case, two labelled lines and the |
|
I opened #3299 with a test-only vertical ramp and a DXIL group-dimensions check. On RTX 4070 and app-local WARP, implicit and explicit LOD each match all eight group cases. An independent HLSL spatial control changes all 32 mip results on both adapters. The |
Part of #2935 and #3224. Target branch
main.Change (
src/gfx1013_direct_compute.inl,src/dxil_module.h): direct compute accepts implicit-derivative image operations (image_sample,image_sample_b,image_sample_c,image_gather4,image_get_lod) when the guest group has a multiple of four threads. Other group sizes keep "implicit derivatives require a pixel stage".src/wave64_emulate.hlsli) treats a compute quad as four consecutive lanes, with ddx fromlane ^ 1and ddy fromlane ^ 2. SM 6.6 forms its compute quads from four consecutive threads when numthreads is one-dimensional. For a 2D group it uses 2x2 blocks instead.numthreads(X*Y*Z, 1, 1).initialize()still rebuilds the guest x/y/z IDs from the logical lane index (wave rank * 32 + host lane) with the original shape. This relies on host lane order following thread order within a wave, which the test checks on the RTX only.!dx.valver). Validator 1.6 rejects derivative operations in compute with "Function uses features incompatible with the shader stage (cs)". Every other module keeps 1.6, so no other output changes.tests/native_direct_container_check.pykeeps its refusal check on a six-thread group, and gains agroup=argument for multi-dimensional fixtures.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on
main50e4f763plus this commit.native_compute_implicit_lod_{controls,warp,hardware}covers(32,1,1)and(8,4,1)wave32 groups and(64,1,1)and(8,4,2)wave64 groups.image_sample_l.main'scompile_dxil, the test stops at "implicit derivatives require a pixel stage".native_|startup_compute|compile_dxilselection passes 416 of 417.native_scalar_lds_hardwarefails as onmain.A limit of that test. If I remove the flattening and declare the guest's 2D numthreads, the test still passes on the RTX 5080. This driver does not appear to form 2x2 quads for 2D compute groups, so on this GPU the test cannot show that the flattening is needed. I kept the flattening because it is what SM 6.6 specifies for 2D groups. A driver that follows that rule would otherwise pair the wrong lanes. WARP cannot run this path here.
Measured with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests, base and change both onmain50e4f763.image_storewith a partial dmask: 5 with 0x7 (the prefix-mask slice of compute: store prefix-mask images at their exact width in direct compute #3243) and 2 with 0x9;image_store, 1 at the sampler LOD fields and 1 at the numeric SCC.AI-assisted.