Skip to content

shader: lower s_nor_b32 and s_nand_b32 on lane mask in gfx2hlsl (Part of #1723) - #2030

Closed
tedin7 wants to merge 8 commits into
R0Y00:mainfrom
tedin7:x2w-r20-s-nor-nand
Closed

tedin7 wants to merge 8 commits into
R0Y00:mainfrom
tedin7:x2w-r20-s-nor-nand

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1723

What this unblocks: Run 20 census #9 (64/61 pairs).

Source: AMD RDNA 2 instruction set architecture guide, the SOP2 instructions s_nor_b32 and s_nand_b32 (bitwise on the 32-bit scalar operands) and the EXEC / wave32 description (a write to exec_lo in wave64 leaves the high half unchanged).

gfx2hlsl refused s_nor_b32 and s_nand_b32 whenever an operand or the destination was a lane mask. They now lower on a mask when every source is a lane mask: bit i of ~(a op b) depends only on bit i of each source, so the lane's own bit is exact. The destination may be an SGPR (any stage) or exec_lo (only for compute with at most 32 threads per group, the one wave32 proof available; pixel, vertex, mesh and larger compute groups keep refusing it, because a write to exec_lo leaves lanes 32..63 of a wave64 wave unchanged). s_xnor_b32, a vcc_lo or high-half destination, mixed mask and word sources, and s_pack_hh_b32_b16 on a lane mask stay refused.

SCC is not emitted for these forms: translate() refuses a program that can read it.

Changes:

  • tools/startup/gfx2hlsl.py: lane-complement lowering of s_nor_b32 / s_nand_b32 on masks, with the wave32 gate for the exec_lo destination.
  • tests/startup_gfx2hlsl_s_nor_nand_check.py (new, registered in CMakeLists.txt, with _dispatch_warp / _dispatch_hardware D3D12 UAV readback variants): per-bit CPU reference, GPU readback, and stage_checks() for the stage gate.
  • tests/startup_gfx2hlsl_sop2_complement_check.py: refusal checks narrowed to the forms that stay refused; the shared probe is a 32-thread compute stage.
  • docs/experiments.md: the accepted forms and the stage rule.

Verification (head ef54c20a638f7d0ff72dc3747c6a82158273207a):

  • Linux: python3 -B tests/startup_gfx2hlsl_s_nor_nand_check.py, ..._sop2_complement_check.py, ..._waitcnt_depctr_check.py ok. Without the stage gate, s_nor_nand_check fails on the wave64 cases.
  • Win2025 receipt (named tests): see the comment thread (dev 4/4, release 4/4).
  • tested on RTX 3090 through vkd3d-proton (Linux): 4/4 (startup_gfx2hlsl_sop2_complement, startup_gfx2hlsl_s_nor_nand, startup_gfx2hlsl_s_nor_nand_dispatch_warp, startup_gfx2hlsl_s_nor_nand_dispatch_hardware). The warp-named test ran on the GPU there, not on WARP.

AI-assisted; commands listed were executed locally.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T23:33:48.586887Z 117d2fd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 117d2fd03b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread tools/startup/gfx2hlsl.py Resolved
Comment thread tools/startup/gfx2hlsl.py Resolved
Comment thread CMakeLists.txt Resolved
@tedin7
tedin7 force-pushed the x2w-r20-s-nor-nand branch from 117d2fd to 5baadbc Compare November 25, 2026 00:34
@tedin7
tedin7 force-pushed the x2w-r20-s-nor-nand branch from e73b1f0 to 2ebf8dd Compare November 25, 2026 04:08
@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

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.

@tedin7 tedin7 closed this Nov 25, 2026
legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
's nand/nor rules)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Leyukaka

Copy link
Copy Markdown
Contributor

The exec_lo destination of this PR is the first refusal for 23 requests in a local start-up capture (s_nor_b32 exec_lo, <mask>, <mask>, counts only), at main fc97ade. #2459 took the SGPR-destination forms and left a vcc_lo or exec_lo destination refused.

You wrote that you will reopen this once the Windows queue is clear. Since #2459 merged in between, the branch now overlaps it. If you would rather not rebase, I can port the exec_lo part onto current main, with you credited as co-author and the remaining SCC case guarded the way #2459 does. I will leave it until tomorrow, or hand it back as soon as you pick it up.

AI-assisted.

@Leyukaka

Copy link
Copy Markdown
Contributor

Changing my timeline above: I am taking the exec_lo part over now, since there has been no activity on this PR since 13:51. I will port it onto current main with you as co-author, and hand it back if you resume.

AI-assisted.

@tedin7 tedin7 reopened this Nov 25, 2026
@Leyukaka

Copy link
Copy Markdown
Contributor

I see you reopened this at 23:00 UTC, so I am handing the exec_lo part back as promised and will not open a competing PR. If it saves you a rebase over #2459: my port of that part onto fc97ade is commit 482bade0 on branch snor-exec-lo in my fork. It accepts only NAND and NOR into exec_lo with all-mask sources, leaves SCC unmodelled like the SGPR forms, and keeps XNOR, vcc_lo, exec_hi and pairs refused. Your exec_lo cases and the source-bit table are in its test. Use any of it or none.

AI-assisted.

…ith WARP readback test

Merge origin/main (which took the SGPR-destination forms in the sibling change)
and keep only the exec_lo destination, ported from Leyukaka's snor-exec-lo
commit 482bade. Adds a D3D12 UAV readback check for NOR and NAND.

Co-authored-by: Leyukaka <45659323+Leyukaka@users.noreply.github.com>
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 392a40de0685e69fc27c2d78950d95ff9984aa35:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check d3d12_xs_device_obj -- -j 2): 86.67s (configure 0.00s)
    • Test (ctest --preset dev -R '^startup_gfx2hlsl_(s_nor_nand|sop2_complement)' --parallel 4 --no-tests=error --output-on-failure): 4/4 passed (11.26s: startup_gfx2hlsl_s_nor_nand 0.28s, startup_gfx2hlsl_s_nor_nand_dispatch_hardware 0.68s, startup_gfx2hlsl_s_nor_nand_dispatch_warp 0.72s, startup_gfx2hlsl_sop2_complement 11.06s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check d3d12_xs_device_obj -- -j 2): 69.16s (configure 0.00s)
    • Test (ctest --preset release -R '^startup_gfx2hlsl_(s_nor_nand|sop2_complement)' --parallel 4 --no-tests=error --output-on-failure): 4/4 passed (5.74s: startup_gfx2hlsl_s_nor_nand 0.20s, startup_gfx2hlsl_s_nor_nand_dispatch_warp 0.54s, startup_gfx2hlsl_s_nor_nand_dispatch_hardware 0.53s, startup_gfx2hlsl_sop2_complement 5.62s)
  • Windows Python checks: tests/mesh_heap_sampler_check.py ok (0.9s), tests/startup_buffer_address_check.py ok (0.6s), tests/startup_buffer_format_word3_table_check.py ok (0.1s), tests/startup_compute_request_offline_check.py ok (0.7s), tests/startup_compute_store_format_xyzw_check.py ok (0.3s), tests/startup_compute_translate_check.py ok (0.3s), tests/startup_flat_param_check.py ok (0.2s), tests/startup_gfx2hlsl_add_sub_co_check.py ok (0.2s), tests/startup_gfx2hlsl_add_sub_co_ci_check.py ok (0.2s), tests/startup_gfx2hlsl_bit_alu_check.py ok (1.0s), tests/startup_gfx2hlsl_capture_check.py ok (1.4s), tests/startup_gfx2hlsl_cmp16_check.py ok (0.4s), tests/startup_gfx2hlsl_compare_dst_check.py ok (0.1s), tests/startup_gfx2hlsl_compute_check.py ok (0.6s), tests/startup_gfx2hlsl_cselect_mask_check.py ok (0.1s), tests/startup_gfx2hlsl_cvt_alu_check.py ok (0.3s), tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py ok (0.3s), tests/startup_gfx2hlsl_cvt_pk_int16_check.py ok (0.4s), tests/startup_gfx2hlsl_f32_lg_check.py ok (1.9s), tests/startup_gfx2hlsl_f32_nan_check.py ok (8.2s), tests/startup_gfx2hlsl_fma_mix_check.py ok (0.1s), tests/startup_gfx2hlsl_getpc_refusal_check.py ok (0.1s), tests/startup_gfx2hlsl_handler_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_get_lod_check.py ok (0.2s), tests/startup_gfx2hlsl_int_med3_check.py ok (0.2s), tests/startup_gfx2hlsl_interp_p2_hi_check.py ok (0.3s), tests/startup_gfx2hlsl_join_symbols_check.py ok (0.3s), tests/startup_gfx2hlsl_loop_constants_check.py ok (0.1s), tests/startup_gfx2hlsl_mask_data_check.py ok (0.1s), tests/startup_gfx2hlsl_mask_overwrite_check.py ok (0.1s), tests/startup_gfx2hlsl_operand_count_check.py ok (0.5s), tests/startup_gfx2hlsl_pack_absdiff_check.py ok (4.3s), tests/startup_gfx2hlsl_pack_b32_f16_check.py ok (0.2s), tests/startup_gfx2hlsl_readfirstlane_recompute_check.py ok (0.2s), tests/startup_gfx2hlsl_readfirstlane_uniform_check.py ok (0.2s), tests/startup_gfx2hlsl_refusals_check.py ok (0.9s), tests/startup_gfx2hlsl_root_check.py ok (1.2s), tests/startup_gfx2hlsl_s_nor_nand_check.py ok (0.2s), tests/startup_gfx2hlsl_sad_check.py ok (0.5s), tests/startup_gfx2hlsl_saveexec_same_reg_check.py ok (0.1s), tests/startup_gfx2hlsl_scalar_arity_check.py ok (0.3s), tests/startup_gfx2hlsl_scalar_brev_fold_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_m0_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_table_arity_check.py ok (0.4s), tests/startup_gfx2hlsl_sdwa_cvt_check.py ok (0.4s), tests/startup_gfx2hlsl_sgpr_spill_check.py ok (0.2s), tests/startup_gfx2hlsl_shift64_check.py ok (0.3s), tests/startup_gfx2hlsl_sload_const_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_smem_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_sop2_complement_check.py ok (9.3s), tests/startup_gfx2hlsl_sopk_accum_check.py ok (1.5s), tests/startup_gfx2hlsl_sopk_signext_check.py ok (0.3s), tests/startup_gfx2hlsl_swap_check.py ok (0.6s), tests/startup_gfx2hlsl_vopc_sdwa_check.py ok (7.3s), tests/startup_gfx2hlsl_waitcnt_depctr_check.py ok (0.2s), tests/startup_gfx2hlsl_watch_check.py ok (3.1s), tests/startup_image_2d_array_check.py ok (0.3s), tests/startup_image_3d_check.py ok (0.3s), tests/startup_image_gather_lz_check.py ok (0.9s), tests/startup_image_load_d16_check.py ok (1.7s), tests/startup_image_sample_a16_check.py ok (0.4s), tests/startup_image_sample_b_check.py ok (0.3s), tests/startup_image_sample_c_check.py ok (0.3s), tests/startup_image_sample_l_check.py ok (0.3s), tests/startup_image_sample_lod_check.py ok (0.9s), tests/startup_inline_sampler_check.py ok (0.2s), tests/startup_mesh57_loop_refusal_check.py ok (0.3s), tests/startup_mesh57_skeleton_check.py ok (0.7s), tests/startup_run_ps1_check.py ok (19.0s), tests/startup_run_sh_check.py skipped (0.1s), tests/startup_sampler_heap_check.py ok (0.2s), tests/startup_shader_cache_rekey_check.py ok (3.5s), tests/startup_smem_address_check.py ok (0.2s), tests/startup_stream_fetch_check.py ok (0.3s), tests/startup_stream_interface_check.py ok (0.3s), tests/startup_translator_check.py ok (0.7s)
  • sccache: 10/119 hits; wall 252.5s

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

