Skip to content

Re-enable remote loop visuals with throttled updates#104

Draft
malisimat with Copilot wants to merge 2 commits into
masterfrom
copilot/issue-68-relevance-check
Draft

Re-enable remote loop visuals with throttled updates#104
malisimat with Copilot wants to merge 2 commits into
masterfrom
copilot/issue-68-relevance-check

Conversation

Copilot AI commented May 31, 2026

Copy link
Copy Markdown
Contributor

Remote loop visuals were disabled entirely (SetVisualUpdatesEnabled(false)) as a temporary workaround for severe slowdown during NINJAM sessions. This removes the workaround and re-enables visuals with proper rate-limiting.

Changes

  • LoopRemote: 15 Hz visual throttleUpdate() checks elapsed time before consuming the dirty flag. Deferred updates retain _modelDirty for the next tick rather than exchange-then-re-set.
  • StationRemote: interval change-guardSetRemoteInterval() early-outs when length, visual length, and position are all unchanged, eliminating redundant resize/dirty-flag work on each job tick.
  • No geometry rebuild — the existing vertex-shader path (fixed mesh + 1D waveform texture + PBO double-buffer upload) means per-update cost is O(2048) decimation + texture upload. The throttle caps this at 15×/sec per loop.
void LoopRemote::Update()
{
    if (!_modelDirty.load())
        return;

    std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
    double elapsed = std::chrono::duration<double>(now - _lastVisualUpdate).count();
    if (elapsed < (1.0 / _MaxVisualUpdateHz))
    {
        // Leave _modelDirty set so the update is retried next tick.
        _bufferBank.UpdateCapacity();
        _monitorBufferBank.UpdateCapacity();
        return;
    }

    _modelDirty.store(false);
    _lastVisualUpdate = now;
    Loop::Update();
}

Notes

  • _MaxVisualUpdateHz (15.0) is tunable if real-world testing shows it's still too aggressive.
  • allowUnchangedSkip in LoopModel::UpdateModel provides an additional early-out for playing-state loops where nothing has changed.
  • Needs NINJAM session testing to confirm the throttle + vertex-shader path is sufficient.

Copilot AI added 2 commits May 31, 2026 22:53
Remove the SetVisualUpdatesEnabled(false) workaround from issue #68.
Remote loop visual updates are now re-enabled but throttled to 15 Hz
to prevent excessive decimation/upload cost.

Changes:
- LoopRemote::Update() now rate-limits visual model refreshes using
  steady_clock, re-setting the dirty flag when throttled so updates
  are retried on the next tick.
- StationRemote::SetRemoteInterval() early-outs when length, visual
  length, and position are all unchanged, avoiding redundant buffer
  resize and dirty-flag work on each job tick.
- Added _intervalVisualLengthSamps to StationRemote for the change
  guard.

The existing vertex-shader architecture (fixed geometry + 1D waveform
texture + GPU displacement) means no geometry rebuild is needed per
update - only waveform decimation and PBO texture upload.

Relates to #68
Restructure LoopRemote::Update() to check the time throttle before
clearing _modelDirty, eliminating the exchange-then-re-set pattern
that could theoretically race. Also use explicit types per review.
Copilot AI changed the title Re-enable remote loop visuals with throttled updates (issue #68) Re-enable remote loop visuals with throttled updates May 31, 2026
Copilot AI requested a review from malisimat May 31, 2026 22:59
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.

2 participants