mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
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:
@@ -20,17 +20,20 @@
|
||||
#ifndef VIEWPORTCORE_H
|
||||
#define VIEWPORTCORE_H
|
||||
|
||||
// Platform-agnostic render core. Owns the wgpu state + scene state +
|
||||
// per-frame render path. Talks to its embedder through ViewportHost
|
||||
// (window/canvas surface, scheduling, notifications) — has no Qt or
|
||||
// browser dependencies of its own.
|
||||
// Platform-agnostic render core. Owns the wgpu lifecycle state +
|
||||
// (eventually) scene state + per-frame render path. Talks to its
|
||||
// embedder through ViewportHost (window/canvas surface, scheduling,
|
||||
// notifications) — has no Qt or browser dependencies of its own.
|
||||
//
|
||||
// Empty for now: this header / TU is the placeholder for the
|
||||
// incremental Path-A refactor (#77-#86). Each subsequent commit moves
|
||||
// one subsystem out of ViewportWindow.cpp into here and updates the
|
||||
// public surface accordingly. Until that work lands, ViewportWindow
|
||||
// retains its render body; this class is just the target for the
|
||||
// move.
|
||||
// First migration target (#84-a): wgpu instance/adapter/device/queue/
|
||||
// surface ownership. The next subsystems (pipelines, models, render
|
||||
// path) move incrementally across subsequent commits — each leaving
|
||||
// the desktop build green. ViewportWindow currently holds reference
|
||||
// members pointing back at ViewportCore's storage so its body doesn't
|
||||
// have to acquire a `core_.` prefix on every wgpu touch. Those
|
||||
// references shrink as render methods themselves move over.
|
||||
|
||||
#include <webgpu/webgpu.h>
|
||||
|
||||
#include "ViewportHost.h"
|
||||
|
||||
@@ -44,8 +47,28 @@ public:
|
||||
|
||||
ViewportHost* host() const { return host_; }
|
||||
|
||||
// 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
|
||||
// the friend declaration goes away.
|
||||
friend class ViewportWindow;
|
||||
|
||||
private:
|
||||
ViewportHost* host_;
|
||||
|
||||
// ---- wgpu lifecycle state ------------------------------------------------
|
||||
//
|
||||
// Plain pointers (wgpu C handles); zero-init means "not yet
|
||||
// initialised". Owned by ViewportCore now; reference members in
|
||||
// ViewportWindow alias these so the existing call sites don't
|
||||
// need to change to use a `core_.` prefix.
|
||||
WGPUInstance instance_ = nullptr;
|
||||
WGPUAdapter adapter_ = nullptr;
|
||||
WGPUDevice device_ = nullptr;
|
||||
WGPUQueue queue_ = nullptr;
|
||||
WGPUSurface surface_ = nullptr;
|
||||
WGPUTextureFormat surface_format_ = WGPUTextureFormat_Undefined;
|
||||
bool surface_configured_ = false;
|
||||
};
|
||||
|
||||
#endif // VIEWPORTCORE_H
|
||||
|
||||
Reference in New Issue
Block a user