startup: lower CLAMP_BORDER comparison samplers with fixed border colors #2541
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2549"
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 consolelogkyo on 2026-11-25T20:29:48Z.
Part of #2023 (item F slice).
Summary
tools/pixel_aot.py&tools/startup/gfx2hlsl.py: Addsallow_border=Truetocomparison_sampler_stateforStage.image_compare(image_sample_candimage_sample_c_lz), acceptingSQ_TEX_CLAMP_BORDER(6) alongsideSQ_TEX_CLAMP_LAST_TEXEL(2) independently inCLAMP_XandCLAMP_Y(SQ_IMG_SAMP_WORD0bits2:0and5:3). When either axis usesCLAMP_BORDER,SQ_IMG_SAMP_WORD3bits31:30(BORDER_COLOR_TYPE, Mesasrc/amd/registers/gfx10-rsrc.json) must beTRANS_BLACK(0),OPAQUE_BLACK(1), orOPAQUE_WHITE(2);REGISTER(3, indexed viaBORDER_COLOR_PTR) is refused becauseD3D12_STATIC_SAMPLER_DESChas no register-indexed border color. When neither axis usesCLAMP_BORDER,BORDER_COLOR_TYPEandBORDER_COLOR_PTRremain ignored. Half-border, mirror-once-border, wrap/mirror modes, and the standalonepixel_aot.comparison_sampler_statedefault (allow_border=False) stay refused.const_words():s_mov_b32 sN, 0x40000000(OPAQUE_BLACKwithBORDER_COLOR_PTR == 0) assembles as inline float constant244(2.0);Stagenow tracks the 32-bit pattern forconst_words()(cleared on overwrites and branch joins) without changingself.symor runtime SGPR assignments.src/startup_stubs/translated_sampler_bindings.h: MapsSQ_IMG_SAMP_WORD3bits31:30(0..2) toD3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK,D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK, andD3D12_STATIC_BORDER_COLOR_OPAQUE_WHITEindecode_sampler()(falling back toTRANSPARENT_BLACKfor3) and carries the matching{rgb, rgb, rgb, alpha}floats intodynamic_sampler().tests/startup_image_sample_c_border_check.py(startup_image_sample_c_border_controls,_warp,_hardware): 21 source-built gfx1013 pixel fixtures covering translation/manifest/refusal controls (REGISTERborder on X, Y, or XY, half-border, mirror-once-border, wrap/mirror, reserved word 3 bits, and standalonepixel_aotisolation), inline-float0x40000000(2.0) constant sampler words, and D3D12 draws with DXCps_6_0and FXCps_5_1across in-bounds,-X/+X/+Yout-of-bounds, mixed(6, 2)and(2, 6)X/Y addressing, bilinear 50/50 and 75/25 border-edge PCF, RGBA border readback separatingOPAQUE_BLACK(0,0,0,1)fromTRANS_BLACK(0,0,0,0)andOPAQUE_WHITE(1,1,1,1), and four negative-control mutations (including the pre-fixTRANSPARENT_BLACK-only border behavior).tests/startup_sampler_comparison_check.cppandtests/startup_translated_sampler_bindings_check.cppwith static and dynamic border-color assertions.Verification
Executed locally on Windows 11 (
Releasebuild, Microsoft Basic Render Driver / WARP and AMD Radeon RX 9070 XT, with both DXCps_6_0and FXCps_5_1):ctest --test-dir out/build/release --output-on-failure -R "^(startup_image_sample_c_border_controls|startup_image_sample_c_border_warp|startup_image_sample_c_border_hardware|startup_image_sample_c|startup_sampler_comparison|startup_translated_sampler_bindings|startup_translated_sampler_bindings_shared_axis_control|startup_gfx2hlsl_sample_c_lz_mip|startup_translator)$": 10/10 passedctest --test-dir out/build/release -j 8 --output-on-failure -R "^startup_gfx2hlsl_" -E "^startup_gfx2hlsl_.*_(warp|hardware)$": 70/70 passedout/pe-env/Scripts/python.exe -B tests/pixel_compare_check.pyandtests/pixel_aot_check.py: passedAI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:50:28Z.
Review: COMMENTED
Review of head
34b74000(comment only, no approval). The PR's own change is identical to016c68ad(range-diff: unchanged); only main was merged in.Verdict: sound. The shader-side change has a real D3D12 draw test against a CPU reference. No other open or merged PR covers CLAMP_BORDER comparison samplers.
Checked
tools/pixel_aot.py(allow_borderis opt-in, default stays strict),tools/startup/gfx2hlsl.pyandsrc/startup_stubs/translated_sampler_bindings.h(static and dynamic border color, REGISTER type falls back and is refused upstream when a border axis is used).python3 -B tests/startup_image_sample_c_border_check.py: controls ok.comparison_sampler_statemakes the controls fail.python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py: ok.git diff --check origin/main...HEAD: clean.startup_image_sample_c_border_controls/warp/hardwarepass (draw readback vs CPU model, DXC and FXC).Notes
offscreen_checkfor this PR, so the first draw run used an older binary and failed onborder_white. Passingoffscreen_checkin--targetsfixed it (a pipeline plan gap, not a PR bug).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T20:47:51Z.
Hardware run at head
34b74000(build exit code 0).Environment: NVIDIA GeForce RTX 3070 Ti, driver 32.0.16.2101 (NVIDIA 621.01) and Windows 11 Pro build 26300.9974 as reported by the system,
devpreset (MSVC). The runs were serial (-j1).Command:
ctest --preset dev --no-tests=error -j1 -V -R '^startup_image_sample_c_border'Result: 3/3 passed, 0 failed (
_controls,_warp,_hardware). 0 capability skips (77).startup_image_sample_c_border_hardware(test 755) prints 13 cases and 4 mutants fordxc, and the same forfxc: 26 cases and 8 mutants in total. Every mutant line sayscaught(dropped_w3_border_color,forced_clamp_last_texel,swapped_xy_addressing,opaque_black_as_trans_black). The 26 case lines and 8 mutant lines of the WARP run (test 754) are identical to those of test 755 (compared withdiff).The ctest output does not print the adapter. As a separate measurement, I ran the same script directly (
python -B tests/startup_image_sample_c_border_check.py draw <dxc> <build>/offscreen_check.exe hardware <fxc>) under a small local wrapper that also printed the stdout of the firstoffscreen_checkcall the script makes. That stdout contains:backend=hardware debug_layer=enabledadapter=NVIDIA GeForce RTX 3070 Ti vendor=10de device=2482driver=32.0.16.2101debug_errors=0 debug_warnings=0I have these debug-layer lines for the first invocation only, not for the other cases. The case and mutant lines of this direct run match test 755.
Not covered by this run: AMD, and any test outside the filter above.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:50:30Z.
Win2025 WARP receipt for head
34b74000after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
34b74000af157a0de922d680a46b89016cd3ac26:--preset dev):cmake --build --preset dev --target offscreen_check d3d12_xs_device_obj d3d12_xs_shim startup_sampler_comparison_check startup_translated_sampler_bindings_check -- -j 2):6.26s(configure2.15s)ctest --preset dev -R '^(startup_image_sample_c_border_(controls|warp)|startup_image_sample_c|startup_sampler_comparison|startup_translated_sampler_bindings|startup_gfx2hlsl_sample_c_lz_mip|startup_translator|startup_image_3d|startup_sampler_)' --parallel 4 --no-tests=error --output-on-failure): 25/25 passed (5.20s:startup_image_3d_hardware1.73s,startup_image_3d_warp1.75s,startup_sampler_heap_hardware1.95s,startup_sampler_heap_warp2.02s,startup_gfx2hlsl_sample_c_lz_mip0.26s,startup_image_sample_c0.35s,startup_sampler_heap_wrapped_warp0.19s,startup_image_3d_controls0.17s,startup_sampler_heap_controls0.14s,startup_image_sample_c_border_controls0.28s,startup_sampler_lod_dropped_warp0.06s,startup_sampler_lod_warp0.06s,startup_sampler_x_swapped_warp0.06s,startup_translated_sampler_bindings0.03s,startup_sampler_x_warp0.08s,startup_translated_sampler_bindings_shared_axis_control0.03s,startup_sampler_comparison0.02s,startup_sampler_x_hardware0.06s,startup_sampler_lod_hardware0.06s,startup_sampler_x_swapped_hardware0.09s,startup_sampler_lod_dropped_hardware0.07s,startup_sampler_heap_wrapped_hardware0.16s,startup_translator0.64s,startup_image_sample_c_border_hardware2.50s,startup_image_sample_c_border_warp2.56s)/O2(--preset release):cmake --build --preset release --target offscreen_check d3d12_xs_device_obj d3d12_xs_shim startup_sampler_comparison_check startup_translated_sampler_bindings_check -- -j 2):9.55s(configure2.13s)ctest --preset release -R '^(startup_image_sample_c_border_(controls|warp)|startup_image_sample_c|startup_sampler_comparison|startup_translated_sampler_bindings|startup_gfx2hlsl_sample_c_lz_mip|startup_translator|startup_image_3d|startup_sampler_)' --parallel 4 --no-tests=error --output-on-failure): 25/25 passed (4.44s:startup_image_3d_warp1.61s,startup_image_3d_hardware1.67s,startup_sampler_heap_hardware1.72s,startup_sampler_heap_warp1.80s,startup_sampler_heap_wrapped_warp0.17s,startup_image_sample_c0.28s,startup_image_3d_controls0.13s,startup_sampler_x_warp0.05s,startup_gfx2hlsl_sample_c_lz_mip0.21s,startup_sampler_heap_controls0.13s,startup_sampler_x_swapped_warp0.05s,startup_sampler_lod_warp0.06s,startup_translated_sampler_bindings0.02s,startup_sampler_lod_dropped_warp0.07s,startup_sampler_comparison0.02s,startup_translated_sampler_bindings_shared_axis_control0.02s,startup_sampler_x_hardware0.05s,startup_sampler_lod_hardware0.05s,startup_sampler_x_swapped_hardware0.07s,startup_sampler_lod_dropped_hardware0.05s,startup_sampler_heap_wrapped_hardware0.15s,startup_translator0.60s,startup_image_sample_c_border_controls0.23s,startup_image_sample_c_border_warp1.99s,startup_image_sample_c_border_hardware1.99s)tests/form_coverage_check.pyok (13.3s),tests/mesh_clip_cull_check.pyok (4.0s),tests/mesh_dynamic_geometry_check.pyok (0.2s),tests/mesh_heap_sampler_check.pyok (0.6s),tests/pso_readiness_check.pyok (0.7s),tests/rdna2_tools_check.pyok (2.3s),tests/startup_buffer_address_check.pyok (0.4s),tests/startup_buffer_format_word3_table_check.pyok (0.1s),tests/startup_compute_request_offline_check.pyok (0.5s),tests/startup_compute_translate_check.pyok (0.2s),tests/startup_flat_param_check.pyok (0.1s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.1s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.1s),tests/startup_gfx2hlsl_bit_alu_check.pyok (0.6s),tests/startup_gfx2hlsl_capture_check.pyok (0.9s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.2s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.3s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.1s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.1s),tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyok (0.1s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.1s),tests/startup_gfx2hlsl_f32_nan_check.pyok (4.5s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.1s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_image_get_lod_check.pyok (0.1s),tests/startup_gfx2hlsl_int_med3_check.pyok (0.1s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.2s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.1s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.3s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (3.7s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.2s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.2s),tests/startup_gfx2hlsl_refusals_check.pyok (0.7s),tests/startup_gfx2hlsl_root_check.pyok (0.9s),tests/startup_gfx2hlsl_sad_check.pyok (0.4s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.3s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.3s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.1s),tests/startup_gfx2hlsl_shift64_check.pyok (0.1s),tests/startup_gfx2hlsl_sload_const_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_smem_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (6.5s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (0.8s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.1s),tests/startup_gfx2hlsl_swap_check.pyok (0.3s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (4.2s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.5s),tests/startup_image_2d_array_check.pyok (0.2s),tests/startup_image_3d_check.pyok (0.1s),tests/startup_image_gather_lz_check.pyok (0.7s),tests/startup_image_load_d16_check.pyok (0.8s),tests/startup_image_sample_a16_check.pyok (0.1s),tests/startup_image_sample_b_check.pyok (0.1s),tests/startup_image_sample_c_check.pyok (0.2s),tests/startup_image_sample_l_check.pyok (0.2s),tests/startup_image_sample_lod_check.pyok (0.6s),tests/startup_inline_sampler_check.pyok (0.1s),tests/startup_mesh57_skeleton_check.pyok (0.2s),tests/startup_run_ps1_check.pyok (9.5s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.1s),tests/startup_shader_cache_rekey_check.pyok (1.8s),tests/startup_smem_address_check.pyok (0.1s),tests/startup_stream_fetch_check.pyok (0.2s),tests/startup_stream_interface_check.pyok (0.2s),tests/startup_translator_check.pyok (0.4s)sccache: 8/213 hits; wall103.9sNote: the first run missed the new border tests because the plan did not rebuild
offscreen_check; this run adds it as a target.*_hardwareruns on WARP in the VM and passed here too.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T20:52:20Z.
On Windows 11 (26100.9711) I ran the PR's original fixture against the renderer built from
34b74000. On Intel UHD 770 (32.0.101.5973), RTX 4060 (32.0.15.9579), and WARP (10.0.26100.9711), DXC and FXC each matched all 13 four-channel outputs and caught all four sampler mutations. LLVM 15 also reassembled the 21 recorded programs byte for byte. The Server 2025 CPU and WARP run built the renderer. I checked its source revision and both artifact digests before the local runs.I also checked the intersection of bilinear filtering and mixed X/Y addressing. The replay script uses four assembled guest programs, switches which axis uses the border, and selects opaque black or white. Its reference filters four independent depth comparisons at the four probe positions. Across three reference depths, each device/compiler pair matched all 12 four-channel results. Swapping the two addressing modes changed six of those results, and all six changed to the exact predicted values. Local hardware runs used the system D3D12 runtime with the debug layer unavailable.