pixel_aot: build export16 on the integer binary16 helpers #2709
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2717"
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 Ybucaille on 2026-11-26T03:23:28Z.
Refs #614
Change
export16in thepixel_aotpreamble rounds a binary32 toward zero to a binary16 and widens it again. It used the driver conversionsf32tof16/f16tof32, and NVIDIA's Vulkan compiler foldsf16tof32(f32tof16(x))intox. The correction step then compares the input with itself, so the rounding is lost:draw-core-vulkanon NVIDIA read3e14a000instead of3e148000at pixel x=16 (reported on #614 and #2297).It now uses the preamble's integer helpers:
narrow16(round to nearest even, from the encoding) andwiden16, then steps the half back by one when it exceeds the input in magnitude. That is the same algorithm as before, but no driver conversion is left to fold.export16moves belownarrow16so HLSL sees the declarations in order.Edge cases, by reasoning: ±0 keeps its sign (no step); a value rounding up into the next binade steps back to the largest half of the lower binade; a finite value of 65520 or more gives
0x7c00then0x7bff(65504), as before; infinity stays infinity. Subnormal halves are exact, becausewiden16cannot flush them.Test
tests/pixel_aot_check.py draw-core-vulkan <dxc> <device>(Linux, DXC 1.10.2605.37):--allow-denorm-mismatchpixel_mismatch x=16 y=0--allow-denorm-mismatchNegative control: with the step-back line removed, Intel exits 1 with
pixel_mismatch x=16 y=0, so the draw does check the rounding.Not run here: the D3D12
draw-coreon Windows. A Windows Release run ofpixel_aot_warp/pixel_aot_hardware(draw-core) would confirm that WARP and a GPU still match bit for bit; the reference values do not change, since the algorithm is the same.docs/experiments.md: the Vulkan section now states the cause instead of a hypothesis.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:32:16Z.
Review: COMMENTED
Review of head
861f1deb(comment only).Checked:
export16now usesnarrow16(round to nearest even) andwiden16, then steps the half back by one when it exceeds the input in magnitude. Round-to-nearest-even is at most one step above the truncated value, so this gives round toward zero. Walked the edge cases: +/-0 (no step), round up into the next binade, finite value >= 65520 (0x7c00 -> 0x7bff = 65504), infinity (stays infinity), negative sign bit kept. All match the PR text.export16is moved belownarrow16/widen16, so HLSL sees the declarations in order.export16(mesh_shadow_check, mesh_lit_check, pixel_sample_lod_check, pixel_sample_offset_check, pixel_aot_check) use the preamble, so they exercise the new code.Commands run (Linux, PR head merged with current main, clean merge):
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: okpython3 tests/bidi_controls_check.py: okNot run here: DXC mutation of the helper (no DXC on this host). Behavior is guarded by the existing D3D12 WARP pixel_aot tests; Windows WARP run follows.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:44:24Z.
Win2025 WARP receipt for head
861f1deb(PR head, 3 behind main).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
861f1debbf6b0253c2dfeb6bcc67cac298d6088c:--preset dev):cmake --build --preset dev --target offscreen_check -- -j 2):87.90s(configure21.37s)ctest --preset dev -R '^(pixel_aot|pixel_sample|mesh_shadow|mesh_lit|pixel_compare)' --parallel 2 --no-tests=error --output-on-failure): 206/206 passed (252.28s:pixel_aot_bits_warp12.96s,pixel_aot_warp13.27s,pixel_aot_three_way_warp4.72s,pixel_aot_buffer_color_warp4.88s,pixel_aot_core_vector_warp12.13s,pixel_aot_predicate_rounding_warp7.23s,pixel_aot_sample_clamp_controls0.91s,pixel_aot_sample_clamp_compile2.52s,mesh_lit_draw_hardware2.14s,pixel_aot_comparisons_warp11.21s,mesh_lit_fallback_hardware1.90s, `mesh_/O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 2):252.29s(configure3.70s)ctest --preset release -R '^(pixel_aot|pixel_sample|mesh_shadow|mesh_lit|pixel_compare)' --parallel 2 --no-tests=error --output-on-failure): 206/206 passed (179.56s:pixel_aot_bits_warp7.88s,pixel_aot_warp8.23s,pixel_aot_three_way_warp4.11s,pixel_aot_core_vector_warp4.65s,pixel_aot_buffer_color_warp3.68s,pixel_aot_predicate_rounding_warp4.63s,pixel_aot_sample_clamp_controls0.52s,pixel_aot_sample_clamp_compile1.56s,mesh_lit_draw_hardware0.85s,pixel_aot_comparisons_warp4.13s,mesh_lit_fallback_hardware1.04s, `mesh_tests/form_coverage_check.pyok (14.4s),tests/mesh_clip_cull_check.pyok (4.5s),tests/mesh_dynamic_geometry_check.pyok (0.3s),tests/mesh_heap_sampler_check.pyok (0.7s),tests/pso_readiness_check.pyok (0.9s),tests/rdna2_tools_check.pyok (2.8s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.3s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.5s),tests/startup_gfx2hlsl_f32_nan_check.pyok (5.5s),tests/startup_gfx2hlsl_scalar_null_check.pyok (0.3s), `tests/startupsccache: 26/1250 hits; wall605.4sCommands: x2w_pipe.py win2025 2717 --no-skip-build --targets offscreen_check --regex pixel_aot|pixel_sample|mesh_shadow|mesh_lit|pixel_compare (dev + release).
AI-assisted; commands listed were executed locally.