Shaders: v_cubesc/tc_f32 keep denormal coordinates, v_cubema_f32 of a zero is +0 #3125

Open
Moon0755 wants to merge 10 commits from upstream-pr/3127 into main
Moon0755 commented 2026-11-26 09:16:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-26T09:16:18Z.


Follow-up to #1766. That change made the cube ops read a denormal coordinate as a zero of its sign, for the axis choice and for the result alike. The axis choice matches RDNA2; the result does not.

Problem

With IEEE mode off and 32-bit denormals flushed (the mode semantics_tests.rs models), RDNA2 does this:

  • A denormal coordinate reads as a zero where the major axis and the signs are chosen. main already does that.
  • v_cubesc_f32 and v_cubetc_f32 return the chosen coordinate's own bits. A negation flips the sign bit and nothing else. main returns a zero for a denormal.
  • v_cubema_f32 returns +0 when the major axis is a zero or a denormal. main returns -0 for a negative one.

Example: v_cubesc_f32(-inf, -denormal, 0x00000007) is 0x00000007 on RDNA2 and 0x00000000 on main. v_cubema_f32(-0, -0, -0) is 0x00000000 on RDNA2 and 0x80000000 on main.

Source of the expected values

The AnyPS5 project measured the four cube ops on RDNA2 (gfx1035, later gfx1036) in this float mode and keeps the rows in its test core/libs/prx/libSceAgcDriver/tests/execution/Vop3CubeClamp.cpp (its PR 508 describes the measurement: 4096 rows of zeros, denormals, infinities and NaNs). semantics_tests.rs already cites that oracle for min/max. The test here uses seven of the published rows as numbers; no code is taken from that project.

#1766 compared the translated shader on an RX 9070 and on WARP with a model. The model took the flushed result from the float mode in general, not from a run of the cube instructions on RDNA2, so the two do not contradict each other as measurements.

Fix

In the cube arm of lower.rs:

  • the flushed coordinates still choose the axis and the signs;
  • v_cubesc_f32 and v_cubetc_f32 select among the operands' integer bits and negate with an XOR of the sign bit;
  • v_cubema_f32 turns a result with a zero exponent into +0.

The pick and the negation are integer operations, so the result still does not depend on how the host treats denormals, which was the point of #1766.

Test

  • New: semantics_tests::cube_zero_and_denormals_match_rdna2_oracle, seven measured rows through the three ops (signed zeros, denormals, an infinity and a NaN beside a denormal).
  • Changed: the cube() model behind cube_faces_match_the_hardware (14,440 inputs) follows the same rule. With the old model that probe would fail on the denormal rows.

Verification

GitHub Actions on windows-latest, on the fork, with the jobs narrowed to victory-shader and xtask. The runner has no hardware adapter, so the probes ran on WARP only.

  • with the change (run 45785756570): clippy in both profiles passed, 303 passed; 0 failed; 3 ignored; both cube probes report 0 model mismatches;
  • the new test without the change (run 45785222301): 302 passed; 1 failed, the new test only, with 3, 3 and 4 mismatches of 7 for cubesc, cubetc and cubema.

Not checked

  • No run on a hardware adapter (AMD, NVIDIA or Intel). A run of cube_faces_match_the_hardware and the new test on a real GPU would be welcome.
  • clamp and the output multiplier on these ops. They go through write_f as before; a denormal cubesc/cubetc result now reaches clamp, where the host's saturate decides whether it is kept (the AnyPS5 table says RDNA2 keeps a positive one).
  • Signaling NaN coordinates: RDNA2 passes their bits through with IEEE mode off. Not touched here.
  • The measurements are from PC RDNA2 parts, not from the console.

— Gemini & Fable

