startup-runtime: FXC flushes constant integer bits in gfx2hlsl flat parameters and colour exports #1259
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#1259
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Jess-Doit on GitHub · 2026-11-24 05:52 UTC · original
What happens
tools/startup/gfx2hlsl.pykeeps shader registers asuintand converts to float at the stage interface:exp parambecomeso.param<n> = float4(F(v..));o.fparam<n> = o.param<n>feedsv_interp_mov_f32, which readsU(i.fparam<n>.c);exp mrtbecomeso.mrt<n> = float4(F(v..)).translate_to()(the--pendingpath the stand-in loads) compiles those stages with FXCvs_5_1/ps_5_1. When the register holds a constant, FXC foldsasfloat(<literal>)at compile time and flushes binary32 denormal patterns to 0. Integer bit patterns such as 1, 2 or0x80000001are denormals as floats, so they are lost before the shader runs.Source-built repro on local HEAD (Windows 10 22H2
19045.6456, FXC and DXC from Windows SDK10.0.26100.0):1,2,0x7fc00001and0x80000001intov6–v9and exports them withexp param0.v_interp_mov_f32 ... p0, attr0.x..wand exports them tomrt0.The FXC listing of the translated vertex stage is
mov o0.xyzw, l(0,0,0x7fc00001,0)for bothparam0andfparam0. A translated pixel stage that exports the same constants directly compiles tomov o0.xyzw, l(0,0,0x7fc00001,1.000000).A one-pixel draw into
R32G32B32A32_FLOATreads back the following on the in-box WARP (10.0.19041.5794) and on a GTX 1060 (32.0.15.6094), with the debug layer on and 0 errors or warnings:vs_6_0/ps_6_000000001,00000002,7fc00001,80000001(exact)vs_5_1/ps_5_1, constants00000000,00000000,7fc00001,00000000+ (SV_VertexID >> 31))So the hardware and the flat interface keep the bits. The loss is FXC's constant folding.
/Odkeeps them too, but it turns off all FXC optimisation.This matters for titles because a flat attribute often carries an integer selector or index that the pixel stage compares or branches on. XCL hit the same class of problem, where a flat input that must keep its bits was converted (their #249).
@Jess-Doit on GitHub · 2026-11-24 05:52 UTC · original
I'll take the flat-parameter half:
gfx2hlsldeclares flat copies asnointerpolation uint4 fparam<n>;F();v_interp_mov_f32reads them withoutU().Check: a source-built vertex/pixel pair, translated and compiled with FXC
5_1(the--pendingpath) and with DXC6_0. It must read back the four patterns exactly on WARP and hardware. Two negative controls:float4flat copy must lose1,2and0x80000001under FXC;Out of scope: constant integer bits in colour exports (
mrt). The right output type depends on the bound render-target format, so that needs its own change. I'll note the measured result there and leave it open.AI-assisted (Claude Code).
@Jess-Doit on GitHub · 2026-11-24 06:03 UTC · original
I'll take the colour-export half of #1259. I’ll start with uncompressed
exp mrttoR32_UINTandR32_SINT, using the bound RTV formats to select a format-specific shader cache entry. The first check will use the same shader and root across the two integer formats, with an ordinary UNORM output in the same draw.I’ll compare source-built FXC
ps_5_1and DXCps_6_0outputs on the GTX 1060 and Windows 10 in-box WARP. I'll also isolate the raw-binary32 float export in a separate check, using optimized FXC, a run-time operand, and DXC to pin down a workaround. Packed integer exports need their own encoding evidence.AI-assisted (Codex).
@R0Y00 on GitHub · 2026-11-24 07:44 UTC · original
The reported two FXC paths have regression coverage on main. #1262 keeps flat interpolants as integer register words and requests fresh translations for older caches. #1266 checks typed UINT/SINT MRT output and exact binary32 FLOAT words, including rejection of a mismatched cached variant. Release checks passed on RTX 4060 Laptop and WARP with both FXC and DXC. The existing scope for packed integer exports remains separate.