Skip to content

Commit

Permalink
stupid test
Browse files Browse the repository at this point in the history
  • Loading branch information
FrogTheFrog committed Jan 8, 2025
1 parent 9b9767b commit 9964a68
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/platform/windows/display_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ namespace platf::dxgi {
return true;
}

bool
std::optional<int>
validate_and_test_gpu_preference(const std::string &display_name, bool verify_frame_capture) {
std::string cmd = "tools\\ddprobe.exe";

Expand All @@ -375,7 +375,7 @@ namespace platf::dxgi {
}
catch (bp::process_error &e) {
BOOST_LOG(error) << "Failed to start ddprobe.exe: "sv << e.what();
return false;
return std::nullopt;
}

BOOST_LOG(info) << "ddprobe.exe " << boost::algorithm::join(args, " ") << " returned 0x"
Expand All @@ -387,16 +387,13 @@ namespace platf::dxgi {
if (result == S_OK || result == E_ACCESSDENIED) {
// We found a working GPU preference, so set ourselves to use that.
if (set_gpu_preference_on_self(i)) {
return true;
}
else {
return false;
return i;

Check warning on line 390 in src/platform/windows/display_base.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_base.cpp#L390

Added line #L390 was not covered by tests
}
}
}

// If no valid configuration was found, return false
return false;
return std::nullopt;

Check warning on line 396 in src/platform/windows/display_base.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_base.cpp#L396

Added line #L396 was not covered by tests
}

// On hybrid graphics systems, Windows will change the order of GPUs reported by
Expand All @@ -411,22 +408,22 @@ namespace platf::dxgi {
// we spawn a helper tool to probe for us before we set our own GPU preference.
bool
probe_for_gpu_preference(const std::string &display_name) {
static bool set_gpu_preference = false;
static std::map<std::string, int> gpu_preference;

// If we've already been through here, there's nothing to do this time.
if (set_gpu_preference) {
return true;
// If we've already been through here, there's no need to test for preference again.
if (const auto pref_it { gpu_preference.find(display_name) }; pref_it != gpu_preference.end()) {
return set_gpu_preference_on_self(pref_it->second);

Check warning on line 415 in src/platform/windows/display_base.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_base.cpp#L415

Added line #L415 was not covered by tests
}

// Try probing with different GPU preferences and verify_frame_capture flag
if (validate_and_test_gpu_preference(display_name, true)) {
set_gpu_preference = true;
if (const auto pref = validate_and_test_gpu_preference(display_name, true); pref) {
gpu_preference.emplace(display_name, *pref);

Check warning on line 420 in src/platform/windows/display_base.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_base.cpp#L420

Added line #L420 was not covered by tests
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;
if (const auto pref = validate_and_test_gpu_preference(display_name, false); pref) {
gpu_preference.emplace(display_name, *pref);

Check warning on line 426 in src/platform/windows/display_base.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_base.cpp#L426

Added line #L426 was not covered by tests
return true;
}

Expand Down

0 comments on commit 9964a68

Please sign in to comment.