Bvh: a TLAS takes an instance only from a built BLAS header #72

Manually merged
github merged 1 commit from github-bot/gh-72 into gh-pr/72/base 2026-11-28 21:31:14 +00:00 AGit
Owner

@⁠almostxxx27 on GitHub · 2026-11-28 19:50 UTC · original
almostxxx27:issues/34_HeaderCheckInInstancesDescs → main · +162 −5 · 4 files · 1 commits · merged 2026-11-28 21:29 UTC

InstanceDescs read the root and bounds of every readable BLAS header, so a zeroed header (version 0, root 0) entered the TLAS as an instance with root node pointer 0 and empty bounds. InstanceDescs.IsBuilt now requires dword 0 low 16 bits = 6, bit 24 (serialized) clear and a box root (type 4 or 5) in dword 12; an instance that fails keeps InvalidNode, so XdxrTlas leaves it out like a null or unreadable BLAS.

AmdBvhLayout gains Box16Type and NodeTypeMask. InstanceDescsTests cover a built BLAS, a zeroed header, a still-serialized header, a triangle root and a box16 root. docs/raytracing.md TLAS row updated.

Refs #34

**@⁠almostxxx27** on GitHub · 2026-11-28 19:50 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/72) `almostxxx27:issues/34_HeaderCheckInInstancesDescs` → `main` · +162 −5 · 4 files · 1 commits · merged 2026-11-28 21:29 UTC InstanceDescs read the root and bounds of every readable BLAS header, so a zeroed header (version 0, root 0) entered the TLAS as an instance with root node pointer 0 and empty bounds. InstanceDescs.IsBuilt now requires dword 0 low 16 bits = 6, bit 24 (serialized) clear and a box root (type 4 or 5) in dword 12; an instance that fails keeps InvalidNode, so XdxrTlas leaves it out like a null or unreadable BLAS. AmdBvhLayout gains Box16Type and NodeTypeMask. InstanceDescsTests cover a built BLAS, a zeroed header, a still-serialized header, a triangle root and a box16 root. docs/raytracing.md TLAS row updated. Refs #34
InstanceDescs read the root and bounds of every readable BLAS header,
so a zeroed header (version 0, root 0) entered the TLAS as an instance
with root node pointer 0 and empty bounds. InstanceDescs.IsBuilt now
requires dword 0 low 16 bits = 6, bit 24 (serialized) clear and a box
root (type 4 or 5) in dword 12; an instance that fails keeps
InvalidNode, so XdxrTlas leaves it out like a null or unreadable BLAS.

AmdBvhLayout gains Box16Type and NodeTypeMask. InstanceDescsTests cover
a built BLAS, a zeroed header, a still-serialized header, a triangle
root and a box16 root. docs/raytracing.md TLAS row updated.

Refs #34

Co-authored-by: Copilot <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 19:51:19 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-28 20:56 UTC · original

thanks, this is a good catch. a zeroed or still-serialized header turning into a TLAS instance with root 0 is exactly the kind of thing that sends traversal somewhere it shouldn't go.

I checked the rule against what we have written down: version 6 in the low 16 bits, bit 24 as the serialized flag that rehydration clears, and the root pointer in dword 12 with its type in the low 3 bits all match docs/raytracing.md and what XdxrBlas.Build writes (0x80000006). the tests cover the cases I'd want, and CI is green on both.

one small thing to know: AmdBvhLayout lives in FiveStar.Shaders, and the program cache is keyed on that assembly's hash, so any change there means everyone re-translates once. that's fine this time, because a bigger translator change is about to land on main anyway, so this can ride along with it.

looks good to me.

**@⁠ThatRecompDev** on GitHub · 2026-11-28 20:56 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/72#issuecomment-7245657133) thanks, this is a good catch. a zeroed or still-serialized header turning into a TLAS instance with root 0 is exactly the kind of thing that sends traversal somewhere it shouldn't go. I checked the rule against what we have written down: version 6 in the low 16 bits, bit 24 as the serialized flag that rehydration clears, and the root pointer in dword 12 with its type in the low 3 bits all match docs/raytracing.md and what XdxrBlas.Build writes (0x80000006). the tests cover the cases I'd want, and CI is green on both. one small thing to know: AmdBvhLayout lives in FiveStar.Shaders, and the program cache is keyed on that assembly's hash, so any change there means everyone re-translates once. that's fine this time, because a bigger translator change is about to land on main anyway, so this can ride along with it. looks good to me.
github-bot changed target branch from main to gh-pr/72/base 2026-11-28 21:31:12 +00:00
github manually merged commit 05c5222f17 into gh-pr/72/base 2026-11-28 21:31:14 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-28 21:29 UTC · original

merged, thanks!

it went in right after today's big translator change, so the re-translation it causes is folded into the one everyone does anyway.

same note as on #71: we keep commit messages on main free of AI trailers, so the squash dropped the Co-authored-by line.

**@⁠ThatRecompDev** on GitHub · 2026-11-28 21:29 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/72#issuecomment-7246061265) merged, thanks! it went in right after today's big translator change, so the re-translation it causes is folded into the one everyone does anyway. same note as on #71: we keep commit messages on main free of AI trailers, so the squash dropped the Co-authored-by line.
This discussion has been locked. Commenting is limited to contributors.
No description provided.