Repository navigation
feat(ui): add "Reload Default Renderers" that resets a device's renderers in place - #28
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Changes
reloadStandardRenderers(deviceName, device).rendererOfSubtypeOrFirst(deviceName, subtype, excludeObjectIndex = VSR_INVALID_INDEX).removeRenderersForDevice, which had no callers.RendererList(new,src/vsr/ui/imgui/windows/):Viewport,RemoteViewportandStudioViewportall use it.Viewport.cppis now smaller than it was before this branch.renderer_hasActions()).RemoteViewportandStudioViewportthat only logged a warning are deleted.front().Testing
New tests:
vsr::RendererList, which runs without a device.test_Scene.cpp.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 exceptvsr::RenderTools, which can't loadlibosdCPU.soin the local environment and is unrelated to this change.Known gaps
defaultsubtype, so no test covers this.RemoteViewport's Camera menu, Center View and Reset View still only log a warning.