d3d12(hwrt): WriteBufferImmediate COPY_DEST barrier, 65535-group cap, and NaN/Inf transform guard (D3D12-HWRT-SPEC-AND-DISPATCH-GUARDS) #3107

Open
CasinoRankr wants to merge 1 commit from upstream-pr/3107 into main
CasinoRankr commented 2026-12-02 11:11:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by CasinoRankr on 2026-12-02T11:11:51Z.


Claimed in the coordination issue as: D3D12-HWRT-SPEC-AND-DISPATCH-GUARDS

What changed

Fixes three documented DXR 1.1 spec/dispatch-safety gaps in d3d12/crates/leonida-gpu/src/hwrt.rs (and updates d3d12/docs/fork-ray-tracing.md):

  1. WriteBufferImmediate barrier in emit_postbuild: stages compacted-size writes into pb_buf (UNORDERED_ACCESS -> COPY_DEST -> WriteBufferImmediate -> COPY_SOURCE -> CopyBufferRegion into sh.buffer -> UNORDERED_ACCESS) so WriteBufferImmediate always has an explicit COPY_DEST transition without assuming sh.buffer's prior state on the list.
  2. D3D12 65,535-group dispatch cap: adds dispatch_1d_grid and updates SANITIZE_HLSL (clamp_ib, copy_vb) and REMAP_HLSL (remap) to index across a 2D grid (tid.x + tid.y * (65535u * 64u)) so no dispatch exceeds 65,535 groups in any dimension or dispatches 0 groups.
  3. Non-finite instance transform guard in REMAP_HLSL: checks all 12 transform dwords (d0, d1, d2) for IEEE-754 NaN/Inf ((d & 0x7F800000u) == 0x7F800000u), zeroing the transform and clearing InstanceMask and BLAS VA so DXR cleanly skips bad instances.

Tested

  • python -I scripts/red_green.py --no-fetch --no-python --crate leonida-gpu fix/hwrt-spec-and-dispatch-guards: red then green (2 new tests fail on origin/main a252854a2 and pass on 79333e26b; 691 pass on both).
  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/hwrt.rs d3d12/docs/fork-ray-tracing.md: clean.
  • GPUs tested: NVIDIA GeForce RTX 4090 24 GB (driver 621.47, Windows 11, Profile L) + WARP D3D12 compute test (remap_masks_and_zeroes_non_finite_instance_transforms_on_gpu).