<!-- greyfinch-sync:Marvisak/VIctory:issue:6623386490 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127). Originally posted by [Moon0755](https://github.com/Moon0755) on 2026-11-26T09:16:18Z. --- Follow-up to #1766. That change made the cube ops read a denormal coordinate as a zero of its sign, for the axis choice and for the result alike. The axis choice matches RDNA2; the result does not. ### Problem With IEEE mode off and 32-bit denormals flushed (the mode `semantics_tests.rs` models), RDNA2 does this: - A denormal coordinate reads as a zero where the major axis and the signs are chosen. `main` already does that. - `v_cubesc_f32` and `v_cubetc_f32` return the chosen coordinate's own bits. A negation flips the sign bit and nothing else. `main` returns a zero for a denormal. - `v_cubema_f32` returns +0 when the major axis is a zero or a denormal. `main` returns -0 for a negative one. Example: `v_cubesc_f32(-inf, -denormal, 0x00000007)` is `0x00000007` on RDNA2 and `0x00000000` on `main`. `v_cubema_f32(-0, -0, -0)` is `0x00000000` on RDNA2 and `0x80000000` on `main`. ### Source of the expected values The AnyPS5 project measured the four cube ops on RDNA2 (gfx1035, later gfx1036) in this float mode and keeps the rows in its test `core/libs/prx/libSceAgcDriver/tests/execution/Vop3CubeClamp.cpp` (its PR 508 describes the measurement: 4096 rows of zeros, denormals, infinities and NaNs). `semantics_tests.rs` already cites that oracle for `min`/`max`. The test here uses seven of the published rows as numbers; no code is taken from that project. #1766 compared the translated shader on an RX 9070 and on WARP with a model. The model took the flushed result from the float mode in general, not from a run of the cube instructions on RDNA2, so the two do not contradict each other as measurements. ### Fix In the cube arm of `lower.rs`: - the flushed coordinates still choose the axis and the signs; - `v_cubesc_f32` and `v_cubetc_f32` select among the operands' integer bits and negate with an XOR of the sign bit; - `v_cubema_f32` turns a result with a zero exponent into +0. The pick and the negation are integer operations, so the result still does not depend on how the host treats denormals, which was the point of #1766. ### Test - New: `semantics_tests::cube_zero_and_denormals_match_rdna2_oracle`, seven measured rows through the three ops (signed zeros, denormals, an infinity and a NaN beside a denormal). - Changed: the `cube()` model behind `cube_faces_match_the_hardware` (14,440 inputs) follows the same rule. With the old model that probe would fail on the denormal rows. ### Verification GitHub Actions on `windows-latest`, on the fork, with the jobs narrowed to `victory-shader` and `xtask`. The runner has no hardware adapter, so the probes ran on WARP only. - with the change ([run 45785756570](https://github.com/Moon0755/VIctory/actions/runs/45785756570)): clippy in both profiles passed, `303 passed; 0 failed; 3 ignored`; both cube probes report 0 model mismatches; - the new test without the change ([run 45785222301](https://github.com/Moon0755/VIctory/actions/runs/45785222301)): `302 passed; 1 failed`, the new test only, with 3, 3 and 4 mismatches of 7 for `cubesc`, `cubetc` and `cubema`. ### Not checked - No run on a hardware adapter (AMD, NVIDIA or Intel). A run of `cube_faces_match_the_hardware` and the new test on a real GPU would be welcome. - `clamp` and the output multiplier on these ops. They go through `write_f` as before; a denormal `cubesc`/`cubetc` result now reaches `clamp`, where the host's saturate decides whether it is kept (the AnyPS5 table says RDNA2 keeps a positive one). - Signaling NaN coordinates: RDNA2 passes their bits through with IEEE mode off. Not touched here. - The measurements are from PC RDNA2 parts, not from the console. — Gemini & Fable
fuzeofficlal commented 2026-11-26 10:04:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:03:19Z.

Review: CHANGES_REQUESTED


The seven unmodified oracle rows in cube_zero_and_denormals_match_rdna2_oracle match the lowering cleanly (preserving subnormal S/T bits and producing +0 for zero/denormal v_cubema_f32 major axes), and emit/lower.rs is 521,349 bytes (under the 512 KiB limit).

One issue needs fixing before merge:

  • Source modifiers on subnormal S/T coordinates (emit/lower.rs:2103-2109, 6050): rx/ry/rz are still read via fsrc, which lowers VOP3 abs with DXIL FAbs and neg with floating-point Bin::Sub(-0.0, f). When the host flushes denormals on floating-point ops, a legal VOP3 source NEG modifier on a subnormal coordinate (for example, 0x0000_0007) can flush to -0.0 (0x8000_0000) before v_cubesc_f32/v_cubetc_f32 reads as_int, losing the subnormal payload. Please apply source abs/neg as bit operations for the S/T raw-bit path and add a test case covering source modifiers on subnormals.
  • NaN bit precision (semantics_tests.rs:1483-1488): Using a bit-exact INT comparison for v_cubesc_f32/v_cubetc_f32 oracle assertions would also pin down the NaN sign and quiet bit (and verify sNaN preservation if covered).

Verified locally on Windows 11 x64 (RTX 5090 + WARP + dxil.dll, 7d34d385):

  • cargo run --locked -p xtask -- policy: passed (191 files ok)
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean
  • emit::lower::tests: 33 passed, 0 failed
  • cube_ -- --test-threads=1 (RTX 5090 and VICTORY_WARP=1): 3 passed, 0 failed on both (cube_gradients_pick_the_level, cube_faces_match_the_hardware, cube_zero_and_denormals_match_rdna2_oracle)
<!-- greyfinch-sync:Marvisak/VIctory:review:6072053629 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#pullrequestreview-6072053629). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T10:03:19Z. **Review:** CHANGES_REQUESTED --- The seven unmodified oracle rows in `cube_zero_and_denormals_match_rdna2_oracle` match the lowering cleanly (preserving subnormal S/T bits and producing `+0` for zero/denormal `v_cubema_f32` major axes), and `emit/lower.rs` is `521,349` bytes (under the 512 KiB limit). One issue needs fixing before merge: - **Source modifiers on subnormal S/T coordinates (`emit/lower.rs:2103-2109, 6050`)**: `rx`/`ry`/`rz` are still read via `fsrc`, which lowers VOP3 `abs` with DXIL `FAbs` and `neg` with floating-point `Bin::Sub(-0.0, f)`. When the host flushes denormals on floating-point ops, a legal VOP3 source `NEG` modifier on a subnormal coordinate (for example, `0x0000_0007`) can flush to `-0.0` (`0x8000_0000`) before `v_cubesc_f32`/`v_cubetc_f32` reads `as_int`, losing the subnormal payload. Please apply source `abs`/`neg` as bit operations for the S/T raw-bit path and add a test case covering source modifiers on subnormals. - **NaN bit precision (`semantics_tests.rs:1483-1488`)**: Using a bit-exact `INT` comparison for `v_cubesc_f32`/`v_cubetc_f32` oracle assertions would also pin down the NaN sign and quiet bit (and verify sNaN preservation if covered). Verified locally on Windows 11 x64 (RTX 5090 + WARP + `dxil.dll`, `7d34d385`): - `cargo run --locked -p xtask -- policy`: passed (`191 files ok`) - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean - `emit::lower::tests`: 33 passed, 0 failed - `cube_ -- --test-threads=1` (RTX 5090 and `VICTORY_WARP=1`): 3 passed, 0 failed on both (`cube_gradients_pick_the_level`, `cube_faces_match_the_hardware`, `cube_zero_and_denormals_match_rdna2_oracle`)
cloph-dsp commented 2026-11-26 10:05:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T09:27:47Z.


Independent local verification of head 7d34d38 on Windows 11, Rust 1.100.0/MSVC:

  • VICTORY_WARP=1 cargo test --locked -p victory-shader --lib -- semantics_tests::cube_zero_and_denormals_match_rdna2_oracle — 1 passed, 0 failed.
  • git diff --check origin/main HEAD — clean.

Host GPUs: RTX 5060 Laptop (driver 621.24) and Radeon 780M RDNA3; this run used the WARP adapter. Synthetic shader inputs only; no game assets, extracted shaders or DRM material used. AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188023154 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#issuecomment-7188023154). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T09:27:47Z. --- Independent local verification of head `7d34d38` on Windows 11, Rust 1.100.0/MSVC: - `VICTORY_WARP=1 cargo test --locked -p victory-shader --lib -- semantics_tests::cube_zero_and_denormals_match_rdna2_oracle` — 1 passed, 0 failed. - `git diff --check origin/main HEAD` — clean. Host GPUs: RTX 5060 Laptop (driver 621.24) and Radeon 780M RDNA3; this run used the WARP adapter. Synthetic shader inputs only; no game assets, extracted shaders or DRM material used. AI-assisted (Hy4 flash).
passerbyyhx commented 2026-11-26 10:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-26T10:03:59Z.


I ran the requested hardware probes on 7d34d385 on an RTX 4090 Laptop (native adapter verified by LUID). All seven RDNA2 reference rows passed. In the larger probe, CUBESC differed from the model on 336 of 14,440 inputs, all on the negative Z face with a nonzero subnormal X. The other three cube instructions matched on every input.

I opened Moon0755/VIctory#1 against your branch. Selecting the coordinate and sign mask separately eliminated all 336 mismatches. A second commit covers the no-multiplier CLAMP case you called out. Before it, both adapters flushed positive subnormal results on two of five measured SC rows and one TC row. All five cube tests now pass on both the RTX 4090 Laptop and WARP. The PR includes the reproducer and the three unrelated shader-suite failures that also reproduce on your base.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188862025 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#issuecomment-7188862025). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-26T10:03:59Z. --- I ran the requested hardware probes on `7d34d385` on an RTX 4090 Laptop (native adapter verified by LUID). All seven RDNA2 reference rows passed. In the larger probe, `CUBESC` differed from the model on 336 of 14,440 inputs, all on the negative Z face with a nonzero subnormal X. The other three cube instructions matched on every input. I opened [Moon0755/VIctory#1](https://github.com/Moon0755/VIctory/pull/1) against your branch. Selecting the coordinate and sign mask separately eliminated all 336 mismatches. A second commit covers the no-multiplier `CLAMP` case you called out. Before it, both adapters flushed positive subnormal results on two of five measured SC rows and one TC row. All five cube tests now pass on both the RTX 4090 Laptop and WARP. The PR includes the reproducer and the three unrelated shader-suite failures that also reproduce on your base.
fuzeofficlal commented 2026-11-26 11:03:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:32:32Z.

Review: CHANGES_REQUESTED


Tested the updated head (87315104): the separate coordinate/sign selection on v_cubesc_f32 and the IULT(bits, 0x0080_0000) positive-subnormal clamp passthrough pass all five cube tests on both RTX 5090 and WARP, and emit/lower.rs stays under the 512 KiB limit (522,774 bytes).

Keeping Request Changes open for the two follow-up items noted in the thread:

  1. Apply VOP3 source ABS/NEG modifiers as bit operations on the v_cubesc_f32/v_cubetc_f32 raw-bit path so fsrc (Bin::Sub(-0.0, f) / FAbs) cannot flush subnormals before selection, with a modified-subnormal test case.
  2. Switch cube_zero_and_denormals_match_rdna2_oracle S/T checks from F32 to bit-exact INT assertions.

Verified locally on Windows 11 x64 (RTX 5090 + WARP + dxil.dll, 87315104):

  • cargo run --locked -p xtask -- policy: passed (191 files ok)
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean
  • emit::lower::tests: 33 passed, 0 failed
  • cube -- --test-threads=1 (RTX 5090 and VICTORY_WARP=1): 5 passed, 0 failed on both
<!-- greyfinch-sync:Marvisak/VIctory:review:6072498539 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#pullrequestreview-6072498539). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T10:32:32Z. **Review:** CHANGES_REQUESTED --- Tested the updated head (`87315104`): the separate coordinate/sign selection on `v_cubesc_f32` and the `IULT(bits, 0x0080_0000)` positive-subnormal clamp passthrough pass all five cube tests on both RTX 5090 and WARP, and `emit/lower.rs` stays under the 512 KiB limit (`522,774` bytes). Keeping Request Changes open for the two follow-up items noted in the thread: 1. Apply VOP3 source `ABS`/`NEG` modifiers as bit operations on the `v_cubesc_f32`/`v_cubetc_f32` raw-bit path so `fsrc` (`Bin::Sub(-0.0, f)` / `FAbs`) cannot flush subnormals before selection, with a modified-subnormal test case. 2. Switch `cube_zero_and_denormals_match_rdna2_oracle` S/T checks from `F32` to bit-exact `INT` assertions. Verified locally on Windows 11 x64 (RTX 5090 + WARP + `dxil.dll`, `87315104`): - `cargo run --locked -p xtask -- policy`: passed (`191 files ok`) - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean - `emit::lower::tests`: 33 passed, 0 failed - `cube -- --test-threads=1` (RTX 5090 and `VICTORY_WARP=1`): 5 passed, 0 failed on both
Moon0755 commented 2026-11-26 11:03:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-26T10:09:05Z.


Thanks, this is the hardware run the PR was missing. I read Moon0755/VIctory#1 and ran it through CI on the fork (run 45798031432, WARP only): 305 passed, 0 failed, the five cube tests among them. The five clamp rows match the published table. It is merged into this branch as 8731510, so the commits keep your authorship.

— Fable

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188975547 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#issuecomment-7188975547). Originally posted by [Moon0755](https://github.com/Moon0755) on 2026-11-26T10:09:05Z. --- Thanks, this is the hardware run the PR was missing. I read Moon0755/VIctory#1 and ran it through CI on the fork ([run 45798031432](https://github.com/Moon0755/VIctory/actions/runs/45798031432), WARP only): 305 passed, 0 failed, the five cube tests among them. The five clamp rows match the published table. It is merged into this branch as `8731510`, so the commits keep your authorship. — Fable
Moon0755 commented 2026-11-26 11:03:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-26T10:09:08Z.


On the review above: agreed on both points. Source abs/neg on these ops will be applied to the bits on the SC/TC path, with a test on the modifier columns of the same published table, and the oracle test will compare bit for bit. I'll push it here after a CI run on the fork.

The branch now also carries Moon0755/VIctory#1 (the negative-Z select and the clamp case, found on an RTX 4090), so the head is 8731510.

— Fable

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188976891 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#issuecomment-7188976891). Originally posted by [Moon0755](https://github.com/Moon0755) on 2026-11-26T10:09:08Z. --- On the review above: agreed on both points. Source `abs`/`neg` on these ops will be applied to the bits on the SC/TC path, with a test on the modifier columns of the same published table, and the oracle test will compare bit for bit. I'll push it here after a CI run on the fork. The branch now also carries Moon0755/VIctory#1 (the negative-Z select and the clamp case, found on an RTX 4090), so the head is `8731510`. — Fable
fuzeofficlal commented 2026-11-26 12:05:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T11:18:41Z.

Review: APPROVED


Verified c09afc9a on RTX 5090 and WARP: both previous items are cleanly resolved — VOP3 source abs/neg are now applied bitwise on the raw SC/TC path, and cube_zero_and_denormals_match_rdna2_oracle uses bit-exact INT assertions for SC/TC.

Verified locally on Windows 11 x64 (RTX 5090 + WARP + dxil.dll, c09afc9a):

  • cargo run --locked -p xtask -- policy (191 files ok; emit/lower.rs = 523,730 bytes, 558 bytes below the 524,288-byte cap) and cargo clippy --workspace --all-targets -- -D warnings (default and --all-features): clean.
  • emit::lower::tests: 33 passed, 0 failed.
  • RTX 5090 and VICTORY_WARP=1 (--test-threads=1): all 6 cube tests passed and emit::semantics_tests 38 passed, 0 failed (1 ignored).

Two minor non-blocking nits:

  1. In cube_srcmod_bit_paths_match_rdna2_oracle (semantics_tests.rs:1514-1558), none of the 4 cases currently select a negative subnormal with abs enabled along the raw SC/TC path (sc_mods puts abs on x, which is only selected in row 4 where x is already +0x0000_0007; tc_mods puts abs on z, which is never selected because y is never major). Adding a row that selects a negative subnormal under abs (e.g., SC(|-denorm|, 0, +1) or TC(0, +1, |-denorm|)) would also lock down raw abs.
  2. rustfmt --edition 2024 --check flags formatting on newly added lines 1485, 1497, and 1513 in semantics_tests.rs.
<!-- greyfinch-sync:Marvisak/VIctory:review:6073236461 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#pullrequestreview-6073236461). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T11:18:41Z. **Review:** APPROVED --- Verified `c09afc9a` on RTX 5090 and WARP: both previous items are cleanly resolved — VOP3 source `abs`/`neg` are now applied bitwise on the raw SC/TC path, and `cube_zero_and_denormals_match_rdna2_oracle` uses bit-exact `INT` assertions for SC/TC. Verified locally on Windows 11 x64 (RTX 5090 + WARP + `dxil.dll`, `c09afc9a`): - `cargo run --locked -p xtask -- policy` (`191 files ok`; `emit/lower.rs` = `523,730` bytes, 558 bytes below the 524,288-byte cap) and `cargo clippy --workspace --all-targets -- -D warnings` (default and `--all-features`): clean. - `emit::lower::tests`: 33 passed, 0 failed. - RTX 5090 and `VICTORY_WARP=1` (`--test-threads=1`): all 6 cube tests passed and `emit::semantics_tests` 38 passed, 0 failed (1 ignored). Two minor non-blocking nits: 1. In `cube_srcmod_bit_paths_match_rdna2_oracle` (`semantics_tests.rs:1514-1558`), none of the 4 cases currently select a negative subnormal with `abs` enabled along the raw SC/TC path (`sc_mods` puts `abs` on `x`, which is only selected in row 4 where `x` is already `+0x0000_0007`; `tc_mods` puts `abs` on `z`, which is never selected because `y` is never major). Adding a row that selects a negative subnormal under `abs` (e.g., `SC(|-denorm|, 0, +1)` or `TC(0, +1, |-denorm|)`) would also lock down raw `abs`. 2. `rustfmt --edition 2024 --check` flags formatting on newly added lines `1485`, `1497`, and `1513` in `semantics_tests.rs`.
Moon0755 commented 2026-11-26 12:05:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-26T11:08:45Z.


Both points from the review are in, head c09afc9.

  • Source abs/neg on v_cubesc_f32 / v_cubetc_f32 now act on the operand bits (AND with 0x7FFF_FFFF, then XOR with 0x8000_0000) on the raw-bit path. The axis and sign decisions are unchanged.
  • New test cube_srcmod_bit_paths_match_rdna2_oracle: rows 6, 7, 8 and 11 of the published table, columns 9 (|x|, -y, -z) and 10 (-x, -y, |z|), compared bit for bit.
  • cube_zero_and_denormals_match_rdna2_oracle compares S/T bit for bit as well; all rows pass, the NaN rows included.

CI on the fork, WARP only: without the change the new test fails (run 45800496753; WARP itself flushes the subnormal in the float abs/neg, so the mechanism shows there too), with it 306 pass (run 45805387961). Not run on a hardware adapter. lower.rs is 523,730 bytes.

— Devin & Fable

<!-- greyfinch-sync:Marvisak/VIctory:comment:7190331676 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#issuecomment-7190331676). Originally posted by [Moon0755](https://github.com/Moon0755) on 2026-11-26T11:08:45Z. --- Both points from the review are in, head `c09afc9`. - Source `abs`/`neg` on `v_cubesc_f32` / `v_cubetc_f32` now act on the operand bits (AND with `0x7FFF_FFFF`, then XOR with `0x8000_0000`) on the raw-bit path. The axis and sign decisions are unchanged. - New test `cube_srcmod_bit_paths_match_rdna2_oracle`: rows 6, 7, 8 and 11 of the published table, columns 9 (`|x|, -y, -z`) and 10 (`-x, -y, |z|`), compared bit for bit. - `cube_zero_and_denormals_match_rdna2_oracle` compares S/T bit for bit as well; all rows pass, the NaN rows included. CI on the fork, WARP only: without the change the new test fails ([run 45800496753](https://github.com/Moon0755/VIctory/actions/runs/45800496753); WARP itself flushes the subnormal in the float abs/neg, so the mechanism shows there too), with it 306 pass ([run 45805387961](https://github.com/Moon0755/VIctory/actions/runs/45805387961)). Not run on a hardware adapter. `lower.rs` is 523,730 bytes. — Devin & Fable
Moon0755 commented 2026-11-26 12:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-26T11:45:55Z.


Both nits are in, head de77244, tests only.

  • A measured row for the case you named: column 13 of the published table, v_cubesc_f32 v23, v4, -v5, |v6| clamp, rows 6, 8 and 11. Row 8 selects a negative subnormal z under abs through the negative x axis; all three give 0x00000007. New test clamped_cube_abs_of_negative_denormal_matches_rdna2_oracle, bit for bit.
  • The three lines rustfmt flagged are formatted from the cargo fmt --check output in CI. Two older hunks in that file (now at 1931 and 3450) are not from this PR and are left alone.

CI on the fork, WARP only: 307 passed (run 45812258458).

— Devin & Fable

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191137286 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#issuecomment-7191137286). Originally posted by [Moon0755](https://github.com/Moon0755) on 2026-11-26T11:45:55Z. --- Both nits are in, head `de77244`, tests only. - A measured row for the case you named: column 13 of the published table, `v_cubesc_f32 v23, v4, -v5, |v6| clamp`, rows 6, 8 and 11. Row 8 selects a negative subnormal `z` under `abs` through the negative `x` axis; all three give `0x00000007`. New test `clamped_cube_abs_of_negative_denormal_matches_rdna2_oracle`, bit for bit. - The three lines `rustfmt` flagged are formatted from the `cargo fmt --check` output in CI. Two older hunks in that file (now at 1931 and 3450) are not from this PR and are left alone. CI on the fork, WARP only: 307 passed ([run 45812258458](https://github.com/Moon0755/VIctory/actions/runs/45812258458)). — Devin & Fable
Dukestar69 commented 2026-11-26 14:01:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T13:09:56Z.

Review: APPROVED


Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-shader --lib cube -- --test-threads=1: 7/7 passed on RTX 5090 and WARP (all 5 new cube denormal/zero/srcmod/clamp tests pass).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly preserves denormal coordinates in v_cubesc/v_cubetc_f32 and returns +0.0 for v_cubema_f32 of zero.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6074685359 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3127#pullrequestreview-6074685359). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T13:09:56Z. **Review:** APPROVED --- Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib cube -- --test-threads=1`: 7/7 passed on RTX 5090 and WARP (all 5 new cube denormal/zero/srcmod/clamp tests pass). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly preserves denormal coordinates in `v_cubesc`/`v_cubetc_f32` and returns `+0.0` for `v_cubema_f32` of zero. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/3127:upstream-pr/3127'
git switch 'upstream-pr/3127'

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/3127'
git switch 'upstream-pr/3127'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3127'
git switch 'upstream-pr/3127'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3127'
git switch 'main'
git merge --squash 'upstream-pr/3127'
git switch 'main'
git merge --ff-only 'upstream-pr/3127'
git switch 'main'
git merge 'upstream-pr/3127'
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
Marvisak/VIctory!3125
No description provided.