Skip to content

cvcGL: VolumeNode turns VTK's FinishEveryRender off (no glFinish per still volume render) - #1327

Merged
transfix merged 10 commits into
masterfrom
feat/vtk-finish-every-render
Nov 17, 2026
Merged

transfix merged 10 commits into
masterfrom
feat/vtk-finish-every-render

Conversation

@transfix

@transfix transfix commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

VolumeNode now turns off VTK's FinishEveryRender (a new opt-in VTK property, below), wherever the VTK it builds against has it. There is no process-wide state.

Why

VTK's GPU volume ray caster ends every render with glFinish(). That lets its timer measure the GPU's work, but only an auto-adjusting render (an interactive one) uses that time. Every still render pays for the wait anyway: the CPU waits for the whole frame queued so far, so the CPU's and the GPU's times add instead of overlapping.

The first fix, in #1324, swapped glad's glFinish pointer. That is process-wide state, so Joe asked for the fix to go into VTK instead, and it was reverted there.

cy-pca/cvcpkg#625 patches cvcpkg's VTK (vtk 9.5.0+cvc.5); the patch is written to go upstream:

  • It adds an opt-in vtkGPUVolumeRayCastMapper::FinishEveryRender, plus the same property on vtkSmartVolumeMapper, forwarded to its GPU mapper.
  • On (the default), every render waits, as before.
  • Off, only a render that adjusts its sample distance by its own time waits. In practice that is an interactive render: the smart mapper turns auto-adjust on from the window's desired update rate.

Changes

  • src/cvcGL/CMakeLists.txt: check_cxx_source_compiles against VTK::RenderingVolumeOpenGL2 defines CVC_VTK_HAS_FINISH_EVERY_RENDER when vtkSmartVolumeMapper has FinishEveryRenderOff(). libcvc still builds against an unpatched VTK and renders as before. The check only compiles (a static-library try_compile), so a link failing for another reason cannot turn it off, and it runs again at every configure, because VTK's version stays 9.5.0 across cvcpkg's revisions. Configure prints cvcGL: VTK has FinishEveryRender; VolumeNode turns it off or cvcGL: VTK has no FinishEveryRender; volume renders keep VTK's glFinish.
  • VolumeNode and scene_views' twin mapper: both call FinishEveryRenderOff() under that define.
  • New test cvcgl_volume_finish:
    • The VolumeNode's mapper has FinishEveryRender off.
    • The pixels are byte-identical with it off, then on, then off again.
    • It uses no glad hooks or other process-wide instrumentation.
    • Without the define it only checks that the volume draws.
  • Docs: RENDER_PERF_ROADMAP.md Phase 6.

Measured

Setup:

  • terrain_lab.ari, which has 6 volumes, at 1280×720 on the Intel Arc iGPU, Windows, MSVC Release.
  • libcvc was built against VTK from vtk cvc.5 (and vtk-python): opt-in FinishEveryRender for the GPU volume ray caster cy-pca/cvcpkg#625, built locally with cvcpkg build vtk --local into a copy of the deps prefix.
  • It is an in-process A/B. For "on", the scratch harness sets every volume's mapper back to FinishEveryRender on before each frame; "off" is this PR as is.
  • Four interleaved runs per setting and path, each the median of 200 frames. No compiler was running during any run.
