Crafter.Graphics/tests
catbot b5b8c04237 perf(tlas): dirty-track the per-frame TLAS instance+metadata upload (#118)
BuildTLAS rebuilt the host instance+metadata buffers with an O(n) copy of
every 64 B VkAccelerationStructureInstanceKHR + metadata entry every frame,
unconditionally, then flushed the whole high-water capacity (VK_WHOLE_SIZE)
on both buffers. At the millions-of-instances target that copy dominates the
CPU frame, and the whole-buffer flush costs on non-coherent BAR/VRAM.

Add a generation counter so only changed host-authored fields are copied, and
feed the same dirty span into the ranged FlushDevice(offset, bytes) overload:

- RenderingElement3D::hostDataVersion + MarkHostDataDirty() (bumps a global
  monotonic counter). TlasWithBuffer::uploadedVersion records, per frame, the
  version last copied into each slot. A slot is copied only when its element
  advanced past the recorded version; version 0 ("untracked") reads dirty every
  frame, so callers that don't opt in keep the prior copy-every-frame behaviour.
  Globally-unique versions make this correct under relocation (Remove's
  swap-and-pop, and remove+add that nets the same count on the refit path)
  without tracking element identity. The reset on every topology change covers
  buffer reallocation and the reshuffled element->slot mapping.
- The dirty [first, last] envelope drives both the copy and the flush: a new
  VulkanBuffer::FlushDevice(cmd, access, stage, offset, bytes) overload flushes
  + barriers just that span for instanceBuffer, and the ranged
  FlushDevice(offset, bytes) for metadataBuffer. When nothing is dirty both are
  skipped — the skipped HOST->build barrier only ever ordered host writes, never
  the application's compute-written GPU-owned transform (that compute->build
  ordering is the caller's, and is unchanged).

Constraint honoured: transformOwnedByGpu transforms are still never host-copied.
The API field/method are mirrored on the WebGPU class for source portability
(the WebGPU build re-uploads its small mirror wholesale and ignores the version).

New test TLASInstanceDirtyTracking drives the real RT device and reads back the
host-mapped buffers to assert: tracked elements upload once then skip until
re-marked, untracked elements always upload, and relocation on the refit path
re-uploads exactly the moved slots — with zero validation-layer errors over the
ranged flush.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 19:58:45 +00:00
..
BLASBuildOptions perf(mesh): place RT geometry in device-local memory via #89 upload strategy (#73) 2026-06-17 17:49:25 +00:00
DeferredDeletion fix(device): fence-keyed deferred resource-deletion queue (#101) 2026-06-17 13:21:12 +00:00
FontAdvanceCache perf(font): cache per-codepoint advances in font units (#57) 2026-06-16 17:00:48 +00:00
FontAtlasDirtyRect perf(font): upload only the dirty sub-rect of the glyph atlas (#51) 2026-06-16 15:40:37 +00:00
FrameLoopSync feat(window): multi-frame-in-flight frame pacing (#40) 2026-06-16 15:37:11 +00:00
InputFieldHitTest perf(input-field): O(n) cursor hit test via Font::NearestCursorByte (#56) 2026-06-16 16:55:03 +00:00
MemoryTypeFallback fix(device): add preferred mask + required-only fallback to GetMemoryType (#59) 2026-06-16 16:03:50 +00:00
MeshDecompressStagingRelease test(mesh): pin static-build deletion count in #67 staging-release test (#110) 2026-06-17 18:50:38 +00:00
MipChainBarrierBatch perf(image): batch final mip-chain layout transition (#70) 2026-06-16 18:30:44 +00:00
MouseScroll feat(input): wire native mouse-wheel scroll on Wayland + Win32, normalize all backends to ±1/detent (#32) 2026-06-12 15:02:28 +00:00
PipelineCacheValidation test(pipeline): cover pipeline-cache header validation (#69) 2026-06-16 18:23:25 +00:00
PushConstantRewrite fix(vulkan-rt): configurable recursion depth + per-shader TLAS push for compute (#21) 2026-06-03 18:35:39 +00:00
ShapeTextCache perf(text): cache shaped runs in ShapeText (#52) 2026-06-16 15:40:52 +00:00
TLASHighWaterMark perf(rt): allocate TLAS metadata buffer in BAR/VRAM, not system RAM (#75) 2026-06-17 17:50:01 +00:00
TLASInstanceDirtyTracking perf(tlas): dirty-track the per-frame TLAS instance+metadata upload (#118) 2026-06-17 19:58:45 +00:00
UIClipFlag perf(ui): gate per-pixel clip compares behind a flags bit (#50) 2026-06-16 16:57:07 +00:00
UIFusedShader perf(ui): add additive DispatchFused to collapse consecutive UI passes (#47) 2026-06-16 17:03:24 +00:00
UploadStrategy cache directwrite 2026-06-16 20:10:23 +02:00
VulkanBufferFlushGate perf(vulkan-buffer): skip flush/invalidate on coherent memory (#60) 2026-06-16 17:04:26 +00:00
VulkanBufferRangedFlush perf(ui): flush only the written descriptor range, not the whole heap (#61) 2026-06-16 18:29:24 +00:00
VulkanBufferResizeReuse perf(buffer): capacity-reuse in VulkanBuffer::Resize (#63) 2026-06-16 18:22:09 +00:00