@MasterDomino ready for review/merge: head 392a40de, CI green, Win2025 WARP dev+release receipt on this exact head posted above.

@Leyukaka thank you for the exec_lo port. #2459 took the SGPR-destination forms, so I merged main (merge commit, no force-push), kept main's lowering and brought over only your exec_lo destination from 482bade0, with you as co-author. SCC is not modelled, as in the SGPR forms, and vcc_lo, exec_hi, pairs and XNOR into exec_lo stay refused. I replaced the old per-lane test with startup_gfx2hlsl_s_nor_nand plus _dispatch_warp and _dispatch_hardware: a D3D12 UAV readback of NOR and NAND into exec_lo and an SGPR over every pair of source bits, against an integer reference. Your exec_lo cases in startup_gfx2hlsl_sop2_complement stay.

Verification (Win2025, head 392a40de): ctest --preset dev and --preset release with -R '^startup_gfx2hlsl_(s_nor_nand|sop2_complement)': 4/4 passed each. Linux: python3 -B tests/startup_gfx2hlsl_s_nor_nand_check.py and tests/startup_gfx2hlsl_sop2_complement_check.py pass.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 9d9dbe9147256a3d1223e7cfb61803c985c31c9a:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2): 6.52s (configure 2.53s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2): 1.80s (configure 3.94s)
  • Windows Python checks: tests/mesh_heap_sampler_check.py ok (1.1s), tests/startup_buffer_address_check.py ok (0.8s), tests/startup_buffer_format_word3_table_check.py ok (0.1s), tests/startup_compute_request_offline_check.py ok (0.9s), tests/startup_compute_store_format_xyzw_check.py ok (0.5s), tests/startup_compute_translate_check.py ok (0.4s), tests/startup_flat_param_check.py ok (0.3s), tests/startup_gfx2hlsl_add_sub_co_check.py ok (0.2s), tests/startup_gfx2hlsl_add_sub_co_ci_check.py ok (0.3s), tests/startup_gfx2hlsl_bit_alu_check.py ok (1.3s), tests/startup_gfx2hlsl_capture_check.py ok (1.9s), tests/startup_gfx2hlsl_cmp16_check.py ok (0.5s), tests/startup_gfx2hlsl_cmp_class_f16_sdwa_check.py ok (48.4s), tests/startup_gfx2hlsl_compare_dst_check.py ok (0.1s), tests/startup_gfx2hlsl_compute_check.py ok (0.5s), tests/startup_gfx2hlsl_cselect_mask_check.py ok (0.1s), tests/startup_gfx2hlsl_cvt_alu_check.py ok (0.2s), tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py ok (0.3s), tests/startup_gfx2hlsl_cvt_pk_int16_check.py ok (0.3s), tests/startup_gfx2hlsl_f32_lg_check.py ok (1.6s), tests/startup_gfx2hlsl_f32_nan_check.py ok (6.4s), tests/startup_gfx2hlsl_fma_mix_check.py ok (0.1s), tests/startup_gfx2hlsl_getpc_refusal_check.py ok (0.1s), tests/startup_gfx2hlsl_handler_arity_check.py ok (0.2s), tests/startup_gfx2hlsl_heap_record_check.py ok (0.3s), tests/startup_gfx2hlsl_image_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_get_lod_check.py ok (0.2s), tests/startup_gfx2hlsl_int_med3_check.py ok (0.1s), tests/startup_gfx2hlsl_interp_p2_hi_check.py ok (0.3s), tests/startup_gfx2hlsl_join_symbols_check.py ok (0.3s), tests/startup_gfx2hlsl_loop_constants_check.py ok (0.1s), tests/startup_gfx2hlsl_mask_data_check.py ok (0.1s), tests/startup_gfx2hlsl_mask_overwrite_check.py ok (0.1s), tests/startup_gfx2hlsl_operand_count_check.py ok (0.4s), tests/startup_gfx2hlsl_pack_absdiff_check.py ok (3.0s), tests/startup_gfx2hlsl_pack_b32_f16_check.py ok (0.2s), tests/startup_gfx2hlsl_readfirstlane_recompute_check.py ok (0.1s), tests/startup_gfx2hlsl_readfirstlane_uniform_check.py ok (0.2s), tests/startup_gfx2hlsl_refusals_check.py ok (0.8s), tests/startup_gfx2hlsl_root_check.py ok (1.0s), tests/startup_gfx2hlsl_s_abs_check.py ok (0.1s), tests/startup_gfx2hlsl_s_bitset_check.py ok (0.1s), tests/startup_gfx2hlsl_s_ff0_check.py ok (0.1s), tests/startup_gfx2hlsl_s_ff1_check.py ok (0.1s), tests/startup_gfx2hlsl_s_flbit_check.py ok (0.1s), tests/startup_gfx2hlsl_s_nor_nand_check.py ok (0.2s), tests/startup_gfx2hlsl_s_quadmask_check.py ok (0.1s), tests/startup_gfx2hlsl_sad_check.py ok (0.4s), tests/startup_gfx2hlsl_saveexec_same_reg_check.py ok (0.1s), tests/startup_gfx2hlsl_scalar_arity_check.py ok (0.3s), tests/startup_gfx2hlsl_scalar_brev_fold_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_m0_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_null_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_table_arity_check.py ok (0.5s), tests/startup_gfx2hlsl_sdwa_cndmask_check.py ok (0.3s), tests/startup_gfx2hlsl_sdwa_cvt_check.py ok (0.3s), tests/startup_gfx2hlsl_sgpr_spill_check.py ok (0.2s), tests/startup_gfx2hlsl_shift64_check.py ok (0.2s), tests/startup_gfx2hlsl_sload_const_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_smem_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_sop2_complement_check.py ok (7.1s), tests/startup_gfx2hlsl_sopk_accum_check.py ok (1.2s), tests/startup_gfx2hlsl_sopk_signext_check.py ok (0.2s), tests/startup_gfx2hlsl_spill_branches_check.py ok (1.2s), tests/startup_gfx2hlsl_swap_check.py ok (0.4s), tests/startup_gfx2hlsl_vopc_sdwa_check.py ok (6.1s), tests/startup_gfx2hlsl_waitcnt_depctr_check.py ok (0.1s), tests/startup_gfx2hlsl_watch_check.py ok (2.9s), tests/startup_image_2d_array_check.py ok (0.2s), tests/startup_image_3d_check.py ok (0.2s), tests/startup_image_gather_lz_check.py ok (0.8s), tests/startup_image_load_d16_check.py ok (1.4s), tests/startup_image_sample_a16_check.py ok (0.3s), tests/startup_image_sample_b_check.py ok (0.3s), tests/startup_image_sample_c_check.py ok (0.3s), tests/startup_image_sample_l_check.py ok (0.3s), tests/startup_image_sample_lod_check.py ok (0.9s), tests/startup_inline_sampler_check.py ok (0.2s), tests/startup_mesh57_depth_only_check.py ok (0.3s), tests/startup_mesh57_lane_spill_check.py ok (0.3s), tests/startup_mesh57_loop_check.py ok (0.3s), tests/startup_mesh57_loop_refusal_check.py ok (0.2s), tests/startup_mesh57_skeleton_check.py ok (1.9s), tests/startup_run_ps1_check.py ok (16.6s), tests/startup_run_sh_check.py skipped (0.1s), tests/startup_sampler_heap_check.py ok (0.2s), tests/startup_shader_cache_rekey_check.py ok (3.2s), tests/startup_smem_address_check.py ok (0.2s), tests/startup_stream_fetch_check.py ok (0.3s), tests/startup_stream_interface_check.py ok (0.3s), tests/startup_translator_check.py ok (0.6s)
  • sccache: 1314/1415 hits; wall 151.1s

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

