translator: keep integer words in flat parameters #1255
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1262"
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 Jess-Doit on 2026-11-24T06:02:42Z.
Change
Refs #1259. This is the flat-parameter half; colour exports stay open there.
tools/startup/gfx2hlsl.pycopied a flat parameter asnointerpolation float4 fparam<n>, set too.param<n>after the float export, andv_interp_mov_f32read it back withasuint. The--pendingpath compiles with FXCvs_5_1/ps_5_1. FXC foldsasfloat()of a constant and flushes binary32 denormal patterns to 0, so constant integer words such as 1, 2 or0x80000001reached the pixel stage as 0.Now:
exp param<n>also writeso.fparam<n> = uint4(<the exported registers>), with no float conversion. Acomprexport writes the bits of its unpacked halves.hlsl_vs()drops that line for attributes the pixel stage reads only interpolated, so those get no flat copy, as before.nointerpolation uint4 fparam<n> : FPARAM<n>in both stages. The rectangle-list fourth corner still copies the first vertex's flat words.v_interp_mov_f32readsi.fparam<n>.<c>directly.Interpolated parameters (
v_interp_p1/p2) are unchanged.Fixture
tests/startup_flat_param_check.pyuses a source-built gfx1013 pair, recorded as words and as assembly:1,2,0x7fc00001and0x80000001toparam0. As binary32 these are three denormals and a NaN with a payload.v_interp_mov_f32 ... p0, attr0.x..wand exports them tomrt0.Controls (no arguments):
v6–v9, with noU()on the read;attr0.xonly throughv_interp_p1/p2gets nofparam0in either stage.binary <llvm-mc>: the three sources reassemble to the recorded words. This is added to the gfx1013 CI job.draw:offscreen_check --startup-flat-param(tests/startup_flat_param.cpp) draws one pixel with the translated pair intoR32G32B32A32_FLOATand compares the four words. It runs with FXC5_1when available and with DXC6_0:00000001,00000002,7fc00001,8000000100000000,00000000,7fc00001,00000000(the negative control)The run-time words are
word + ((vid >> 31) << 23). A plain+ (vid >> 31)is not enough: FXC finds that1 + (vid >> 31)is always a denormal and flushes it anyway.Verification
Tested
588e8777(on48b31812) on Windows 10 22H219045.6456with a GTX 1060 6 GB (10de:1c03, driver32.0.15.6094) and in-box WARP (1414:008c,10.0.19041.5794), using FXC and DXC from Windows SDK10.0.26100.0. The D3D12 debug layer was enabled and reported 0 errors and 0 warnings on every draw.Debug and Release each passed all 13 selected tests, with no skips:
startup_flat_param_{controls,warp,hardware}, and the existing translated-shader testsstartup_sampler_heap_*,startup_stream_{request,draw}_*andstartup_r8_uint_*.In the first run the two flat-parameter draws failed because of the fixture itself: its vertex stage put all three vertices at one point, so nothing was drawn. After that fix, which changed only the test script,
startup_flat_param_*was run again in both configurations and passed 3/3. The other 11 tests passed in the first run, with the same build. Flat-parameter output, the same on both adapters and in both configurations:The binary check passed with a local LLVM 23.1.6
llvm-mc. CI runs it with LLVM 15.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:18:09Z.
Review: COMMENTED
Reviewed at commit
a578b0b82a873125f3088bd4e572a06771f1a38e.Verification
Linux
git diff --check origin/main...HEAD— cleantests/docs_links_check.py— passed (16 Markdown files, 284 links)tests/bidi_controls_check.py— passed (1067 tracked files)tests/startup_flat_param_check.py— passed (controls + interpolated-only omission)LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so tests/startup_flat_param_check.py binary /usr/bin/llvm-mc-19— passed (fixture words match llvm-mc)Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP)
--preset dev):cmake --build --preset dev --target offscreen_check -- -j 6— built cleanly (23.49s)ctest --preset dev -R '^startup_flat_param_' --parallel 4 --no-tests=error --output-on-failure— 3/3 passed (startup_flat_param_controls0.17s,startup_flat_param_warp0.84s,startup_flat_param_hardware0.85s; total0.89s)/O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 6— built cleanly (23.93s)ctest --preset release -R '^startup_flat_param_' --parallel 4 --no-tests=error --output-on-failure— 3/3 passed (startup_flat_param_controls0.18s,startup_flat_param_warp0.80s,startup_flat_param_hardware0.82s; total0.87s)Code Review Notes
tools/startup/gfx2hlsl.py: Emittingo.fparam<n> = uint4(...)directly from the exported register words (andU(f16tof32(...))forcompr), declaringnointerpolation uint4 fparam<n> : FPARAM<n>, and readingi.fparam<n>.<c>inop_v_interp_mov_f32cleanly avoids FXC constant-foldingasfloat()and flushing binary32 denormal bit patterns to 0.hlsl_vs()filters outo.fparam<n> =lines for attributes not inself.flat, preserving the existing behavior where purely interpolated parameters emit no flat copy.tests/startup_flat_param_check.py+tests/startup_flat_param.cpp: Strong positive and negative controls (including the pre-fixfloat4copy with constant words vs. run-time words under FXC 5_1 and DXC 6_0).Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T06:19:57Z.
Merged current main into the branch as
a578b0b8to clear the conflicts with #1244 and #1258. All six were in registration lists (CI,AGENTS.md, CMake, docs,desktop_gpu.h,offscreen_check.cpp). The diff againstmainis the same as the original PR, andgfx2hlsl.pymerged without conflicts.Retested
a578b0b8on the same host and adapters as the PR body, with the same build andctestfilter. Debug and Release each passed 13/13, with no skips and 0 debug-layer errors or warnings. Thestartup_flat_param_*output is unchanged.