ifcviewer: move wgpu lifecycle state ownership into ViewportCore

First chunk of the #84 ViewportCore extraction. The seven wgpu lifecycle
handles (instance, adapter, device, queue, surface, surface_format,
surface_configured) now live as ViewportCore members; ViewportWindow
keeps reference aliases pointing at ViewportCore's storage so its
existing render-method bodies don't need a `core_.` prefix added at
every call site — 230+ touches deferred until each method moves
across.

Member init order in ViewportWindow's constructor:
  core_(this)               → constructs ViewportCore with host_=this
  instance_(core_.instance_) → binds the alias to core_'s field
  …                           same for adapter/device/queue/surface/…

Friend declaration on ViewportCore::ViewportWindow lets the references
bind to its private fields. The friend bond shrinks each commit as
render methods (and their `device_` / `queue_` references) migrate into
ViewportCore proper; the goal state is no friend and no aliases.

Next #84 chunks (separate commits) move pipelines, models_gpu_, pool_,
streaming_thread_, then the render/cull/encode methods. Each leaves
the desktop build green.

Builds: desktop / bonsai / web all green. Tests 100/100.
This commit is contained in:
Dion Moult
2026-06-05 09:39:57 +10:00
parent 1a17ba9e6d
commit e37a78f4f5
3 changed files with 62 additions and 18 deletions
+13 -1
View File
@@ -606,7 +606,19 @@ static WGPUStringView svFromCStr(const char* s) {
// -----------------------------------------------------------------------------
ViewportWindow::ViewportWindow(QWindow* parent)
: QWindow(parent) {
: QWindow(parent),
core_(this),
// Bind reference aliases to ViewportCore's storage so the
// existing `device_` / `queue_` / … sites in this TU keep
// working unchanged. Each reference goes away as its owning
// render method moves into ViewportCore.
instance_ (core_.instance_),
adapter_ (core_.adapter_),
device_ (core_.device_),
queue_ (core_.queue_),
surface_ (core_.surface_),
surface_format_ (core_.surface_format_),
surface_configured_(core_.surface_configured_) {
// wgpu doesn't need a GL context; we just need a real native window
// whose backing layer matches the GPU API wgpu will drive.
//