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

low ms/frame when sharing/recording screen #8218

Open
akosil opened this issue Dec 9, 2024 · 5 comments
Open

low ms/frame when sharing/recording screen #8218

akosil opened this issue Dec 9, 2024 · 5 comments

Comments

@akosil
Copy link

akosil commented Dec 9, 2024

Version/Branch of Dear ImGui:

v1.91.6 WIP , docking branch

Back-ends:

imgui_impl_dx11

Compiler, OS:

Windows 10

Full config/build information:

example_win32_directx11 build from v1.91.6 WIP - docking branch

Details:

high ms / frame (worse performance) when sharing screen on discord or recording screen with OBS

Screenshots/Video:

image

Minimal, Complete and Verifiable Example code:

-
@ocornut
Copy link
Owner

ocornut commented Dec 9, 2024

You would need to investigate this on your own but it seems like a problem of your recording software, if not a feature (perhaps they are hijacking something to make vsync simulate 20 hz, is the 20 fps framerate stable?)
Maybe try with different examples/backends.

@akosil
Copy link
Author

akosil commented Dec 11, 2024

I will try to find the issue.
Another issue i found: When I undock a window and move it outside the main viewport, the main application experiences higher ms/frame (worse performance). Is this expected behavior, or could it be a bug?

@ocornut
Copy link
Owner

ocornut commented Dec 11, 2024

Is that also when recording?
What sort of ms/frame amount does it goes from and to ?

We create new windows and swapchains so there is a cost but normally it should be relatively negligible.
It’s related to your first question because our examples app are fully throttled using a vsync wait, and that may be affected by drivers and other sources.

@akosil
Copy link
Author

akosil commented Dec 11, 2024

2nd issue is without recording:
Application is running on main screen (240hz).
If I move out a window to main screen, with vsync on actually I get slightly higher FPS right now, but without vsync the performance drop is visible.
If I move out a window to second screen(60hz), I always get a way worse performance.
If I change the hz from 240 to 60, I get same performance drop wherever I undock the window.

ms/frame values without vsync:
normal, no undock: 3.284 ms / frame
undock from main screen to main screen: 5.912 ms / frame
undock from main screen to second screen: 9.253 ms / frame

I attached an image for reference:
With vsync
image
Without vsync
image

@ocornut
Copy link
Owner

ocornut commented Dec 11, 2024

Profiling would be needed, but unfortunately this can be due to so many things:

  • drivers
  • drivers settings related to vsync
  • possibly swapchain swapeffect

One thing that may be worth trying

  • change the SwapChain setup from
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;

to

sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;

And the other more modern FLIP modes.
For this to work:

  • you need to ensure the project is built with Windows 10+ SDK (by default our vsproj are committed with SDK 8.1, need Visual Studio to upgrade them to SDK 10.
  • need to change it in example_win32_directx11/main.cpp AND in backends/imgui_impl_win32.cpp's ImGui_ImplDX11_CreateWindow() function.

I would be curious to know if it makes a difference for you.
If it does it may be tempting to migrate committed examples to rely on SDK 10 + make backend inherit SwapEffect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants