ifcviewer: move initWgpu + probeAndCreatePool + shutdown into ViewportCore (#84-l)

The instance/adapter/device/queue/pool/surface-format wgpu lifecycle now
lives in ViewportCore — including the OOM-scoped pool size probe and
the worker-thread startup. ViewportWindow::initWgpu becomes a Qt shell
that handles env-var tuning + nav-button preset wiring, then delegates
to core_.initWgpu(); the VW-only pipeline builders (HiZ, edge, overlays,
pick) still run after. ViewportWindow::shutdown drops the VW-only
resources (depth, msaa, hiz, edge, overlays, pick) and lets
core_.shutdown() release the shared wgpu handles it now owns.

The wgpu-native log callback (wgpuSetLogCallback / WGPULogLevel) is
gated on !__EMSCRIPTEN__: it's not part of the W3C spec header, and
the emdawnwebgpu port doesn't ship wgpu.h — validation errors there
land in the browser console regardless.

Drive-by: update test_federation to compare HomeView::target as
Eigen::Vector3f (left stale by #79 when QVector3D was retired).
This commit is contained in:
Dion Moult
2026-06-05 18:06:25 +10:00
parent 66a21923b8
commit 2b43e6f7e0
5 changed files with 364 additions and 367 deletions
+27
View File
@@ -223,6 +223,33 @@ public:
void ensureSelectionFlagsBuffer();
void uploadSelectionFlagsIfDirty();
// ---- wgpu lifecycle ----------------------------------------------------
//
// initWgpu brings up the wgpu instance, gets the platform surface
// from host_->createSurface, requests adapter + device + queue,
// probes the streaming pool capacity, starts the background loader
// thread, and picks the swap-chain surface format. Does NOT build
// pipelines — the host runs the pipeline construction after this
// (so VW can still keep its HiZ / edge / pick / overlay builders
// co-located).
//
// `web_limits` forces the WebGPU spec mandatory floor (128 MB max
// storage binding, 256 MB max buffer) instead of the adapter's
// actual maximum — used by --web-limits to verify chunking fits
// through browser constraints.
//
// shutdown tears down everything ViewportCore owns. The host's own
// teardown (depth/MSAA/HiZ/edge/pick attachments + overlays) must
// run BEFORE this call so its device-owned resources release
// against a still-live device.
bool initWgpu(bool web_limits);
void shutdown();
private:
bool probeAndCreatePool();
public:
// Friend access for ViewportWindow's reference proxies. As each
// render method moves into ViewportCore it stops needing these
// (it touches the fields directly); once everything has migrated