startup: bind LOD-clamped static samplers (smpl) in the translated compute Dispatch #2577
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2585"
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 NiiRoZz on 2026-11-25T22:03:03Z.
Depends on #2580. Refs #2274.
What changed
src/startup_stubs/d3d12_compute_dispatch.inl: the compute manifest reader acceptssmpl <i> <w0> <w1> <w2> <w3>lines, the static sampler with the descriptor's MinLOD and MaxLOD that the translator writes since #2482. They go through the draw path's own code (TranslatedSamplers::read_manifest_line,decode_staticsandcreate_translated_rootintranslated_sampler_bindings.h), so no second sampler mechanism is added. For compute, the only difference from a draw is that the root signature is set withSetComputeRootSignature; static samplers need nothing else at Dispatch.smpcgives "a comparison sampler" andsmpheapgives "a sampler from the sampler heap". Binding the heap table for compute would need the draw path's sampler snapshot (snapshot_samplers,create_sampler_snapshot_heap) taken from the compute root's sampler heap pointer,SetDescriptorHeapswith the sampler heap, andSetComputeRootDescriptorTable. That is left for the first program that needs it.tests/startup_compute_dispatch_texture_check.pyandtests/startup_stream_consumer.cpp: a new filtered case. The existing sampling case uses a 1x1 texture, so it cannot tell filter or address modes apart. The new case puts a constant wrap, linear sampler (MAX_LOD 12, so the translator writessmpl 0 0x0 0xc00000 0x18500000 0x0) in the texture input program. The consumer's newdispatch-sampled-2x1mode samples a 2x1 RGBA8 texture whose left texel has red 0 and right texel red 1.0, at the left edge. Only a linear filter that wraps reads 0.5 there.smpcline and an addedsmpheapline each refuse with one logged reason and leave the output untouched.docs/experiments.md: a subsection under the translated compute Dispatch section.Measured
Result: 8 of 8 passed (WARP and hardware for
startup_compute_dispatch,_texture,_heapand_heap_word), with no capability skips.New filtered case, on both adapters: every thread read red 0.5. With the clamp sampler, every thread read red 0. The
smpcandsmpheapcontrols refused with their reasons and left the output untouched.Negative control for the code change: with the
smplmatch disabled,startup_compute_dispatch_texture_warpfails. The Dispatch logsrefused: a sampler that is not a plain static one.Local census (counts only): 7 compute programs, about 135 thousand Dispatch calls, refused first for "a sampler that is not a plain static one". All 7 manifests hold only
smplsampler lines: 6 with one line and 1 with two. None hassmpcorsmpheap. In 6 of the 7, word 0 is 0x92 (clamp in U, V and W). The other uses wrap. When their manifests are read against the new classifier, every line of all 7 is accepted and each has a compiled program, so all 7 now pass manifest loading.Hypothesis / unverified
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:06:37Z.
Review: COMMENTED
Review of head
38a752af(comment only, no merge).Code read: the new
smplbranch insrc/startup_stubs/d3d12_compute_dispatch.inl(lines ~115-126) reusesTranslatedSamplers::read_manifest_line, which already handlessmpland setslod_limits(translated_sampler_bindings.h:69-96). Thesmpc/smpheapchecks run before the genericsmpfallback, so each refuses with its own reason. The index checki == tr.samplers.statics.size()keeps the manifest order strict. No problem found.Test: the new filtered case uses a wrap + linear sampler with MAX_LOD 12 and a clamp control, and the author lists a negative control (
smplmatch disabled makes the texture test fail). Good. As the PR says, the fixture texture has one mip, so the LOD clamp itself is not covered.Not merge-ready from our side:
Commands run (Linux):
git diff --check origin/main...HEAD,python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py(all clean). The D3D12 tests and mutations were not run here (no Windows run in this review).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T22:55:35Z.
Two device-free checks pass, and five mutations of the heap-index tracking are all caught
The
heap_wordcheck is the new half here: 6 more forms accepted, 10 refused controls. It splits fromheap_recordexactly where the change does —heap_recordnames the record,heap_wordnames what the index wordis (a root constant word, times a scale, plus an addend, modulo 2³²).
The other three checks in this PR (
startup_compute_dispatch_check.py,…_heap_check.py,…_texture_check.py) exit 1without arguments — they need DXC, an adapter and a dispatch mode, so they are the GPU half and I did not run them.
Mutations of
heap_word_offsetand the index tracking2instead of1rcmark no longer recognised (return mark[1:] if … else None→return None)heap_index.clear()at a join replaced withpasswrote = scalar_destinations(…)→set())The first three are
heap_word's own business and it catches all three, which is what you would want from a check addedspecifically for "6 more forms".
The last two are the interesting ones because they are caught by both, and they are the invariants that make the whole
scheme sound:
mark from one predecessor survives into a block reachable from another, and the index is named for the wrong word.
wrote = set()means a laters_movover the register leaves the stale mark in place, sothe new value is named by the old word's identity.
Both are invisible unless a fixture has two paths into a join and a write between the naming and the use, and both
fixtures here do.
Note on the two PRs
This PR's
gfx2hlsl.pyhunk is a superset of the earlier heap-record change I reviewed (heap_recordis unchanged apartfrom being joined by
heap_word), so the mutations above cover the whole current state of the file's heap handling ratherthan only the delta. If the two are stacked, the merged result is what I measured.
Method note
Four of my first five anchors missed purely on indentation — I had copied the leading spaces from a
git diffexcerpt,where the
+prefix shifts the column by one. Anchors taken by line number from the file itself (Get-Contentindexed)all hit. Worth doing that way in a file this size.
AI-assisted; pure Python, Windows 11 build 26300, no DXC or GPU for the rows above.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:56:22Z.
Not merging yet: this branch still carries the commits of two open PRs, so it cannot land on its own.
git merge-base --is-ancestor <#2490 head> <this head>: yes.d3d12_compute_dispatch.inl,startup_compute_dispatch_check.py,startup_compute_dispatch_texture_check.pyand conflicts instartup_stream_consumer.cpp,d3d12_xs_device.cpp,gfx2hlsl.py,docs/experiments.md,CMakeLists.txt,AGENTS.md. The pre-squash copies of the chain are what collides with main.Suggested path for @NiiRoZz: land #2470 and #2490 first (or rebuild this branch from current main so only the
smplchange is left in the diff), then this PR shrinks to the sampler part and can be tested on its own.No push was made to the branch. No test was run on this head.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T06:05:47Z.
Review: COMMENTED
Merged origin/main into this branch (merge commit
03aa5ffc8, no force, no rebase). Conflicts were the pre-squash copies of the compute Dispatch chain; #2470 and #2490 are already in main via #2532 (checked by sm3, confirmed by MasterDomino in the #2470 thread), so I kept main's side everywhere and kept only this PR's ownsmplchange.git diff origin/main --statnow shows 4 files only:d3d12_compute_dispatch.inl(+7),startup_stream_consumer.cpp,startup_compute_dispatch_texture_check.py,docs/experiments.md.Review of what is left:
smpandsmpllines go through the draw path'sread_manifest_line;smpcandsmpheaprefuse with their own reasons. Sound.smpc/smpheaprefused with one logged reason, output untouched) guards the behaviour: point or clamp would read 0.Verification (Windows Server 2025, merged head
03aa5ffc8, applied on top of the PR head):ctest --preset dev -R '^startup_compute_dispatch_': 100% tests passed out of 8 (warp and hardware for dispatch, texture, heap, heap_word).ctest --preset release -R '^startup_compute_dispatch_' --no-tests=error: 8/8 passed.python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: clean.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T06:05:12Z.
Merged origin/main into this branch (merge commit
03aa5ffc8, no force, no rebase). Conflicts were the pre-squash copies of the compute Dispatch chain; #2470 and #2490 are already in main via #2532 (checked by sm3, confirmed by MasterDomino in the #2470 thread), so I kept main's side everywhere and kept only this PR's ownsmplchange.git diff origin/main --statnow shows 4 files only:d3d12_compute_dispatch.inl(+7),startup_stream_consumer.cpp,startup_compute_dispatch_texture_check.py,docs/experiments.md.Review of what is left:
smpandsmpllines go through the draw path'sread_manifest_line;smpcandsmpheaprefuse with their own reasons. Sound.smpc/smpheaprefused with one logged reason, output untouched) guards the behaviour: point or clamp would read 0.Verification (Windows Server 2025, merged head
03aa5ffc8, applied on top of the PR head):ctest --preset dev -R '^startup_compute_dispatch_': 100% tests passed out of 8 (warp and hardware for dispatch, texture, heap, heap_word).ctest --preset release -R '^startup_compute_dispatch_' --no-tests=error: 8/8 passed.python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: clean.AI-assisted; commands listed were executed locally.