Preserve comparison sampling through the SPIR-V to HLSL bridge #670
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#670
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@R0Y00 on GitHub · 2026-11-22 18:47 UTC · original
Why this is on the integration path
#656 unblocked subgroup ballot extraction in the external-frontend bridge. In the fixed-profile follow-up scan, all 807 affected compute records emitted HLSL. DXC accepted 29, timed out on 42, and rejected 736. The first diagnostic in the rejected group points to a texture sampling call using a comparison sampler. This identifies a common compile blocker. The supported operation and its output still need an independent comparison.
First implementation
Identify the SPIR-V image operation and sampler type that cause one representative failure. Reproduce it with a small source-built compute fixture and a known depth texture. Keep ordinary sampling and comparison sampling distinguishable across HLSL emission and descriptor binding. Match the reference, coordinate and LOD semantics of the selected form. Record which forms the fixture exercises and reject unsupported variants with a specific diagnostic. Extend the existing bridge tests around #553 and #656.
Acceptance
You can claim the public reproducer or the lowering and binding change. Leave the first failing command and your proposed interface in a comment before opening the PR. Refs #218 and #656.
@rwZephyr on GitHub · 2026-11-22 19:00 UTC · original
Public compile-stage reproducer for #670. Both source-built modules validate under Vulkan 1.2. With one sampler ID used by both sampling forms, pinned SPIRV-Cross emits a
SamplerComparisonStateand passes it to ordinarySampleLevel. DXC rejects that call. With separate sampler IDs, DXC compiles successfully.Tested locally on Windows 11 25H2 x64
26200.9974at Xbox2Windowsedc2e54e7e75fcd7c0f13e98b47ba119d9a08268. Tools: SPIRV-Toolsv2025.5with its pinned headers, SPIRV-Cross57e4efcc84112abcd426dc5ec248b5339bee04f2, and DXC1.8.2502.8. AI-assisted.Save as
source.hlsl:The first failing command was
dxc -T cs_6_6 -E main -Fo shared.dxil shared.hlsl. First diagnostic:The comparison instructions here are
OpImageSampleDrefExplicitLodwith literalLod 0. The ordinary control isOpImageSampleExplicitLodwithLod 0. For a follow-up, I propose carrying sampler kind per use through the named bridge profile so the host can bind an ordinary sampler and a comparison sampler in separate slots. Keep the first implementation toTexture2D<float>and literal zero LOD. With point-clamp sampling, a constant0.5depth,LESS_EQUAL, and a separate ordinary texture of value0.375, the proposed dispatch reference is[1.0, 0.0, 0.375]followed by unchanged guards. The evidence here covers SPIR-V validation, HLSL emission, and DXC compilation. GPU dispatch and correspondence to the private scan are still unverified.@rwZephyr on GitHub · 2026-11-22 19:03 UTC · original
GPU readback follow-up to the compile-stage reproducer. I dispatched its validated, cross-compiled separate-sampler shader using a standalone D3D12 host. AI-assisted, run locally.
Windows 11 25H2 x64
26200.9974, Xbox2Windows checkoutedc2e54e7e75fcd7c0f13e98b47ba119d9a08268, MSVC19.44.35230, SDK10.0.26100. Same SPIRV-Toolsv2025.5, SPIRV-Cross57e4efcc84112abcd426dc5ec248b5339bee04f2, and DXC1.8.2502.8as above. Tested RX 9070 XT (1002:7550, driver32.0.32029.2010) and WARP (1414:008c,10.0.26100.9818). Both reporteddebug_layer=unavailable.One
cs_6_6dispatch per backend. The host bound 2×2R32_FLOATSRVs att0/t1, a point-clamp comparison sampler (LESS_EQUAL) ats2, a point-clamp ordinary sampler ats3, and a raw output buffer atu4. At UV(0.25, 0.25), the shader compares references0.25and0.75against depth0.5and samples ordinary value0.375.Both backends returned
3f800000,00000000,3ec00000(1.0, 0.0, 0.375), with all 13 guard words unchanged and zero mismatches or skips. Changing only the CPU reference at word 1 gave exactly one mismatch on each backend (expected=3f800000 actual=00000000).Reproduce from a directory containing
separate.dxilgenerated by the earlier comment and the host source below saved ascompare-readback.cpp:This verifies the GPU behavior of the separate-sampler control. The shared-sampler lowering and repository CTest integration are still open.
Standalone D3D12 readback host
@rwZephyr on GitHub · 2026-11-22 19:06 UTC · original
Sampler-split prototype follow-up. Starting from
shared.spvasmin the compile-stage reproducer, the prototype adds an ordinary sampler at set 0 binding 5, leaves the comparison sampler at binding 2, and redirects only the ordinaryOpSampledImageto the new sampler. The host takes the two slots as separate binding kinds. This is an opt-in scratch pass for the direct, non-arrayTexture2D<float>compute profile with literal LOD 0.The transformed SPIR-V passed Vulkan 1.2 validation. Pinned SPIRV-Cross emitted
SampleCmpLevelZerowiths2andSampleLevelwiths5. DXC compiled the result ascs_6_6. On the RX 9070 XT and WARP, both comparison outputs and the ordinary sample were[1.0, 0.0, 0.375], with all 13 guards exact. The wrong reference failed only at word 1 (expected=3f800000 actual=00000000). An occupied binding and a nonzero comparison LOD were rejected. The already-separated input was preserved, and the four existing address-window/ballot hardware and WARP CTests passed with zero skips.Run locally on Windows 11 25H2 x64
26200.9974at Xbox2Windowsedc2e54e7e75fcd7c0f13e98b47ba119d9a08268. MSVC19.44.35230, SDK10.0.26100, Python3.12.10, SPIRV-Toolsv2025.5, SPIRV-Cross57e4efcc84112abcd426dc5ec248b5339bee04f2, DXC1.8.2502.8. RX 9070 XT1002:7550driver32.0.32029.2010, WARP1414:008cdriver10.0.26100.9818. Debug layer unavailable on both. AI-assisted.Save the prototype below as
split_sampler.py. For the previous standalone host, changes.ShaderRegister = 2 + i;tos.ShaderRegister = i == 0 ? 2 : 5;for this run.Repository integration still needs agreement on who allocates the extra sampler slot and how the bridge passes it to the host. This run covers the source-built profile only.
SPIR-V sampler-split prototype
@rwZephyr on GitHub · 2026-11-22 19:17 UTC · original
Proposed interface for the sampler split: host-reserved ordinary-sampler slot
Following up on the prototype in #670, which left open who allocates the extra sampler slot. I'd like to claim the lowering and binding change, and I'm checking the interface first, as the issue asks.
Proposal. The host reserves a free ordinary-sampler slot and passes it explicitly to the lowering pass. The pass does not choose a slot itself.
(descriptor set, ordinary binding)supplied by the host. The prototype exposes this as--ordinary-binding N.OpImageSampleExplicitLoduses are redirected to a newUniformConstantsampler at the supplied binding, in the same descriptor set.descriptor_set,comparison_bindingandordinary_bindingso the host can bind an ordinaryD3D12_SAMPLER_DESCand a comparison one in separate slots.Scope. Direct, non-array
Texture2D<float>sampling in compute, at literal LOD 0 only:OpImageSampleExplicitLodandOpImageSampleDrefExplicitLodwith a constant zeroLod, from a standaloneUniformConstantsampler declared in the entry-point interface. Arrays, other formats, non-constant or nonzero LOD, graphics stages and sampler kinds reached through function parameters are rejected and stay out of scope.Question. Does a host-supplied slot fit the bridge's binding contract? If the bridge should own allocation instead, for example by taking the lowest free binding in the set or by using a fixed reserved range, I'll follow that. If the slot should be recorded in the named bridge profile rather than passed as an argument, I'll do it that way.
If agreed, the PR would add:
cs_6_6, and dispatches on WARP and a physical adapter. It checks the three outputs[1.0, 0.0, 0.375], all 13 guard words, and a wrong-reference control that must fail at exactly word 1. The hardware leg returns 77 when no capable adapter is present;What this covers. These results are from the public source-built fixture only. I have not measured the effect on the 807-record compute cohort from #656; the maintainer can rerun that cohort after integration. The separate CS package WARP readback discrepancy in that comment is unrelated to this change and remains open. This does not touch #671 or #560.
AI-assisted. Prepared with an AI coding assistant; all commands were run locally on Windows 11 with an RX 9070 XT and WARP.
@R0Y00 on GitHub · 2026-11-22 19:21 UTC · original
The host-reserved binding is the right boundary for this opt-in profile. Please proceed with a focused PR from the shared-sampler reproducer. Keep the original comparison binding and require the caller to supply a free ordinary-sampler binding in the same descriptor set. Emit the binding mapping for the host and keep modules outside this profile on the existing path.
For the first PR, keep the tested scope to direct, non-array
Texture2D<float>compute sampling with literal LOD zero. Include the occupied binding, nonzero comparison LOD, and already-separated controls from your prototype. Register the source-built compile and readback checks with the existing bridge fixtures. Link the failing DXC diagnostic and your WARP/RX 9070 XT results so the implementation can be reviewed independently. The 807-record rescan can follow once the public fixture is in place.@R0Y00 on GitHub · 2026-11-22 21:58 UTC · original
The scoped bridge implementation merged in #681. At
6f620f7the source-built fixture passed all eight SPIR-V tests across WARP and RX 9070 XT. The same fixture demonstrates the unsplit DXC failure, valid SPIR-V and DXIL after the split, ordinary and comparison readbacks, and wrong-reference and descriptor controls. Closing the focused implementation as complete. The 807-record fixed-profile rescan remains a separate measurement and has no new result here.