d3d12/shader: the ray-box test misses a present child's inverted box (D3D12-BVH-INVERTED-MISS) #3036
Closed
leonida/mandy
upipibi wants to merge 0 commits from
d3d12/bvh-inverted-miss into main
pull from: d3d12/bvh-inverted-miss
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!3036
Loading…
Reference in a new issue
No description provided.
Delete branch "d3d12/bvh-inverted-miss"
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.
D3D12-BVH-INVERTED-MISS. The software ray-box test now misses a present child whose box is inverted (minimum above maximum on any axis), as AMD's form of the hardware test does.
What was wrong
bvh::boxesand the box test emitted byemit/intersect.rstake each axis's near and far asmin/maxof the two slab distances. That is symmetric in the box's two corners, so a box withmin > maxon an axis is entered as the box between its corners. A child that isn't there already gets this right: its inverted infinite bounds are skipped by thechildren[n] != NONEcheck (after VIctory bc3cd4b0). A present child doesn't.AMD's software stand-in for the hardware intersection, GPURT
fast_intersect_bbox(IntersectCommon.hlslL393-441, MIT; used where the intrinsic isn't), picks each axis's entry and exit by the sign of the ray's inverse direction. For an inverted box the entry then comes after the exit: an empty interval, so a miss in either direction. The exception is a box inverted by no more than that test's growth of a few ulps (L515-518).This reads AMD's source; it doesn't measure the console's instruction. If you'd rather keep this off by default until someone checks it on RDNA hardware, it's a one-line change.
What it changes
bvh::inverted_miss():LEONIDA_BVH_INVERTED_MISS, on unless0. The translator's build script already keys everyLEONIDA_*name it reads into the shader cache, so a run with=0gets its own translations.bvh::boxes→boxes_as(.., inverted_miss), which is pure, for tests. A box withb[a] > b[3 + a]on any axis is missed.emit/intersect.rs: the same compare in the emitted code. It uses orderedOGT, so a NaN gives "not inverted" and the existing NaN rule decides, the same as the reference's>.d3d12/docs/switches.md: the new row, astools/d3d12_switches.pywrites it. Only that row is added; the regenerated page also changes an unrelated, staleLEONIDA_PROMPTS_PADline, which I left alone.Only
-RayTracingruns this path, and it is off by default, so default frame rates do not change.How it was tested
RTX 3070 8 GB, driver 621.40, Windows 11 24H2. No game files: the GPU tests build their nodes by hand.
cargo test -p leonida-shader --lib --locked: 421 passed, 0 failed, 5 ignored.bvh::+emit::intersect_tests: 23 of 23 pass with the switch unset, and 23 of 23 withLEONIDA_BVH_INVERTED_MISS=0.emit/intersect.rschange reverted (the reference still misses inverted boxes), the four*_node_test_*_matches_the_reference_on_the_cardtests fail atintersect_tests.rs:593. They pass with the change. The four new nodes are what make the card test cover this: present children inverted on x, on every axis, on y alone and on z alone, in 32- and 16-bit form. In the 16-bit node the infinite minimum rounds to -0, which is still above its -inf maximum, so it is still inverted.bvh::tests::an_inverted_box_is_missedcovers boxes inverted on x and y, on y alone, on z alone, and on every axis with infinite bounds, plus a flat box. It runs both ray directions, sorted and not.python -I tools/d3d12_switches.py --check d3d12/docs/switches.mdpasses, as doespython -I tests/test_d3d12_switches.py(20 OK).cargo clippy -p leonida-shader --all-targets -- -D warnings: nothing in the changed files. The 6 errors left are inemit/valu_tests.rsand are onmainalready.Also checked, earlier, on VIctory-NVIDIA's equal code: a port of GPURT's function compared with the reference over 1,000,000 random rays and boxes per case.
One small difference is left: a box inverted by only 1-8 ulps. GPURT enters it through its 6-ulp box growth and rounding, and the explicit compare misses it. Properly ordered boxes and the title's inf/-inf slots aren't affected.
Not tested: the game with
-RayTracing.Credit
A port of HQasper's
VICTORY_BVH_INVERTED_MISS(VIctory-NVIDIA 72230a3e1, an opt-in there), adapted to this tree'sboxesand emitted test. The two card-test nodes and the GPURT comparison are mine.AI-assisted: written with Claude Code (Claude Opus 5.5). A separate read-only reviewer agent (Claude Opus 5.5) audited the diff before this was opened.
🤖 Generated with Claude Code
Independent run on Windows 11, MSVC toolchain 1.98.1. Head
1a8773e1fmerged into currentmain0ae5a2664: the merge is clean.cargo test -p leonida-shader --lib: 421 passed, 0 failed, 5 ignored. I touchedbuild.rsfirst so the translator's source hash was fresh.bvh::+emit::intersect_tests: 23 of 23 pass with the switch unset, and 23 of 23 withLEONIDA_BVH_INVERTED_MISS=0.*_node_test_*_matches_the_reference_on_the_cardtests pass. With--nocaptureneither device printed "skipped", so they ran on both the hardware device and WARP.emit/intersect.rsput back tomain, all four card tests fail. Each fails on the hardware pass withbatch 2 thread 14: Some((5, 5, Ray { extent: 6.0, ... })). The line isintersect_tests.rs:601here rather than 593, because of the merge withmain. With the change they pass. That run stops at the hardware pass, so it doesn't show WARP's answer on the reverted emit.python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.python -I tests/test_d3d12_switches.py: OK.cargo clippy -p leonida-shader --lib --tests: no warning inbvh.rsoremit/intersect.rs.Not checked: AMD hardware, and the game with
-RayTracing. The card here is the same vendor as yours, so this is a second machine, not a second vendor.GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
Closing this to free this account's only open-PR slot for a fix that runs by default: D3D12-TARGETS-AT-RESTORE, a release of a host-written texture at a shared address losing the older one. This path only runs with
-RayTracing, so it can wait.Nothing is lost. The branch stays at
upipibi:d3d12/bvh-inverted-miss(1a8773e1f), with the tests and the red/green described above. Anyone may take it, or I'll reopen this when a slot frees.