mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
2b43e6f7e0044cddd4b67f13d04e2b3590ff670f
21028 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2b43e6f7e0 |
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). |
||
|
|
66a21923b8 |
ifcviewer: move buildPipelines + selection-flags wiring into ViewportCore (#84-k)
Move the main render pipeline construction + the selection flags
buffer/bind group lifecycle. Both buildPipelines and the selection
flags methods produce/consume state ViewportCore already owns
(main_pipeline_, frame_bgl_, etc.) plus a handful of "frame
infrastructure" fields this commit also brings across.
State moved (7 fields):
WGPUBuffer frame_uniform_buffer_
WGPUBindGroup frame_bind_group_
WGPUBuffer selection_flags_buffer_
uint32_t selection_flags_capacity_
std::vector<u32> selection_flags_scratch_
SelectionState selection_
VisibilityState visibility_
Methods moved:
buildPipelines (~150 lines + 320-line MAIN_WGSL string)
ensureSelectionFlagsBuffer (~60 lines)
uploadSelectionFlagsIfDirty (~10 lines)
Plus the MAIN_WGSL constant + the svFromCStr helper into
ViewportCore.cpp's anonymous namespace. ViewportWindow.cpp keeps its
own svFromCStr copy (still used by 50+ label fields in the not-yet-
moved pipeline builders + render encoders).
Shared constants extracted to ViewportCore.h:
kMaxSectionPlanes (was OverlayRenderer::kMaxSectionPlanes — assert
in VW.cpp keeps them in sync)
kViewportSampleCount (was SAMPLE_COUNT in VW; VW keeps a static
constexpr alias for the existing callsites)
struct FrameUniforms (canonical layout for the per-frame UBO,
consumed by both core's buildPipelines and
VW's still-in-flight updateFrameUniforms)
Builds: desktop / bonsai / web all green. Tests 100/100.
|
||
|
|
8cf7d4346d |
ifcviewer: move volume readout helpers into ViewportCore (#84-j)
Tiny followup to #84-i — move the const-lookup volume helpers used by
bonsai's measurement HUD:
double volumeOfObjects(const std::vector<uint32_t>&) const
vector<pair<uint32_t, double>> volumesPerObject(
const std::vector<uint32_t>&) const
The det3OfPlacement static helper moves with them into ViewportCore.cpp's
anonymous namespace (the original kept its mirror in
ViewportWindow.cpp; ViewportWindow's own internal callers are gone now
since these methods moved).
Pure read of models_gpu_ + mesh_local_volumes — all in core already.
Trivial transplant.
Builds: desktop / bonsai / web all green. Tests 100/100.
|
||
|
|
707bb8f5d4 |
ifcviewer: move camera mutators + AABB helpers into ViewportCore (#84-i)
Move the cluster of camera-state mutators + per-object AABB helpers now that the camera fields all live in ViewportCore. CameraState struct is canonical in core; ViewportWindow keeps a `using` alias so bonsai's HomeView round-trip (Commands.cpp setHome / restoreHome) compiles unchanged. Moved: void viewAll() void setCamera(...) — pitch + distance clamping included void setStandardView(yaw, pitch) — bypasses clamp for ±90° void toggleProjection() std::string cameraString() const CameraState cameraState() const void frameAabb(mn, mx, padding) bool computeObjectAabb(id, float[3], float[3]) const bool computeObjectAabb(id, Eigen::Vector3f&, Eigen::Vector3f&) const ViewportWindow keeps thin forwarders for the public ones (bonsai calls them). setCamera additionally flips initial_view_applied_ on the VW side — the auto-viewAll suppression flag isn't in core yet because the trigger for auto-viewAll lives in the still-in-VW applyCachedModel path. The isExposed()+requestUpdate() Qt pattern inside the moved bodies becomes host_->requestFrame(); two viewAll/toggleProjection diagnostic prints become fprintf since Log::info() doesn't reach into core.cpp through the Qt logging surface. Builds: desktop / bonsai / web all green. Tests 100/100. |
||
|
|
14e7c9fc42 |
ifcviewer: move camera math into ViewportCore (#84-h)
Move the three camera-math methods that compute view/projection
matrices, scene bounds, and per-chunk screen footprint for the
streaming priority signal:
void buildViewProj(Eigen::Matrix4f&, Eigen::Matrix4f&) const
bool computeSceneAabb(float[3], float[3]) const
float chunkScreenAreaPx(const ModelGpuData::Chunk&,
const Eigen::Matrix4f&) const
Plus the orbitEye helper (anonymous namespace in ViewportCore.cpp;
the qDegreesToRadians dep got swapped for an inline M_PI/180 constant).
ViewportWindow.cpp's 9 internal callers (cull, streaming, pick,
render, debug) updated to use core_.buildViewProj() etc. The
buildViewProj forwarder stays out of ViewportWindow.h since no
external caller needs it — bonsai/minimal both go through
public API methods like viewAll which still wrap core_ access
on the VW side.
Builds: desktop / bonsai / web all green. Tests 100/100.
|
||
|
|
a0db182d2b |
ifcviewer: move camera + surface-geom state into ViewportCore (#84-g)
Move the camera/projection/clear-color fields that buildViewProj, updateFrameUniforms, the cull screen-area projector, and the bonsai- side cameraState/setCamera/viewAll surface depend on. Same alias pattern; no method bodies move in this commit — the next one moves the camera math methods now that all their state is in core. State moved (12 fields): int configured_w_, configured_h_ float camera_target_[3], camera_distance_ float camera_yaw_deg_, camera_pitch_deg_, camera_fov_y_deg_ float camera_near_, camera_far_ bool projection_ortho_ Eigen::Vector4f background_color_ ViewportWindow keeps reference aliases for each (including a proper `float (&camera_target_)[3]` reference-to-array binding) so the ~150 call sites that touch camera state stay unchanged. Aliases collapse when their owning methods migrate. Builds: desktop / bonsai / web all green. Tests 100/100. |
||
|
|
8da0993457 |
ifcviewer: move scene mutators + releaseWgpuModelGpuData into ViewportCore (#84-f)
Move the eight scene-mutation methods that drive bonsai's load/unload
and georeference setters, plus the per-model GPU teardown helper.
All are mechanical transplants — no logic change — so behaviour stays
identical; only the owner has changed.
Methods moved (ViewportWindow public-API methods stay as forwarders
to keep the bonsai-side callers compiling):
removeModel / resetScene / hideModel / showModel
setFederatedFalseOrigin
setModelCoordinateOperation
setModelTransformation
recomposeAndUploadModel
State moved:
bool wgpu_initialized_ (storage → core_, alias kept in VW for
the initWgpu call site that still flips
it; goes when initWgpu moves)
Free function moved:
releaseWgpuModelGpuData(ModelGpuData&, BufferPool&) → ViewportCore.cpp
(must live in IfcViewerCore now that ViewportCore.cpp's
removeModel / resetScene call it; ViewportWindow.cpp's remaining
two call sites continue to resolve through ModelGpuData.h's
declaration — same linker view, different definition TU)
The `if (isExposed()) requestUpdate()` Qt pattern inside the moved
bodies became `host_->requestFrame()` since ViewportCore can't see
QWindow; the desktop ViewportHost override at the bottom of
ViewportWindow.cpp continues to translate that into requestUpdate().
Builds: desktop / bonsai / web all green. Tests 100/100.
|
||
|
|
b2fe9c4a71 |
ifcviewer: move const-lookup methods into ViewportCore (#84-e)
Move two pure-read methods (no GPU touch, no Qt) that the bonsai measurement / federation-origin paths use: bool findInstance(uint32_t, InstanceLookup&) const bool firstGeometryPointWorldM(uint32_t, Vector3d&) const ViewportWindow keeps both public-API method names — they now forward to core_ for the implementation so existing callers in bonsaiviewer/Measurement.cpp + Federation hooks don't have to change. The InstanceLookup type also stays a `using` alias in ViewportWindow (was added in #74). Both methods were already de-Qt'd (`findInstance` delegates to InstanceCompose; `firstGeometryPointWorldM` is pure Eigen). The move is a straight transplant — no behaviour change. Builds: desktop / bonsai / web all green. Tests 100/100. |
||
|
|
ad6822ac85 |
ifcviewer: move composeInstanceFromPlacement into ViewportCore (#84-d)
First method-body migration. composeInstanceFromPlacement composes the
federated-false-origin × model-transformation × coordinate-operation ×
placement chain and re-derives the world AABB; it's a small,
self-contained method that only reads scene state and one matrix.
Moved:
Eigen::Matrix4d federated_false_origin_meters_ (storage → core_)
void composeInstanceFromPlacement(InstanceCpu&, ...) (body → core_)
ViewportWindow keeps:
- alias reference to federated_false_origin_meters_ (existing
setFederatedFalseOrigin call site still writes through it)
- no method declaration — internal callers route through core_
Internal caller (recomposeAndUploadModel) now invokes
core_.composeInstanceFromPlacement; once recomposeAndUploadModel
itself moves into ViewportCore the call shortens back.
Pattern for the rest of #84: state moves, then method body moves,
then internal callers update. Each commit leaves desktop / bonsai /
web green and tests 100/100. This is one of many such steps.
|
||
|
|
303f903a10 |
ifcviewer: move scene state into ViewportCore (#84-c)
Move the five scene-state fields that drive per-model GPU upload + the
streaming residency loop into ViewportCore:
BufferPool pool_ — vertex+index sub-allocator
StreamingThread streaming_thread_ — background chunk reader
std::unordered_map<uint32_t, ModelGpuData> models_gpu_
— per-model state
uint32_t next_model_id_ — model-id allocator
uint32_t next_object_id_ — globally-unique object-id allocator
ViewportCore.h gains transitive includes for BufferPool / StreamingThread
/ ModelGpuData; ViewportWindow keeps the same names as reference aliases
so existing method bodies that touch them don't have to change.
Same risk profile as #84-a and #84-b: the storage moved but the values
are still set and consumed by the same code paths, so behaviour stays
identical.
Builds: desktop / bonsai / web all green. Tests 100/100.
|
||
|
|
d0be7b775a |
ifcviewer: move render pipelines into ViewportCore (#84-b)
Move the 15 pipeline + bind-group-layout + shader-module handles
that buildPipelines / buildEdgePipeline / buildPickPipeline write to.
Same pattern as #84-a: storage lives in ViewportCore, ViewportWindow
keeps reference aliases so existing builder-method bodies don't
have to acquire a `core_.` prefix at every touch point.
Moved fields:
Main render group:
main_shader_module_, frame_bgl_ (group 0), model_bgl_ (group 1),
pipeline_layout_, main_pipeline_, main_pipeline_transparent_
HiZ occlusion-cull group:
hiz_shader_module_, hiz_bgl_, hiz_pipeline_layout_, hiz_pipeline_
Edge silhouette group:
edge_shader_module_, edge_bgl_, edge_pipeline_layout_, edge_pipeline_
Pick pass:
pick_pipeline_ (reuses pipeline_layout_ — same set of bindings)
ViewportWindow's constructor binds 16 new alias references after
the 7 lifecycle ones from #84-a; member-init order matches
declaration order so core_ is constructed before any alias binds.
Builds: desktop / bonsai / web all green. Tests 100/100.
|
||
|
|
e37a78f4f5 |
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. |
||
|
|
1a17ba9e6d |
ifcviewer: de-Qt QColor/QPoint/QSet/QElapsedTimer in ViewportWindow
Last round of straight-swap Qt value types in ViewportWindow + its
overlay co-pilot.
setBackgroundColor(const QColor&) → (float r, float g, float b, float a)
QColor background_color_ → Eigen::Vector4f (linear, 0..1)
QPoint {nav_,box_select_,fps_, } → Eigen::Vector2i
{section_drag_start_mouse_}
QSet<int> fps_keys_held_ → std::unordered_set<int>
QElapsedTimer fps_last_tick_, → Stopwatch (new header in
fly_render_clock_, IfcViewerCore — std::chrono-
render_thread_local_ backed, exposes the existing
timers in render() QElapsedTimer .start/.restart/
.elapsed/.nsecsElapsed surface)
Also propagates the QPoint → Eigen::Vector2i change through
OverlayRenderer::encodeMarquee since the marquee corner coords flow
through that interface.
API-level helpers:
toV2i(QPoint) — small inline in ViewportWindow.cpp, isolates
the QMouseEvent→Vector2i conversion at the
five mouse-event handlers
Stopwatch.h — new file, IfcViewerCore. Same call shape as
QElapsedTimer; backed by std::chrono::steady_clock.
QSet method swaps:
.isEmpty() → .empty()
.contains(k) → .count(k) (C++17, no std contains() until C++20)
.remove(k) → .erase(k)
Eigen::Vector2i doesn't have .manhattanLength(); the box-select drag
threshold uses std::abs(diff.x()) + std::abs(diff.y()) inline.
Bonsai side: View.cpp's setBackgroundColor wrapper now decomposes the
QColor into floats at the call site (kept locally so the bonsai UI
keeps its QColor-driven theming).
Closes #81 + the QElapsedTimer half of #83. QTimer
(pivot_indicator_hide_timer_) still uses Qt — it needs the host's
scheduleOnce mechanism that lands with #85.
Builds: desktop / bonsai / web all green. Tests 100/100.
|
||
|
|
b62e14a06a |
ifcviewer: de-Qt ViewportWindow public API (QString → std::string)
Take QString out of ViewportWindow's outward-facing surface so it can
eventually move into a Qt-free ViewportCore:
void queueLoadSidecar(const QString&) → (const std::string&)
uint32_t loadSidecar(const QString&) → (const std::string&)
QString cameraString() const → std::string …
void captureNextFrameToPng(const QString&, bool)
→ (const std::string&, bool)
void setHudText(const QString&) → (const std::string&)
Internal members also moved off QString:
std::deque<QString> pending_sidecars_ → std::deque<std::string>
QString pending_screenshot_path_ → std::string
Implementation strategy: convert at the boundary where ViewportWindow
still leans on Qt internals — `loadSidecar` bridges to QString once
for QFile/QDir/QFileInfo path handling; the screenshot save path
constructs a QString locally for QImage::save; the OverlayRenderer's
HUD setter still takes QString so setHudText converts before calling
through. Each of those bridges goes away when ViewportCore lands and
OverlayRenderer / SceneLoader / SidecarBuilder get their own de-Qt
sweeps. cameraString now produces its CSV via snprintf — no QString
ever instantiated.
Bonsai-side updates (compile-only):
ifcviewer-minimal/main.cpp — queueLoadSidecar / captureNextFrameToPng
callers add .toStdString() on the QString
parser result
modules/viewport/View.cpp — setHudText callers add .toStdString() to
their `QString::arg(...)` formatter chains;
two `QString()` empty sentinels become
`std::string()`
Measurement.cpp — same pattern, two setHudText sites
ifcviewer/LengthMeasurement.cpp — same, three sites
The cameraString string-streaming fix-up in ViewportWindow.cpp drops
the temporary .toUtf8().constData() bridge from #82 — Log::Stream's
std::string overload now handles it directly.
Builds: desktop / bonsai / web all green. Tests 100/100. Closes #80.
|
||
|
|
6dd3558db9 |
ifcviewer: replace qInfo/qWarning with a Qt-free logger seam
Add Log.h (in IfcViewerCore) — a tiny stream-style logger that backs fprintf(stderr,...), with overloads for the common primitives + char strings. Mimics qInfo()/qWarning()'s syntax surface enough that mass-replacing qInfo()→Log::info() and qWarning()→Log::warn() keeps existing call sites parsing unchanged; .noquote() / .nospace() exist as compat no-ops so chained qInfo().noquote()<<x<<y patterns survive. QString streaming is a transitional concern — the QString → std::string sweep (#80) hasn't landed yet, so ViewportWindow and friends still construct QStrings for log payloads. LogQt.h (in IfcViewer, not Core) adds the QString / QStringView operator<< overloads so those streaming sites work without source changes during the in-flight Qt removal. When #80 retires QString, LogQt.h drops out. ViewportWindow.cpp: 132 qInfo/qWarning callsites converted. The two printf-style qInfo("fmt %s", ...) callsites get fprintf with explicit [info]/[warn] prefixes to keep the output discoverable. Also de-Qt'd: AreaMeasurement.cpp — 1 qInfo("fmt", …) → fprintf SceneLoader.cpp — 4 qDebug + 1 qWarning printf-style → fprintf GeometryStreamer.cpp — 2 qDebug printf-style → fprintf ifcviewer-minimal/main.cpp — 2 qWarning << → Log::warn Drops <QDebug> from each. Closes #82. Builds: desktop / bonsai / web all green. Tests 100/100 pass. |
||
|
|
77cf535b45 |
ifcviewer: de-Qt math types (Eigen everywhere)
Replace Qt math wrappers with Eigen across ViewportWindow, OverlayRenderer, Federation, and the bonsai-side viewport modules. Eigen was already the canonical type for the actually-important matrix work (InstanceCompose, ModelGpuData, federation matrices); QVector3D/QVector4D/QMatrix4x4 were leftover from when Qt was the path of least resistance. They offered nothing over Eigen for our use case beyond a few graphics helpers (lookAt / perspective / ortho) which were 30 lines to write. Substitutions: QMatrix4x4 → Eigen::Matrix4f QVector2D → Eigen::Vector2f QVector3D → Eigen::Vector3f QVector4D → Eigen::Vector4f API rewrites: .lengthSquared() → .squaredNorm() .length() → .norm() .isNull() → .isZero() .setToIdentity() → .setIdentity() .constData() → .data() .toVector3D() → .head<3>() .inverted(&ok) → tryInvert4f(M, out) Q::dotProduct(a,b) → a.dot(b) Q::crossProduct(a,b) → a.cross(b) QMat4x4(... row-major) → Eigen::Map<const Matrix4f>(col-major buf) QMat4x4().lookAt(...) → lookAtRH(eye, target, up) QMat4x4().perspective(.) → perspectiveYFovGL(fovy, aspect, n, f) QMat4x4().ortho(...) → orthoGL(l, r, b, t, n, f) Default-init divergence handled explicitly (QMatrix4x4() = identity, QVector3D() = zero; Eigen leaves both uninitialized). Public API (CameraState, HomeView, ViewportWindow::computeObjectAabb, the addSectionPlaneAtSurface / pickSurfaceAt / raycast signatures) follows through to Eigen too; bonsai-side View.cpp and Commands.cpp updated to match. Camera helpers (lookAtRH, perspectiveYFovGL, orthoGL, tryInvert4f) extracted to a new CameraMath.h so OverlayRenderer's gizmo MVP and ViewportWindow's buildViewProj share the same definitions. Federation drops its <QVector3D> include in favour of <Eigen/Dense> (already had the latter for the georef matrices). Builds: desktop IfcViewerMinimal ✓, BonsaiViewer ✓, web IfcViewerWeb ✓. Tests: 100/100 pass. Closes #78 + #79; opens the door for #80-#83. |
||
|
|
c314dd3ca8 |
ifcviewer: scaffold ViewportHost + ViewportCore (Path A step 1)
Define the boundary the Path-A web-bring-up refactor will move things
across:
- ViewportHost.h is the embedder interface — surface creation,
framebuffer geometry, frame scheduling, quit, and notification
callbacks (onObjectPicked, onToolModeChanged, …). Desktop hosts
forward notifications to Q_SIGNALS; the future web host pushes
them to JS callbacks.
- ViewportCore.{h,cpp} is the platform-agnostic render-core target.
Empty today — the body fills in across the #78-#86 sequence as
each Qt subsystem (matrices, vectors, strings, timers, render
path, input) gets de-Qt'd and moved over.
- ViewportWindow now multiply-inherits ViewportHost alongside QWindow
and implements the host overrides as thin forwarders: createSurface
returns the cached surface_, requestFrame -> requestUpdate, quit ->
QCoreApplication::quit, onObjectPicked -> emit objectPicked.
Renamed the DPR accessor `dpr()` (vs `devicePixelRatio`) to avoid
the inherited-virtual clash with QWindow's qreal-returning version.
No method movement yet — this is purely the architectural scaffold so
subsequent commits have a destination.
|
||
|
|
e55a360aa2 |
web: scaffold IfcViewerWeb (Emscripten clear-color renderer)
First Emscripten target. main_web.cpp brings up a wgpu instance against
a <canvas id="viewer-canvas">, requests adapter+device asynchronously
via the standard webgpu.h callback chain, configures the surface, and
clears to the BonsaiViewer slate background on each RAF tick. No
sidecar load, no pipelines, no scene state yet — the goal is to end-
to-end verify the build + canvas + wgpu plumbing.
src/ifcviewer-web/ is a separate CMake root (not a subdir under the
desktop cmake/CMakeLists.txt) so the web build doesn't have to opt out
of Qt / OpenCASCADE / IfcGeom find_packages it can't satisfy. It adds
src/ifcviewer EXCLUDE_FROM_ALL and consumes only IfcViewerCore.
src/ifcviewer/CMakeLists.txt now gates the wgpu-native fetch + the
Qt-using IfcViewer target + install commands behind NOT EMSCRIPTEN.
The wgpu_native link target still resolves under Emscripten as an
INTERFACE library that activates --use-port=emdawnwebgpu (Dawn's
webgpu.h, replaces the legacy -sUSE_WEBGPU=1).
Build:
source path/to/emsdk_env.sh
emcmake cmake -S src/ifcviewer-web -B build-web -G Ninja
ninja -C build-web
python3 -m http.server --directory build-web 8080
# open http://localhost:8080/IfcViewerWeb.html in a WebGPU-capable
# browser (Chrome 113+, Edge 113+).
Phase B step 3 of #45.
|
||
|
|
c098146c35 |
Remove Autodesk viewer examples
Remove the bonsaiviewer-autodesk Cargo examples that were used for local UI and dialog experiments. Generated with the assistance of an AI coding tool. |
||
|
|
fe6a0452bf |
ifcviewer: split out IfcViewerCore static library
Pull the Qt-free / OpenCASCADE-free files out of the IfcViewer target into a new IfcViewerCore static lib: BufferPool, ChunkPlanner, InstanceCompose, SidecarCache, StreamingLoader, StreamingThread, LodBuilder, plus the header-only InstancedGeometry / ModelGpuData / VertexQuantization / Selection / Visibility headers. IfcViewer PUBLIC- links IfcViewerCore so existing consumers see no change. This is the boundary the Emscripten web target will link against — keeps Qt, IfcGeom, OpenCASCADE, CGAL, and Boost out of the wasm build. Explicit file list, not glob, because the boundary is the whole point. |
||
|
|
cb19f22ee4 |
BufferPool: drop Qt log dependency
Replace qInfo() growth-event logging with fprintf(stderr,...) so BufferPool.cpp has no Qt touchpoints. Lets the test target drop its Qt6::Core link too. Prerequisite for the IfcViewerCore library boundary the web target will link against. |
||
|
|
1fe4570860 |
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. |
||
|
|
749476d1a7 |
docs: rewrite stale GL-era docs (env-vars + viewport_architecture)
Two long-stale docs that described the deleted OpenGL backend are replaced with current-state rewrites under `src/bonsaiviewer/docs/` and wired into the toctree. The originals are removed. ## env-vars.rst (replaces src/ifcviewer/settings.rst) The orphan `src/ifcviewer/settings.rst` was written for the OpenGL backend (`IFC_*` prefix, MDI-specific knobs) and was never wired into any Sphinx toctree — it sat as a one-off file in the C++ source tree, undiscoverable from a normal docs build. * **Dead — dropped entirely.** `IFC_SKIP_MDI`, `IFC_MAX_SUBDRAWS`, `IFC_SUBDRAW_DIAG` were GL-only `glMultiDrawElementsIndirect` instrumentation. wgpu has no MDI. `IFC_FPS_HITCH_MS` no longer exists in source. * **Renamed.** `IFC_HIZ_MOTION` → `WGPU_HIZ_MOTION`, `IFC_CULL_THREADS` → `WGPU_CULL_THREADS`. * **New, previously undocumented.** Ten `WGPU_*` vars added during the port + bring-up (WGPU_HIZ, WGPU_HIZ_TRACE, WGPU_MIN_PX, WGPU_MIN_PX_MOTION, WGPU_FLY_DEBUG, WGPU_NAV_PRESET, WGPU_PRESENT_MODE, WGPU_STREAM_DEBUG, WGPU_STREAM_DEEP_DEBUG, WGPU_STREAM_EVICT_LOG). Descriptions written from each variable's use-site so wording matches actual behaviour. * **LOD-build section kept verbatim.** IFC_LOD_ERROR, IFC_LOD_RATIO, IFC_LOD_MIN_SAVINGS, IFC_LOD_DEBUG — sidecar-bake knobs, backend-agnostic. * **GUI-promoted "old IFC_* graveyard" section dropped.** The file is an env-var reference, not a record of historical spellings. ## viewport_architecture.rst (replaces src/ifcviewer/README.md) The 994-line `src/ifcviewer/README.md` was an archive of the GL-era phase-by-phase perf narrative. ~95% of it described deleted code: OpenGL 4.5 Core, `glMultiDrawElementsIndirect`, VAO/VBO/EBO, `GL_ARB_shader_draw_parameters`, BVH-per-model, sidecar v5/v7/v9 (current is v13), the now-non-existent `./IfcViewer` binary, Phase 3F "static batching next" plans superseded by the chunk-pool architecture, Phase 3E "GPU compute culling removed" since re-added as task #17 pending. Salvaging the ~50 lines of still-correct content would have left a Frankenstein doc internally contradicting itself. Replaced with a focused architecture page covering current reality: consumer split (BonsaiViewer shell vs IfcViewerMinimal standalone), stack (wgpu-native v29, Qt6, IfcOpenShell, IfcUtil, Eigen3, meshoptimizer), five core ideas (unique-mesh instancing, quantized 12 B vertex, chunked streaming on a probed VRAM pool, sidecar v13 fast path, event-driven rendering), per-frame pipeline (cull → upload → streaming → opaque pass → transparent pass → edge → overlay → present), federation + false-origin compose, file map limited to files that actually exist in `src/ifcviewer/` today, build/run via `build_viewer.sh`, cross-refs to env-vars.rst, debug-output.rst, and connectors/. ## Toctree `src/bonsaiviewer/docs/index.rst` gains `env-vars` and `viewport_architecture` entries alongside the existing `connectors/index` and `debug-output`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
ce7d2fa329 |
docs: split Autodesk connector docs into user + developer pages
`autodesk.rst` had grown to mix end-user concerns (where do my tokens live, how do I install the bundle, why isn't sign-in working) with developer concerns (cargo build, fmt/clippy/test, packaging script flow, per-OS toolchain notes, CI). Reorganise into: * **`autodesk.rst`** — Autodesk Connector. User-facing. Bonsai-Viewer- level intro (Forma/APS/Docs, "Add from cloud"); install-from-zip per OS; first-run setup (client ID, OAuth port, browser redirect); where settings / cache / OAuth tokens live; proxy / TLS guidance for corporate installs. * **`autodesk_development.rst`** — Autodesk Connector Development. Developer-facing. Tech stack (FLTK, ureq, keyring, dirs, serde, chrono, webbrowser); `cargo build --release`; `cargo test --all-features` / clippy / fmt-check; protocol probing via stdio pipe; packaging via `packaging/build.py`; per-OS build / keychain / codesign notes; CI workflow overview. Absorbs the entirety of the old `autodesk_packaging.rst`, which is removed. `connectors/index.rst` toctree updated: `autodesk_packaging` → `autodesk_development`. `cloud_sync_protocol.rst` untouched — language-agnostic protocol spec. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
9d9f4054f6 |
bonsaiviewer-autodesk: replace Python connector with the Rust impl
The Python implementation of the Autodesk Forma connector
(bonsaiviewer_autodesk/) is deprecated. The Rust port that's been
maturing under src/bonsaiviewer-autodesk-rs/ is now the connector
and takes over the original folder name.
## File operations
* `git rm -r src/bonsaiviewer-autodesk` — drop the 18 tracked Python
source/test/packaging files. (~6.5k untracked build artefacts in
venv/build/dist/egg-info are removed too, but those were never in
the index.)
* `mv src/bonsaiviewer-autodesk-rs src/bonsaiviewer-autodesk` —
the Rust impl takes over the canonical folder name.
* `rm -rf src/bonsaiviewer-autodesk-rs-egui` — abandoned egui-based
experiment, never committed.
* `src/bonsaiviewer-autodesk/.gitignore` extended with `/dist` to
keep packaging output out of the index alongside the existing
`/target` rule.
The Rust binary in Cargo.toml already has `name = "bonsaiviewer-
autodesk"` and `connector.json`'s `exec` field already points at that
name — so the connector loader, build_viewer.sh symlink, and
win/build-all-win.py CONNECTOR_DIR all keep working without edits.
## Packaging shape preserved
`packaging/build.py` is rewritten to:
* shell out to `cargo build --release` instead of pyinstaller,
* copy the produced binary + connector.json into the same
`dist/autodesk/` layout the PyInstaller flow produced,
* zip into `dist/autodesk-<os>-<arch>.zip` with the same
naming pattern (CI artifact uploads keep working).
The Rust binary statically links its deps, so unlike PyInstaller
there's no `_internal/` directory — single executable inside
`dist/autodesk/`. Everything downstream (`build_viewer.sh` symlink,
`win/build-all-win.py collect_connector_files`, the zip step in
`build_rocky.yml`) only cares that `dist/autodesk/` exists, so the
on-disk contract is preserved.
Verified locally: `python3 src/bonsaiviewer-autodesk/packaging/build.py`
produces `dist/autodesk/{bonsaiviewer-autodesk, connector.json}`
(3.9 MB stripped ELF) and `dist/autodesk-linux-x86_64.zip` (~1.5 MB
compressed).
## CI updates
* `.github/workflows/build_rocky.yml` and `build_rocky_arm.yml`:
drop the `pip install ".[build]"` step — `packaging/build.py` is
stdlib-only now, the cargo build wrapped inside it does the work.
* `.github/workflows/build_win.yml`: same — drop pip install,
packaging script handles cargo internally.
* `.github/workflows/build-bonsaiviewer-autodesk.yml`: full rewrite
of the dedicated connector test/build workflow. Replaces the
Python {3.11, 3.13} test matrix with `cargo fmt --check`,
`cargo clippy --all-targets -- -D warnings`, and `cargo test
--all-features`. The OS/arch build matrix is unchanged
(linux-x86_64, macos-arm64, macos-x86_64, windows-x86_64) but
installs a Rust toolchain via dtolnay/rust-toolchain@stable and
caches target/ via Swatinem/rust-cache.
`win/build-all-win.py` and `build_viewer.sh` are unchanged — they
only reference the `dist/autodesk/` path, which the new
`packaging/build.py` populates identically.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
b3fbcd6a66 |
refactor: extract src/ifcutil/ from src/ifcviewer/ (Unit, Geolocation, Placement)
Unit / Geolocation / Placement are schema-agnostic IFC helpers ported
from ifcopenshell.util.{unit,geolocation,placement}. Nothing about
them is viewer-specific: pure IfcParse + Eigen, no Qt, no IfcGeom, no
renderer. Living under src/ifcviewer/ implies an unwanted dependency
direction every time a non-viewer caller (test_federation, the bonsai
SettingsView georef readout, a future standalone IFC tool) wants to
use them.
Move them to a new `src/ifcutil/` static lib (IfcUtil). The lib has
PUBLIC `target_include_directories(${CMAKE_CURRENT_SOURCE_DIR})` so
callers that link IfcUtil can keep `#include "Unit.h"` etc. without
relative-path adjustments — the include dir propagates transitively
via IfcViewer's PUBLIC link.
## Changes
* `git mv src/ifcviewer/{Geolocation,Placement,Unit}.{h,cpp}
→ src/ifcutil/` (history follows the rename).
* `src/ifcutil/CMakeLists.txt`: IfcUtil static lib, PUBLIC links
IfcParse + Eigen3::Eigen, PUBLIC include dir.
* `cmake/CMakeLists.txt`: `add_subdirectory(../src/ifcutil ifcutil)`
before ifcviewer/ so the link target exists when IfcViewer's
CMakeLists runs.
* `src/ifcviewer/CMakeLists.txt`: IfcUtil added to IfcViewer's PUBLIC
link_libraries.
* `src/ifcviewer/tests/CMakeLists.txt`: test_federation drops the
explicit `${IFCVIEWER_SRC}/{Unit,Geolocation,Placement}.cpp`
source list and links `IfcUtil` instead (matches how production
code resolves the symbols).
* `src/bonsaiviewer/modules/models/SettingsView.cpp`: the two
explicit `#include "../../../ifcviewer/{Geolocation,Unit}.h"`
paths swap to `../../../ifcutil/…`. All other callers use bare
`#include "Unit.h"` style and continue to work via the propagated
include dir.
## Verification
* `ninja -C build-viewer` builds clean: IfcUtil + IfcViewer +
IfcViewerMinimal + BonsaiViewer + all four pre-existing
ifcviewer tests + the two from-wgpu tests.
* `test_federation` runs green: 226 assertions in 22 test cases
pass with IfcUtil linked instead of the explicit-source compile.
* `git log --follow` traces e.g. `Geolocation.cpp` back through the
rename to its prior location in src/ifcviewer/.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
32d9fd6c1c |
build-all: restore full PYTHON_VERSIONS list
|
||
|
|
b123ee69d6 |
viewer: two-pass alpha transparency + Alt+X global x-ray cap
## The bug
FZK-Haus windows rendered fully opaque despite every piece of the
data path carrying alpha correctly: vertex format is RGBA u8x4,
InstanceCpu/InstanceGpu carry color_override_rgba8 with its alpha
byte, fs_main returns vec4(rgb, in.color.a). Cause: the main render
pipeline's color target had `blend = nullptr`, which in wgpu disables
the blend stage entirely — fragment RGBA overwrites the back buffer
unmodified, alpha discarded.
## Why "just enable blend" isn't enough
Two failure modes that don't go away with a one-liner:
1. `depthWriteEnabled = True` on the main pipeline would make a
transparent window-frame pane occlude geometry behind it in
depth, so the wall behind the window then fails the depth test
and never draws — you'd see the silhouette of the window with
whatever colour was in the back buffer before, not the wall.
2. Order-dependent blending across transparent surfaces in arbitrary
cull order — overlapping transparent surfaces would shift colours
as the camera moves.
Standard fix for a BIM viewer is two-pass opaque-then-transparent.
## What this commit adds
### Per-mesh "has any alpha < 255" classifier
* `ModelGpuData::mesh_has_alpha` (uint8_t vector, parallel to meshes).
* Sized in `applyCachedModel`.
* Populated in `applyStreamedChunk` by scanning each in-chunk mesh's
vertex bytes for a vertex's alpha byte < 255 (offset 11 within
the 12-byte vertex record — the 4th byte of the third u32, which
the shader reads as `w2 >> 24`). Single chunk-arrival site covers
both sidecar streaming and the worker-result drain. First-load
IFC-without-sidecar geometry still routes opaque until the sidecar
bake completes; A-path scan is deferred.
### Per-chunk opaque/transparent partition during cull
* `Chunk::opaque_visible_vertices` / `opaque_visible_draws`
(per-frame counts).
* Transient `visible_draws_scratch_transparent` +
`transparent_per_draw_vertex_counts` filled alongside the existing
opaque half during the cull walk. Post-walk concat appends
transparent entries onto the opaque half and continues the
cumulative prefix-sum sequence — single buffer, single bind
group, no doubling.
* Classifier inside the cull lambda:
`xray_active ? always_transparent
: override_active ? (override.alpha < 255)
: mesh_has_alpha[mesh_id]`
### Per-chunk uniform layout extension
From `[total_draws, total_verts, 0, 0]` to
`[total_draws, total_verts, opaque_verts, opaque_draws]`. The third
slot is what `render()` passes as `firstVertex` to the transparent-
pass draw call so the shader's vid lands in the transparent range of
the same visible_draws_scratch buffer.
### `main_pipeline_transparent_`
Copy of `main_pipeline_` with `color_target.blend = SrcAlpha /
OneMinusSrcAlpha`. depthWriteEnabled stays True (see below).
### Two-pass `render()`
Opaque pass (`main_pipeline_`, firstVertex=0,
vertexCount=opaque_visible_vertices) then transparent pass
(`main_pipeline_transparent_`, firstVertex=opaque_visible_vertices,
vertexCount=total - opaque). Each loop skips empty halves so an
opaque-only chunk costs one draw call, transparent-only one draw,
mixed chunks two.
### depth_transparent.depthWriteEnabled = True (NOT off)
Initially set False (standard "let further-back geometry paint
through transparent front faces" trick) but that broke the edge-
detect pass: edge detection reads the depth buffer to find
silhouette discontinuities, and windows-without-depth meant the
glass had no silhouette at all (panes looked like framed holes) and
the edges of opaque geometry behind the glass painted through at
full intensity. Keeping the write avoids that — trade-off is depth-
test occlusion between transparent surfaces (closer occludes
farther), which for BIM panes that don't overlap in screen space
is invisible. Real fix for the overlap case is OIT or sort-back-
to-front, not depth-write toggling.
## Alt+X global X-ray (drops in basically free)
* `xray_alpha_cap` field on FrameUniforms + WGSL counterpart, default
1.0 (no effect). fs_main clamps `out.a = min(in.color.a, cap)`.
* `ViewportWindow::xray_alpha_cap_` member, default 1.0. Alt+X
toggles between 1.0 and 0.3.
* Cull classifier sees `xray_alpha_cap_ < 1.0` and forces every
instance into the transparent pass so the blend stage actually
fires (an opaque-pass fragment with capped alpha would still
overwrite the back buffer).
* No per-instance state mutation needed — toggle is a single float
in a uniform plus a re-cull. Excluding objects from x-ray later
would mean tagging them so the classifier skips the force-
transparent branch for them, also small.
Stress-tested on FZK-Haus: window glass visibly translucent with
correct silhouette edges; Alt+X turns the whole scene to a tinted
ghost of itself and back without artefact.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
748b4e72a9 |
macOS: re-enable Python wrapper + stage IfcViewerMinimal.app bundle
Three coupled fixes that close the macOS bring-up loop:
## 1. ifcwrap: fix INSTALL_RPATH on Apple
The ifcopenshell_wrapper Python module had `INSTALL_RPATH "$ORIGIN"` set
for "NOT WIN32 AND NOT WASM_BUILD" — but `$ORIGIN` is a Linux ld.so
placeholder, not a macOS dyld one. macOS dyld doesn't expand it; it
bakes the literal string `$ORIGIN` into LC_RPATH, which resolves to
nothing at runtime. The wrapper's hard-link `@rpath/ifcopenshell
.document.rdb.dylib` then fails to load even though INSTALL(TARGETS …
LIBRARY DESTINATION "${python_package_dir}/ifcopenshell") above had
already dropped the plug-in dylib right next to the wrapper.
Split the rpath assignment: `@loader_path` on Apple (the dyld
equivalent of `$ORIGIN`), `$ORIGIN` elsewhere.
This is what
|
||
|
|
8ab5c31e75 |
refactor: merge ifcviewer-wgpu into ifcviewer, drop Wgpu prefix
The GL backend is gone (task #53). The wgpu/non-wgpu folder split and the Wgpu* class prefix were both disambiguation artefacts from the overlap period — now pure dead weight. ## Folder + library merge * `src/ifcviewer-wgpu/` → folded into `src/ifcviewer/` (git mv tracks every file as a rename so blame/log history survives). * `src/ifcviewer-wgpu-minimal/` → `src/ifcviewer-minimal/` (the exe was already named `IfcViewerMinimal`; this just brings the folder + CMake target name into line). * `src/ifcviewer-wgpu/tests/test_wgpu_{selection,visibility}.cpp` → `src/ifcviewer/tests/test_{selection,visibility}.cpp`, folded into the existing `add_ifcviewer_unit_test(...)` helper. * The `IfcViewerWgpu` static library is dissolved — its sources become part of the unified `IfcViewer` static library, which now bundles scene/loader + renderer in one target. The pre-merge circular dependency (IfcViewer linking IfcViewerWgpu just to get the ViewportWindow.h include path that SceneLoader.h needs) goes away. * The wgpu-native FetchContent block, the Cocoa/QuartzCore link on Apple, the OBJCXX-enabled `.mm` source, and the wgpu-native runtime install all move into `src/ifcviewer/CMakeLists.txt` unchanged. ## Type renames (Wgpu prefix dropped from every Wgpu* identifier) WgpuAreaMeasurement → AreaMeasurement WgpuBufferPool → BufferPool WgpuLengthMeasurement → LengthMeasurement WgpuMetalSurface → MetalSurface WgpuModelGpuData → ModelGpuData WgpuOverlayFrame → OverlayFrame WgpuOverlayRenderer → OverlayRenderer WgpuSectionPlane → SectionPlane WgpuSelectionState → SelectionState WgpuStreamingLoader → StreamingLoader WgpuStreamingThread → StreamingThread WgpuViewportWindow → ViewportWindow WgpuVisibilityState → VisibilityState CMake target IfcViewerWgpuMinimal → IfcViewerMinimal (exe name was already this since wgpu shipped as default). Deliberately kept: `onWgpuLog` (wgpu-native log callback — names a binding to an external API, not one of *our* types), and the WGPU* enum/struct prefixes from wgpu-native's own headers. `WgpuMemProbe` lives in the separate `src/wgpu-mem-probe/` standalone diagnostic project and isn't touched. ## Include-path updates Every `#include "../ifcviewer-wgpu/Wgpu<X>.h"` → `"../ifcviewer/<X>.h"`, every in-directory `#include "Wgpu<X>.h"` → `"<X>.h"`. Includes from sibling subdirectories (modules/, etc.) are updated to point at `../../../ifcviewer/` instead of `../../../ifcviewer-wgpu/`. ## cmake/CMakeLists.txt simplification The redundant `add_subdirectory(ifcviewer-wgpu)` blocks (one inside the BUILD_BONSAIVIEWER fan-in, one in the BONSAIVIEWER-less standalone block) collapse into a single unconditional `add_subdirectory(../src/ifcviewer ifcviewer)`. The standalone block keeps only `wgpu-mem-probe` (the diagnostic tool, unrelated to the viewer lib). ## Verification * Full build green: `IfcViewer` static lib, `IfcViewerMinimal` exe, `BonsaiViewer` exe, all four pre-existing ifcviewer unit tests, and the two new-location tests (`test_selection`, `test_visibility`). * No stray `Wgpu<X>` identifier remains across `src/ifcviewer/`, `src/bonsaiviewer/`, `src/ifcviewer-minimal/` (verified by grep). * Renames tracked by git as `R` entries — `git log --follow` on ViewportWindow.cpp etc. continues to show history through the move. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
7f87408b78 |
bonsaiviewer: rework add-models false-origin guess + drop fly-mode input lag
Two independent threads that landed on this branch.
## 1. Federation false-origin guess: arm-on-add + frame-on-origin
The
|
||
|
|
2b91e41fc4 |
bonsaiviewer: stage all IfcOpenShell dylibs (core + plug-ins) on macOS
The .app bundle's Frameworks/ staging rule was only globbing ifcopenshell.*.dylib (the dlopen-only plug-ins) on the assumption that macdeployqt would follow BonsaiViewer's link-time @rpath deps for the lib-prefixed core shared libs. In practice it doesn't — non-Qt @rpath deps whose source path is outside the standard system / Qt prefixes get skipped silently. In a static build this didn't matter: libifcopenshell.geometry, libIfcParse, libIfcViewer, etc. were statically embedded in BonsaiViewer.exe, so there was no runtime dep. With --shared (added in |
||
|
|
cc54237f51 |
viewport: move first-model false-origin guess out of refresh()
Loading a model whose first placement sits at the world origin
stack-overflowed BonsaiViewer instantly on Windows (and macOS).
WinDbg trace was a 5-frame Qt signal-slot cycle hitting the guard
page ~1400 levels deep; Linux escaped only because that machine's
iterator order put a non-origin instance first, which made the guess
return a non-default value and naturally terminated the recursion
after one step.
Root cause is the architecture, not the specific guard inside the
guess function. `ViewportView::refresh()` was connected to six
SessionState signals (projectReset, projectOpened, modelsChanged,
federationChanged, visibilityChanged, modelGeometryReady) and was
calling `maybeGuessFederatedFalseOrigin` on every model on every
fire. That helper called `session_state_->notifyFederationChanged()`
unconditionally after the mutation, which re-emitted
SessionState::federationChanged, which re-entered refresh(), which
re-entered the guess — a hidden emit-in-slot loop. The "current ==
defaults" guard at the top of the guess prevented further mutations
once the value moved off defaults, but on machines where the guess
itself returned defaults the guard never fired and the loop ran
forever.
Cleanup:
* refresh() is now terminal: it reads federation state, pushes it to
the viewport, and returns. No mutations, no signal emissions.
maybeGuessFederatedFalseOrigin is removed from its for-loop.
* The guess is renamed to `tryGuessFirstModelFalseOrigin(uint32_t)`
and is now invoked only from the modelGeometryReady connection,
not from refresh(). Conditions:
1. modelIds().size() == 1 (the just-loaded model is the only
model — i.e. this is the "first model added" edge)
2. federation->federatedFalseOrigin() == defaults (nobody has
set the origin yet — possibly because the previous attempt
guessed defaults and no-op'd, in which case we deliberately
want to retry next time a model lands)
No one-shot flag: add→remove→add cycles re-attempt the guess
precisely while the origin is still default, which is the right
semantics.
* SessionState now relays Federation::federatedFalseOriginChanged
onto its own bus via notifyFederationChanged. This replaces the
manual `session_state_->notifyFederationChanged()` call the old
guess made post-mutation. With the relay in place, any future
mutation site (commands, settings dialog, project load) will
propagate to views automatically — the emit point lives at the
data change, not at every caller. Views still subscribe to
SessionState only; Federation stays a back-end detail.
Reproduced with ISSUE_053_20181220Holter_Tower_10.ifcview on
Windows (build
|
||
|
|
ddee88bed3 |
build_osx: --shared + skip geometry-writer plug-ins (~3x bundle shrink)
Mirrors the Rocky workflow's two-part size reduction (27249770e "Reduce Rocky package size") on macOS: 1. Pass `--shared` to nix/build-all.py. The default builds IfcOpenShell as static libs, which means every plug-in dylib (schemas × 8, kernels × 3, mappings × 8, writers × 8, document serializers × ~4, linework processing) statically embeds a full copy of libIfcParse + libIfcGeom. With --shared the plug-ins reference @rpath/libIfcParse.dylib + @rpath/libIfcGeom.dylib and the per-plug-in dylib drops from ~30-50 MB to a few MB each. Dominant size win. 2. Filter `ifcopenshell.geometry.writer.*.dylib` out of BonsaiViewer's plug-in staging step in src/bonsaiviewer/CMakeLists.txt. These are the per-schema OBJ / glTF / DAE / STP / IGS / SVG / TTL export converters — heavy because each one inlines the full schema, and BonsaiViewer is a viewer, never an exporter, so they're pure deadweight inside the bundle. Additive on top of --shared. Bundle went 300 MB → expected ~100 MB, in line with Linux (~100 MB) and Windows (~80 MB). The IFCOPENSHELL_BUILD_PYTHON_WRAPPER=off gate is unchanged for now — once we confirm BonsaiViewer.app size + functionality look sane, we can ungate the Python wrapper and see if shared-builds-on-macOS shake out its install issues too. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
37aa68e66c |
ifcopenshell plug-in loader: stable anchor + bundle-aware fallbacks
# What Two upstream-shaped fixes to ifcopenshell's runtime plug-in discovery so the schema/serializer plug-ins are findable in deployment layouts other than a flat \`<prefix>/lib/\` (specifically: macOS .app bundles). ## (1) Stable anchor variable instead of a function pointer \`schema_plugin_directory()\` used \`&load_schema_plugins\` as the anchor whose containing module \`dladdr\` is asked to resolve. Function addresses are not reliably equal to a single canonical location across toolchains — on macOS arm64 with BonsaiViewer.app, \`&load_schema_plugins\` took the address of a PLT/stub inside the consumer binary rather than the actual symbol inside \`libIfcParse.dylib\`. \`dladdr\` then dutifully returned the consumer's path and the loader started searching \`BonsaiViewer.app/Contents/MacOS/\` for plug-ins that were never installed there. A variable doesn't suffer from this — it has exactly one canonical address inside its defining dylib. Add \`ifcopenshell_libifcparse_anchor\` (exported via IFC_PARSE_API) and use \`&that\` instead. Standard pattern used by Boost.DLL, GStreamer, \`_dyld_get_image_*\`, etc. ## (2) Bundle-aware fallback search paths The primary search path is \`dirname(libIfcParse)\`. That works for flat installs (Linux \`lib/\`, Windows \`bin/\`) where plug-ins are siblings of libIfcParse. macOS app bundles split the layout: \`macdeployqt\` puts non-Qt @rpath deps in \`Contents/Frameworks/\`, Apple convention asks for \`Contents/PlugIns/\`, and some install rules co-locate libIfcParse with the exe in \`Contents/MacOS/\`. Plug-ins typically end up in a sibling directory, not the same one. In \`add_search_paths_or_default\`, after registering the primary path, also register \`<parent>/PlugIns\`, \`<parent>/Frameworks\`, and \`<parent>/MacOS\` on Apple platforms. \`discover_exact\` short-circuits on the first hit so duplicates and missing directories are harmless. # What this does NOT do The plug-in dylibs still need to actually be inside the app bundle somewhere for these fallbacks to find them — the upstream install rules (\`install(TARGETS …)\` in \`src/ifcparse/CMakeLists.txt\`, \`src/serializers/CMakeLists.txt\`, etc.) put them in \`<prefix>/lib/\` which lives outside \`BonsaiViewer.app\`. That side of the fix is a follow-up — either an explicit bundle-aware install destination on the plug-in targets, or an install(CODE) sweep that mirrors them into the bundle. # What this also un-does Reverts the BonsaiViewer-only \`install(CODE)\` hack that was about to copy \`ifcopenshell.*.dylib\` from \`lib/\` into \`BonsaiViewer.app/Contents/MacOS/\` — superseded by the loader-side fix above, which lets us put the plug-ins anywhere sane inside the bundle without further consumer-side stitching. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
5ffae41bbd |
WgpuViewportWindow: stop using QSurface::MetalSurface on macOS
NSZombieEnabled-lldb on macOS revealed the actual cause of the
"OS_os_log displayLock" / segfault that has been chasing us:
*** -[QMetalLayer displayLock]:
message sent to deallocated instance 0xb5e234e40
Qt's QMetalLayer (its CAMetalLayer subclass installed when surfaceType
== MetalSurface) is dealloc'd while Qt's QCocoaWindow still holds an
internal reference to it. Once wgpu-native bridge-retains the layer in
its Rust surface code and re-publishes the drawable pool from
configureSurface, Qt's QMetalLayer life is implicitly handed to
wgpu-native and Qt's separate ref winds up dangling. The next Qt
expose event sends -displayLock to the dead pointer.
Earlier guesses (Qt-6.11/macOS-26 incompatibility, multi-display) were
both wrong — single-display still crashed, and the Tahoe os_log
selector-cast theory was a red herring; the real error is "deallocated
instance", revealed only by NSZombieEnabled.
# Fix
Set surfaceType to OpenGLSurface on macOS too. On macOS that still
gives us a layer-backed NSView; Qt just doesn't install QMetalLayer.
WgpuMetalSurface_mac.mm's else-branch (the one that always fires when
the existing layer isn't already a CAMetalLayer) now consistently
attaches a vanilla CAMetalLayer we fully own — wgpu-native can do
whatever it wants to the layer's lifetime without stepping on any
Qt-side bookkeeping.
We never bind a real GL context on top of OpenGLSurface — it's just
the most portable "hardware-rendering-ready surface" hint Qt has, and
it's already what Linux and Windows use.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
aba8ac727d |
wgpu: query surface capabilities before configuring present mode
Default WGPUPresentMode was a static Mailbox. That works on DX12 and
on Vulkan with most drivers, but the Metal backend in wgpu-native v29
only exposes [Fifo, Immediate], and asking for Mailbox makes
wgpuSurfaceConfigure panic from Rust:
thread '<unnamed>' panicked at src/lib.rs:605:5:
Error in wgpuSurfaceConfigure: Validation Error
Caused by:
Requested present mode Mailbox is not in the list of supported
present modes: [Fifo, Immediate]
fatal runtime error: failed to initiate panic, error 5, aborting
# Fix
Query wgpuSurfaceGetCapabilities and walk a preference list
(Mailbox → FifoRelaxed → Immediate → Fifo), picking the first mode
the surface actually lists. Fifo is the only spec-required mode and
will always be present, so the loop always finds something.
The env override (WGPU_PRESENT_MODE=...) still wins when set, but
also drops back to Fifo if the requested mode isn't supported on the
current backend — no panic.
# Outcomes per backend
DX12 / Vulkan: picks Mailbox (low input lag, our previous default).
Metal (macOS): picks Immediate (Mailbox unavailable). On Metal the
CAMetalLayer presents through CoreAnimation, so the
compositor still vsync-aligns; Immediate is effectively
low-latency-with-no-tearing on macOS.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
f66ad22f1d |
macOS: ship libwgpu_native.dylib into the bundle and set the rpath
BonsaiViewer.app crashed at launch on a fresh macOS arm64 mac with:
Library not loaded: @rpath/libwgpu_native.dylib
Referenced from: /Applications/BonsaiViewer.app/Contents/MacOS/BonsaiViewer
Reason: no LC_RPATH's found
The exe had \`LC_LOAD_DYLIB @rpath/libwgpu_native.dylib\` (CMake baked
that in from the upstream dylib's install_name), but zero \`LC_RPATH\`
entries, so dyld had nowhere to look — and macdeployqt hadn't pulled
the dylib in either, since it sat at \`<install_root>/lib/\` rather
than inside the .app.
Two changes:
- \`src/ifcviewer-wgpu/CMakeLists.txt\`: on macOS, when
BUILD_BONSAIVIEWER is on, install libwgpu_native.dylib straight
into \`BonsaiViewer.app/Contents/Frameworks/\` instead of
\`<prefix>/lib/\`. That matches the standard macOS bundle layout.
- \`src/bonsaiviewer/CMakeLists.txt\`: set
\`INSTALL_RPATH "@executable_path/../Frameworks"\` on the
BonsaiViewer target on Apple. That's where dyld looks at launch,
and where the dylib now lives.
Together the @rpath load resolves at launch without depending on
macdeployqt to follow non-Qt @rpath references (it usually only
chases Qt frameworks).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
edc598357b |
wgpu: default present mode to Mailbox (was Fifo)
# Why The stage-1 default was Fifo because it is the only present mode WebGPU spec *requires* every backend to support — conservative, "always works", lowest power. But on DX12 Fifo maps to a DXGI flip-discard swap chain whose default \`MaximumFrameLatency\` is 3, which queues ~50ms of pre-rendered work between submit and display. Even when the FPS counter shows 60 the cursor-bound interactions (marquee, pivot, orbit) feel ~3 frames behind because they *are*. # What Mailbox: vsync-aligned (no tearing) with a one-frame queue (last-frame-wins). ~16ms input→display latency. wgpu-native handles the fallback to Fifo automatically on backends that don't implement Mailbox (Vulkan + NVIDIA on Linux is the historical one). # Trade-off Mailbox uncaps the render loop: with no vsync gating, the \`requestUpdate()\` → render → present loop spins at whatever Qt's event loop allows (~600 Hz on an empty scene), and the GPU does useful-but-discarded work on each redundant frame. On any non-trivial scene the GPU is the bottleneck and the loop self-paces near the display rate. The FPS counter measures \`render()\` invocations, not unique frames the user actually sees — that's expected. # Override WGPU_PRESENT_MODE=fifo restores the old behaviour for the rare laptop-battery / heat-conscious case. fifo_relaxed / immediate also still work as before. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
6b72a60d8c |
WgpuMetalSurface_mac: switch to <AppKit/AppKit.h> umbrella
The narrow `<AppKit/NSView.h>` header only forward-declares NSWindow,
so `view.window.backingScaleFactor` fails to compile on macOS with:
error: property 'backingScaleFactor' cannot be found in forward
class object 'NSWindow'
Use the AppKit umbrella header so NSWindow's interface (including
backingScaleFactor) is in scope. Same idiomatic include any non-trivial
Cocoa code reaches for; we're already linking -framework Cocoa so
there's no compile-time cost beyond a slightly heavier translation
unit (the .mm is ~30 lines anyway).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
21d394501f |
ifcviewer-wgpu: bring up macOS Metal surface (task #32)
Without this, BonsaiViewer.app launched on macOS would show a white
viewport for the same reason Windows did before
|
||
|
|
d4d0c934b1 |
ifcviewer-wgpu: wire Windows HWND surface creation
Without a Windows branch in `WgpuViewportWindow::createSurface()` we
were falling through to the `qWarning() << "wgpu surface creation not
yet wired for this platform"` else clause on Windows runs, causing
`init() -> createSurface()` to return false and the viewport to render
nothing (the user sees the Qt window's background fill — a white
viewport — and the log says "wgpu init failed; viewport will not
render in DebugView").
Add a `#elif defined(Q_OS_WIN)` branch that fills a
`WGPUSurfaceSourceWindowsHWND` chained-struct from
`GetModuleHandleW(nullptr)` (HINSTANCE) and `winId()` (HWND, as a Win32
window handle on the Qt Windows platform plugin), then passes it as
`surface_desc.nextInChain` to `wgpuInstanceCreateSurface`.
`<windows.h>` is pulled in inside the gated block with NOMINMAX and
WIN32_LEAN_AND_MEAN defined first so the preprocessor pollution
(`min`, `max`, etc.) doesn't leak into Eigen / `std::min`,`std::max`
elsewhere in the TU.
Note on the unrelated DXC log line the user also sees:
[wgpu err] DxcCreateInstance failed:
No such interface supported (0x80004002)
That is wgpu-native's DX12 backend probing for a modern
`dxcompiler.dll`. `E_NOINTERFACE` means a *too-old* dxcompiler.dll was
found on the system DLL search path (typical: a stale copy in
System32 / Visual Studio install). wgpu-native then falls back to its
Vulkan backend, so this log line is recoverable on its own — the
fatal failure was the missing surface branch above. If we hit shader
compilation issues after this lands, we can ship a known-good
dxcompiler.dll + dxil.dll alongside wgpu_native.dll separately.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
1b920e502f |
ifcviewer-wgpu: pick the Windows ARM64 wgpu-native archive when targeting ARM64
The Windows branch of the wgpu-native FetchContent block was hardcoding the x86_64 archive name regardless of host arch — the macOS and Linux branches already switch on \`CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64"\`, but Windows didn't get the same treatment because the wgpu work was done on x86_64 hosts. Result on \`windows-11-arm\`: CMake downloaded \`wgpu-windows-x86_64-msvc-release.zip\`, IfcViewerWgpu linked against the x86_64 import library, and the final link of IfcViewerWgpuMinimal/BonsaiViewer emitted ~60 unresolved \`wgpu*\` externs because the import-lib symbols are x86_64-only. Upstream wgpu-native v29.0.0.0 already publishes \`wgpu-windows-aarch64-msvc-release.zip\` — switching on \`CMAKE_SYSTEM_PROCESSOR\` so the right archive gets fetched is sufficient. Also restores the ARM64 row in \`.github/workflows/build_win.yml\` that the prior commit dropped (the comment there was wrong; upstream does ship the binary, our CMake just wasn't asking for it). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
6fa55b7c25 |
build_osx: zip and upload .app bundles to S3
The existing "Package .zip archives" step only sweeps
\`\$install_root/bin/\` for plain executable files (via \`find -type f
-perm /111\`). That captures \`IfcConvert\` and \`IfcGeomServer\` but
misses macOS app bundles entirely:
- BonsaiViewer.app installs at \`\$install_root/BonsaiViewer.app\`
(BUNDLE DESTINATION ".") — not under bin/, and it's a directory,
not a file.
So the prior bonsai macOS CI run got a green tick but the
ifcopenshell-builds S3 bucket only ended up with IfcConvert +
IfcGeomServer + the python wheel — no BonsaiViewer.
Add a second packaging pass that finds \`*.app\` directories at the
install-prefix root and zips each one as-is. macdeployqt has already
embedded the Qt frameworks inside the bundle during install/strip, so
no extra dependency staging is needed.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|
|
b0ef47819f |
ci: IFCOS_BUILD_PYTHON_WRAPPER env-gate (off for bonsai macOS CI)
# Why this exists
The bonsai macOS CI (`build_osx.yml`, arm64) currently fails the
`IfcOpenShell-Python` smoke test with:
ImportError: dlopen(.../_ifcopenshell_wrapper.cpython-311-darwin.so,
0x0002):
Library not loaded: @rpath/ifcopenshell.document.rdb.dylib
Reason: tried: '$ORIGIN/ifcopenshell.document.rdb.dylib'
(no such file)
`_ifcopenshell_wrapper.cpython-311-darwin.so` has a hard `LC_LOAD_DYLIB`
of `@rpath/ifcopenshell.document.rdb.dylib` and its only `LC_RPATH` is
`$ORIGIN` (= `site-packages/ifcopenshell/`). The plug-in dylib is not
present at that path on macOS, so the wrapper fails to load and the
build smoke test (`build-all.py: compile_python_wrapper`) errors out.
BonsaiViewer.app builds, installs, and macdeployqt-deploys cleanly
before this point — the failure is downstream and unrelated to wgpu,
BonsaiViewer, or anything else on this branch.
# Where the regression came from
Two commits on the branch line that became `ifcviewer-wgpu`:
|
||
|
|
938dda80d0 |
ci: GCC 11 portability + BUNDLE DESTINATION "." on macOS
Linux (Rocky manylinux, GCC 11): - WgpuAreaMeasurement.h: include <cstddef> directly. GCC 11 does not transitively pull `size_t` through <vector>, so triangleCount()'s return type fails to parse. - WgpuViewportWindow.cpp:meshLocalToGlobal: use static_cast<double>(...) instead of double(mesh_local[N]) when constructing the Eigen::Vector4d. The latter triggers GCC 11's most-vexing-parse: it reads `Vector4d local(double(mesh_local[0]), double(mesh_local[1]), ...)` as a function declaration of `local` taking parameters `double mesh_local[0]` etc., colliding with the outer `mesh_local` parameter and failing with "redefinition of double* mesh_local". macOS arm64: - IfcViewerWgpuMinimal + BonsaiViewer install rules: change `BUNDLE DESTINATION bin` → `BUNDLE DESTINATION .`. Qt's deploy generator emits `macdeployqt <Target>.app` with no path prefix, which only resolves when the bundle sits at the install-prefix root. `BUNDLE DESTINATION bin` put it at `<prefix>/bin/Target.app` and the install/strip step failed with "Could not find app bundle". Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
45e9f763c8 |
ci: fix bonsai cross-platform build on Linux, macOS arm64, Windows x64
Bundles four portability fixes uncovered by manually firing the platform workflows against this branch: - WgpuOverlayRenderer.cpp: GCC 11 (Rocky manylinux runner) does not parse a multi-line raw string inside `#define`. Converted THICK_LINE_HELPERS_WGSL from a `#define` to a `static const char*` and switched AXIS_WGSL / SECTION_WGSL / MARQUEE_WGSL to `std::string` so they can concatenate at static-init time. Three call sites now pass `.c_str()` to svFromCStr. - bonsaiviewer/CMakeLists.txt: added BUNDLE DESTINATION to the install rule (same fix already applied to IfcViewerWgpuMinimal). MACOSX_BUNDLE targets fail at configure on macOS without it even when nobody runs `make install`. - build_osx.yml: dropped the x64 (Intel cross-compile) matrix row. The runner is arm64 so `brew --prefix qt` returns the arm64 prefix; we'd need a separate x86_64 Qt install under /usr/local to cross-build BonsaiViewer. Revisit if Intel-Mac demand resurfaces. - build_win.yml: dropped the ARM64 matrix row. wgpu-native does not ship a Windows-ARM64 binary, so IfcViewerWgpu's link step fails with ~60 unresolved wgpu* externs. Re-enable when upstream publishes that target. Cherry-pick this commit to v0.8.0 so the workflow_dispatch buttons see the dropped rows. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
d390911d75 |
build_osx: build BonsaiViewer on macOS via build-all.py
Linux (build_rocky.yml) and Windows (win/build-all-win.py) already pass BUILD_BONSAIVIEWER=ON when building from source; macOS was the odd one out. Three small changes to bring it up to parity: 1. .github/workflows/build_osx.yml — \`brew install qt\` (Qt6 with Svg) in the Install Dependencies step, then set QT_DIR=\$(brew --prefix qt) and BUILD_BONSAIVIEWER=ON in the Run Build Script env. 2. nix/build-all.py — install_qt6() now honours a pre-set QT_DIR. Before this change get_qt6_aqt_config() raised on non-Linux, blocking bonsai builds on macOS/Windows from ever using a system-provided Qt6. We now validate that QT_DIR points at a real Qt6 install (probes lib/cmake/Qt6/Qt6Config.cmake) and skip the aqt download path if so. Linux flow is unchanged: when QT_DIR is unset the function falls through to the existing aqtinstall path. build_osx.yml stays workflow_dispatch-only — slow run (~1h with ccache, longer cold), so manual fire when wanted. Cherry-pick this file + nix/build-all.py to v0.8.0 to make the workflow dispatchable against the ifcviewer-wgpu branch before the squash lands. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
57a94095e8 |
ci: wgpu mac — drop the bare \-j\ flag
Ninja rejects \`-j\` without a numeric argument (unlike make, which treats bare \`-j\` as unlimited parallelism). Build step exited with \`ninja: fatal: invalid -j parameter\`. Drop the \`-- -j\` tail entirely; Ninja already parallelises across available cores by default. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
025e60e635 |
ci: wgpu mac — cover ifcviewer-wgpu-minimal + wgpu-mem-probe in paths filter
The first run after BUNDLE DESTINATION fix didn't trigger because that commit only touched src/ifcviewer-wgpu-minimal/CMakeLists.txt, which the workflow's paths: list didn't cover. Add the two sibling subprojects (-minimal and wgpu-mem-probe) since they participate in the same configure pass. (Manual workflow_dispatch is still unavailable until this workflow lands on the default branch — GitHub gates the "Run workflow" button on the default branch's copy of the file.) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |