mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +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:
@@ -111,6 +111,20 @@ public:
|
||||
// could rescue them, or whether eviction is the only path.
|
||||
bool can_grow() const { return !growth_disabled_ && per_sub_buffer_capacity_ > 0; }
|
||||
|
||||
// Test-only seam. Production code populates sub-pools lazily through
|
||||
// alloc() → addSubBuffer() → wgpuDeviceCreateBuffer; that path needs a
|
||||
// real WGPUDevice and is impractical to exercise from a unit test.
|
||||
// tests/test_buffer_pool.cpp uses this method to preseed a sub-pool
|
||||
// with a known capacity and a fake (non-null) WGPUBuffer handle the
|
||||
// allocator only treats as opaque — the free-list bookkeeping never
|
||||
// dereferences it. Not for production use.
|
||||
void addSubBufferForTesting(WGPUBuffer fake_buffer, uint64_t capacity);
|
||||
// Drop fake-handle sub-pools without calling wgpuBufferRelease on
|
||||
// them. Tests must call this before the pool destructs (or rely on
|
||||
// the FakePoolGuard fixture in test_buffer_pool.cpp), otherwise
|
||||
// ~BufferPool → destroy() would dereference the fake handles.
|
||||
void clearSubPoolsForTesting();
|
||||
|
||||
private:
|
||||
struct FreeRange { uint64_t offset; uint64_t size; };
|
||||
struct SubPool {
|
||||
|
||||
Reference in New Issue
Block a user