fix(vulkan-rt): work around NVIDIA descriptor-heap AS-read device-loss (#15)
Reading an acceleration structure through VK_EXT_descriptor_heap aborts with VK_ERROR_DEVICE_LOST on NVIDIA 610.43.02 — a brand-new-extension driver fault isolated in #7 (engine setup is correct and validation-clean; images/buffers through the same heap work, and both traceRayEXT and inline rayQuery fault identically on the AS read). An acceleration structure can equally be reached by its device address via OpConvertUToAccelerationStructureKHR, which reads no descriptor and so never touches the faulting heap path. glslang has no GLSL spelling for that conversion, so VulkanShader rewrites the compiled SPIR-V at module-load time: every `OpLoad %accelStruct <heap-ptr>` becomes a load of the TLAS device address from a synthesized push-constant block followed by the convert. RTPass pushes the active frame's TLAS address into that push constant. User GLSL and example code are unchanged; acceleration structures still bind into the heap normally. The workaround is gated on Device::workaroundDescriptorHeapAS (true only on the NVIDIA proprietary driver) and confined to one fenced block in Crafter.Graphics-ShaderVulkan.cppm plus the RTPass push and the shaderInt64 feature toggle — delete those once a fixed NVIDIA driver ships and the heap AS read becomes the direct path again. Verified: VulkanTriangle ray-traces correctly on native NVIDIA (RTX 4090), validation-layer-clean, no device loss. The SPIR-V rewrite was independently validated with spirv-val on both the VulkanTriangle and Sponza raygen modules. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
b9f65f5273
commit
950059c86e
7 changed files with 270 additions and 30 deletions
|
|
@ -27,6 +27,7 @@ import :RenderPass;
|
|||
import :Window;
|
||||
import :Device;
|
||||
import :PipelineRTVulkan;
|
||||
import :RenderingElement3D;
|
||||
|
||||
export namespace Crafter {
|
||||
struct RTPass : RenderPass {
|
||||
|
|
@ -34,8 +35,22 @@ export namespace Crafter {
|
|||
|
||||
RTPass(PipelineRTVulkan* p) : pipeline(p) {}
|
||||
|
||||
void Record(VkCommandBuffer cmd, std::uint32_t /*frameIdx*/, Window& window) override {
|
||||
void Record(VkCommandBuffer cmd, std::uint32_t frameIdx, Window& window) override {
|
||||
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, pipeline->pipeline);
|
||||
// NVIDIA descriptor-heap AS-read workaround (issue #15 / #7): feed
|
||||
// the active frame's TLAS device address into the push-constant
|
||||
// block that VulkanShader synthesizes, so the rewritten raygen can
|
||||
// reach the acceleration structure by address instead of through
|
||||
// the faulting heap descriptor. Inert on every other driver.
|
||||
if (Device::workaroundDescriptorHeapAS) {
|
||||
VkDeviceAddress tlasAddr = RenderingElement3D::tlases[frameIdx].address;
|
||||
VkPushDataInfoEXT pushInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_PUSH_DATA_INFO_EXT,
|
||||
.offset = 0,
|
||||
.data = { .address = &tlasAddr, .size = sizeof(tlasAddr) },
|
||||
};
|
||||
Device::vkCmdPushDataEXT(cmd, &pushInfo);
|
||||
}
|
||||
Device::vkCmdTraceRaysKHR(cmd,
|
||||
&pipeline->raygenRegion,
|
||||
&pipeline->missRegion,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue