fix(vulkan-rt): merge TLAS push constant into existing block (#18)
The NVIDIA descriptor-heap AS-read workaround (#15) rewrote 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 — which SPIR-V forbids ("at most one push constant block statically used per entry point"), and vkCreateShaderModule's spirv-val check rejected: Entry point id '4' uses more than one PushConstant interface. WorkaroundNvidiaAS::Patch now detects an existing PushConstant variable and, when present, appends a single ulong member (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' explicit Offset/ArrayStride/ MatrixStride decorations (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. That offset is published via Device::workaroundTlasPushOffset and RTPass feeds it to vkCmdPushDataEXT so the address lands where the rewritten load reads it (0 for the synthesized case, preserving prior behaviour). Verified on the affected driver (NVIDIA 610.43.02, RTX 4090): VulkanTriangle ray-traces correctly and validation-clean both with and without a user-declared raygen push constant. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
f24107264d
commit
45ecc91424
4 changed files with 204 additions and 55 deletions
|
|
@ -178,6 +178,12 @@ export namespace Crafter {
|
|||
// path and RTPass pushes the active TLAS address as push data. Delete
|
||||
// this flag and everything keyed on it once a fixed driver ships.
|
||||
inline static bool workaroundDescriptorHeapAS = false;
|
||||
// Byte offset of the TLAS-address member inside the patched raygen's
|
||||
// push-constant block — 0 for a freshly synthesized block, or the end
|
||||
// of the user's own block when the address is appended to it (the
|
||||
// shader can't have two push-constant blocks). VulkanShader sets this
|
||||
// at module load; RTPass feeds it to vkCmdPushDataEXT.
|
||||
inline static std::uint32_t workaroundTlasPushOffset = 0;
|
||||
|
||||
static void CheckVkResult(VkResult result);
|
||||
static std::uint32_t GetMemoryType(std::uint32_t typeBits, VkMemoryPropertyFlags properties);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue