ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.57k stars 10.36k forks source link

Win32+DX12: Vertical Offset After Connecting Another Display #6519

Open VegiBurrito opened 1 year ago

VegiBurrito commented 1 year ago

Hey

We ran into a bug the other day that shows up when you connect another monitor to your PC after the application has already been started.

We were able to reproduce the problem with one of your example applications, too. win32 + directx12 on commit #534340c

So, this is what we did:

This problem is admittedly not extremely crucial. But in certain situations it causes some inconvenience for us.

Thank you

ocornut commented 1 year ago

Can you check if it happens with win32 + dx11 ? how about e.g. glfw + opengl3 ?

VegiBurrito commented 1 year ago

Oh yes, and sorry for not checking them right away.

So, I couldn't reproduce the issue with any of the two (win32+dx11, glfw+opengl3). And at first, I wasn't even able to reproduce again the issue with win32+dx12 ... That shocked me a bit.

But I didn't give up and was finally able to reproduce it with win32+dx12 (but not with the other two). Well, the ability to reproduce it depends on which monitor is selected as the primary one.

My setup is this:

So depending on which Dell is selected as the primary I do get the bug or not :-/

Note: it doesn't matter if I move the application window to the primary/secondary monitor first before plugging in the third monitor.

If you had any pointers for what I could do next - I was happy to try it. But don't worry too much about this bug. It's inconvenient and somewhat weird, but it's not a fatal game breaker ;)

On Wed, Jun 14, 2023 at 1:46 PM omar @.***> wrote:

Can you check if it happens with win32 + dx11 ? how about e.g. glfw + opengl3 ?

— Reply to this email directly, view it on GitHub https://github.com/ocornut/imgui/issues/6519#issuecomment-1591585299, or unsubscribe https://github.com/notifications/unsubscribe-auth/BASKUPUSEKDEZRHFXPRKOWDXLHPUHANCNFSM6AAAAAAZGSSIFI . You are receiving this because you authored the thread.Message ID: @.***>

-- Contents of this email may be confidential and/or proprietary, are intended solely for the addressee, and must not be disseminated or re-distributed without permission. If you have received this email in error, please notify the sender and system manager, and delete the message - taking any other action is strictly prohibited.

ocornut commented 1 year ago

Assuming that's in master (but you didn't specify the branch and didn't fill issue template) everything related to this would be in example_win32_direct12/main.cpp and not imgui-core code, but fixing examples for edge case is always desirable.

VegiBurrito commented 1 year ago

Sounds great! Thanks so much for picking up that problem!

Version/Branch of Dear ImGui:

Version: 1.89.7 WIP (18963) Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp Compiler: MSVC Operating System: Windows

My Issue/Question:

Plugging in another monitor while the application is already running can result in a vertical and horizontal offset. In the end, it feels like the rendering result from ImGui was placed incorrectly in the window (shifted upwards and slightly to the left). More details in the previous posts.

Screenshots/Video

Nope

Standalone, minimal, complete and verifiable example:

example_win32_directx12 from the examples folder

Demonese commented 1 year ago

This may be a bug in Windows or the graphics card driver. I can't reproduce this problem, but I had a similar problem on another device.

After resizing the window, the content may be offset by the height of the title bar.

The solution is to use DirectComposition and create a swapchain through CreateSwapChainForComposition. This might help you.