shader: lower 64-bit scalar bit-count and scan ops in gfx2hlsl (Part of #1723) #2065
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2072"
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 tedin7 on 2026-11-25T00:01:14Z.
Part of #1723
What this unblocks: shaders that count or scan bits in scalar registers (s_bcnt0/1, s_ff0/ff1 and s_flbit on 64-bit pairs) now translate in gfx2hlsl instead of stopping at
Unsupported.Adds s_bcnt0_i32_b32/b64, s_bcnt1_i32_b32/b64, s_ff0_i32_b64, s_ff1_i32_b64, s_flbit_i32_b64 and s_flbit_i32_i64 to
tools/startup/gfx2hlsl.py. The 32-bit s_ff0/s_ff1/s_flbit forms are left to the open PRs that already carry them. The counts set SCC to result != 0; the scans return -1 for no match and leave SCC alone. A 64-bit source must be a register pair up to s105; inline constants, exec/vcc/m0, lane-mask data and modifiers are refused.Verification:
python3 -B tests/startup_gfx2hlsl_s_bit_scan_check.pyon this branch: PASS (every opcode against an integer reference over edge values and every single-bit and single-hole 64-bit pattern).tools/startup/gfx2hlsl.pyfromorigin/main: fails withUnsupported: s_bcnt0_i32_b32.python3 -B tests/startup_gfx2hlsl_bit_alu_check.py,tests/startup_gfx2hlsl_b64_shift_check.py,tests/startup_gfx2hlsl_capture_check.py: pass.startup_gfx2hlsl_s_bit_scanin CMakeLists.txt. Not run on Win2025 (Python-only change).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:06:02Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
a3184b26adℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:59:44Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:01:24Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
a3184b2ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:06:02Z.
Code review location:
CMakeLists.txt; line 2328The startup translator now accepts eight scalar count/scan forms, but this commit updates neither
README.mdnordocs/experiments.md. The existing scalar-bit experiment notes cover other translators, so they do not describe these handlers' register-only/no-lane-mask restrictions or the new reproduction test. RootAGENTS.mdexplicitly requires a documentation update when a public capability changes; add an experiment entry with the supported scope,python3 -B tests/startup_gfx2hlsl_s_bit_scan_check.py, and the CPU-only validation boundary.AGENTS.md reference: AGENTS.md:L211-L212
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:59:44Z.
Code review location:
CMakeLists.txt; line 2328Added an experiment entry in
docs/experiments.md("Startup scalar bit counts and scans") in720cd5e1: supported scope, register-only/no-lane-mask limits, the reproduction commandpython3 -B tests/startup_gfx2hlsl_s_bit_scan_check.py, and the CPU-only validation boundary (no WARP readback yet). Branch rebased on origin/main; push pending.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:01:47Z.
Code review location:
CMakeLists.txt; line 2328Re-checked on current head
37865d85: the scalar bit-count and scan capability is documented in docs/experiments.md. Resolving. AI-assisted; commands listed were executed locally.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:01:47Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:52:00Z.
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is.
We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T23:51:52Z.
Review: CHANGES_REQUESTED
Windows Release at
8bb32249,ctest --preset release --no-tests=error -j 1 -R '^startup_gfx2hlsl_s_bit_scan($|_)' -V, passed the host test but failed both the WARP and RTX 4060 Laptop draws before reaching DXC. On the first FXCs_bcnt0_i32_b32case the expected words are00000020,00000000,0000001f,00000013; both adapters read four zeros with the debug layer enabled and no warnings. The fixture currently exports these small integers as subnormal float bit patterns. Please encode the scalar result using a transport that preserves all its bits through the existing float MRT, or use an integer readback, then rerun both compilers on both backends. Include a wrong-count control that trips the readback.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T00:40:07Z.
Review: APPROVED
The previous head still produced zeros on both adapters. At
73f69a60, the source-built draw XORs each bit result with0x3f000000before the float render target. The transformation keeps every expected word finite and preserves a distinct bit pattern for each result. Windows Release passed 3/3 with no skips (ctest --preset release --no-tests=error -j 1 -R '^startup_gfx2hlsl_s_bit_scan($|_)' -V). Both FXC and DXC matched on WARP and RTX 4060 Laptop, debug layer enabled. The wrong-count oracle failed by the named readback mismatch on both compilers and both adapters. The integer host tests still cover the SCC behavior.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:04:06Z.
@MasterDomino: #2072 is ready for review/merge at head
73f69a60(73f69a6042b70b975047f4c80c83c063be22da7c).What changed since the last head:
maintwice (merge commits, no force-push; the only conflict was a keep-both line in the Linux check list).startup_gfx2hlsl_s_bit_scan_warp/_hardwarerun all eight forms (s_bcnt0/1 b32/b64, s_ff0/ff1 b64, s_flbit b64/i64) as a pixel stage and compare the read-back words with the integer reference (FXC 5_1 and DXC 6_0), with a wrong-expectation control that must fail.73f69a60also carries the float-render-target carry fix pushed by R0Y00; the receipt below is on that exact head.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
73f69a6042b70b975047f4c80c83c063be22da7c:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):1.16s(configure2.04s)ctest --preset dev -R '^startup_gfx2hlsl_s_bit_scan(_warp)?$' --parallel 6 --no-tests=error --output-on-failure): 2/2 passed (7.32s:startup_gfx2hlsl_s_bit_scan0.30s,startup_gfx2hlsl_s_bit_scan_warp7.10s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):7.33s(configure2.25s)ctest --preset release -R '^startup_gfx2hlsl_s_bit_scan(_warp)?$' --parallel 6 --no-tests=error --output-on-failure): 2/2 passed (5.81s:startup_gfx2hlsl_s_bit_scan0.14s,startup_gfx2hlsl_s_bit_scan_warp5.69s)tests/mesh_heap_sampler_check.pyok (0.6s),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.4s),tests/startup_compute_store_format_xyzw_check.pyok (0.2s),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.2s),tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.2s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.0s),tests/startup_gfx2hlsl_f32_nan_check.pyok (4.0s),tests/startup_gfx2hlsl_fma_mix_check.pyok (0.1s),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_interp_p2_hi_check.pyok (0.2s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.2s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_data_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.1s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.2s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (2.0s),tests/startup_gfx2hlsl_pack_b32_f16_check.pyok (0.1s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.1s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.1s),tests/startup_gfx2hlsl_refusals_check.pyok (0.5s),tests/startup_gfx2hlsl_root_check.pyok (0.6s),tests/startup_gfx2hlsl_s_bitset_check.pyok (0.1s),tests/startup_gfx2hlsl_sad_check.pyok (0.3s),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.2s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.2s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.1s),tests/startup_gfx2hlsl_shift64_check.pyok (0.2s),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 (4.6s),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.2s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (3.6s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.4s),tests/startup_image_2d_array_check.pyok (0.1s),tests/startup_image_3d_check.pyok (0.1s),tests/startup_image_gather_lz_check.pyok (0.5s),tests/startup_image_load_d16_check.pyok (0.8s),tests/startup_image_sample_a16_check.pyok (0.2s),tests/startup_image_sample_b_check.pyok (0.2s),tests/startup_image_sample_c_check.pyok (0.2s),tests/startup_image_sample_l_check.pyok (0.1s),tests/startup_image_sample_lod_check.pyok (0.5s),tests/startup_inline_sampler_check.pyok (0.1s),tests/startup_mesh57_loop_refusal_check.pyok (0.1s),tests/startup_mesh57_skeleton_check.pyok (0.4s),tests/startup_run_ps1_check.pyok (11.3s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.1s),tests/startup_shader_cache_rekey_check.pyok (2.1s),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: 4/6 hits; wall70.3sAI-assisted; commands listed were executed locally.