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

Bump dependencies for imgui-winit example #400

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mkrasnitski
Copy link
Contributor

imgui-wgpu-rs now supports wgpu 0.19 and winit 0.29, but only on the git HEAD. A release hasn't been cut yet so keeping this as draft for now. Also, resizing the window now crashes the app with the following error:

wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `pixels_command_encoder`
    In a set_scissor_rect command
    Scissor Rect { x: 0, y: 0, w: 642, h: 483 } is not contained in the render target (640, 480, 1)

I figured this PR would be a good place to track this while the root cause is figured out.

@parasyte
Copy link
Owner

The validation error is from desynchronized draw and resize. Resize is deferred by winit-input-helper, but drawing is not.

It can be fixed by reordering these operations. E.g. by moving the drawing code after the resize, but before the world.update() call. Or alternatively and preferably, move the resize out of the input.update() guard and use the normal winit event matching instead.

Sigh. These are some skeletons in the closet. The history here is sort of documented in #270 (comment).

I ended up matching on the event for RedrawRequested separately from using input.update()'s return value for some of the reasons described there. We kind of got away with it, but these events should not be deferred.

Deferring these events causes problems like the resize looking horrible while the user drags the window frame around. The intermediate frame gets stretched and warped. The right way to handle resize will correctly redraw every frame while the resize is in progress. And doing that means no deferral of resize and redraw events.

And yeah, deferring events is what you are expected to do with winit-input-helper: https://github.com/rukai/winit_input_helper/blob/106e033c718ccfb346866c054d23025666ae13ae/examples/example.rs#L33-L35

So, it's probably time for it to go.

@parasyte
Copy link
Owner

I'm also completely misremembering how it ended up that RedrawRequested is treated differently from the rest of the event handling. Because this was there since the beginning with a salient comment:

// The one and only event that winit_input_helper doesn't have for us...
if let Event::WindowEvent {
event: WindowEvent::RedrawRequested,
..
} = event

All of the examples inherited it.

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