[PR #1210] xdxr_build: take the BOX16 half sign without a shift-then-mask (AMD driver miscompile) #1242

Open
opened 2026-11-26 20:20:34 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1210
Author: @whoalin1
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: amd-val-box16-sign


📝 Commits (1)

  • 4a4aa9b xdxr_build: take the BOX16 half sign without a shift-then-mask

📊 Changes

3 files changed (+7691 additions, -7687 deletions)

View changed files

📝 docs/bvh.md (+4 -1)
📝 runtime/src/xdxr_build.comp (+4 -2)
📝 runtime/src/xdxr_build.inc (+7683 -7684)

📄 Description

Claimed in the coordination issue as: XDXR-BOX16-SIGN-AMD (claim)

Depends on: none

What and why

On the AMD Windows driver (24.10.24, Vulkan 1.3.280, gfx1035), every MINIMIZE_MEMORY BOX16 build through xdxr_build.comp produced corrupt boxes: tools/xdxr_bvh.py check-build reported ~20,727 problems ("child box not inside its parent's box") and essentially all rays missed. BOX32 builds of the same trees were bit-exact, and NVIDIA produced correct output from the identical SPIR-V module — an AMD shader-compiler miscompile, not a logic bug.

Bisection isolated half_directed() in runtime/src/xdxr_build.comp: it computed the half's sign as (u >> 16) & 0x8000. The bit-equivalent (u & 0x80000000u) >> 16 produces correct output on the same driver. In SPIR-V the old form is OpShiftRightLogical + OpBitwiseAnd with a 0x8000 mask; the new form reuses the existing 0x80000000 constant. Deterministic across runs and across -O/-O0 glslc output.

Changes:

  • runtime/src/xdxr_build.comp: one-line rewrite + comment.
  • runtime/src/xdxr_build.inc: regenerated with glslc from Vulkan SDK 1.4.363.0 (the large diff is SPIR-V result-ID renumbering).
  • docs/bvh.md: note in the BOX16 section.

Tested

  • vk_xdxr_build_test + xdxr_bvh.py check-build --rays 1000 on the AMD iGPU: 20,727 problems → all cases match (box16/paired/extremes/refit).
  • d3d12_xdxr_rt + its check on AMD iGPU: all match (was failing before).
  • NVIDIA RTX 4070 SUPER re-run: still all match (no regression).
  • py -3.14 -I tests/test_xdxr_bvh.py: 47 tests OK.
  • LEONIDA_VK_VALIDATION=1 ctest sweep on AMD iGPU: 0 VUIDs (unrelated suite run the same session).

GPUs tested: AMD Radeon Graphics (Ryzen 5 7600 iGPU, gfx1035-class RDNA2, driver 24.10.24, Vulkan 1.3.280, Windows 11); NVIDIA GeForce RTX 4070 SUPER (driver 610.88, Windows 11)

AI-assisted: yes (Devin)

Checklist

  • Based on current main and merges cleanly
  • One topic; follow-up work goes in a new pull request
  • No game data, keys or decryption
  • N/A — runtime shader-source workaround, no translator rule added

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1210 **Author:** [@whoalin1](https://github.com/whoalin1) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `amd-val-box16-sign` --- ### 📝 Commits (1) - [`4a4aa9b`](https://github.com/ubiquitarianism/leonida/commit/4a4aa9b6dca4dc2c471b1a1517f3058421bae5db) xdxr_build: take the BOX16 half sign without a shift-then-mask ### 📊 Changes **3 files changed** (+7691 additions, -7687 deletions) <details> <summary>View changed files</summary> 📝 `docs/bvh.md` (+4 -1) 📝 `runtime/src/xdxr_build.comp` (+4 -2) 📝 `runtime/src/xdxr_build.inc` (+7683 -7684) </details> ### 📄 Description Claimed in the coordination issue as: XDXR-BOX16-SIGN-AMD ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143281151)) Depends on: none ### What and why On the AMD Windows driver (24.10.24, Vulkan 1.3.280, gfx1035), every `MINIMIZE_MEMORY` **BOX16** build through `xdxr_build.comp` produced corrupt boxes: `tools/xdxr_bvh.py check-build` reported ~20,727 problems ("child box not inside its parent's box") and essentially all rays missed. BOX32 builds of the same trees were bit-exact, and NVIDIA produced correct output from the identical SPIR-V module — an AMD shader-compiler miscompile, not a logic bug. Bisection isolated `half_directed()` in `runtime/src/xdxr_build.comp`: it computed the half's sign as `(u >> 16) & 0x8000`. The bit-equivalent `(u & 0x80000000u) >> 16` produces correct output on the same driver. In SPIR-V the old form is `OpShiftRightLogical` + `OpBitwiseAnd` with a `0x8000` mask; the new form reuses the existing `0x80000000` constant. Deterministic across runs and across `-O`/`-O0` glslc output. Changes: - `runtime/src/xdxr_build.comp`: one-line rewrite + comment. - `runtime/src/xdxr_build.inc`: regenerated with glslc from Vulkan SDK 1.4.363.0 (the large diff is SPIR-V result-ID renumbering). - `docs/bvh.md`: note in the BOX16 section. ### Tested - `vk_xdxr_build_test` + `xdxr_bvh.py check-build --rays 1000` on the AMD iGPU: **20,727 problems → all cases match** (box16/paired/extremes/refit). - `d3d12_xdxr_rt` + its check on AMD iGPU: all match (was failing before). - NVIDIA RTX 4070 SUPER re-run: still all match (no regression). - `py -3.14 -I tests/test_xdxr_bvh.py`: 47 tests OK. - `LEONIDA_VK_VALIDATION=1` ctest sweep on AMD iGPU: 0 VUIDs (unrelated suite run the same session). GPUs tested: AMD Radeon Graphics (Ryzen 5 7600 iGPU, gfx1035-class RDNA2, driver 24.10.24, Vulkan 1.3.280, Windows 11); NVIDIA GeForce RTX 4070 SUPER (driver 610.88, Windows 11) AI-assisted: yes (Devin) ### Checklist - [x] Based on current `main` and merges cleanly - [x] One topic; follow-up work goes in a new pull request - [x] No game data, keys or decryption - [x] N/A — runtime shader-source workaround, no translator rule added --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1242
No description provided.