fix(vulkan-rt): merge TLAS push constant into existing block (#18) #20
No reviewers
Labels
No labels
claude:done
claude:in-progress
claude:ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-18"
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?
Problem
The NVIDIA descriptor-heap AS-read workaround (#15) rewrites in-shader heap acceleration-structure reads into a load of the TLAS device address from a push-constant block. It always synthesized a new push-constant block, so any ray-tracing shader that already declared one ended up with two. SPIR-V allows at most one push-constant block statically used per entry point, so
vkCreateShaderModule'sspirv-valcheck rejected the module:Fix
WorkaroundNvidiaAS::Patchnow detects an existingPushConstantvariable and, when present, appends a singleulongmember (the TLAS address) to that block instead of adding a second one — reading the address through the shader's own push-constant variable. The append offset is the end of the user's block, computed from the members' explicitOffset/ArrayStride/MatrixStridedecorations (correct under both scalar and std140 layout) and rounded up to 8.Shaders with no push constant of their own keep getting a freshly synthesized single-member block at offset 0, exactly as before.
The offset is published via
Device::workaroundTlasPushOffset, whichRTPassfeeds tovkCmdPushDataEXTso the address lands where the rewritten load reads it (0 for the synthesized case → prior behaviour unchanged).Tests
New
tests/PushConstantRewritecompiles representative raygen shaders with glslang, runs the realPatchover them, and asserts withspirv-val(the same invocationvkCreateShaderModuleuses) that the result is valid with exactly one push-constant block — covering the merge path (mat4/vec3/uint, lone uint, array layout), the synthesize path, and a no-op case (push constant but no AS read), and checking the published TLAS offset for each.Also verified end-to-end on the affected driver (NVIDIA 610.43.02, RTX 4090):
VulkanTriangleray-traces correctly and validation-clean both with and without a user-declared raygen push constant.Screenshots
Resolves #18
🤖 Generated with Claude Code