Merge pull request 'perf(tlas): dirty-track the per-frame TLAS instance+metadata upload (#118)' (#140) from claude/issue-118 into master

This commit is contained in:
catbot 2026-06-18 15:07:44 +02:00
commit 2783e47674
5 changed files with 437 additions and 12 deletions

View file

@ -484,6 +484,39 @@ namespace Crafter {
);
}
// Ranged variant of FlushDevice(cmd, ...): flushes only the host writes
// in [offset, offset+bytes) (rounded outward to nonCoherentAtomSize, and
// a no-op on coherent memory — same gate as the other FlushDevice
// overloads) and records the HOST->(dstStageMask, dstAccessMask) barrier.
// Use after writing a sub-range so the cache-flush cost scales with the
// bytes touched rather than the whole high-water capacity. The barrier
// itself still spans the whole buffer (VK_WHOLE_SIZE): the execution/
// visibility dependency is cheap regardless of range, and only the
// flush's cache maintenance is bandwidth-sensitive.
void FlushDevice(VkCommandBuffer cmd, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask, VkDeviceSize offset, VkDeviceSize bytes) requires(Mapped) {
FlushDevice(offset, bytes);
VkBufferMemoryBarrier barrier = {
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT,
.dstAccessMask = dstAccessMask,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.buffer = buffer,
.offset = 0,
.size = VK_WHOLE_SIZE
};
vkCmdPipelineBarrier(
cmd,
VK_PIPELINE_STAGE_HOST_BIT,
dstStageMask,
0,
0, NULL,
1, &barrier,
0, NULL
);
}
void FlushHost() requires(Mapped) {
// Coherent memory needs no explicit invalidate — device writes are
// automatically visible to the host.