Lower binary16 interpolation of plain 32-bit exports #2219

Merged
Ybucaille merged 2 commits from upstream-pr/2227 into main 2026-11-25 06:44:28 +00:00
Ybucaille commented 2026-11-25 06:18:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ybucaille on 2026-11-25T06:18:18Z.


Refs #1996 (item C). Follow-up of #2052, as discussed with @denn0x there.

Summary

#2052 lowered v_interp_p1ll_f16 / v_interp_p2_f16 only when the vertex stage exports the attribute with compr. As denn0x found in an aggregate scan, the programs that use the pair export it as a plain 32-bit word instead: the vertex stage packs the two binary16 halves itself (e.g. with v_cvt_pkrtz_f16_f32) and exports without compr, so #2052 refused all of them. This lowers that plain form.

What it does

  • For a plain export, half h of 32-bit channel c is f16tof32(word_c >> 16 * h). When, and only when, the pixel stage reads the attribute as binary16, the vertex stage also outputs two interpolated float4 copies, hparamN_lo and hparamN_hi, the f16tof32 of the low and high halves of the four words. The pixel stage reads channel c of the copy that high selects. Channels x to w are accepted.
  • The compr path is unchanged (half h of channel c is still float channel 2 * c + h; channels above y are still refused there).
  • Refused: an attribute exported both with and without compr, and a read of a channel exported as off. All the refusals of #2052 still apply (modifiers, op_sel, readers of the upper half, branches between p1ll and p2, I/J not the entry values).
  • The control "attribute not exported with compr", which used to expect a refusal, now checks that the plain export is lowered.

Evidence

