upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_backend.h
diff options
context:
space:
mode:
authorFilippe Faria <138038594+bronze-ff@users.noreply.github.com>2026-11-23 16:37:56 -0300
committerFilippe Faria <138038594+bronze-ff@users.noreply.github.com>2026-11-23 16:37:56 -0300
commit224fc74f5c9d990ca5e7b1a38532b004b2dff694 (patch)
treedd43ae99a409c94f767d1543c991c458284f39a7 /runtime/src/vulkan_backend.h
parent867d922f09b86583859796a174df89555fb32da8 (diff)
d3d12: stage ARRAY_OF_POINTERS instances whose upload VA wraps below the arena
Without Resizable BAR, UPLOAD buffers live in system memory, outside the GPU address arena. Their VA is (device address - arena base), which wraps when the buffer's device address lies below the arena's. stage_khr_instances refused such an entry as an overflow (va > UINT64_MAX - heap_base), so the whole TLAS build list failed with "invalid copy or resolve" and nothing was submitted. The unsigned sum heap_base + va wraps back to the buffer's device address, as the replay's other VA translations already rely on. Measured on an RTX 5060 (NVIDIA 621.14) on a board without Resizable BAR: d3d12_indirect_rt failed with "RayQueryKHR ARRAY expected hit=1 miss=0, got hit=0 miss=0" on every run; LEONIDA_ARENA_LOG=1 shows the upload buffers at VA 0xfffffffffe07xxxx. Adds d3d12_indirect_rt_upload_sysmem, which runs the same test with LEONIDA_UPLOAD_SYSMEM=1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/vulkan_backend.h')
-rw-r--r--runtime/src/vulkan_backend.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h
index e659a762d..9b43e843e 100644
--- a/runtime/src/vulkan_backend.h
+++ b/runtime/src/vulkan_backend.h
@@ -2131,7 +2131,10 @@ private:
2131 VkBuffer buffer = VK_NULL_HANDLE; 2131 VkBuffer buffer = VK_NULL_HANDLE;
2132 VkDeviceSize offset = 0; 2132 VkDeviceSize offset = 0;
2133 std::uint64_t room = 64; // one D3D12_RAYTRACING_INSTANCE_DESC 2133 std::uint64_t room = 64; // one D3D12_RAYTRACING_INSTANCE_DESC
2134 if (!va || !vk.buffer_at(va, room, buffer, offset) || room < 64 || va > UINT64_MAX - vk.heap_base) { 2134 // No overflow check on heap_base + va: a buffer outside the arena whose device address lies below the
2135 // arena's (an UPLOAD heap in system memory without Resizable BAR) has a VA that wraps (address - base),
2136 // and the unsigned sum wraps back to its device address, as the replay's other VA translations do.
2137 if (!va || !vk.buffer_at(va, room, buffer, offset) || room < 64) {
2135 funcs.vkUnmapMemory(context_.device(), stage.memory); 2138 funcs.vkUnmapMemory(context_.device(), stage.memory);
2136 discard(); 2139 discard();
2137 return ReplayResult::invalid_copy; 2140 return ReplayResult::invalid_copy;