perf(mesh): dirty-range vertex upload for deforming-mesh Refit (#119) #138
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!138
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-119"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Deforming-mesh
Mesh::RefitUploadDeviceLocals the entire vertex array every frame on the in-place UPDATE path (full host write + flush + barrier on the direct path; full re-stage + copy on the staged path), even when only a few vertices moved (Crafter.Graphics-Mesh.cpp:407-409).Fix
VulkanBuffer::UploadDeviceLocalRange— a dirty-range counterpart toUploadDeviceLocalthat writes/flushes (direct) or stages/copies (staged) and barriers only the half-open element range[offset, offset+count)of an already-allocated device-local buffer. NoResize, so the device address (and the geometry an AS UPDATE reads) stays stable. The direct-vs-staged choice is read from the buffer's actual memory type — not the sub-range size, whichPreferDirectDeviceWritewould mis-route onto a non-host-visible buffer. The ranged flush is rounded tononCoherentAtomSizeand clamped to the allocation size (mappedSizeis now recorded for every buffer).Mesh::Refitoverload taking the full vertex/index arrays plus a(dirtyVertexOffset, dirtyVertexCount)window. The existing full-spanRefitdelegates to it with the whole array as the window, so its behaviour is unchanged. On the UPDATE path only the window is uploaded; the rest of the device buffer keeps last refit's positions. When an UPDATE isn't possible (noallowUpdate, or counts changed) it falls back to the full-span rebuild — which is why the full arrays are still passed (window clamped to bounds).Refit.Contract change
Callers wanting the optimization pass the dirty window:
Refit(verts, indices, dirtyVertexOffset, dirtyVertexCount, cmd). The originalRefit(verts, indices, cmd)is untouched.Testing
crafter-build test— all 20 tests pass.BLASBuildOptionsnow exercises the dirty-range refit on the direct path, the staged path (forced via the zeroed upload budget), and the count-change rebuild fallback, asserting AS-handle /blasAddrstability and zero Vulkan validation errors. The wasm/wasm32-wasip1target also builds cleanly, covering the DOM overload.Resolves #119
🤖 Generated with Claude Code