Shaders: lower v_cvt_f32_f64 (binary64 to binary32) #52

Open
Altorru wants to merge 1 commit from upstream-pr/52 into main
Altorru commented 2026-11-25 07:06:26 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Altorru on 2026-11-25T06:10:18Z.


Ports the v_cvt_f32_f64 support from fxceless/victory-fork@3bff182 (the match arm, f64_pair and f64_to_f32_bits), without that commit's unrelated changes.

Why: the instruction decoded but had no lowering, so any shader using it failed with '... is not supported' and its pipeline was dropped. Issue #38 names three compute programs stopped by v_cvt_f32_f64 (5dc3b25986622949, 6f225b641c5b0708, 926c46bab3b86bd6).

What: reads a binary64 operand as (lo, hi) dwords (VGPR or SGPR pair, inline f64 constants, or a 32-bit literal in the high dword) and converts to binary32 bits with round-to-nearest-even, subnormals, infinity and NaN, using integer operations only (no host DOUBLES support).

Verification: new host test cvt_f32_f64_lowers builds v_cvt_f32_f64 v1, s[16:17] and lowers it; cargo test -p victory-shader passes (171 tests). Numeric behavior on hardware is covered by the upstream test this is taken from; I could not run a GPU here.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6598400921 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/52). Originally posted by [Altorru](https://github.com/Altorru) on 2026-11-25T06:10:18Z. --- Ports the `v_cvt_f32_f64` support from `fxceless/victory-fork@3bff182` (the match arm, `f64_pair` and `f64_to_f32_bits`), without that commit's unrelated changes. **Why:** the instruction decoded but had no lowering, so any shader using it failed with '`...` is not supported' and its pipeline was dropped. Issue #38 names three compute programs stopped by `v_cvt_f32_f64` (`5dc3b25986622949`, `6f225b641c5b0708`, `926c46bab3b86bd6`). **What:** reads a binary64 operand as `(lo, hi)` dwords (VGPR or SGPR pair, inline f64 constants, or a 32-bit literal in the high dword) and converts to binary32 bits with round-to-nearest-even, subnormals, infinity and NaN, using integer operations only (no host `DOUBLES` support). **Verification:** new host test `cvt_f32_f64_lowers` builds `v_cvt_f32_f64 v1, s[16:17]` and lowers it; `cargo test -p victory-shader` passes (171 tests). Numeric behavior on hardware is covered by the upstream test this is taken from; I could not run a GPU here.
Altorru commented 2026-11-25 07:06:29 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Altorru on 2026-11-25T06:37:21Z.


Rebased-free follow-up: the test moved to the end of mod tests (same test, same encoding, unchanged behaviour). It used to sit at the same anchor as #49's permlane16_and_x16_lower, so the two PRs conflicted textually even though the arms they cover are unrelated. Both orders now merge cleanly, and cargo test -p victory-shader is still 171 passed.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7154983519 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/52#issuecomment-7154983519). Originally posted by [Altorru](https://github.com/Altorru) on 2026-11-25T06:37:21Z. --- Rebased-free follow-up: the test moved to the end of `mod tests` (same test, same encoding, unchanged behaviour). It used to sit at the same anchor as #49's `permlane16_and_x16_lower`, so the two PRs conflicted textually even though the arms they cover are unrelated. Both orders now merge cleanly, and `cargo test -p victory-shader` is still 171 passed.
Aniseto commented 2026-11-25 15:08:46 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Aniseto on 2026-11-25T14:39:34Z.


Ran the shader tests at 3f21662 (clean PR head on main 90b529f):

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB), driver 32.0.16.2124
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXIL validator 1.9.2609.5 (VICTORY_DXIL), debug build

Results

  • cargo test --locked -p victory-shader --lib cvt_f32_f64_lowers -- --nocapture: 1 passed, 0 failed, 0 ignored, 212 filtered out (exit 0)
  • cargo test --locked -p victory-shader --lib -- --test-threads=1: 211 passed, 0 failed, 2 ignored (exit 0)
  • cargo test --locked -p victory-shader --lib emit::intersect_tests::the_32_bit_node_test_in_a_host_buffer_matches_the_reference_on_the_card -- --exact --nocapture: 1 passed, 0 failed, 0 ignored (exit 0). That test asserts an SM 6.6 device is available, so the GPU path ran on this adapter.

What this adds
The PR says the author could not run a GPU, and the thread has no hardware report: this is the first run of this change on a real card. The new cvt_f32_f64_lowers test passes here; it checks the emitted lowering only. The numeric behavior of v_cvt_f32_f64 on hardware is not measured by that test, so I am not claiming it here. The hardware part of this report is that the crate's GPU tests run through the real adapter on this Blackwell part with DXIL validator 1.9.2609.5.

Not tested
The three shader programs named in issue #38, the title's shader pack, live pipeline creation, retail runs, a WARP control lane, the console compiler's DXC, release profile, AMD and Intel GPUs.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7165614629 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/52#issuecomment-7165614629). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-25T14:39:34Z. --- Ran the shader tests at `3f21662` (clean PR head on `main` `90b529f`): **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB), driver 32.0.16.2124 - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: Rust 1.98.1 (pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXIL validator 1.9.2609.5 (`VICTORY_DXIL`), debug build **Results** - `cargo test --locked -p victory-shader --lib cvt_f32_f64_lowers -- --nocapture`: 1 passed, 0 failed, 0 ignored, 212 filtered out (exit 0) - `cargo test --locked -p victory-shader --lib -- --test-threads=1`: 211 passed, 0 failed, 2 ignored (exit 0) - `cargo test --locked -p victory-shader --lib emit::intersect_tests::the_32_bit_node_test_in_a_host_buffer_matches_the_reference_on_the_card -- --exact --nocapture`: 1 passed, 0 failed, 0 ignored (exit 0). That test asserts an SM 6.6 device is available, so the GPU path ran on this adapter. **What this adds** The PR says the author could not run a GPU, and the thread has no hardware report: this is the first run of this change on a real card. The new `cvt_f32_f64_lowers` test passes here; it checks the emitted lowering only. The numeric behavior of `v_cvt_f32_f64` on hardware is not measured by that test, so I am not claiming it here. The hardware part of this report is that the crate's GPU tests run through the real adapter on this Blackwell part with DXIL validator 1.9.2609.5. **Not tested** The three shader programs named in issue #38, the title's shader pack, live pipeline creation, retail runs, a WARP control lane, the console compiler's DXC, release profile, AMD and Intel GPUs. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/52:upstream-pr/52'
git switch 'upstream-pr/52'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/52'
git switch 'upstream-pr/52'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/52'
git switch 'upstream-pr/52'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/52'
git switch 'main'
git merge --squash 'upstream-pr/52'
git switch 'main'
git merge --ff-only 'upstream-pr/52'
git switch 'main'
git merge 'upstream-pr/52'
git push origin 'main'
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
Zettrox/ztrx!52
No description provided.