shader: fix BVH resource classification and specialization crash #555
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!555
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/555/head"
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?
@FirasDev on GitHub · 2026-09-10 13:53 UTC · original
FirasDev:feat/hardware-raytracing→main· +1563 −112 · 20 files · 17 commits · closed without mergingThis builds on #493 by @frans (cherry-picked as-is: the opcode decode, the stub, the --stub-bvh flag, and his tests), plus two fixes I found by running Astro Bot (PPSA21567) against it with --stub-bvh enabled.
Fix 1: the BVH resource was classified wrong. The stub registered its resource operand as a buffer resource, which routes it through SRT specialization to resolve the descriptor as a compile-time constant. But the BVH node-pool base address is a runtime pointer (two SGPRs read directly), not something specialization can resolve, so it crashed immediately. This reads it the same way S_LOAD's raw-address path already does, and leaves it unregistered with resource tracking, so nothing tries to constant-fold it.
Fix 2: resource specialization aborted the whole process on a control-flow-dependent descriptor. With fix 1 in, Astro Bot got much further, then hit an unrelated crash: some other shader (not BVH) computes part of a descriptor differently depending on runtime control flow, and ResolveInvariantPhi correctly detects that divergence, but the caller treated it as fatal for the entire shader. That's the same kind of "descriptor doesn't make sense" situation NullImageDescriptor/ValidImageDescriptor already tolerate elsewhere in this file, so this applies the same tolerance: zero out just that one resource and keep going instead of aborting.
Testing: ran against Astro Bot (PPSA21567) with --stub-bvh. Before these fixes: hard crash before the BVH instruction is even reached. After: compiles far more shaders than before, then hits a separate, unrelated access violation in the PS5 module loader (runtimeLinker.cpp) that has nothing to do with either fix or with ray tracing. Astro Bot does not fully boot yet, these two fixes remove two real crashes along the way.
This also carries the from-scratch BVH parsing/walking work (src/graphics/rt/), a standalone test confirming the host GPU can create an RT-capable Vulkan device, and a working bottom-level acceleration structure builder verified to actually build a BLAS on real hardware. None of that is wired into the shader pipeline yet, still blocked on real ray-query codegen, it's groundwork for that.
AI disclosure: I used Claude to help investigate, implement, and test this. I reviewed and ran everything against real hardware and a real game before submitting.
francoisatt's cherry-picked stub commit and our own new graphics/rt and tests files had French comments and space-based indentation instead of this project's tabs, per review feedback on the PR. Translates every French comment to English, runs clang-format over every src/*.{cpp,h,inc} file this branch touches, strips a stray UTF-8 BOM that had been on nine files since they were first written, and fixes the three CMakeLists.txt lines that lost their tabs to an earlier PowerShell paste. tests/ShaderRecompilerComputeTests.cpp keeps its existing 2-space indentation: it's outside the project's clang-format scope (only src/ is covered) and already used that convention before this PR.@rodjunger on GitHub · 2026-09-10 17:25 UTC · original · edited 2026-09-10 17:27 UTC
Some comments are in french. Please at least read what Claude has generated before submitting a PR.
@rodjunger on GitHub · 2026-09-10 17:26 UTC · original
On
src/graphics/shader/recompiler/frontend/translate/Memory.cppline 1058 (outdated):french comment
@FirasDev on GitHub · 2026-09-10 17:33 UTC · original
Those are unmodified, from @francoisatt's own commits in #493 (
c1befc761d,3b16edede2), cherry-picked as-is like the PR description says, would you like me to translate them ?@rodjunger on GitHub · 2026-09-10 17:43 UTC · original
I'm not an official maintainer but I don't see how a maintainer or anyone would want comments in french, so it's good to update them to english. The next thing that looks off to me is the formatting, I don't know if it's a github bug but most files seem to have really broken formatting, running a linter/formatter wouldn't hurt
@francoisatt on GitHub · 2026-09-11 06:58 UTC · original
@FirasDev sorry about the French comments — those were mine, thanks for translating them. I'll keep code comments in English from now on.
@Nmzik on GitHub · 2026-10-06 18:08 UTC · original
Software Rt is on main
Pull request closed