compute: allow implicit-derivative image sampling in direct compute #3255
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3255"
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 R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T02:09:59Z.
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 #3243) and 2 with 0x9;image_store, 1 at the sampler LOD fields and 1 at the numeric SCC.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T02:29:08Z.
Review: CHANGES_REQUESTED
Reviewed
0dc638312aon mainf9286e7d(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.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T03:01:27Z.
Thanks for the review and the extra readbacks. Pushed
346da2ba, rebased onmainc827d8ba, which addresses each point:docs/experiments/native-compute-implicit-derivatives.mdcovers:numthreads, and validator 1.8 only for these modules;It is linked from
docs/experiments.md.native_compute_implicit_lodadds:It keeps the earlier 32- and 64-thread shapes, including (8,4,1) and (8,4,2). The controls check two distinct refusals: the 36-thread wave32 group stops at "partial final wave in multi-wave group", and the 6-thread group stops at "implicit derivatives require a pixel stage".
image_sample_b: bias +1 selects mip 2, the same asimage_sample_lat LOD 2;image_sample_c: LESS against a depth mip chain, at the implicit LOD 1;image_get_lod: the clamped and unclamped LOD;image_gather4: with a sampler fixed to mip zero, it returns the four mip-0 taps, the same asimage_gather4_lat LOD 0.The refusal for implicit Gather with a constant sampler that is not fixed to mip zero stays as a negative.
compute_checkgains a scalar R32_FLOAT comparison case and a mip-zero static sampler, both used only by these cases.Results:
native_compute_implicit_lod_controlsand_hardwarepass. Inbox WARP reports the capability skip.ctest -R "native_|startup_compute|compile_dxil|compute_"passes on a full build, exceptnative_scalar_lds_hardware, which fails as onmain.bias-plus-onereadback;image_get_lodoutputs fails theget-lodreadback.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by akimfomin on 2026-11-28T03:11:21Z.
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
346da2bahead, including the 6-thread and 36-thread refusal controls. If an independent run comes back, I’ll link its exact case results here.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T03:14:54Z.
Review: APPROVED
The changes at
346da2baanswer 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
8178cd9fon main0637fced. Debug and Release /O2 each had 3 passes and one WARP capability skip:I then rebuilt against main
9872074a(tree3ae3518f). Release /O2 passed the derivative controls and hardware value checks plus both adjacent MIMG cache-flag hardware cases. WARP still returned a capability skip.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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T03:35:45Z.
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
a44e1f95and the refreshed compiler stack4a007912. For the(8,4,1)case,native_compute_implicit_lod_hardwareexpected0x3f800000and read0x3f948000. RX 9060 XT driver 32.0.32029.2010, Windows 11 build 26300. The published 1D cases and compile controls passed on that adapter. Our independent RTX 4060 run passed the hardware fixture.This gives the existing AMD replay a pinned main failure to compare against. Please preserve the
(8,4,1)reproducer and compare the actual per-thread index mapping and the explicit-LOD control before attributing the mismatch.Imported from R0Y00/Xbox2Windows. Originally posted by akimfomin on 2026-11-28T03:41:26Z.
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
a44e1f95and prints separate implicit and explicit results for the same(8,4,1)case. A CPU check injected a failure in the first arm and confirmed the other arm still runs and the overall test stays failing. The reported word is 1.16015625, outside the fixture’s three solid mip colours, so I would keep sampler and coordinate behaviour open alongside lane order.If you or your agent are already rerunning the AMD case, two labelled lines and the
(12,1,1)control in #159 would answer the next question. The commands and precise revision are ready to reuse.Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-28T06:15:53Z.
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
(8,4,1)case is still the useful AMD retest. If you have time to rerun it on RX 9060 XT, the implicit and explicit readbacks from #3299 would show whether the original fractional value persists with zero horizontal derivative.