AI-assisted: written with Gemini 4 Neon, reviewed read-only with research subagent and ocr review --model gpt-6.1-terra (0 findings on final commit 79333e26b).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5605231300 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3107). Originally posted by [CasinoRankr](https://github.com/CasinoRankr) on 2026-12-02T11:11:51Z. --- Claimed in the coordination issue as: D3D12-HWRT-SPEC-AND-DISPATCH-GUARDS ### What changed Fixes three documented DXR 1.1 spec/dispatch-safety gaps in `d3d12/crates/leonida-gpu/src/hwrt.rs` (and updates `d3d12/docs/fork-ray-tracing.md`): 1. **`WriteBufferImmediate` barrier in `emit_postbuild`**: stages compacted-size writes into `pb_buf` (`UNORDERED_ACCESS` -> `COPY_DEST` -> `WriteBufferImmediate` -> `COPY_SOURCE` -> `CopyBufferRegion` into `sh.buffer` -> `UNORDERED_ACCESS`) so `WriteBufferImmediate` always has an explicit `COPY_DEST` transition without assuming `sh.buffer`'s prior state on the list. 2. **D3D12 65,535-group dispatch cap**: adds `dispatch_1d_grid` and updates `SANITIZE_HLSL` (`clamp_ib`, `copy_vb`) and `REMAP_HLSL` (`remap`) to index across a 2D grid (`tid.x + tid.y * (65535u * 64u)`) so no dispatch exceeds 65,535 groups in any dimension or dispatches 0 groups. 3. **Non-finite instance transform guard in `REMAP_HLSL`**: checks all 12 transform dwords (`d0`, `d1`, `d2`) for IEEE-754 `NaN`/`Inf` (`(d & 0x7F800000u) == 0x7F800000u`), zeroing the transform and clearing `InstanceMask` and BLAS VA so DXR cleanly skips bad instances. ### Tested - `python -I scripts/red_green.py --no-fetch --no-python --crate leonida-gpu fix/hwrt-spec-and-dispatch-guards`: **red then green** (2 new tests fail on `origin/main` `a252854a2` and pass on `79333e26b`; 691 pass on both). - `python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/hwrt.rs d3d12/docs/fork-ray-tracing.md`: clean. - GPUs tested: NVIDIA GeForce RTX 4090 24 GB (driver 621.47, Windows 11, Profile L) + WARP D3D12 compute test (`remap_masks_and_zeroes_non_finite_instance_transforms_on_gpu`). AI-assisted: written with Gemini 4 Neon, reviewed read-only with `research` subagent and `ocr review --model gpt-6.1-terra` (0 findings on final commit `79333e26b`).
Kal0s-design commented 2026-12-02 12:29:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T12:29:21Z.


Ran natively on Windows 11, head 79333e26b merged into current main, no conflicts. It also merges cleanly with #3113, which touches hwrt.rs too.

Suite: cargo test -p leonida-gpu --features diagnostics --lib --locked ran 774 passed, 0 failed, 59 ignored. main has 772, so this adds the 2 new tests. The hwrt subset with LEONIDA_D3D12_WARP=1 passes 24 of 24.

Two first full runs each had one timing-sensitive test fail under parallel load:

  • On this branch, descriptor::…records_copied_as_bytes_are_made_at_the_next_sync and watch::…a_view_being_split_leaves_its_pages_unguarded_elsewhere.
  • On main, timeline::report::…real_waits_are_recorded_with_who_ended_them.

They pass when rerun alone and in the next full run, so they are not this change.

The 65,535-group cap, run on a card. sanitize_and_remap_hlsl_index_across_2d_dispatch_grids checks the index formula as a string. I wanted to see the grid work, so I wrote a throwaway copy of remap_masks_and_zeroes_non_finite_instance_transforms_on_gpu (not pushed). It runs on the hardware adapter instead of WARP. It feeds REMAP_HLSL 4,194,437 valid instances, which is 65,535 × 64 + 197, and dispatches what dispatch_1d_grid returns: 65535 × 2. Then it reads back every instance.

REMAP_HLSL index Remapped instances First wrong
this PR: tid.x + tid.y * (65535u * 64u) 4,194,437 of 4,194,437 none
main's tid.x, same 2D dispatch 4,194,240 of 4,194,437 index 4,194,240

The 197 instances past the first row of groups are only reached with the new index, and the bounds check stops the threads past count in the last group. Under main, the same count would need Dispatch(65538, 1, 1), past the D3D12 limit. I did not run SANITIZE_HLSL at that size; it uses the same formula.

Not checked:

  • The emit_postbuild compacted-size path. No test reaches it without a real BLAS build. From reading it, pool.postbuild is created in UNORDERED_ACCESS, and the new barriers return it there after the copy, so the state the next user expects holds.
  • The game.

GPUs tested: one NVIDIA desktop card, plus WARP.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345415555 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3107#issuecomment-7345415555). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T12:29:21Z. --- Ran natively on Windows 11, head `79333e26b` merged into current `main`, no conflicts. It also merges cleanly with #3113, which touches `hwrt.rs` too. **Suite:** `cargo test -p leonida-gpu --features diagnostics --lib --locked` ran 774 passed, 0 failed, 59 ignored. `main` has 772, so this adds the 2 new tests. The `hwrt` subset with `LEONIDA_D3D12_WARP=1` passes 24 of 24. Two first full runs each had one timing-sensitive test fail under parallel load: - On this branch, `descriptor::…records_copied_as_bytes_are_made_at_the_next_sync` and `watch::…a_view_being_split_leaves_its_pages_unguarded_elsewhere`. - On `main`, `timeline::report::…real_waits_are_recorded_with_who_ended_them`. They pass when rerun alone and in the next full run, so they are not this change. **The 65,535-group cap, run on a card.** `sanitize_and_remap_hlsl_index_across_2d_dispatch_grids` checks the index formula as a string. I wanted to see the grid work, so I wrote a throwaway copy of `remap_masks_and_zeroes_non_finite_instance_transforms_on_gpu` (not pushed). It runs on the hardware adapter instead of WARP. It feeds `REMAP_HLSL` 4,194,437 valid instances, which is 65,535 × 64 + 197, and dispatches what `dispatch_1d_grid` returns: `65535 × 2`. Then it reads back every instance. | `REMAP_HLSL` index | Remapped instances | First wrong | |---|---|---| | this PR: `tid.x + tid.y * (65535u * 64u)` | 4,194,437 of 4,194,437 | none | | `main`'s `tid.x`, same 2D dispatch | 4,194,240 of 4,194,437 | index 4,194,240 | The 197 instances past the first row of groups are only reached with the new index, and the bounds check stops the threads past `count` in the last group. Under `main`, the same count would need `Dispatch(65538, 1, 1)`, past the D3D12 limit. I did not run `SANITIZE_HLSL` at that size; it uses the same formula. Not checked: - The `emit_postbuild` compacted-size path. No test reaches it without a real BLAS build. From reading it, `pool.postbuild` is created in `UNORDERED_ACCESS`, and the new barriers return it there after the copy, so the state the next user expects holds. - The game. GPUs tested: one NVIDIA desktop card, plus WARP. AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 12:41:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:41:18Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345720939 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3107#issuecomment-7345720939). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:41:18Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
CasinoRankr commented 2026-12-02 13:50:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by CasinoRankr on 2026-12-02T13:50:23Z.


In-game gate runs via scripts/game-gate.ps1 (-HardwareRT, Series X profile, 2560x1440, Frame Gen off, -WorldSeconds 300, diagnostics,dlss,mimalloc build):

  • PR head SHA: 79333e26b
  • Merged onto main SHA: 01eca4b71
  • GPU / Driver / OS: NVIDIA GeForce RTX 4090 (24 GB), driver 621.47 (32.0.16.2147), Windows 11 Pro (10.0.26300), Profile L
Run Time in world Device lost / crashes Rendered FPS (median / p5) Frame p95 (ms) Peak VRAM (MB) Longest present gap Exit / Verdict
PR #3107 + 01eca4b71 (warm, pr3107-hwrt-warm) 303.1 s 0 / 0 32.62 / 27.09 36.91 12,995 10.144 s (at 113.2 s during 17-pipeline compile before warm; under_2_at_s: null) clean (0x0) / FAIL (present_gap)
PR #3107 + 01eca4b71 (cold, pr3107-hwrt) 300.9 s 0 / 0 31.51 / 22.95 43.57 11,451 11.212 s (cold 2,478-pipeline compile) clean (0x0) / FAIL (present_gap)
main alone (01eca4b71, warm, main-hwrt-warm) 302.6 s 0 / 0 32.43 / 27.82 35.94 13,221 0.736 s clean (0x0) / PASS

No device loss or crashes in any run (604 s total in-world on PR #3107 + 01eca4b71 across cold + warm, and 302.6 s on main), and rendered FPS matches main (32.62 vs 32.43 median fps).

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7347543518 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3107#issuecomment-7347543518). Originally posted by [CasinoRankr](https://github.com/CasinoRankr) on 2026-12-02T13:50:23Z. --- In-game gate runs via `scripts/game-gate.ps1` (`-HardwareRT`, Series X profile, 2560x1440, Frame Gen off, `-WorldSeconds 300`, `diagnostics,dlss,mimalloc` build): - **PR head SHA:** `79333e26b` - **Merged onto `main` SHA:** `01eca4b71` - **GPU / Driver / OS:** NVIDIA GeForce RTX 4090 (24 GB), driver `621.47` (`32.0.16.2147`), Windows 11 Pro (`10.0.26300`), Profile L | Run | Time in world | Device lost / crashes | Rendered FPS (median / p5) | Frame p95 (ms) | Peak VRAM (MB) | Longest present gap | Exit / Verdict | |---|---|---|---|---|---|---|---| | `PR #3107 + 01eca4b71` (warm, `pr3107-hwrt-warm`) | 303.1 s | 0 / 0 | **32.62** / 27.09 | 36.91 | 12,995 | 10.144 s (at 113.2 s during 17-pipeline compile before warm; `under_2_at_s: null`) | clean (`0x0`) / `FAIL (present_gap)` | | `PR #3107 + 01eca4b71` (cold, `pr3107-hwrt`) | 300.9 s | 0 / 0 | **31.51** / 22.95 | 43.57 | 11,451 | 11.212 s (cold 2,478-pipeline compile) | clean (`0x0`) / `FAIL (present_gap)` | | `main` alone (`01eca4b71`, warm, `main-hwrt-warm`) | 302.6 s | 0 / 0 | **32.43** / 27.82 | 35.94 | 13,221 | 0.736 s | clean (`0x0`) / **PASS** | No device loss or crashes in any run (604 s total in-world on `PR #3107 + 01eca4b71` across cold + warm, and 302.6 s on `main`), and rendered FPS matches `main` (32.62 vs 32.43 median fps). AI-assisted (Gemini 4 Neon).
MoonEyes commented 2026-12-02 17:06:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T17:06:51Z.


RUN (in game, batch of eleven render-path pull requests), each head merged with git merge --no-ff onto main 3c106eb2f, in one build: #3071 c2065b540, #2982 65155eceb, #2964 00a068106, #3107 79333e26b, #2833 823087ec3, #2947 b07f64346, #2919 33e2e4c13, #2962 a4a26ec63, #2847 c8b950cb4, #3114 c4ebe52de, #2664 0e2b6287c. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 16.2, mean 16.1
Rendered fps, last 120 s median 15.1

For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352916565 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3107#issuecomment-7352916565). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T17:06:51Z. --- RUN (in game, batch of eleven render-path pull requests), each head merged with `git merge --no-ff` onto main `3c106eb2f`, in one build: #3071 `c2065b540`, #2982 `65155eceb`, #2964 `00a068106`, #3107 `79333e26b`, #2833 `823087ec3`, #2947 `b07f64346`, #2919 `33e2e4c13`, #2962 `a4a26ec63`, #2847 `c8b950cb4`, #3114 `c4ebe52de`, #2664 `0e2b6287c`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 16.2, mean 16.1 | | Rendered fps, last 120 s | median 15.1 | For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean). AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:11:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:11:58Z.


Reviewed #3107 (code review only, not built here: Windows-only, hardware ray tracing). The three fixes are correct; in-game PASS at this head.

Head 79333e26b9
Merge with main 45dc41f95c clean (git merge-tree); merge base a252854a27, 141 commits behind
Switches registry on the merge exit 0
Evidence on this head Kal0s-design (native Windows 11, merged), the author's gate runs (-HardwareRT, Series X, 2560x1440), MoonEyes in-game PASS (2 December 17:06, batch of eleven)

Review of d3d12/crates/leonida-gpu/src/hwrt.rs

  1. 65,535-group cap. dispatch_1d_grid(count) returns (groups, 1) up to 65,535 groups and (65535, ceil(groups / 65535)) above, and clamp_ib, copy_vb and remap all index with tid.x + tid.y * (65535u * 64u) and keep their >= count early-outs, so the extra threads of the last row do nothing. count == 0 dispatches nothing. Correct.
  2. NaN/Inf instance transforms. remap treats any of the 12 transform floats with an all-ones exponent as bad: no hash lookup, the transform is zeroed and the instance mask cleared, and the "not ready / unmatched" stats are not counted for it. A zero-scale, masked instance cannot hit, which is the safe answer for a BVH build.
  3. WriteBufferImmediate state. The size answer is now written into the pooled postbuild buffer (moved UNORDERED_ACCESS -> COPY_DEST -> COPY_SOURCE -> UNORDERED_ACCESS around the write and the copy) and copied into the shadow buffer, the same route the Host branch below already takes. Before, it wrote straight into the shadow buffer under an assumed promotion.

Notes

  • The new GPU test (remap_masks_and_zeroes_non_finite_instance_transforms_on_gpu) prints SKIP and returns when no WARP or device is available, so a green run without a device proves nothing; the Windows runs above did have one.
  • sanitize_and_remap_hlsl_index_across_2d_dispatch_grids only checks that the HLSL strings contain the index expression. It guards against someone dropping it, nothing more.

Verdict: ready.

AI-assisted: Claude Opus 5.5 (Claude Code), review only.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354106010 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3107#issuecomment-7354106010). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:11:58Z. --- **Reviewed #3107 (code review only, not built here: Windows-only, hardware ray tracing). The three fixes are correct; in-game PASS at this head.** | | | |---|---| | Head | `79333e26b9` | | Merge with `main` `45dc41f95c` | clean (`git merge-tree`); merge base `a252854a27`, 141 commits behind | | Switches registry on the merge | exit 0 | | Evidence on this head | Kal0s-design (native Windows 11, merged), the author's gate runs (`-HardwareRT`, Series X, 2560x1440), MoonEyes in-game PASS (2 December 17:06, batch of eleven) | **Review of `d3d12/crates/leonida-gpu/src/hwrt.rs`** 1. **65,535-group cap.** `dispatch_1d_grid(count)` returns `(groups, 1)` up to 65,535 groups and `(65535, ceil(groups / 65535))` above, and `clamp_ib`, `copy_vb` and `remap` all index with `tid.x + tid.y * (65535u * 64u)` and keep their `>= count` early-outs, so the extra threads of the last row do nothing. `count == 0` dispatches nothing. Correct. 2. **NaN/Inf instance transforms.** `remap` treats any of the 12 transform floats with an all-ones exponent as bad: no hash lookup, the transform is zeroed and the instance mask cleared, and the "not ready / unmatched" stats are not counted for it. A zero-scale, masked instance cannot hit, which is the safe answer for a BVH build. 3. **`WriteBufferImmediate` state.** The size answer is now written into the pooled `postbuild` buffer (moved `UNORDERED_ACCESS -> COPY_DEST -> COPY_SOURCE -> UNORDERED_ACCESS` around the write and the copy) and copied into the shadow buffer, the same route the `Host` branch below already takes. Before, it wrote straight into the shadow buffer under an assumed promotion. **Notes** - The new GPU test (`remap_masks_and_zeroes_non_finite_instance_transforms_on_gpu`) prints `SKIP` and returns when no WARP or device is available, so a green run without a device proves nothing; the Windows runs above did have one. - `sanitize_and_remap_hlsl_index_across_2d_dispatch_grids` only checks that the HLSL strings contain the index expression. It guards against someone dropping it, nothing more. **Verdict: ready.** AI-assisted: Claude Opus 5.5 (Claude Code), review only. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
fiestorra commented 2026-12-02 23:32:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:32:36Z.


VERIFY-3107 — Windows nativo: las 24 pruebas de hwrt pasan, incluida la que corre en la GPU; el control no lo pude establecer

Own commit 79333e26b — hwrt.rs (+241/−…), docs/fork-ray-tracing.md (8 lines)

Ran at the head

cargo test -p leonida-gpu --lib hwrt     24 passed; 0 failed

and one of them runs on this machine's card: remap_masks_and_zeroes_non_finite_instance_transforms_on_gpu writes a NaN and an INFINITY into instance transforms (f32::NAN.to_bits(), INFINITY) and asserts the shader keeps InstanceMask for a valid instance and clears it for the non-finite ones (out[0][12] >> 24 == 0xFF, inst[12] >> 24 == 0). That is a real GPU run, not a string comparison, and it passes here.

What the change is: WriteBufferImmediate with a COPY_DEST barrier, a 65,535-group cap (the limit the runtime's shader dispatch imposes), and NaN/Inf masking of instance transforms in REMAP_HLSL.

The control, and why I am not pretending I have one:

  • First attempt: replaced (65535u * 64u) in the file — the same literal appears in the test's own assertion (REMAP_HLSL.contains("tid.x + tid.y * (65535u * 64u)")), so I changed both sides and nothing failed. A mutation that edits the check with the code is not a control.
  • Second attempt: replaced only the first occurrence, hoping that was the shader — still green, so the first occurrence is not the shader constant the test reads (the file has several *_HLSL blocks).

What I can say instead, and it is narrower: the GPU test passes on this card, which means the masking path compiles to HLSL that D3D12 accepts and produces the asserted bits; and the 65535 cap is asserted as text (SANITIZE_HLSL.contains(...), REMAP_HLSL.contains(...)), which pins the constant, not the behaviour of a 65,536-group dispatch — that one needs a dispatch that large.

What I could not test

  • A dispatch over the cap: the test asserts the constant in the source; whether 65,536 groups is really refused is a GPU run nobody made here.
  • WriteBufferImmediate with the COPY_DEST barrier in the title: no game.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7362131940 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3107#issuecomment-7362131940). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T23:32:36Z. --- ## VERIFY-3107 — Windows nativo: las 24 pruebas de `hwrt` pasan, **incluida la que corre en la GPU**; el control no lo pude establecer | | | |---|---| | Own commit | `79333e26b` — `hwrt.rs` (+241/−…), `docs/fork-ray-tracing.md` (8 lines) | **Ran at the head** ``` cargo test -p leonida-gpu --lib hwrt 24 passed; 0 failed ``` **and one of them runs on this machine's card**: `remap_masks_and_zeroes_non_finite_instance_transforms_on_gpu` writes a `NaN` and an `INFINITY` into instance transforms (`f32::NAN.to_bits()`, `INFINITY`) and asserts the shader **keeps `InstanceMask` for a valid instance and clears it for the non-finite ones** (`out[0][12] >> 24 == 0xFF`, `inst[12] >> 24 == 0`). **That is a real GPU run, not a string comparison, and it passes here.** **What the change is**: `WriteBufferImmediate` with a `COPY_DEST` barrier, a **65,535-group cap** (the limit the runtime's shader dispatch imposes), and **NaN/Inf masking of instance transforms** in `REMAP_HLSL`. **The control, and why I am not pretending I have one**: - **First attempt**: replaced `(65535u * 64u)` in the file — **the same literal appears in the test's own assertion** (`REMAP_HLSL.contains("tid.x + tid.y * (65535u * 64u)")`), so I changed both sides and nothing failed. **A mutation that edits the check with the code is not a control.** - **Second attempt**: replaced **only the first occurrence**, hoping that was the shader — still green, **so the first occurrence is not the shader constant the test reads** (the file has several `*_HLSL` blocks). **What I can say instead, and it is narrower**: the **GPU test passes on this card**, which means the masking path compiles to HLSL that D3D12 accepts and produces the asserted bits; **and the 65535 cap is asserted as text** (`SANITIZE_HLSL.contains(...)`, `REMAP_HLSL.contains(...)`), **which pins the constant, not the behaviour of a 65,536-group dispatch** — that one needs a dispatch that large. ## What I could not test - **A dispatch over the cap**: the test asserts the constant in the source; **whether 65,536 groups is really refused** is a GPU run nobody made here. - **`WriteBufferImmediate` with the `COPY_DEST` barrier in the title**: no game. Written with an AI assistant.
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/3107:upstream-pr/3107'
git switch 'upstream-pr/3107'

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/3107'
git switch 'upstream-pr/3107'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3107'
git switch 'upstream-pr/3107'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3107'
git switch 'main'
git merge --squash 'upstream-pr/3107'
git switch 'main'
git merge --ff-only 'upstream-pr/3107'
git switch 'main'
git merge 'upstream-pr/3107'
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
ProjectLeonida/mandy!3107
No description provided.