sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
400 stars 91 forks source link

Suggestion: fix DXGI_ERROR_UNSUPPORTED when run against discrete GPU #126

Open name1ess0ne opened 3 years ago

name1ess0ne commented 3 years ago

Hello guys,

ScreenRecorderLib fails on some machines with DXGI_ERROR_UNSUPPORTED error. That happens because of Desktop Duplication API cannot work on discrete GPU in hybrid systems. https://docs.microsoft.com/en-US/troubleshoot/windows-client/shell-experience/error-when-dda-capable-app-is-against-gpu https://www.freemancw.com/2020/11/desktop-duplication-on-hybrid-graphics-systems/

I have spent some time investigating this issue and maybe there could be programmatic solution starting from Window 10 v1803. https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_6/nf-dxgi1_6-idxgifactory6-enumadapterbygpupreference The trick is to use EnumAdapterByGpuPreference with DXGI_GPU_PREFERENCE_MINIMUM_POWER instead of EnumAdapters. That will not solve the problem for all users, but at least it helps those who use latest versions of Windows 10.

Originally posted by @name1ess0ne in https://github.com/sskodje/ScreenRecorderLib/issues/63#issuecomment-787564840

sskodje commented 3 years ago

Hey, thanks for the suggestion! I'll look into incorporating this into the next major release that i'm working on.

name1ess0ne commented 3 years ago

Thank you!