Lower scalar byte and halfword sign extension in pixel AOT #527

Merged
descent81 merged 1 commit from upstream-pr/533 into main 2026-11-22 10:10:24 +00:00
descent81 commented 2026-11-22 10:01:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by descent81 on 2026-11-22T10:01:01Z.


Instructions and observable behavior

This adds the two SOP1 sign-extension forms s_sext_i32_i8 and s_sext_i32_i16 to the straight-line pixel translator. Only the low byte or low halfword supplies the sign. Both instructions preserve SCC, so a later conditional select must still observe the condition set before the extension. See the AMD RDNA 2 ISA, integer arithmetic.

How the fixture distinguishes mistakes

The shader compares each full 32-bit result with a runtime CPU reference. Python derives the reference by decoding the corresponding low bytes as signed little-endian integers. Two additional output channels independently expose the saved SCC after each width.

Input word Signed byte Signed halfword
0xabcd807f 127 -32641
0xabcd7f80 -128 32640
0xabcd0000 0 0
0x1234ffff -1 -1

The first two rows place the byte and halfword sign bits in opposition. Changing the last row's references to 255 and 65535 must turn both equality channels off while the two SCC channels stay on.

Local verification

  • The full pixel binary fixture suite passed using LLVM 15, including assembly and disassembly of the new gfx1013 fixture.
  • All five readbacks matched on RTX 4060 and WARP, 4,096 pixels per draw and zero reported debug errors or warnings.
  • Base commit aba0555. The fixture exercises two SOP1 mnemonics present in both dashboard references. Aggregate coverage depends on the measured CI run.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6541050834 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/533). Originally posted by [descent81](https://github.com/descent81) on 2026-11-22T10:01:01Z. --- ## Instructions and observable behavior This adds the two SOP1 sign-extension forms `s_sext_i32_i8` and `s_sext_i32_i16` to the straight-line pixel translator. Only the low byte or low halfword supplies the sign. Both instructions preserve SCC, so a later conditional select must still observe the condition set before the extension. See the [AMD RDNA 2 ISA, integer arithmetic](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf). ## How the fixture distinguishes mistakes The shader compares each full 32-bit result with a runtime CPU reference. Python derives the reference by decoding the corresponding low bytes as signed little-endian integers. Two additional output channels independently expose the saved SCC after each width. | Input word | Signed byte | Signed halfword | | --- | ---: | ---: | | 0xabcd807f | 127 | -32641 | | 0xabcd7f80 | -128 | 32640 | | 0xabcd0000 | 0 | 0 | | 0x1234ffff | -1 | -1 | The first two rows place the byte and halfword sign bits in opposition. Changing the last row's references to 255 and 65535 must turn both equality channels off while the two SCC channels stay on. ## Local verification - The full pixel binary fixture suite passed using LLVM 15, including assembly and disassembly of the new gfx1013 fixture. - All five readbacks matched on RTX 4060 and WARP, 4,096 pixels per draw and zero reported debug errors or warnings. - Base commit `aba0555`. The fixture exercises two SOP1 mnemonics present in both dashboard references. Aggregate coverage depends on the measured CI run.
upstream-sync closed this pull request 2026-11-24 06:43:32 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!527
No description provided.