startup: lower cube coordinate operations in gfx2hlsl #2506
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2514"
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 lambirou on 2026-11-25T19:21:25Z.
Problem
Startup shader translation refuses the gfx1013 cube coordinate operations
v_cubeid_f32,v_cubesc_f32,v_cubetc_f32andv_cubema_f32. The refusal census in #1723 lists36, 35 and 35 pairs for the cube group, with no existing
gfx2hlsllowering.Change
tools/startup/gfx2hlsl.py.ConstantFoldAMDGCNCubeIntrinsic: z is the major axis when|z| >= |x|and|z| >= |y|, otherwise y when|y| >= |x|, otherwise x. A face is negative only for anonzero, non-NaN negative coordinate.
v_cubema_f32returns twice the signed major coordinate.clamp, source neg/abs, and reject a missing operand, a non-VGPR destination, andmodifiers other than
clamp. Temporary names are unique across blocks.-0.0on themajor axis. The draw compares all four output words on WARP and hardware.
* 2.0ffactor musteach mismatch.
Verification
Result: 3/3 passed on WARP 10.0.26100.10068 and on an AMD Radeon RX 9060 XT
(driver 32.0.32029.2010, Windows 11 build 26300), with FXC
vs_5_1/ps_5_1and DXCvs_6_0/ps_6_0. The debug layer was unavailable on this host. The full non-hardwarestartup_gfx2hlsl_selection passed 103/103.Limits
census pairs; the archive census itself uses a local cache.
Refs #1723. Original contributions are under the MIT License. AI-assisted implementation and
first verification; the orchestrator reviewed the diff, ran the tests and the hardware draw.
Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-25T19:30:34Z.
@R0Y00 — this PR is ready for maintainer review.
Cube coordinate lowering for #1723. The first planned slice,
s_bitcmp0/1_b32, was already merged, so this takes the next unclaimed cube group (36/35/35 census pairs). It lowersv_cube{id,sc,tc,ma}_f32with LLVM's major-axis and face-sign rules,clamp, source neg/abs, and a source-built draw with swapped-id/sc, tie-order and cubema-factor negative controls.CI is green:
Assemble and translate gfx1013 fixtures,Run platform-independent Python checks on Linux, andBuild and test on Windows. The PR isMERGEABLE/CLEAN. Local validation: 3/3startup_gfx2hlsl_cubeon WARP and RX 9060 XT with FXC and DXC; 103/103 non-hardwarestartup_gfx2hlsl_tests.The limits are in the PR body: NaN coordinates are not drawn, the fixture does not cover every census pair, and this measures the desktop translator rather than gfx1013 hardware.
Requesting review here because this account cannot assign reviewers directly (
RequestReviewsByLoginpermission is refused).Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T19:36:42Z.
For the compute-stage cube item in #2463 I reran the 80-byte, LLVM 15-assembled shader against this PR's translator at
7a2887ba. The fixture dispatches 18 threads: six face interiors, four nonzero tie cases and all eight combinations of signed-zero X/Y/Z. Each thread stores the raw face ID, S, T and signed major axis times two. Both DXC defaults and-Gismatched all 72 result words and 248 sentinel words. For the eight signed-zero inputs the selected face was +Z, with the original X, negated Y and original Z sign bits visible in the coordinates.Windows 11 build 26100.9711, debug layer unavailable. Intel UHD 770 (32.0.101.5973), RTX 4060 (32.0.15.9579) and WARP (10.0.26100.9711) agreed. On each device, swapping X/Y for the face calculation, flipping S, flipping T, clearing the signed major and demoting Z on ties respectively produced 5, 18, 18, 9 and 25 mismatching words. The exact source, oracle and measurement commands are in the standalone compute fixture on this PR head.
AI-assisted with Codex (GPT-6.2 Astra, xhigh).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T20:03:03Z.
The graphics draw and RavenCurseBurg’s separate compute readback give both stage paths a reference. #2035 already carries overlapping cube-coordinate helpers and a separate cube texture sampling change. Please coordinate with its author so there is one implementation for the four operations, keep the compute face/tie/signed-zero fixture and its controls, and leave cube-image sampling in its own slice. Keep any NaN behavior scoped to the evidence you have.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:40:47Z.
Review: COMMENTED
Review of head
c3bb1ee8(comment only).Checked:
tools/startup/gfx2hlsl.pyfollow LLVM'sConstantFoldAMDGCNCubeIntrinsic. I compared face id, sc, tc and ma for all three major axes, and the tie order (z, then y, then x). Negative faces use< 0.0f, so-0.0and NaN are not negative, as the PR states.clamp. Temp names are unique per use.windows.ymlline are added, and the PR's own CI run exercised the changed workflow (all jobs green).* 2.0fin cubema fails the Python control. The tie-order change (>=to>) is not caught by the Python control. It is covered only by the draw test, which the PR describes as its negative control.Commands executed locally:
gh pr update-branch,python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD,python3 -I -B tests/startup_gfx2hlsl_cube_check.py(plain and with two mutations, then reverted).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:40:48Z.
Win2025 WARP receipt for head
c3bb1ee8after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
c3bb1ee8e9db1ef94f8f76aedf927c789858e3d6:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):30.18s(configure2.26s)ctest --preset dev -R '^startup_gfx2hlsl_cube' --parallel 4 --no-tests=error --output-on-failure): 3/3 passed (2.82s:startup_gfx2hlsl_cube_controls0.10s,startup_gfx2hlsl_cube_warp2.68s,startup_gfx2hlsl_cube_hardware2.69s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):69.29s(configure2.05s)ctest --preset release -R '^startup_gfx2hlsl_cube' --parallel 4 --no-tests=error --output-on-failure): 3/3 passed (3.18s:startup_gfx2hlsl_cube_controls0.11s,startup_gfx2hlsl_cube_warp3.02s,startup_gfx2hlsl_cube_hardware3.03s)tests/mesh_heap_sampler_check.pyok (0.7s),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.7s),tests/startup_compute_translate_check.pyok (0.3s),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.2s),tests/startup_gfx2hlsl_bit_alu_check.pyok (0.6s),tests/startup_gfx2hlsl_capture_check.pyok (1.0s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.2s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.4s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.1s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.1s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.2s),tests/startup_gfx2hlsl_f32_nan_check.pyok (4.7s),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_countsccache: -195/-196 hits; wall164.3sAI-assisted; commands listed were executed locally.