From 79c9c23232b1858bc8a53c5fe02236b2f5795112 Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Sat, 21 Sep 2024 20:28:27 +0800 Subject: [PATCH] Try fix probing failed issue on some weird systems --- src/platform/windows/display_base.cpp | 2 ++ src/process.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/platform/windows/display_base.cpp b/src/platform/windows/display_base.cpp index 7058b77b..bafb8bb1 100644 --- a/src/platform/windows/display_base.cpp +++ b/src/platform/windows/display_base.cpp @@ -419,11 +419,13 @@ namespace platf::dxgi { // Try probing with different GPU preferences and verify_frame_capture flag if (validate_and_test_gpu_preference(display_name, true)) { + set_gpu_preference = true; return true; } // If no valid configuration was found, try again with verify_frame_capture == false if (validate_and_test_gpu_preference(display_name, false)) { + set_gpu_preference = true; return true; } diff --git a/src/process.cpp b/src/process.cpp index f0461c50..d56357ac 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -252,14 +252,23 @@ namespace proc { // Set primary display if needed if (shouldActuallySetPrimary) { auto disp = shouldSetVDisplayPrimary ? vdisplayName : prevPrimaryDisplayName; - BOOST_LOG(info) << "Setting display " << disp << " primary!!!"; + BOOST_LOG(info) << "Setting display " << disp << " primary"; - VDISPLAY::setPrimaryDisplay(disp.c_str()); + if (!VDISPLAY::setPrimaryDisplay(disp.c_str())) { + BOOST_LOG(info) << "Setting display " << disp << " primary failed! Are you using Windows 11 24H2?"; + } } // Set virtual_display to true when everything went fine this->virtual_display = true; this->display_name = platf::to_utf8(vdisplayName); + + if (config::video.headless_mode) { + // When using headless mode, we don't care which display user configured to use. + // So we always set output_name to the newly created virtual display as a workaround for + // empty name when probing graphics cards. + config::video.output_name = this->display_name; + } } } #endif