Skip to content

Commit

Permalink
If a best platform is selected, we filter out the non-best platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Nov 10, 2023
1 parent ce7f120 commit 992f9ac
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions src/server/graphics/default_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <boost/throw_exception.hpp>

#include <sstream>
#include <algorithm>

namespace mg = mir::graphics;

Expand Down Expand Up @@ -295,18 +296,7 @@ auto mir::DefaultServerConfiguration::the_rendering_platforms() ->
bool found_supported_device{false};
for (auto& device : supported_devices)
{
if (device.support_level == mg::probe::best)
{
// In the case that we've discovered a best platform (most likely a hardware platform)
// then we abandon all other platforms.
// TODO: Remove me once a multi-rendering-platform paradigm is fully supported, and we
// don't just select the first (or last?) platform and use that everywhere.
platform_modules.clear();
platform_modules.emplace_back(std::move(device), platform);
found_supported_device = true;
break;
}
else if (device.support_level >= mg::probe::supported)
if (device.support_level >= mg::probe::supported)
{
found_supported_device = true;
}
Expand All @@ -327,6 +317,32 @@ auto mir::DefaultServerConfiguration::the_rendering_platforms() ->
else
{
platform_modules = mir::graphics::rendering_modules_for_device(platforms, display_targets, dynamic_cast<mir::options::ProgramOption&>(*the_options()), the_console_services());

// In the case that we've discovered a best platform (most likely a hardware platform)
// then we abandon any platform that is not best.
// TODO: Remove me once a multi-rendering-platform paradigm is fully supported, and we
// don't just select the first (or last?) platform and use that everywhere.
bool has_best_support_level = false;
for (auto const& platform : platform_modules)
{
if (platform.first.support_level == mg::probe::best)
{
has_best_support_level = true;
break;
}
}

if (has_best_support_level)
{
auto it = platform_modules.begin();
while (it != platform_modules.end())
{
if (it->first.support_level != mg::probe::best)
it = platform_modules.erase(it);
else
it++;
}
}
}

for (auto const& [device, platform]: platform_modules)
Expand Down

0 comments on commit 992f9ac

Please sign in to comment.