Skip to content

Draw the viewport on every WPF frame (37-50 FPS on 75-144 Hz screens) - #406

Open
DerpyNewb wants to merge 1 commit into
donkeyProgramming:masterfrom
DerpyNewb:pr/viewport-fps-cap
Open

DerpyNewb wants to merge 1 commit into
donkeyProgramming:masterfrom
DerpyNewb:pr/viewport-fps-cap

Conversation

@DerpyNewb

Copy link
Copy Markdown
Contributor

hey, small one. on a 75, 100 or 144 Hz screen the 3D viewport runs at 37, 50 or 48 FPS, so slower than on a 60 Hz screen

D3D11Host only draws when 16 ms have passed since the last drawn frame. WPF raises CompositionTarget.Rendering once per display refresh though, not at a fixed 60 Hz, and the time of a skipped tick isn't carried over. so whenever the refresh period doesn't divide 16 ms, ticks get dropped: at 75 Hz they're 13.3 ms apart, so only every second one gets through

TargetElapsedTime now defaults to zero, so it draws on every WPF frame. the property is still there if something wants a cap. the two comments saying WPF is limited to 60 FPS are updated too

files

  • GameWorld.Core/WpfWindow/D3D11Host.cs: the default, plus the check pulled out into IsFrameDue so it can be tested
  • GameWorld.Core/WpfWindow/WpfGame.cs: comment only
  • GameWorld.CoreTest/Rendering/FrameRateTests.cs: new

testing

  • FrameRateTests counts the frames drawn in one simulated second at 60, 75, 100 and 144 Hz. with the old 16 ms default it fails at 75 (37 drawn), 100 (50) and 144 (48), with the new default all four pass
  • GameWorld.CoreTest: 570 passed, 0 failed
  • built AssetEditor.csproj the way pr-test.yml does, 0 errors

it's been in my fork since October

D3D11Host only rendered when 16 ms had passed since the last drawn frame. WPF raises
CompositionTarget.Rendering once per display refresh, not at a fixed 60 Hz, and a skipped
tick's time isn't carried over, so any refresh period that doesn't divide 16 ms dropped whole
frames: 75 Hz drew 37 FPS, 100 Hz 50 and 144 Hz 48. TargetElapsedTime now defaults to zero.
FrameRateTests fails on the old default at 75, 100 and 144 Hz.

This branch has not been deployed

No deployments
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