shader: preserve raw bits in integer pixel constant loads #674
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/680"
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 Joacoorandom on 2026-11-22T19:45:33Z.
Change
Lower s_bitset0_b64 and s_bitset1_b64 on initialized, even-aligned SGPR pairs. Read the old 64-bit destination and index before replacing either half, mask the index to six bits, change only the selected bit, and preserve SCC. Track the new forms in the unsupported-shader scanner.
The exact-bit GPU cases exposed a UINT-export issue: setting bit 31 on a NaN-shaped word produced 0x7fffffff instead of 0xffffffff on the tested NVIDIA driver. The integer-export profile now uses integer-typed constant-buffer loads and keeps scalar bit copies, including vector copies, as integer expressions through the final UINT return. Value identities prevent a later floating-point overwrite from exporting stale bits. The constant-buffer byte layout is unchanged.
AMD RDNA 2 ISA, bit-wise instructions, specifies six-bit indexing and unchanged SCC.
No prerequisite PR. Integrated with main at
0a9cc04; shared changes are in the pixel lowerer and scanner.Verification
Head:
149fc21bc8(implementation24936e2, plus main integration).Linux x64, Python 3.14.4 and LLVM 18:
Passed: 34 focused assembly/disassembly/lowering round trips (32 instruction/source/architecture combinations plus copy/overwrite controls), existing pixel binary checks, form-coverage checks, 10 Markdown files / 129 links, 584 source/configuration files and PR whitespace checks. CI also runs the focused binary check with LLVM 15.
Windows 11 build 26300.9974, MSVC 19.44.35230, Python 3.12.8, SDK 10.0.26100:
6/6 tests passed; no skips. Each new backend check matched 458 positive draws and detected 64 wrong-reference cases plus two clear/set shader mutations:
Existing WARP scalar/blend, bit-field-mask, no-carry integer and float-to-uint conversion checks passed. The actual JUnit/record run was processed by form_coverage.py; the new tests contribute two SOP1 forms in each gfx1013/gfx1030 reference list. The full repository suite was not run.
Evidence and follow-up
Original MIT-licensed assembly programs are generated from Python; the reference applies the operation to one Python 64-bit integer. Cases include word boundaries and wrapping indices, aliased index registers, prior SCC values, inline constants, full/empty/patterned destinations and signaling-NaN bit patterns. Integer expected values are written directly, without host floating-point conversion.
Rejection controls retain undefined old halves, pending loads/writes, malformed pairs, unsupported source kinds and undefined SCC. Existing exact HLSL assertions and mutations were updated for integer-typed constant loads; no reference result or rejection requirement was removed.
README links the new reproduction section in docs/experiments.md. Coverage records are attached to the draw test results; skipped or failed tests do not turn forms green. This establishes fixture behavior against the ISA reference, not console execution or title startup.
Checklist
AI-assisted implementation, tests and documentation.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T04:29:30Z.
The independent RTX 3060 Ti run on #715 preserved both
0xffffffffwords in the bit-31 case and caught a reference of0x7fffffff. I’m proceeding with #715 for the two bitset forms and the alias/SCC controls. The focused round-trip and copy/overwrite controls here are useful. Please keep any broader integer-export changes as a separate contribution with a still-failing source-built case on current main, so we can assess the change across the other UINT-export paths.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T11:21:37Z.
The wider UINT transport issue is reproducible on current main
87dd090. I replayed your source-built cases with RTX 4060 Laptop driver 32.0.16.1656, Windows 26200.9974, debug layer enabled. The minimal case iss_bitset1_b64 s[60:61], 31, both initial words0xffffffff, with the low word copied to a UINT export. Main reads0x7ffffffffor that channel, while this branch33a24a0reads the expected0xffffffffon the same setup. WARP on main passed the full matrix. Please rebase the fix to preserve the raw integer transport on top of #715 and keep this reproducer plus the copy/overwrite controls. Keep the landed scalar bitset code and shared scanner; a narrow test and patch would let us verify whether the input load, the bit-copy path, or their combination is needed.I also varied the two changes independently in the generated HLSL from main. For this minimal case, a uint4 constant buffer passed with and without a raw UINT return. A raw return alone still produced 0x7fffffff with the float4 buffer. That makes the buffer load the first change to try, with the full copy/overwrite matrix guarding any remaining transport differences.
An isolated lowerer patch that only types b0 loads as unsigned in integer-export mode also passed the full 458 exact draws, 64 wrong-reference checks and both mutations on the same RTX 4060 Laptop. The existing generated-HLSL assertions still expect float input bitcasts. The prototype stays local until the remaining shared lowerer controls are verified.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T12:24:55Z.
I synced the original branch with main and pushed
046a2bd. The remaining change is the uint4 primary constant load for integer readback, using the typed-load approach from this PR. The existing #715 bitset lowering and scanner stay in place, and the byte layout is unchanged. The existing bitset draw now covers the immediate-index-31 case through a VGPR copy and checks that a later float overwrite wins. The old lowerer on RTX returned 0x7fffffff and matched the wrong reference. The new head passed that draw on WARP and RTX 4060 Laptop. The WARP e64 draw, LLVM 15 binary suite, Python controls and coverage/docs checks also passed. Waiting for GitHub CI on the new head.