path on (VTK's default) off (this PR)
window (arigl run): whole frame 79.4 ms [76.2–80.5] 49.3 ms [47.3–52.6]
window: render() 50.3 ms 11.1 ms
window: AriRuntime::frame() 25.0 ms 33.8 ms
offscreen (arigl snapshot's path): whole frame 69.1 ms [66.4–71.4] 26.5 ms [25.4–27.6]
offscreen: render() 50.5 ms 9.2 ms
  • The last offscreen frame's pixels hash the same (255194a985ec7f24) in all eight runs, on and off.
  • The saving (30–43 ms) is larger than the 25 ms measured this morning on an older master. The machine was also slower this afternoon for both settings.
  • In the window, AriRuntime::frame() grows. Probably GL calls there now wait for part of the GPU work that the volume's glFinish used to wait for. Not profiled.

Tests

Against the patched VTK, all pass:

  • cvcgl_volume_finish
  • cvcgl_volume_half_float
  • cvcgl_volume_range
  • cvcgl_volren_node
  • cvcgl_volslice_node
  • cvcgl_volume_slice (49 checks)
  • cvcgl_ariadne_realize

Against the published, unpatched VTK (libcvc's usual prefix), the branch builds, configure prints cvcGL: VTK has no FinishEveryRender; volume renders keep VTK's glFinish, and cvcgl_volume_finish passes on its fallback (the volume draws).

VTK version

libcvc does not pin VTK: CI runs cvcpkg install vtk, which takes the catalog's latest. cy-pca/cvcpkg#625 is merged and vtk 9.5.0+cvc.5 is being published, so CI picks it up with no change here. Until then CI builds against cvc.3/cvc.4 and runs cvcgl_volume_finish on its fallback. A local prefix needs cvcpkg install vtk again to get cvc.5.

…s it

VTK's GPU volume ray caster ends every render with glFinish() for a timer only an
auto-adjusting render uses; in terrain_lab that wait was about 25 ms of a 45 ms frame.
cvcpkg's VTK (cy-pca/cvcpkg#625: vtk 9.5.0+cvc.5, written for upstream) adds an opt-in
vtkGPUVolumeRayCastMapper::FinishEveryRender, and vtkSmartVolumeMapper's, forwarded to its GPU
mapper. VolumeNode's mapper and scene_views' twin turn it off: a still render queues its ray cast
and returns; an interactive render still waits, as it adjusts its sample distance by its time.
No process-wide state.

A compile check (check_cxx_source_compiles against VTK::RenderingVolumeOpenGL2) defines
CVC_VTK_HAS_FINISH_EVERY_RENDER, so libcvc still builds, and renders as before, against an
unpatched VTK.

cvcgl_volume_finish: the VolumeNode's mapper has it off, and the pixels are byte-identical with
it off and on (only with the define; otherwise it checks that the volume draws).
…igure

The check linked a whole VTK program, so a link that failed for another
reason (a wasm one, say) would have turned the property off silently; a
static-library try_compile compiles the header's declaration and links
nothing. Its cached answer is also dropped before each configure: VTK's
version stays 9.5.0 across cvcpkg's revisions, so a build directory
configured against vtk 9.5.0+cvc.3 would otherwise keep "no" after the
prefix gets cvc.5.

Checked by reconfiguring a build against the patched VTK ("has
FinishEveryRender") and one against the catalog's ("no FinishEveryRender").
@transfix
transfix enabled auto-merge (squash) November 16, 2026 22:28
master fails to build arisrvx's python_engine.cpp: #1302 (bridged users)
added room(), bridge_presence(), bridge_absent(), bridge_post() and
listen_chat() calling server_link() with no argument, written against the
process-wide server link that the P0a cleanup replaced with the module's
own state, server_link(PyObject *self). Each of the five now names its
module argument self and passes it, as the other server ops (lent(),
publish(), ...) already do.

Found in #1324's pycvc-linux / cp312 job (run 43956686020),
which builds the PR merged with master.
The realize suite runs every node type's checks in one process. In a
Linux Debug job (Xvfb, llvmpipe) it took 250.6 s, 50 s under the 300 s a
test without a TIMEOUT gets; on a slower runner (#1309's Debug job, where
PhConvoy and Ewave also ran about 1.3x longer) it timed out on all three
attempts. As cvcgl_ewave, cvcgl_wake and cvcgl_volren_node have, it gets
a budget of its own with headroom, so only a real hang fails it.
…-finish-every-render

# Conflicts:
#	docs/roadmap/RENDER_PERF_ROADMAP.md
@transfix
transfix merged commit 4ed4c67 into master Nov 17, 2026
29 checks passed
@transfix
transfix deleted the feat/vtk-finish-every-render branch November 17, 2026 17:12
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