@MasterDomino: #2030 is ready for review/merge.

What changed: merged current main into the branch (one conflict in tools/startup/gfx2hlsl.py, kept both the address-carry handling from main and the lane-mask complement SCC refusal from this PR). New head 9d9dbe91.

Verification:

  • python3 tests/startup_gfx2hlsl_s_nor_nand_check.py ok
  • python3 tests/startup_gfx2hlsl_sop2_complement_check.py PASS
  • CI on 9d9dbe91: Linux checks, gfx1013 fixtures and Windows build all pass
  • Win2025 WARP dev + release PASS on 9d9dbe9147256a3d1223e7cfb61803c985c31c9a (receipt in the comment above)

AI-assisted; commands listed were executed locally.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The four-bit-pair fixtures passed on WARP and RTX, but the new EXEC_LO form is accepted by the mesh-stage lowering too. The slot 57 profile is known wave64. A probe with kind=ms and two marked mask sources emits exec = (~(s1 | s2)) & 1 for s_nor_b32 exec_lo, s1, s2 and likewise for NAND, so upper lanes are changed even though the instruction only writes EXEC_LO. Please require a proven wave32 mask for the new EXEC_LO forms, or explicitly preserve lanes 32–63 in wave64. Add a case with an active upper lane and an inactive low lane result so the current lowering fails. The existing SCC-read refusals should remain.

