Skip to content

Add retained draw-list rendering pipeline with modern OpenGL backend - #7

Closed
tritao wants to merge 1 commit into
FreeCAD:stack/drawlist-pickingfrom
tritao:draw-list-history-v2
Closed

Add retained draw-list rendering pipeline with modern OpenGL backend#7
tritao wants to merge 1 commit into
FreeCAD:stack/drawlist-pickingfrom
tritao:draw-list-history-v2

Conversation

@tritao

@tritao tritao commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

This PR introduces a retained draw-list rendering pipeline alongside Coin’s existing legacy OpenGL renderer.

The work adds a render intermediate representation, a modern OpenGL backend, retained traversal support for core scene-graph nodes, GPU picking, layered rendering, and integration with SoRenderManager.

The legacy renderer remains available through SoRenderManager::RenderPipeline::LEGACY_GL, while the new path can be selected with SoRenderManager::RenderPipeline::DRAW_LIST or the COIN_USE_DRAW_LIST environment variable.

Main changes

Modern OpenGL foundations

  • Add core-profile OpenGL detection and configuration.
  • Add OpenGL debug callback support.
  • Add modern GL function loading and related build integration.
  • Improve EGL and offscreen-context support.
  • Add shader-backed rendering paths where compatibility-mode rendering is unavailable.

Retained rendering infrastructure

  • Add SoIRRenderAction, SoDrawList, and retained render commands.
  • Record geometry, materials, transforms, raster state, lighting, textures, and picking metadata.
  • Add transient geometry allocation with opaque save points for partial rebuilds.
  • Keep retained-rendering implementation helpers private.

OpenGL draw-list backend

  • Add VAO, VBO, vertex-layout, shader, and geometry-cache management.
  • Add opaque, transparent, foreground, selection, and after-main render stages.
  • Add retained lighting, wide-line and wide-point rendering, stipple, alpha testing, blending, depth state, and textured commands.
  • Add GPU ID-buffer picking and selection/highlight rendering.
  • Restore and invalidate shared OpenGL state when switching between rendering paths.

Scene-graph integration

  • Add retained traversal support for generated shapes, primitive caches, markers, images, text, lights, annotations, and render-layer groups.
  • Preserve pixel-aligned text placement and transparent text traversal.
  • Carry explicit shading, two-sided lighting, material, and pipeline state through the retained IR.

SoRenderManager integration

  • Add the RenderPipeline and LightingMode APIs.
  • Add background and foreground render-layer roots.
  • Add scene and foreground invalidation APIs.
  • Support partial foreground rebuilds without rebuilding the retained main scene.
  • Add callbacks between main-scene and foreground traversal.
  • Add an explicit after-main render stage with a depth barrier.
  • Safely clear retained selection state and invalidate shared GL state when switching pipelines.

Compatibility

The new renderer is additive. The legacy OpenGL path remains the default unless the draw-list pipeline is explicitly enabled.

The retained path aims to preserve existing Coin rendering semantics, including:

  • Render modes and lighting modes.
  • Transparency ordering and transparent text.
  • Material and vertex colors.
  • Depth, blend, alpha-test, line, and point state.
  • Background, main-scene, after-main, and foreground ordering.
  • Selection and preselection highlighting.

History structure

The commit series is intentionally split into small, dependency-ordered changes:

  1. Modern OpenGL and build foundations.
  2. Retained IR and traversal infrastructure.
  3. Backend resources and render passes.
  4. Retained-node coverage.
  5. SoRenderManager policy and integration.
  6. Invalidation and safe pipeline switching.
  7. Layered and after-main rendering.
  8. Raster, lighting, text, and compatibility refinements.
  9. Manager-level tests.

Testing

Added coverage for:

  • Render-manager defaults and policy state.
  • Pipeline switching.
  • Shared-context state invalidation.
  • Device-pixel-ratio state.
  • Scene and foreground invalidation.
  • After-main callback retention.
  • Render-stage ordering and depth barriers.
  • Background and hidden-line behavior.

Powers the new FreeCAD renderer at FreeCAD/FreeCAD#31143

@tritao tritao self-assigned this Jul 28, 2026
@tritao

tritao commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

This work has finally reached a good enough state where it makes sense to open a PR.

It now passes all visual tests in FreeCAD, though there are still some selection-related improvements I want to make, think I should be able to finish it in the next few days.

@Lgt2x Is this something you are interested in reviewing?

Comment thread src/rendering/SoGLRenderBackend.cpp Fixed
Comment thread src/rendering/SoGLRenderBackend.cpp Fixed
Comment thread src/rendering/SoIDPickBuffer.cpp Fixed
@tritao
tritao force-pushed the draw-list-history-v2 branch 3 times, most recently from 022bcce to b3f25ec Compare July 28, 2026 23:56
@Lgt2x

Lgt2x commented Jul 29, 2026

Copy link
Copy Markdown
Member

It will take me a while to go through it but yes, I will test & review. Is @oursland in the loop for this?

@tritao
tritao force-pushed the draw-list-history-v2 branch 23 times, most recently from e349a9e to e89f3b7 Compare July 30, 2026 11:09
@tritao
tritao force-pushed the draw-list-history-v2 branch 3 times, most recently from b8bd37b to b47e3a6 Compare July 30, 2026 16:52
Add explicit LegacyGL and DrawList pipeline selection, make DrawList the default for core-only builds, and keep manager viewport/lifetime handling valid without a LegacyGL action. Exercise the complete core EGL path through SoRenderManager.
@tritao
tritao force-pushed the draw-list-history-v2 branch from b47e3a6 to 7af2591 Compare August 9, 2026 00:36
@tritao
tritao changed the base branch from freecad-master to stack/drawlist-picking August 9, 2026 00:37
@tritao

tritao commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by native PR #33, which uses the same integration branch and can participate in the native stacked PR chain.

@tritao tritao closed this Aug 9, 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