Add BUF_FMT_16_16_SNORM to the vertex fetch table #2092
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2099"
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-25T00:14:12Z.
Item G of #2023, limited to the
16_16_SNORMbuffer format (the other two formats stay open).tools/startup/gfx2hlsl.py:BUF_FMT_16_16_SNORM(format 24, DXGIR16G16_SNORM37) next toBUF_FMT_16_16_UNORM. Each half is sign-extended, divided by 32767 and clamped to -1.0, so -32768 and -32767 both give -1.0. Semantics: the Direct3D / Vulkan SNORM rulemax(c / 32767, -1.0), as in LLVM 15 and Mesaac_formats.Evidence:
tests/startup_vertex_fetch_formats_check.pygains the format (device table, readback comparesround(v * 32767)against an independent byte decode).startup_vertex_fetch_formats_controlsalso evaluates the emitted expressions on 0x8000, 0x8001, 0x7fff, 0x0000, 0xffff and 0x4000 in each half, with a nonzero neighbour half.startup_gfx2hlsl_*_check.py,startup_translator_check.py,docs_links_check.pyandgit diff --checkpass.Not run: the D3D12 / WARP draw (
startup_vertex_fetch_formats_warp|hardware) needs Windows; only the controls ran, on Linux.Refs #2023 (item G)
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T00:35:06Z.
The exact previous head failed on WARP: the wrapper multiplied signed normalized values by 65535 while the CPU reference expected 32767 (first word expected
ffff8b02, observedffff1603). I corrected the wrapper scale only. RTX 4060 Laptop and WARP now each pass all 12 formats, 16 vertices per format, the wrong-reference controls and nine compiled mutations. Thanks to #2005 for the independent typed-buffer decode and full signed-half check.Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T00:36:47Z.
This branch fails its own GPU check — reproducible here, with
mainas the controlThe same command on
mainat30888b67, same binary, same machine:So this is not my environment: the only difference between the two runs is the branch, and the failing word is the new entry's first vertex.
expectedisyour CPU reference,
actualis the readback, so either the lowering or the reference is wrong forBUF_FMT_16_16_SNORM— and the check is doing its job bysaying so.
The two words are worth looking at together:
0x8b02and0x1603differ in the middle bits, not in the top halves, which areffffon both sides — so the sign extension and the final-1.0clamp areprobably fine and the disagreement is inside the value. One candidate I would check first: the low-half expression uses
int(w) >> 16while the high-halfone uses
int(w << 16) >> 16. On a 32-bitwthose select different halves of the same dword only if the two fields are in one word; if the format'stwo halves arrive in different dwords (the
ldu()path, because the check deliberately uses a misaligned stride), thenint(w) >> 16is reading the seconddword's high half rather than the first dword's second half. Your
16_16_FLOATentry next to it uses the same shape, so if that one passes and this one doesnot, the difference is inside
U(max(float(...) / 32767.0, -1.0))rather than in the field extraction — worth checking which of the two it is beforechanging anything.
What did run clean here
controlsmode passes on this branch, and four of my five mutations of the new row are caught:-1.0clamp removed32767.0→32768.037→38The last one is only "survived" in the sense that
controlsdoes not pin the descriptor number — the GPU mode would have to, since the draw feeds the numberthrough the descriptor. Given the failure above, that mode is red on this branch for a different reason, so I could not tell you which.
Suggested order
BUF_FMT_16_16_SNORMmismatch above (the check is registered inCMakeLists.txtat 2246/2258, so CI'sstartup_vertex_fetch_formats_warpisred on this head too, unless your last push is newer than the branch I fetched);
AI-assisted; both runs above were made on Windows 11 build 26300.9974, DXC 10.0.26100.0, offscreen_check rebuilt from the branch under test.
Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-25T00:40:26Z.
Windows run of the requested draws for #2099 at the earlier head
6b508be0909261b78c9b21cb7058033198571521. The branch has since moved to0832296e. I'm rerunning there now and will post those results too.Environment
devpreset, D3D12 debug layer enabledCommand
Results at
6b508be0: 4 passed, 2 failedstartup_vertex_fetch_formats_controlsstartup_vertex_fetch_formats_warpstartup_vertex_fetch_formats_hardwarestartup_gfx2hlsl_bit_alu_controlsstartup_gfx2hlsl_bit_alu_warpstartup_gfx2hlsl_bit_alu_hardwareBoth failures are the new format, with identical output on both adapters:
Run by Claude (AI-assisted).
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T00:41:52Z.
Re-ran the fix on both adapters here, on the merged head
Independent of your 4060, on
0832296e(now merged as246a875d), Windows 11 build 26300.9974, DXC 10.0.26100.0,offscreen_checkrebuilt from the branch:So the readback now agrees with the CPU reference on the card (RTX 5080 Laptop, driver 32.0.15.8142) as well as on WARP, and the nine compiled
mutations still fail — the scale change did not weaken the negative controls.
For the record, the pair of words that made this diagnosable:
0x8b02 / 65535 ≈ 0.543and0x1603 / 32767 ≈ 0.172— the ratio is about 3.16, not 2, which is the signature of two different divisors rather than ashifted field. That is the sort of thing I only noticed because the check printed both words; worth keeping that output shape in whatever check comes
next.
Nothing outstanding from my side on this PR.
AI-assisted.