Skip to content

viewport: refresh_hz, a throttled inset shows its last pixels between draws - #1247

Merged
transfix merged 1 commit into
masterfrom
feat/ariadne-viewport-refresh-hz
Nov 15, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/ariadne-viewport-refresh-hz

Conversation

@transfix

Copy link
Copy Markdown
Owner

A viewport widget (or any inset Viewport) draws its scene again in every frame. A mirror of the main view draws every node a second time, with its own camera, so a map beside a busy scene can cost as much as the scene itself. refresh_hz: draws it at most N times a second and shows its last picture in between.

What it adds

  • Viewport::setRefreshHz(hz) (Viewport.h), with refreshHz(), invalidate() and draws(). 0, the default, draws the viewport in every ViewportManager::render(), as before.

    • When it draws: the renderer's EndEvent blits the viewport's rect into a colour texture the size of the window. This runs before any layer above it or ImGui draws, so the copy holds that viewport alone.
    • Between draws: a vtkRendererDelegate draws that texture as a quad, texel for pixel, in place of the scene. It clears the rect's depth, as the renderer would. A quad and not a blit, because GLES and WebGL 2 cannot blit into a multisampled framebuffer.
    • Mirror re-sync: ViewportManager::render() asks each viewport whether it draws this frame. One showing its last pixels skips its mirror re-sync, the per-prop filter pass, as well as its draw.
    • What makes it draw at once: a new rect or window size, being shown again (setVisible, or the layout state), and invalidate().
    • Translucent viewports: one with setBackground(..., opaque = false) draws every frame whatever the rate, since its last pixels would freeze what is under it.
  • refresh_hz: on the Ariadne viewport widget (scene_views.cpp). The view also draws at once:

    • when its show, hide, chrome, camera, shadows, override or starting camera change;
    • while the pointer drags, wheels or picks in it, and for three frames after, so what a pick changed shows without waiting.

    Picks were already a geometry ray cast (vtkCellPicker), so they test the scene as it is, not the last picture.

  • Docs: ARIADNE.md, the refresh_hz row and a "Refresh rate" paragraph under the viewport widget.

Tests (local, Linux, offscreen)

  • cvcgl_viewport_refresh (new, 40 checks): a mirror inset over a red base, run once with no multisampling and once with 4 samples.
    • At 0 Hz it draws in every render.
    • At 2 Hz, a burst of 10 renders draws it 0 times, while the base draws all 10.
    • The renders in between show its last pixels byte for byte. A new background shows only once it draws.
    • Each of invalidate(), a move, the time passing and being shown again draws it.
    • A mirror is not re-synced while it shows its last pixels, and picks up a new node on the render it draws.
    • Translucent draws every render, and 0 Hz again draws every render.
    • Removing it while it is throttled leaves the window rendering.
  • cvcgl_ariadne_pick: its pick view now has refresh_hz: 2, so every existing pick check runs on a throttled view.
    • Over 8 idle frames the orbit view beside it draws 8 times and the pick view 0 times.
    • Dragged, the pick view draws every frame.
  • Unchanged and passing: cvcgl_viewport, cvcgl_viewport_input, cvcgl_ariadne_views, cvcgl_scene_renderer_facade, and the rest of the cvcgl_ariadne_*, cvcgl_viewport* and cvcgl_scene_renderer* tests (10 in all, with the two above).

Measured

A local benchmark (not committed): 400 actors, a mirror inset in the top-right corner, a 1280x720 offscreen window, 200 renders a run:

ms a render inset draws
no inset 25 —
inset, 0 Hz 143–150 200
inset, setRefreshHz(5) 54–62 51–58

At this frame rate, 5 Hz is about one render in four; the rest show the kept picture.

The texture costs one RGBA8 buffer the size of the window per throttled viewport.

… draws

A viewport widget, or any inset Viewport, drew its scene again in every frame; a mirror of the
main view draws every node a second time. Viewport::setRefreshHz(hz) draws it at most hz times a
second and shows its last picture in between, and the Ariadne viewport widget takes it as
refresh_hz:.

- Viewport keeps its last draw: its EndEvent blits the rect into a window-sized colour texture,
  and a vtkRendererDelegate draws that texture as a quad in the renders between (multisampled
  windows included), clearing the rect's depth as the renderer would.
- ViewportManager::render() asks each viewport whether it draws this frame; one showing its last
  pixels skips its mirror re-sync too.
- It draws at once on a new rect or window size, on being shown again and on invalidate(); a
  translucent viewport draws every frame whatever the rate. The widget also invalidates when what
  it shows changes and while the pointer drags, wheels or picks in it, and for three frames after.
- docs/ARIADNE.md: refresh_hz and a "Refresh rate" paragraph.
- Tests: cvcgl_viewport_refresh (new); cvcgl_ariadne_pick runs its pick view at refresh_hz: 2.
@transfix
transfix enabled auto-merge (squash) November 15, 2026 02:10
@transfix
transfix merged commit 736b371 into master Nov 15, 2026
28 checks passed
@transfix
transfix deleted the feat/ariadne-viewport-refresh-hz branch November 15, 2026 07:17
transfix added a commit that referenced this pull request Nov 15, 2026
- app_runtime.cpp: the constructor hands the scene its repeat: count function (#1230), then
  takes the verb table's lock as before.
- e2ee_intrinsics.cpp (#1191): the e2ee-* provider registers its async functions on the calling
  program's host (*ictx.host, else the app's), as every provider on this branch does (B30), so an
  isolated document's e2ee-backup and e2ee-restore park on its own group.
- STATE_EXEC_THREADED.md: the e2ee provider in the provider table and the file list.
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.

1 participant