mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
ifcviewer: extract ChunkPlanner + InstanceCompose; add Tier-1 test trio
The chunk planner (Morton sort + greedy pack) and instance composition (federation × placement matrix chain + world-AABB derive) were inline helpers in ViewportWindow.cpp. Pulled both out as free-function modules so the math + lookup logic can be exercised without a Qt window or a wgpu device. ViewportWindow now delegates; InstanceLookup is a using- alias to InstanceCompose::InstanceLookup. Also added an addSubBufferForTesting / clearSubPoolsForTesting seam to BufferPool so the sub-allocator invariants can be pinned with fake WGPUBuffer handles. The fakes are never dereferenced; the guard drops the sub-pools before destructor would call wgpuBufferRelease. Three new test binaries under src/ifcviewer/tests/, 33 cases / 173 assertions: BufferPool first-fit + alignment + coalescing + multi- sub-pool isolation; ChunkPlanner Morton split / interleave / stable sort / greedy-pack monotonicity and single-mesh-oversize; InstanceCompose identity / translation / order-of-multiplication / large-placement cancellation against federation false origin / column-major writeback / findInstance lookup paths.
This commit is contained in:
@@ -223,3 +223,17 @@ uint64_t BufferPool::largest_free_run_bytes() const {
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
void BufferPool::addSubBufferForTesting(WGPUBuffer fake_buffer, uint64_t capacity) {
|
||||
SubPool sp;
|
||||
sp.buffer = fake_buffer;
|
||||
sp.capacity = capacity;
|
||||
sp.used = 0;
|
||||
sp.free_ranges.push_back({0, capacity});
|
||||
sub_pools_.push_back(std::move(sp));
|
||||
}
|
||||
|
||||
void BufferPool::clearSubPoolsForTesting() {
|
||||
// Skip wgpuBufferRelease — handles are fakes that would crash on deref.
|
||||
sub_pools_.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user