Hello,
We are running into some optimization voodoo.
EDIT 4 figured it out, effective fps too high so all rstick changes are tiny and get 0-ed. You can read about this epic adventure bellow if you're in a mood for a story.
FYI "fps" is ~ 5k it seems. I'm not sure yet what limits the fps to something reasonable when moving the mouse .. if it's incidental due to rendering cost, or there's an fps limit somewhere that we aren't usually checking.
End edit 4
The above works great until we try to use view->Update to not render frames that "have no changes" :
// pseudo code
display->Render() += [...] ( ... )
{
if( Noesis::view->Update(totalTimeElapsed) )
{
context->BeginRender();
view->GetRenderer()->UpdateRenderTree();
view->GetRenderer()->RenderOffscreen();
context->SetDefaultRenderTarget(display->GetClientWidth(), display->GetClientHeight(), true);
view->GetRenderer()->Render();
context->EndRender();
context->Swap();
}
}
This now has some odd behaviors:
- Scrolling with R stick does not work on it's own. (releasedbg)
-- Scrolling with mouse wheel works great all the time.
- Moving the mouse around only within render area makes scrolling work again.
-- Once scrolling started, I can stop moving the mouse and scrolling will continue just fine.
- Adding conditional break points that don't trigger makes scrolling work again (releasedbg).
- Adding a break point will make scroll tick once per break (releasedbg).
- Going from ReleaseDbg to Debug makes scrolling work again.
-- Though even debug has maybe 0.5s lag before scroll starts.
- In releasedbg, adding a stdout or NS_LOG anywhere on frame will (say within ScrollTargetBehavior::OnMouseWheel(), or before view->Update() check will cause scrolling to work again
-- NS_LOG makes things work possibly due to our logger using a mutex? Not sure why stdout would ..
-- I'm certain that it's the logging when view->Update() is returning false that makes scrolling work again.
- Adding a gater in in OnMouseWheel to call target->ScrollToVerticalOffset() at most once per ~1ms also sometimes make scroll work.
- Calling context->Swap() without BeginRender()/EndRender()/UpdateRenderTree()/RenderOffscreen()/Render() also makes scrolling work (though jittery).
Can you think of why something like this would happen?
- Is there a way to mark view "dirty" within ScrollTargetBehavior so view->Update() returns true?
- Is there an invalidate of some kind I need to call after target->ScrollToVerticalOffset() ?
- As an aside, it looks like calling ScrollViewer::ScrollToVerticalOffset can call ScrollViewer::ScrollChanged() ?
- What does ScrollTargetBehavior::OnMouseWheel do differently when triggered with R stick from being triggered by mouse wheel?
-- it looks like there's a frequency of updates difference? Is it flooding something in ScrollViewer ?
-- Mouse::RaiseWheel seems to be triggered regardless, but Rstick goes through View::Scroll and mouse wheel through Mouse::Wheel.
--- Further up Rstick comes direct from Win32Display::EnterMessageLoop() through mScroll()
--- Further up Mouse wheel comes comes from EnterMessageLoop too but through through Win32Display::DispatchEvent()
---- but I don't know why one would scroll and one wouldn't.
- What about going from ReleaseDbg to Debug makes scrolling work again?
-- it seems it not entirely timing related as Debug still lags a few frames before starting to scroll, seems like some kind of event overflow / min difference checker?
- What does context->Swap() do that can make scrolling work again?
-- Is RStick input ignored without Swap? It seems to do some kind of event flush. Though not sure why debug build would work differently then.
--
Edit: Turns out RStick isn't getting ignored! When things aren't scrolling, It's coming through as wheelRotation = 0, but in when things scroll it's +/- some number. Frequency of updates doesn't change it seems.
--
Edit 2 I think I can confirm that View::Scroll gets called with some good value, but Mouse::RaiseWheel gets a 0 rotation. In debug initial couple thousand updates are also 0s but after that scrolling starts getting non zero values after that. If I keep moving the mouse around on screen, then all there are almost no 0 values (debug or relesedbg)
--- There's also a difference in frequency, 0 values happen 1000x more then non 0.
---
Edit 3 crazy idea time: what if our effective fps is like bazillion when we aren't rendering and that messes with input pulling .. so incremental values seem really small ?!