Local (Linux), on the head of this PR:

  • python3 -B tests/startup_gfx2hlsl_interp_f16_check.py: controls ok. New controls: plain export, halves lo and hi, compared word by word with a reference computed from the ISA layout; negative controls: the plain fixture read through the compr mapping, the compr fixture exported plain, and the high bit inverted, each reads other words than its reference.
  • Every other tests/startup_gfx2hlsl_*_check.py, startup_translator_check.py, startup_image_sample_l_check.py, startup_image_3d_check.py, docs_links_check.py, bidi_controls_check.py: pass. git diff --check origin/main...HEAD: clean.
  • The draw mode (what startup_gfx2hlsl_interp_f16_warp / _hardware run) now draws the compr pair and the plain pair for both halves, each against its reference, plus a negative control (the other half against this half's reference must mismatch).

I cannot run the DXIL draws here (no Windows). As a cross-check, I compiled the translated HLSL of the same fixtures to SPIR-V (dxc -spirv) and drew it with Vulkan on lavapipe (llvmpipe) and on an Intel UHD (TGL) GPU, with a local tool that is not part of this PR: compr, plain lo and plain hi match their references bit for bit on all 4096 pixels on both devices, and the three negative controls (plain hi against the lo reference, plain lo against hi, compr against the plain lo reference) fail from pixel (0,0). This is not a substitute for the WARP and hardware runs.

Not run: the Windows WARP and hardware draws, and the /O2 configuration. @tedin7, if your server is free:

ctest --preset dev --no-tests=error -R "^startup_gfx2hlsl_interp_f16_(controls|warp|hardware)$" --output-on-failure

Clean-room: semantics from the same public sources as #2052 (LLVM 15 VOP3Instructions.td / IntrinsicsAMDGPU.td, Mesa ACO emit_interp_instr); fixtures are source-built.

AI-assisted (Claude); the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6598504414 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2227). Originally posted by [Ybucaille](https://github.com/Ybucaille) on 2026-11-25T06:18:18Z. --- Refs #1996 (item C). Follow-up of #2052, as discussed with @denn0x there. ## Summary #2052 lowered `v_interp_p1ll_f16` / `v_interp_p2_f16` only when the vertex stage exports the attribute with `compr`. As denn0x found in an aggregate scan, the programs that use the pair export it as a plain 32-bit word instead: the vertex stage packs the two binary16 halves itself (e.g. with `v_cvt_pkrtz_f16_f32`) and exports without `compr`, so #2052 refused all of them. This lowers that plain form. ## What it does - For a plain export, half `h` of 32-bit channel `c` is `f16tof32(word_c >> 16 * h)`. When, and only when, the pixel stage reads the attribute as binary16, the vertex stage also outputs two interpolated float4 copies, `hparamN_lo` and `hparamN_hi`, the `f16tof32` of the low and high halves of the four words. The pixel stage reads channel `c` of the copy that `high` selects. Channels `x` to `w` are accepted. - The `compr` path is unchanged (half `h` of channel `c` is still float channel `2 * c + h`; channels above `y` are still refused there). - Refused: an attribute exported both with and without `compr`, and a read of a channel exported as `off`. All the refusals of #2052 still apply (modifiers, `op_sel`, readers of the upper half, branches between p1ll and p2, I/J not the entry values). - The control "attribute not exported with compr", which used to expect a refusal, now checks that the plain export is lowered. ## Evidence Local (Linux), on the head of this PR: - `python3 -B tests/startup_gfx2hlsl_interp_f16_check.py`: `controls ok`. New controls: plain export, halves lo and hi, compared word by word with a reference computed from the ISA layout; negative controls: the plain fixture read through the `compr` mapping, the `compr` fixture exported plain, and the high bit inverted, each reads other words than its reference. - Every other `tests/startup_gfx2hlsl_*_check.py`, `startup_translator_check.py`, `startup_image_sample_l_check.py`, `startup_image_3d_check.py`, `docs_links_check.py`, `bidi_controls_check.py`: pass. `git diff --check origin/main...HEAD`: clean. - The `draw` mode (what `startup_gfx2hlsl_interp_f16_warp` / `_hardware` run) now draws the `compr` pair and the plain pair for both halves, each against its reference, plus a negative control (the other half against this half's reference must mismatch). I cannot run the DXIL draws here (no Windows). As a cross-check, I compiled the translated HLSL of the same fixtures to SPIR-V (`dxc -spirv`) and drew it with Vulkan on lavapipe (llvmpipe) and on an Intel UHD (TGL) GPU, with a local tool that is not part of this PR: `compr`, plain lo and plain hi match their references bit for bit on all 4096 pixels on both devices, and the three negative controls (plain hi against the lo reference, plain lo against hi, `compr` against the plain lo reference) fail from pixel (0,0). This is not a substitute for the WARP and hardware runs. **Not run:** the Windows WARP and hardware draws, and the `/O2` configuration. @tedin7, if your server is free: ``` ctest --preset dev --no-tests=error -R "^startup_gfx2hlsl_interp_f16_(controls|warp|hardware)$" --output-on-failure ``` Clean-room: semantics from the same public sources as #2052 (LLVM 15 `VOP3Instructions.td` / `IntrinsicsAMDGPU.td`, Mesa ACO `emit_interp_instr`); fixtures are source-built. AI-assisted (Claude); the commands above were run locally.
upstream-sync closed this pull request 2026-11-25 07:01:06 +00:00
tedin7 commented 2026-11-25 07:01:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:22:25Z.

Review: COMMENTED


Review of head 38614ae010762898417d79865f1534a4a1088fce (Linux only, no Windows run by me).

Findings: P1=0, P2=0.

Checked:

  • Diff is 3 files (tools/startup/gfx2hlsl.py, tests/startup_gfx2hlsl_interp_f16_check.py, docs/experiments.md). Title is neutral, PR is mergeable. CI: Linux python checks and gfx1013 fixtures pass; the Windows build job was still pending when I looked.
  • Plain-export mapping (half h of channel c = f16tof32(word_c >> 16*h), via hparamN_lo/_hi) matches the packed-binary16 layout. The compr path is unchanged.
  • The extra hparam outputs are emitted by the vertex stage only for attributes the pixel stage reads as binary16 (hlsl_vs drops them otherwise), and the p + r - q combine of the generated interpolation wrapper also carries them.
  • Refusals: compr+plain mix, read of an off channel, and the earlier modifier/op_sel/upper-half restrictions are kept.

Commands run locally on the PR head:

  • python3 tests/startup_gfx2hlsl_interp_f16_check.py -> "controls ok", "plain controls ok", "Self-test passed."
  • python3 tests/docs_links_check.py -> 18 files, 412 links OK
  • python3 tests/bidi_controls_check.py -> no bidirectional controls
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: disabled the "read of an off channel" refusal -> test fails ("off channel read as binary16 was translated"). Killed.
  • Mutation 2: made the high half read hparam_lo -> the plain-half readback assertion fails. Killed.
  • Tree restored with git checkout -- . after each mutation.

Nits (non-blocking):

  • plain_params[N] records only the off-set of the latest plain export of a param. If two plain exports to one param differ in their off channels, only the last one is checked. Probably unreachable in practice; a short comment or a refusal would make it explicit.
  • Please let the Windows job finish green before Ready; I did not run Win2025 myself.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052776547 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2227#pullrequestreview-6052776547). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:22:25Z. **Review:** COMMENTED --- Review of head `38614ae010762898417d79865f1534a4a1088fce` (Linux only, no Windows run by me). Findings: P1=0, P2=0. Checked: - Diff is 3 files (`tools/startup/gfx2hlsl.py`, `tests/startup_gfx2hlsl_interp_f16_check.py`, `docs/experiments.md`). Title is neutral, PR is mergeable. CI: Linux python checks and gfx1013 fixtures pass; the Windows build job was still pending when I looked. - Plain-export mapping (half h of channel c = `f16tof32(word_c >> 16*h)`, via `hparamN_lo/_hi`) matches the packed-binary16 layout. The `compr` path is unchanged. - The extra `hparam` outputs are emitted by the vertex stage only for attributes the pixel stage reads as binary16 (`hlsl_vs` drops them otherwise), and the `p + r - q` combine of the generated interpolation wrapper also carries them. - Refusals: compr+plain mix, read of an `off` channel, and the earlier modifier/op_sel/upper-half restrictions are kept. Commands run locally on the PR head: - `python3 tests/startup_gfx2hlsl_interp_f16_check.py` -> "controls ok", "plain controls ok", "Self-test passed." - `python3 tests/docs_links_check.py` -> 18 files, 412 links OK - `python3 tests/bidi_controls_check.py` -> no bidirectional controls - `git diff --check origin/main...HEAD` -> clean - Mutation 1: disabled the "read of an off channel" refusal -> test fails ("off channel read as binary16 was translated"). Killed. - Mutation 2: made the high half read `hparam_lo` -> the plain-half readback assertion fails. Killed. - Tree restored with `git checkout -- .` after each mutation. Nits (non-blocking): - `plain_params[N]` records only the off-set of the latest plain export of a param. If two plain exports to one param differ in their off channels, only the last one is checked. Probably unreachable in practice; a short comment or a refusal would make it explicit. - Please let the Windows job finish green before Ready; I did not run Win2025 myself. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 07:01:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:41:22Z.

Review: COMMENTED


Re-review of head 223208fe829b5d8521d8c8af13a285cfb722052f (previous review: 38614ae). Linux only, no Windows run by me.

Findings: P1=0, P2=0.

Delta since 38614ae (2 files, +13/-7):

  • interp_f16 now resolves the attribute through note_attr, so the pixel attribute follows the interface-table link to the vertex parameter, and the interface component mask is enforced (tools/startup/gfx2hlsl.py:2285). note_attr also records the f16 use, so the duplicate attrs.setdefault in p1/p2 was dropped. This is correct: the lookup into plain_params / compr_params now uses the linked parameter number, which was wrong before for remapped attributes.
  • New test coverage: pixel attr 3 linked to vertex param 0 translates and matches the reference; a mask without w is refused ("undeclared component w").

Checked:

  • PR is mergeable and has a neutral title. CI: Linux python checks pass; fixtures and Windows build were still pending when I looked.
  • Earlier points hold: plain mapping f16tof32(word_c >> 16*h) via hparamN_lo/_hi, compr path unchanged, hparam outputs dropped by hlsl_vs unless read.

Commands run locally on the PR head:

  • python3 tests/startup_gfx2hlsl_interp_f16_check.py -> "plain controls ok", "controls ok"
  • python3 tests/docs_links_check.py -> 18 files, 412 links OK
  • python3 tests/bidi_controls_check.py -> no bidirectional controls
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: bypass the link resolution (use the raw attr number) -> test fails (remapped case no longer translates). Killed.
  • Mutation 2: disable the interface mask check -> test fails ("interface masks off an interpolated channel was translated"). Killed.
  • Tree restored with git checkout -- . after each.

Nits (non-blocking):

  • Carried over: plain_params[N] keeps only the off-set of the latest plain export of a param. A comment or a refusal would make that explicit.
  • Please let the Windows job finish green (and a Win2025 WARP readback run) before Ready; I did not run it.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052995677 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2227#pullrequestreview-6052995677). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:41:22Z. **Review:** COMMENTED --- Re-review of head `223208fe829b5d8521d8c8af13a285cfb722052f` (previous review: `38614ae`). Linux only, no Windows run by me. Findings: P1=0, P2=0. Delta since `38614ae` (2 files, +13/-7): - `interp_f16` now resolves the attribute through `note_attr`, so the pixel attribute follows the interface-table link to the vertex parameter, and the interface component mask is enforced (`tools/startup/gfx2hlsl.py:2285`). `note_attr` also records the `f16` use, so the duplicate `attrs.setdefault` in p1/p2 was dropped. This is correct: the lookup into `plain_params` / `compr_params` now uses the linked parameter number, which was wrong before for remapped attributes. - New test coverage: pixel attr 3 linked to vertex param 0 translates and matches the reference; a mask without `w` is refused ("undeclared component w"). Checked: - PR is mergeable and has a neutral title. CI: Linux python checks pass; fixtures and Windows build were still pending when I looked. - Earlier points hold: plain mapping `f16tof32(word_c >> 16*h)` via `hparamN_lo/_hi`, compr path unchanged, `hparam` outputs dropped by `hlsl_vs` unless read. Commands run locally on the PR head: - `python3 tests/startup_gfx2hlsl_interp_f16_check.py` -> "plain controls ok", "controls ok" - `python3 tests/docs_links_check.py` -> 18 files, 412 links OK - `python3 tests/bidi_controls_check.py` -> no bidirectional controls - `git diff --check origin/main...HEAD` -> clean - Mutation 1: bypass the link resolution (use the raw attr number) -> test fails (remapped case no longer translates). Killed. - Mutation 2: disable the interface mask check -> test fails ("interface masks off an interpolated channel was translated"). Killed. - Tree restored with `git checkout -- .` after each. Nits (non-blocking): - Carried over: `plain_params[N]` keeps only the off-set of the latest plain export of a param. A comment or a refusal would make that explicit. - Please let the Windows job finish green (and a Win2025 WARP readback run) before Ready; I did not run it. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 07:01:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:45:56Z.


I added one integration correction before merging. The f16 pair now reads the stream interface link and component mask, as the ordinary interpolation paths do. A source-built test remaps pixel attr3 to vertex param0 and checks that masking off w is rejected. The plain and compressed GPU draws and wrong-half controls passed on WARP and RTX 4060 Laptop.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7155133696 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2227#issuecomment-7155133696). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T06:45:56Z. --- I added one integration correction before merging. The f16 pair now reads the stream interface link and component mask, as the ordinary interpolation paths do. A source-built test remaps pixel attr3 to vertex param0 and checks that masking off w is rejected. The plain and compressed GPU draws and wrong-half controls passed on WARP and RTX 4060 Laptop.
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!2219
No description provided.