Skip to content

Port the Vulkan renderer onto the retained-instance-data stack - #71

Closed
brianmk wants to merge 171 commits into
coin-Integratefrom
port/vulkan-on-stack
Closed

brianmk wants to merge 171 commits into
coin-Integratefrom
port/vulkan-on-stack

Conversation

@brianmk

@brianmk brianmk commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Adopts upstream's retained-instance-data stack as the base for the fork's Vulkan renderer and adapts the backend to the stack render interface.

What this branch contains

  • Port foundation — adopt the stack IR/params and stage the fork's Vulkan-only backend files.
  • Backend adaptation — SoVulkanRenderBackend::render() takes the stack SoRenderPlan + SoSelectionState; execution order is derived from the plan instead of the fork's private SoDrawList::getSortedOrder(); pass classification is mapped from the stack's orthogonal opacity/stage.
  • Build — COIN_BUILD_VULKAN_RENDERER option, external VMA, Vulkan source lists; libCoin builds against the stack base.
  • Field mapping — fork-only consumer fields mapped onto canonical stack IR fields (no duplicate sources of truth).
  • SoRenderManager::updateClippingPlanes — the public entry point the FreeCAD viewport adapter needs after publishing a fitted plane.
  • Opt-in legacy compat (COIN_BUILD_RENDER_LEGACY_API, default off) — a #if-guarded shim (SoRenderLegacyCompat.h) plus forwarding spellings (SoGeometryDesc::retained, SoMaterialData::flags, SoRenderCommand::pass/pixelText, SoRasterState::fillMode/cullMode, SoDrawList::buildSortedOrder/getSortedOrder, the render(drawlist, params) overload) so the fork's out-of-tree tests keep building while the canonical model is adopted.

Verification

  • coin-port (Vulkan, compat off) and coin-port-compat (compat on) build clean; the non-Vulkan port build is clean.
  • coin-vulkan-tests against the compat libCoin.so: 28/28 pass.

Note

This branch is based on upstream/stack/retained-instance-data, so the diff is large by construction — it carries the upstream stack plus the Vulkan port. The two Draft-grid fixes (feature-edge-only edge overlay, empty auto-clip bbox refresh) are not in it yet; they need a stack-IR feature-edge flag and will follow once they land on the fork (coin-Integrate).

tritao and others added 27 commits September 1, 2026 22:43
…iles

- extend the backend-neutral IR with the additive fields the Vulkan
  backend needs: SoPointShape, SoStencilFunction/Op + SoStencilState,
  SoRenderState::stencil, and SoGeometryDesc::primitiveOffset
- extend SoRenderParams with the external-target / gradient / camera-
  version / frame / replay / interaction-LOD fields
- stage the fork's Vulkan-only files (all new) and helpers so the
  backend can be adapted to the stack interface in following commits
- SoVulkanRenderBackend::render() now takes the stack SoRenderPlan and
  SoSelectionState, matching SoRenderBackend
- execution order is derived from the plan (opaque insertion + transparent
  depth sort) instead of the fork's private SoDrawList::getSortedOrder();
  external entry points build a frame-local plan via SoRenderPlanner
- command pass classification is mapped from the stack's orthogonal
  opacityClass/render stage via soVulkanCommandPass()
- IR: add SoGeometryDesc::retained, SoRasterState point-shape + scissor
  rect, SoMaterialData::flags + SO_MAT_* bits, SO_PARAM_CLEAR_STENCIL
- Vulkan: adapter helpers for cull mode / CCW front-face (IR stores bools)
- CMake: COIN_BUILD_VULKAN_RENDERER option, find_package(Vulkan), external
  VMA, Vulkan source/header lists, C++17 when enabled
- define SoLightingBlock + SoRenderIR::lightToEye/lightToWorld/
  fillLightingBlock on the stack IR (shared by every retained backend)
- add SoIRRenderAction camera-dependent frame flag (screen-constant-size
  and auto-zoom scenes must re-record on camera moves)
- adapt the Vulkan recorder: plan-based execution order, pass/opacity+stage
  adapters, boolean cull/CCW, lights.size(), scissor/point-shape/material
  flag fields
- SoVulkanRenderManager builds a SoRenderPlan and calls the new
  SoRenderBackend::render(drawlist, plan, params)

libCoin now builds with -DCOIN_BUILD_VULKAN_RENDERER=ON against the stack.
- geometry.retained -> geometry.cacheKey != 0
- material.flags/SO_MAT_* -> texture payload + command.pixelRaster.enabled
- drop the unused primitiveOffset
The Vulkan backend now consumes only the canonical stack IR fields.
FreeCAD's Vulkan viewport adapter refreshes the scene-fitted clip planes
after publishing a fitted plane to the shared camera; the stack manager
lacked the public entry point. Additive; no behavior change on its own.
The convergence drops the pre-convergence (fork) retained-render spellings
that FreeCAD's coin-vulkan-tests were written against.  Add an opt-in,
default-off compatibility layer so those tests keep building while the stack
model is adopted:

- SoRenderLegacyCompat.h defines SoRenderPassType + the SO_MAT_* bits and is
  pulled in by SoRenderIR.h; CMake gates it behind COIN_BUILD_RENDER_LEGACY_API
  (COIN_RENDER_LEGACY_API), so the shipping IR is unchanged.
- Legacy IR spellings forward onto canonical fields: SoGeometryDesc::retained
  (cacheKey != 0), SoMaterialData::flags (texture/pixel-raster payload),
  SoRenderCommand::pass/pixelText (opacity+stage / pixelRaster), and
  SoRasterState::fillMode/cullMode (canonical fill mode / cullBackFaces).
- SoDrawList::buildSortedOrder()/getSortedOrder() restore the fork's
  pass-then-view-depth index ordering.
- SoVulkanRenderBackend::render(drawlist, params) rebuilds a plan via
  SoRenderPlanner; buildWorkItems honors an explicitly built sort order.
- SoImage/SoText2 set the legacy material flags; SoGLRenderBackend casts the
  legacy fill mode.

With compat on, coin-vulkan-tests builds and passes 28/28 against the ported
libCoin; the default (compat off) build is unchanged.
Adopt the upstream retained-instance-data stack as the fork's coin line: the
port re-implements the fork's Vulkan features (system VMA, clip-plane
publish, camera-dependent replay, IR hot-path, wide-line, geometry-LOD gate,
scoped prepass fence) on the stack, so its tree supersedes the pre-stack
coin-Integrate content. This merge records coin-Integrate as an ancestor so
the integration branch can advance to the stack port without conflicts.
Comment thread src/io/gzmemio.cpp
break;
case SEEK_END:
if ((file->buflen + offset > 0) &&
(file->buflen + offset <= file->buflen)) {
@brianmk

brianmk commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing: this PR vendored the unmerged upstream FreeCAD/coin stack/* branch into coin-Integrate (41k additions). Superseded - the port will be re-cut against upstream, and fork work consolidated separately.

@brianmk brianmk closed this Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants