Skip to content

Conversation

@Perksey
Copy link
Member

@Perksey Perksey commented Aug 3, 2023

No description provided.

@Perksey Perksey changed the title [net7] Add a pause instruction onto the windowing loop [net7] Improve CPU efficiency of the game loop using pause/yield Aug 4, 2023
@Perksey
Copy link
Member Author

Perksey commented Aug 4, 2023

This has been heavily reworked in response to Discord discourse. This is now ready for review.

@Perksey Perksey marked this pull request as ready for review August 4, 2023 14:56
@Perksey Perksey requested a review from a team as a code owner August 4, 2023 14:56
@HurricanKai
Copy link
Member

I'm happy with this, thanks for writing the code also.

It's a bit unclear to me right now how much we still want to support the whole "custom Run" idea? This would put the final nail in the coffin for this. (But we've added other features in the past that were in this direction)

@Perksey
Copy link
Member Author

Perksey commented Aug 4, 2023

The thing is in 1.X Run was indeed fully custom, and made an explicit decision in 2.0 to regress here in the name of write-once-run-everywhere. There's nothing stopping our users implementing their own Run at all today, but had to change for iOS (and now WASM) compatibility. Users are still free to completely ignore our Run function if they wish.

@Perksey
Copy link
Member Author

Perksey commented Aug 4, 2023

@Beyley @HurricanKai this builds now, is this good for merge?

@HurricanKai
Copy link
Member

I think given this conflicts with custom Run we should resolve that first - what about making a new overload that takes ShouldSpin as a delegate parameter?

@Perksey
Copy link
Member Author

Perksey commented Aug 4, 2023

I think given this conflicts with custom Run we should resolve that first - what about making a new overload that takes ShouldSpin as a delegate parameter?

If the user wants to customise this stuff they should implement the whole run loop themselves. This is the write-once-run-anywhere path where the fact that there is a while loop at all is an implementation detail.

@HurricanKai
Copy link
Member

Fair enough - can we make the ShouldSpin virtual? Would that be a problem? That's less obvious but is at least an escape hatch?

@Perksey
Copy link
Member Author

Perksey commented Aug 4, 2023

That'd be an API contract change and will probably need to go through the proposal system unless you disagree. I agree this would be a nice addition, but out of scope of this PR I think.

@Perksey
Copy link
Member Author

Perksey commented Aug 6, 2023

Actually, the user should be able to opt-out of this behaviour. Thinking about things that need regular DoEvents calls, like rhythm games.

Perksey and others added 6 commits August 6, 2023 22:31
* Proper frame timing in BreakneckSleep

Should _lastTick be a property or left as a field? unsure

* adjusted to feedback

* forgot to make the example work too
@Perksey
Copy link
Member Author

Perksey commented Aug 20, 2023

This is going into draft, and would welcome being picked up by the community.

This contains an experimental attempt at making our frame timing more CPU efficient by using high-resolution sleep primitives. However, we were unable to do so in a way that is consistent and that wasn't "jittery". Please see this Discord thread: https://discord.com/channels/521092042781229087/587346162802229298/1142876986537160865

This is now up for grabs

@Perksey Perksey marked this pull request as draft August 20, 2023 18:10
@Perksey Perksey added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Aug 20, 2023
@Perksey Perksey changed the title [net7] Improve CPU efficiency of the game loop using pause/yield [net7] Use high-resolution sleep primitives to enhance CPU efficiency Aug 20, 2023
@Perksey
Copy link
Member Author

Perksey commented Sep 5, 2023

Closing and adding to the community epic.

@Perksey Perksey closed this Sep 5, 2023
@Perksey Perksey deleted the hotfix/fidgity-spinny branch November 2, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Projects

Status: Stalled

Development

Successfully merging this pull request may close these issues.

4 participants