native: accept CLAMP_BORDER on level-zero comparison samplers #3526
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3526"
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 JB2WIN on 2026-11-29T22:56:02Z.
Change
A literal comparison sampler in native compute (
sampler_index,src/gfx1013_compute_native.cpp) was accepted only with CLAMP_LAST_TEXEL on both U and V ((address & 63) == 0x12).decode_sampleralready binds the address mode per axis and the static border colour. So a level-zero comparison sample (image_sample_c_lz) now also accepts CLAMP_BORDER (6) on U, on V, or on both. These are the rules ofpixel_aot.comparison_sampler_state(..., allow_border=True), which the Python path already uses.With a BORDER axis there are two refusals, each with its own reason. Border colour type 3 (REGISTER, indexed by BORDER_COLOR_PTR) has no static border colour. Comparison gathers (
gather4_c_lz) and implicit-LOD comparison samples have no border model (check_gather_samplerallows only CLAMP_LAST_TEXEL). MIRROR_ONCE_BORDER (7), half-border, wrap and mirror stay refused.Refs #3224, #3023. Follows #3524. On my local #3023 prototype route, 299 compute requests use a comparison sampler with CLAMP_BORDER on U and V and, with #3524, the constant word 3 0x80000000 (OPAQUE_WHITE). On
mainthey stop earlier, at the resource heap, so this moves no request there by itself.Verification
Build
cmake --preset release/cmake --build --preset releaseon2ff74a6a, Windows 11, NVIDIA GeForce RTX 3080, hardware adapter.startup_compute_dispatch_native_check.pystep 5, new border variant on hardware: the comparison sampler gets CLAMP_BORDER on U and OPAQUE_WHITE, and the reference base becomes 0.1875. Only thread x = 2 (u = 1.2, outside, 0.75 < 1.0) passes, which separates a white border from a black one (0) and from a clamped texel (about -0.5). All 6144 volume words match the CPU model, and the debug layer reports no error. The original step 5 runs unchanged before it.native_direct_container_check.py: BORDER on U, on V and on both compiles, and so does OPAQUE_WHITE. V = 7 refuses withunsupported comparison sampler fields. Border type 3 refuses withcomparison sampler border colour from the border colour register.gather4_c_lzand the pixel-stageimage_sample_cwith BORDER refuse withcomparison gather or implicit-LOD sample with a CLAMP_BORDER axis.ctest -R 'native_direct_container|startup_compute_dispatch_native|native_gather_compare|native_sampler_heap|inline_sampler': 9/9 pass.native_sampler_heap_warpandstartup_compute_dispatch_native_warpskip (wave32), as on main.src/reverted (stash, rebuild):native_direct_containerfails withunsupported comparison sampler fields, and the hardware border variant is not translated.decode_samplersets AddressW from it, which has no effect on a 2D or 2D-array view.Evidence and follow-up
All fixtures are source-built and use the existing
comparison_program()and step 5 programs. No game data.Next on the prototype route:
gather through the sampler heap is not translated, then the runtime sampler-heap binding (#3076 stage 2a, in progress).Checklist
AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T23:09:25Z.
Review: COMMENTED
Diff-only review at
343979bd(not built here). The logic matchespixel_aot.comparison_sampler_state(allow_border=True): X and Y each 2 or 6, REGISTER (type 3) refused only when an axis is BORDER, CLAMP_Z not read;decode_samplerhas no colour for type 3, so that refusal is needed. With gather (79) and implicit (40) refused, onlyc_lz(47) reaches BORDER.(border & 0x3ffff000)atgfx1013_compute_native.cpp:1180is unpinned. A case with word 3 =0x80001000expecting "unsupported comparison sampler fields" would pin it.0x0800103ais V = 7, which pins== 6against>= 6. Z is not read on 2D, so a Z = 7 case (0x080011d2) should be an accepted one.0x08001016), so changingu == 6 || v == 6at:1182tou == 6would pass the tests. A refusal case with a V-only border (0x08001032, word 3 =0xc0000000) would catch it.Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T23:20:38Z.
@Leyukaka all four are in
b06f0e06(native_direct_container_check.py):0x80001000with U = 6 refuses withunsupported comparison sampler fields.0x080011d2(Z = 7) compiles.0x08001032) refuses with word 30xc0000000(register reason) and ongather4_c_lz, which pinsu == 6 || v == 6.0x08001010) and mirror (0x08001011) on U refuse.ctest -R native_direct_containerpasses.AI-assisted.