@MasterDomino MasterDomino left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 9d9dbe91. I agree with @R0Y00's open change request.

The exec_lo destination is accepted for every stage kind. A unit probe with kind='ms' (slot 57 mesh is wave64) and two marked mask sources emits exec = (~(s1 | s2)) & 1; for s_nor_b32 exec_lo, s1, s2, and NAND does the same. That write also changes lanes 32–63 of a wave64 wave.

  • What to change: accept the exec_lo destination only for a proven wave32 stage: pixel, or compute with at most 32 threads per group, as the b32 waterfall close already requires (gfx2hlsl.py:~2606).
  • Test: add the upper-lane case R0Y00 asked for.
  • Related: existing s_and_b32 / s_or_b32 / s_mov_b32 writes into exec_lo show the same behaviour in that probe. That can be a separate issue.

The branch also conflicts with main since #2580, in tools/startup/gfx2hlsl.py, where main's mark_heap_index call follows set_s. Keeping that call and dropping the moved lane_complement block should resolve it. Please also refresh the PR description: it still says a vcc_lo destination is accepted and that SCC uses the per-lane projection, and the code now refuses both.

Otherwise the lane semantics look right:

  • NOR/NAND bit i depends only on bit i of each source.
  • Compare masks are zero in inactive lanes, and VGPR writes are guarded after the exec write, so a reactivated lane computes the hardware bit.
  • SCC isn't emitted, and a later read of it is refused.

