Fix FXC SM5.1 compilation of the shared normalization helper #63
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!63
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/63/head"
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?
@philip-roy-jones on GitHub · 2026-11-21 22:06 UTC · original
fix/fxc-sm51-normalization→main· +72 −1 · 3 files · 1 commits · closed without mergingLibrary / area:
tombox-xshaderHLSL emission and the Windows FXC pathExports changed (exports.txt rows): None
Source of the behaviour: HLSL introduced
uint64_tin Shader Model 6.0. The translator's normalized conversions use round-to-nearest-even after exact scaling. Microsoft HLSL scalar types · Existing normalization oracleOn upstream
0fc72956f9ff742a275534c27d9e5a7a9886a0c3, a hand-assembled pixel shader that loads one 32-bit word fromb0, space1and exports it selectsps_5_1. FXC rejects the sharedtb_nrmdeclaration before eliminating the unused helper. The shader scan and the runtime centroid test both reported this failure. #56 · #59The emitter selects SM5.1 for register spaces in VS, PS, CS and GS, and for pixel shaders with UAVs. On Windows,
d3d12_xscan useD3DCompilefor those profiles, including whenTOMBOX_SHADER_COMPILER=fxcis set.xscan --compile 1 --compiler fxcinvokes the SDK executable. DXC maps the same profiles to SM6.2. Profile selection · Runtime compiler selectiontb_nrmnow splits the 24-bit significand × 16-bit scale at bit 16. The upper part and the low 16 bits determine whether the exact product is at a rounding tie. Both pieces fit in SM5uintregisters.Verification
Windows x64, Windows SDK 10.0.26100.0, FXC 10.0.26100.8249, DXC 1.8.2502.11 and D3D12 WARP. The branch commit is
e9488eab22d70e48b63737bbdce2111c5f424561.ps_5_1CBV passthroughv_cvt_pknorm_u16_f32mul nuw nsw i64by 65535.cs_5_1dword store tou0, space1ps_5_0passthrough in space 0image_bvh64_intersect_raywith a CBV-supplied node and rayThe BVH control still needs DXC for its native 64-bit addresses, even though the emitter reports
ps_5_1. Its WARP execution test also passes.cargo test --locked -p tombox-xshader --no-fail-fastcargo test --locked -p d3d12_xs --lib lowered_pixel_shader_compiles_with_fxc_in_both_variantscargo test --locked -p d3d12_xs --lib fxccargo test --locked -p tombox-xshader --bin xscan fxc_compiles_sm51_pixel_exportsxscan.exe <input>.dxbc --compile 1 --compiler fxc --jobs 1, fresh cache forplain,normandstorecargo test --locked -p tombox-xshader --test exec vector_vop3 -- --exact --nocapturepassed 325 constant-input cases and 325 runtime-input cases on WARP, including adjacent float32 values whose exact scaled results straddle 1.5. As an additional readback check, the original DXC helper and the branch FXC/DXC helpers each matched a float64 ties-to-even reference on 393,251 runtime inputs. Those include the floats on either side of every SNORM16 and UNORM16 rounding boundary.Reproduce the SDK compiler runs with synthetic inputs
Save this Python script as
make_inputs.pyin a scratch directory and runpython make_inputs.py. The fixtures contain only the instructions and metadata below.Build the binaries in each revision with
cargo build --locked -p tombox-xshader --bin xscan --bin xshader. From the fixture directory, set$binto that build's debug binary directory and$treetoupstreamorbranch. Put the SDK's x64 compiler directory on PATH.cargo test -p tombox-xshaderpassesmissingwith a notePull request closed