xdxr_build: take the BOX16 half sign without a shift-then-mask (AMD driver miscompile) #1210
Closed
leonida/mandy
whoalin1 wants to merge 0 commits from
amd-val-box16-sign into main
pull from: amd-val-box16-sign
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!1210
Loading…
Reference in a new issue
No description provided.
Delete branch "amd-val-box16-sign"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
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_MEMORYBOX16 build throughxdxr_build.compproduced corrupt boxes:tools/xdxr_bvh.py check-buildreported ~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()inruntime/src/xdxr_build.comp: it computed the half's sign as(u >> 16) & 0x8000. The bit-equivalent(u & 0x80000000u) >> 16produces correct output on the same driver. In SPIR-V the old form isOpShiftRightLogical+OpBitwiseAndwith a0x8000mask; the new form reuses the existing0x80000000constant. Deterministic across runs and across-O/-O0glslc 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 1000on 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).py -3.14 -I tests/test_xdxr_bvh.py: 47 tests OK.LEONIDA_VK_VALIDATION=1ctest 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
mainand merges cleanlyIndependent run on a second AMD Windows driver and on NVIDIA, head 42d66230, built with
scripts\build_runtime.ps1(MSVC 14.44, RelWithDebInfo), Windows 11 build 26300.71f99e22The four tests are
xdxr_build,xdxr_build_check,d3d12_xdxr_rtandd3d12_xdxr_rt_check(ctest, device picked withLEONIDA_VK_DEVICE; the test output names the device in each run).So the miscompile does not reproduce on this newer AMD driver: the BOX16 checks already pass on main here. The fix does not regress either card. I cannot confirm the failure itself, only that the rewritten form is also correct on these two drivers.
The "main" column is
71f99e22, not this branch's parent6293c1c4;xdxr_build.comp,xdxr_build.inc,xdxr_bvh.pyand the two test sources are identical between those two commits. One run of each. No game files.AI-assisted: yes (Claude Code)
Tested 42d662306 applied onto main 66d4f5aa3 on an AMD Radeon RX 7900 XT: a discrete RDNA3 card on the current proprietary driver, next to the two iGPU runs. Setup: AMD Radeon RX 7900 XT (RDNA3, gfx1100), AMD proprietary driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, VS 2022 RelWithDebInfo, Vulkan SDK 1.4.363.0. No game files.
The
.incis the.comp. I regeneratedruntime/src/xdxr_build.incfrom the PR'sxdxr_build.compwithglslc --target-env=vulkan1.2 -O -mfmt=c(shaderc v2026.4, Vulkan SDK 1.4.363.0). All 30316 words are identical to the committed file. The same check onmainalso matches (30320 words).GPU, 2 runs each.
ctest -R "^(xdxr_build|xdxr_build_check|xdxr_builder_validation|d3d12_xdxr_rt|d3d12_xdxr_rt_check)$",LEONIDA_RT_ASunset:66d4f5aa3d3d12_blas_box16d3d12_blas_box16_updateblas_paired_grid_box16blas_box16_two_geometriesblas_box16_sort_tilesctestd3d12_texture_tiles,d3d12_close_parity, since fixed by #1286,d3d12_clear)On this card and driver the BOX16 miscompile does not reproduce:
mainalready builds every BOX16 case bit-exact. The rewrite changes nothing here and causes no regression. It is a bit-equivalent rewrite, so it stays harmless on drivers that compile the old form correctly.Independent confirmation on a second AMD device: clean origin/main 4a50cafc7 fails
d3d12_xdxr_rt_checkon AMD Radeon iGPU (gfx1035, driver 24.10.24, Vulkan 1.3.280, validation on) —d3d12_blas_box16975 +d3d12_blas_box16_update959 internal validation errors ('child box/triangle not inside parent's box'), 711/1000 and 666/1000 rays differ, 0 hits; all other BLAS/TLAS cases pass and the same test passes on RTX 4070 SUPER. Repro:ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure -R d3d12_xdxr_rt_checkunderVK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon LEONIDA_PC_TAIL_UBO=1 LEONIDA_VK_VALIDATION=1. Matches this PR's AMD shader-compiler miscompile diagnosis exactly. AI-assisted verification (Devin).Confirmed on a second AMD part — Ryzen 5 7600 iGPU (Raphael gfx1036, driver 24.10.24, Vulkan 1.3.280, validation on, LEONIDA_PC_TAIL_UBO=1): at origin/main b4b7756e8 both
xdxr_build_checkandd3d12_xdxr_rt_checkfail with the box16 'child box/triangle not inside parent's box' errors (1938 problems, 666/1000 rays differ); at this PR's head 536df5c34 the samectest -R xdxrrun is 8/8 PASS. Same(u >> 16) & 0x8000miscompile — this fix covers both ctest entries. AI-assisted verification (Devin).Dual-GPU verification on
512eae3edis now complete.Runtime rebuild succeeded (
BUILD_RC=0), then the six xdxr-related CTest entries were run with Vulkan validation enabled:Results:
VK_LOADER_DRIVERS_SELECT=*amd-vulkan*,LEONIDA_VK_DEVICE=radeon): 6/6 passed;d3d12_xdxr_rt_checkpassed in 19.36 s andxdxr_build_checkin 82.45 s.VK_LOADER_DRIVERS_SELECT=*nv-vk*,LEONIDA_VK_DEVICE=4070): 6/6 passed;d3d12_xdxr_rt_checkpassed in 18.21 s andxdxr_build_checkin 76.24 s.Together with the earlier
tests/test_xdxr_bvh.py54/54 pass, this covers both the CPU validator and the real dual-GPU build/check path. Logs are local inleonida-w1/.scratch/xdxr_{amd,nv}.log. AI-assisted verification with Devin.Rebased cleanly onto current main (
db1a22d29) as4a4aa9b6d; no conflicts. The branch is unchanged: BOX16 half sign without shift-then-mask. The six xdxr CTests on both GPUs posted earlier stand on the same diff. AI-assisted with Devin.Hi @whoalin1, thanks for this pull request. It currently conflicts with
main(conflicting file(s):runtime/src/xdxr_build.inc), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
Independent Windows 11 + NVIDIA GeForce RTX 3090 Verification (
d9fec29581merged ontomain5825b02ff8)Environment: Windows 11 (
10.0.26200), MSVC19.44.35228, Python3.12.10(-I), Vulkan SDK /glslc/VK_LAYER_KHRONOS_validation1.4.363.1(LEONIDA_VK_VALIDATION=1), physical NVIDIA GeForce RTX 3090 (Ampere, driver610.88, Vulkan1.4). Synthetic BVH fixtures only; no game files.Results on Rebased Head
d9fec29581— PASS (0validation errors)xdxr_build.comp<->xdxr_build.incequivalence check:runtime/src/xdxr_build.compwithglslc --target-env=vulkan1.2 -O -mfmt=c: both produce33,141SPIR-V words, passspirv-val, and have0instruction differences across the entire function body under ID-normalizedspirv-dis(only minorOpConstantdeclaration ordering betweenshadercminor builds).python -I tests/test_xdxr_bvh.py:60/60 OK(2.77s).LEONIDA_VK_VALIDATION=1on RTX 3090):ctest --output-on-failure -R "^(xdxr_builder_validation|xdxr_build|xdxr_build_check|d3d12_xdxr_rt|d3d12_xdxr_rt_check|vk_xdxr_postbuild_readback)$":6/6passed (0failures,0ray mismatches acrossbox16/box16_update/paired_grid_box16/sort_tiles,0VUID-validation errors):xdxr_builder_validation(0.06s)xdxr_build&xdxr_build_check(92.08s)d3d12_xdxr_rt(1.93s) &d3d12_xdxr_rt_check(17.18s)vk_xdxr_postbuild_readback(0.93s)AI-assisted.
Rebased onto current
mainas21a22792dto refresh the stale CI baseline; the single-commit branch reapplied cleanly with no conflicts. Validation:git diff --checkis clean. The shader/GPU regression cannot execute on this Linux VM, so the AMD/NVIDIA behavior remains covered by the prior validator reports rather than locally rerun.Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.