Skip to content

feat(ui): add "Reload Default Renderers" that resets a device's renderers in place - #28

Merged
jeffamstutz merged 9 commits into
mainfrom
feat/reload-default-renderers
Nov 10, 2026
Merged

jeffamstutz merged 9 commits into
mainfrom
feat/reload-default-renderers

Conversation

@jeffamstutz

Copy link
Copy Markdown
Collaborator

Summary

Adds Renderer > Reload Default Renderers to the viewport. It brings a device's renderers back to the standard set the device offers, the same set a device with no renderers in the state gets on load.

Reload resets renderers in place rather than deleting and recreating them:

  • Each renderer whose subtype the device still offers keeps its slot and name. Only its parameters are reset.
  • If a subtype has several renderers, the lowest-index one survives and clones are removed. Renderers of subtypes the device no longer offers are removed.
  • Subtypes the device offers but the state lacks are created before anything is removed, so they don't take the freed slots.
  • Anything that held a removed renderer falls back to the survivor of the same subtype, otherwise to the device's first renderer. SciVis Studio shots use the same rule.

Changes

  • Scene:
    • Adds reloadStandardRenderers(deviceName, device).
    • Adds the fallback helper rendererOfSubtypeOrFirst(deviceName, subtype, excludeObjectIndex = VSR_INVALID_INDEX).
    • Deletes removeRenderersForDevice, which had no callers.
  • RendererList (new, src/vsr/ui/imgui/windows/):
    • It is the viewport's renderer list, bound to a scene and a device. It keeps itself in sync through one update delegate, with no per-frame polling.
    • It keeps the rule that a non-empty list always has a current renderer, and picks a replacement with the helper above.
    • Viewport, RemoteViewport and StudioViewport all use it. Viewport.cpp is now smaller than it was before this branch.
  • Viewport renderer actions:
    • Clone, Reset and Reload are now optional hooks, shown only when the viewport says it supports them (renderer_hasActions()).
    • The renderer-action stubs in RemoteViewport and StudioViewport that only logged a warning are deleted.
  • SciVis Studio: a shot whose renderer was removed now binds to the survivor of the same subtype instead of front().

Testing

  • New tests:

    • vsr::RendererList, which runs without a device.
    • Reload and fallback-helper cases in test_Scene.cpp.
    • Shot-binding cases in test_SciVisStudio.cpp.

    The reload and shot-binding cases load helide at runtime and skip with a warning if it isn't available. Locally they ran and passed.

  • ctest: everything passes except vsr::RenderTools, which can't load libosdCPU.so in the local environment and is unrelated to this change.

Known gaps

  • Stale shot index: a shot's index that points at a removed renderer can be taken by a renderer created later in the same reused slot. Accepted for now.
  • Untested order rule: surviving renderers are meant to keep their menu order after a reload. helide offers only the default subtype, so no test covers this.
  • Remote renderer index mismatch (existed before this branch): the client reads the server's renderer index as a position in its list, while the server sends an object index. It is not fixed here.
  • Camera stubs: in RemoteViewport's Camera menu, Center View and Reset View still only log a warning.

Replaces every renderer object of the viewport's device with the standard
set queried from the device, as a device with no renderers in the state
gets on load. The current subtype stays selected when the device still
offers it.

Viewports now drop their renderer refs when the scene removes a renderer
(via an update delegate) and re-sync their renderer list from the scene
each frame, so another viewport on the same device never keeps refs to
removed renderers.

Scene::removeRenderersForDevice no longer holds APP refs while removing,
which decremented use counts on erased slots, and removes in reverse so
renderers created next reuse the slots in their original order.
BaseViewport's renderer_clone, renderer_resetParameterDefaults and
renderer_reloadDefaults are now virtuals with no-op defaults, and the
Renderer menu offers them only when renderer_hasActions() says the
viewport implements them. Viewport opts in; RemoteViewport and
StudioViewport drop their warning-only stubs, so RemoteViewport's menu
no longer shows Clone/Reload/Reset items that did nothing, while keeping
its subtype selection.
Scene::reloadStandardRenderers keeps the lowest-index renderer of each
subtype the device offers and resets only its parameters, so its slot,
name, and shot and viewport bindings survive. Missing subtypes are
created before clones and dropped subtypes are removed, so a removed
renderer's slot stays empty.

Scene::rendererForDevice is the shared fallback: the device's renderer of
a subtype, otherwise its first renderer. The viewport reselects with it
after a reload, and ProjectContext::bindShotRenderer uses it with the
shot's saved subtype instead of the first renderer.

Scene::removeRenderersForDevice is deleted; nothing calls it.
The name now says what the helper returns: the device's renderer of the
given subtype, otherwise its first renderer.
…odel

BaseViewport::RendererState becomes RendererList: the renderers of one
device in scene storage order plus the current one. Bound to a scene, it
follows renderer additions and removals through its own update delegate,
and a non-empty list always has a current renderer: a removed current
renderer is replaced by the list's renderer of the same subtype,
otherwise its first.

Viewport drops its removal forwarder, the per-frame syncRendererList(),
and the direct list edits in setLibrary, clone, and reload; updateFrame()
now detects a renderer change by the ANARI handle it last gave the render
pass. RemoteViewport and StudioViewport use the same model, so neither
can hold refs to renderers the scene has erased.
…swers

Review follow-ups to the RendererList change. RemoteViewport treats the
list's default pick as unsent, so a renderer the user picks before the
server reports its own is still sent, as it was before. RendererList
shares one lookup by object index; the viewport overlay reads the
current renderer once; the test's includes are grouped and labeled.
Scene::rendererOfSubtypeOrFirst gains an excludeObjectIndex parameter
(default VSR_INVALID_INDEX, excluding nothing), so an update delegate can
ask for the replacement of a renderer the scene is about to remove while
the scene still holds it. RendererList now calls the helper instead of
repeating the subtype-then-first rule over its own list, so the rule
lives in one place. The list is kept in scene storage order, the order
the helper scans, so the pick is unchanged.
Scene::rendererOfSubtypeOrFirst is tested without a device, with made-up
subtypes under the helide device name: lowest-index match, first-renderer
fallback, empty for an unknown device, and the excluded object index.

Scene::reloadStandardRenderers is tested against helide (skipped when it
does not load): the kept renderer's slot, name and metadata survive while
its parameters return to defaults; clones and unoffered subtypes are
removed; missing subtypes are created before anything is removed, so the
removed slot stays empty; other devices are untouched; no use count goes
below zero.

SciVis Studio's bindShotRenderer gains cases for a pick removed by reload
and for a removed pick of a made-up subtype whose survivor is not the
device's first renderer.
Review follow-ups. test_Scene and test_RenderIndex shared a near-copy of
a helide-loading TestDevice; it moves to HelideTestDevice.h with its
methods defined out of the body, per the coding standards. In test_Scene,
indexOf becomes indexOrInvalid, the "excludes nothing" case calls the
helper with its default argument, a GIVEN is retitled to what it checks,
and the single-subtype assumption about helide is spelled out.
@jeffamstutz
jeffamstutz merged commit a2cb005 into main Nov 10, 2026
12 checks passed
@jeffamstutz
jeffamstutz deleted the feat/reload-default-renderers branch November 10, 2026 14:15
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