No cache revision bump is needed: 60 of 72 probe programs translate identically on main and on this head, and the 12 that differ were refused on main.

Runs: Windows 11 build 26300; AMD Radeon RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818.

  • Targeted: ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_(s_nor_nand|sop2_complement)' 4/4, including dispatch on WARP and hardware.
  • Neighbours: ctest -R startup_gfx2hlsl 252/253. The failure, startup_gfx2hlsl_fma_mix_dispatch_hardware, also fails on main on this GPU (#2746).
  • Mutants: five one-line mutants are each caught by startup_gfx2hlsl_sop2_complement: XNOR into exec_lo, a vcc_lo destination into exec_lo, mixed sources into exec_lo, SCC emitted, and scc_effect dropped. The new s_nor_nand check itself catches none of them; it covers only accepted forms and the readback.

AI-assisted; commands listed were executed locally.

… proven wave32 stage

Merge main (keep mark_heap_index and the salu_align4 write); refuse the exec_lo
destination in mesh, vertex and wave64 compute stages; add stage cases to the
s_nor_nand check and a pixel-stage default to the shared probe.
c1 added 2 commits November 26, 2026 07:45
…reads

The wave size of a pixel or vertex stage is unknown to the translator, so only
compute with at most 32 threads per group is proven wave32.
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

@MasterDomino @R0Y00 thanks, both points are addressed at ef54c20a638f7d0ff72dc3747c6a82158273207a.

  1. exec_lo destination in a wave64 stage. s_nor_b32 / s_nand_b32 into exec_lo is now accepted only for compute with at most 32 threads per group, the same proof the b32 waterfall close uses (gfx2hlsl.py, next to mask_source). The slot 57 mesh stage, vertex stages and compute groups above 32 threads refuse it with ... on a lane mask. I did not include pixel: the translator has no wave size proof there (require_spill_lanes_apart says "the wave size is unknown" for ps/vs), so I kept it refused rather than assume wave32. If you want pixel accepted, tell me what proves it and I will add that proof.
  2. Test. startup_gfx2hlsl_s_nor_nand_check.py gains stage_checks(): both opcodes into exec_lo for ps, vs, ms, cs of 64 and 8x8 threads (refused) and cs of 32 and 8x4 threads (accepted), plus the s3 destination staying accepted in a mesh stage. Without the gate this check fails (the wave64 cases are accepted); with it, it passes. The shared Probe in startup_gfx2hlsl_sop2_complement_check.py is now a 32-thread compute stage, so the existing accepted-form cases keep their meaning.
  3. Conflict with main. Merged origin/main, kept main's mark_heap_index call and the salu_align4 write, dropped the moved lane_complement block.
  4. Description. Refreshed: vcc_lo and SCC reads are refused, and the stage rule above. docs/experiments.md states the wave32 requirement.
  5. Related s_and_b32 / s_or_b32 / s_mov_b32 into exec_lo. Left for a separate issue, as you suggested.

Linux, from the worktree at this head: python3 -B tests/startup_gfx2hlsl_s_nor_nand_check.py ok; python3 -B tests/startup_gfx2hlsl_sop2_complement_check.py ok; python3 -B tests/startup_gfx2hlsl_waitcnt_depctr_check.py ok; every tests/startup_gfx2hlsl_*_check.py passes except the two draw checks that need DXC arguments (export_null_draw, mul24_align_draw).

The Win2025 receipt (named tests) follows in an edit to this comment.

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 requested a review from MasterDomino November 26, 2026 07:58
@tedin7
tedin7 requested a review from R0Y00 November 26, 2026 07:58
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Win2025 receipt at ef54c20a638f7d0ff72dc3747c6a82158273207a (Windows Server 2025 build 26100, MSVC 14.44.35207, D3D12 WARP), tests run by name:

  • ctest --preset dev -R '^(startup_gfx2hlsl_s_nor_nand|startup_gfx2hlsl_sop2_complement)' --no-tests=error: 4/4 passed: startup_gfx2hlsl_s_nor_nand, startup_gfx2hlsl_s_nor_nand_dispatch_warp, startup_gfx2hlsl_s_nor_nand_dispatch_hardware, startup_gfx2hlsl_sop2_complement.
  • ctest --preset release with the same regex: 4/4 passed, same four tests.

@MasterDomino @R0Y00 ready for another look.

AI-assisted; commands listed were executed locally.

@MasterDomino MasterDomino left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving ef54c20a. My change request at 9d9dbe91 is addressed.

  1. exec_lo destination. NOR/NAND into exec_lo is now accepted only for compute groups of at most 32 threads (wave32_stage), where lanes 32..63 hold no thread. Pixel, vertex, mesh and larger compute groups refuse it.
    • Mutant: with the gate forced on (wave32_stage = True or ...), startup_gfx2hlsl_s_nor_nand_check.py fails on the new stage_checks(): the ps, cs (64, 1, 1) and cs (8, 8, 1) cases are no longer refused.
    • Pixel: keeping it refused without a wave-size proof is the right call.
  2. Conflict and description: resolved and refreshed. The branch merges cleanly onto current main, and CI is green at the head.

No cache revision bump is needed: main refuses these exec_lo forms, and this head only adds translations for compute groups of at most 32 threads.

Commands, on Windows 11 build 26300, at ef54c20a: python -B tests/startup_gfx2hlsl_{s_nor_nand,sop2_complement,compute,mask_overwrite}_check.py, all exit 0.

@R0Y00, the head now enforces the wave32 requirement from your change request. If you agree, please clear it and I'll merge (or merge it yourself).

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

@R0Y00 the change request of 2026-11-26 05:50Z (on 9d9dbe9: s_nor_b32 / s_nand_b32 into exec_lo accepted in the mesh stage, which is wave64) has been addressed at head ef54c20a:

  • exec_lo as the destination is now accepted only for compute with at most 32 threads per group, the one wave32 proof available. Pixel, vertex, mesh (slot 57) and larger compute groups refuse it, so lanes 32..63 of a wave64 wave are never changed (9b326a3, f802206, ef54c20).
  • A bare probe with no stage is treated as a pixel stage by the gate.
  • Without the stage gate, startup_gfx2hlsl_s_nor_nand fails on the wave64 cases; the SCC-read refusals are unchanged.
  • Win2025 at ef54c20a: dev 4/4 and release 4/4 passed, tests run by name (receipt in this thread).
  • Real GPU (RTX 3090 through vkd3d-proton, Linux): 4/4.
  • MasterDomino approved this head on 2026-11-26 08:03Z; CI is green.

Please re-review this head, or dismiss the old change request if you agree it is resolved.

AI-assisted; commands listed were executed locally.

@MasterDomino

Copy link
Copy Markdown
Collaborator

@tedin7, ef54c20a now conflicts with main (700522ef) in tools/startup/gfx2hlsl.py, after #2736 and the other recent translator merges. Could you merge main again? I'll re-check the new head (the s_nor_nand / sop2_complement checks and the wave32-gate mutant). This PR needs no cache bump, so no revision line should move.

The merge also still needs @R0Y00 to re-review or dismiss his change request at 9d9dbe91.

AI-assisted.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Withdrawn: shader translation is moving to the native C++ frontend (see #870), so we are not continuing this change to the Python translator. The branch stays available if any part is useful later. Thank you to everyone who reviewed and tested it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants