parasyte / pixels

A tiny hardware-accelerated pixel frame buffer. 🦀
https://docs.rs/pixels
MIT License
1.81k stars 123 forks source link

imgui UI out of bounds in example "imgui-winit" #338

Open martinteoharov opened 1 year ago

martinteoharov commented 1 year ago

Whenever I switch between my monitors and run my program I get an instant crash before the first render. I narrowed it down to the UI drawing to a slightly bigger frame. I tried to recreate it in the example mentioned in the title and I also got the same error. A restart of my PC fixes it sometimes.

[2023-02-24T15:14:51Z ERROR wgpu::backend::direct] Handling wgpu errors as fatal by default
thread 'main' panicked at '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: 911, h: 650 } is not contained in the render target Extent3d { width: 910, height: 650, depth_or_array_layers: 1 }

I tried tweaking the code, but I couldn't find a solution. Any advice?

parasyte commented 1 year ago

It looks like an off by one based on the error message, but this is a new failure mode to me.

Do your displays have different logical pixel sizes? Maybe that has something to do with it. I honestly have not done a lot of testing with multiple displays and handling changes to the scaling factor. I can put together a setup and try to reproduce this.

Because that example uses the scaling factor within its resize handler, I suspect these two events need to be handled simultaneously. That's my current theory.

martinteoharov commented 1 year ago

thanks @parasyte . My setup is basically a laptop that i connect to 2 different monitors (1920x1080 and 1920x1200) throughout the day (not at the same time).

ill have a look tomorrow and will try to come up with a solution, thanks for the advice and for the great project, ive found it very useful :))