Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example: Refactor event loop handling for continuous redraw #542

Merged
merged 2 commits into from
Jan 3, 2022

Conversation

msiglreith
Copy link
Contributor

Fixes hangs in case of non-mailbox present modes. I assume acquiring an image from the swapchain hangs when redrawing unconditionally on each incoming event. See rust-windowing/winit#2127 and #541

Tested on Windows with Nvidia gpu

Fixes hangs in case of non-Mailbox present modes.
@Ralith
Copy link
Collaborator

Ralith commented Jan 3, 2022

Per winit's docs, RedrawRequested isn't appropriate for continuously rendering applications. Instead, we should redraw on MainEventsCleared.

@MarijnS95
Copy link
Collaborator

In addition, ControlFlow should be set to Poll instead of Wait so that it renders continuously, instead of whenever the next series of (input) event(s) arrive. Afaik there is no event that wakes up the loop continuously or monotonically.

Copy link
Collaborator

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @msiglreith! After all these changes I'd rename this PR (= the resulting title of the squash-merge commit) to something like "process all events before rendering a frame" and also work in the switch over to "polling" instead of sometimes blocking until any (unrelated to rendering) event. I'll leave the details of that to you unless you prefer me to change it.

@msiglreith msiglreith changed the title example: only redraw when requested by the event loop. example: refactor event loop handling for continuous redraw Jan 3, 2022
@msiglreith
Copy link
Contributor Author

@MarijnS95 I tried to fine a better title, feel free to adjust :D

@MarijnS95 MarijnS95 changed the title example: refactor event loop handling for continuous redraw example: Refactor event loop handling for continuous redraw Jan 3, 2022
@MarijnS95
Copy link
Collaborator

Yeah, I think that perfectly covers it without giving away too much of the (here unnecessary) implementation details, thanks!

@MarijnS95 MarijnS95 merged commit adf0338 into ash-rs:master Jan 3, 2022
@msiglreith msiglreith deleted the wsi-redraw branch January 3, 2022 22:26
MarijnS95 added a commit that referenced this pull request Jan 3, 2022
Ralith pushed a commit that referenced this pull request Jan 3, 2022
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.

3 participants