Skip to content

Commit 38cbcef

Browse files
committed
Next merge fix
1 parent be58a54 commit 38cbcef

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

libraries/gfx/gl4/src/morpheus/gfx/gl4/wgl/adapter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@ concurrency::Generator<Adapter> enumerateAdapters()
126126
if (!restoredContext)
127127
continue;
128128
}
129+
}
129130

130131
} // namespace morpheus::gfx::gl4::wgl

libraries/gfx/gl4/tests/wgl/adapter.tests.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ using PathInfoArray = std::vector<DISPLAYCONFIG_PATH_INFO>;
5151
using ModeInfoArray = std::vector<DISPLAYCONFIG_MODE_INFO>;
5252
using DisplayConfig = std::pair<PathInfoArray, ModeInfoArray>;
5353

54+
/// Path mapping an output monitor to the graphic adapter mapped to it.
55+
using Path = std::pair<DISPLAYCONFIG_TARGET_DEVICE_NAME, DISPLAYCONFIG_ADAPTER_NAME>;
56+
5457
auto getDisplayConfigBufferSizes() -> exp_ns::expected<std::pair<UINT32, UINT32>, std::string>
5558
{
5659
UINT32 pathCount = 0, modeCount = 0;
@@ -80,8 +83,8 @@ auto targetDeviceName(DISPLAYCONFIG_PATH_INFO const& path) -> exp_ns::expected<D
8083
DISPLAYCONFIG_TARGET_DEVICE_NAME targetName = {};
8184
targetName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME;
8285
targetName.header.size = sizeof(targetName);
83-
targetName.header.adapterId = path.sourceInfo.adapterId;
84-
targetName.header.id = path.sourceInfo.id;
86+
targetName.header.adapterId = path.targetInfo.adapterId;
87+
targetName.header.id = path.targetInfo.id;
8588
auto const result = DisplayConfigGetDeviceInfo(&targetName.header);
8689
if (result != ERROR_SUCCESS)
8790
{
@@ -125,31 +128,32 @@ exp_ns::expected<DisplayConfig, std::string> getCurrentDisplayConfig()
125128
// clang-format on
126129
}
127130

128-
auto getTargetDevicesNames(DisplayConfig const& config) -> exp_ns::expected<std::vector<DISPLAYCONFIG_TARGET_DEVICE_NAME>, std::string>
131+
auto getDevicesPaths(DisplayConfig const& config) -> exp_ns::expected<std::vector<Path>, std::string>
129132
{
130-
auto& [paths, modes] = config;
133+
auto& [paths, _] = config;
131134

132135
// clang-format off
133136
auto r = paths | std::ranges::views::transform([](auto const& path)
134137
{
135-
//auto targetDeviceName = targetDeviceName(path);
136-
//auto adapterName = adapterName(path);
137-
138-
return targetDeviceName(path);
138+
return std::pair{targetDeviceName(path), adapterName(path)};
139139
});
140140

141-
auto const result = std::ranges::fold_left(std::move(r), exp_ns::expected<std::vector<DISPLAYCONFIG_TARGET_DEVICE_NAME>, std::string>{},
142-
[](auto&& result, auto element) -> exp_ns::expected<std::vector<DISPLAYCONFIG_TARGET_DEVICE_NAME>, std::string>
141+
auto const result = std::ranges::fold_left(std::move(r), exp_ns::expected<std::vector<Path>, std::string>{},
142+
[](auto&& result, auto element) -> exp_ns::expected<std::vector<Path>, std::string>
143143
{
144144
if (!result) {
145145
return exp_ns::unexpected(result.error());
146146
}
147147

148-
if (!element) {
149-
return exp_ns::unexpected(element.error());
148+
if (!element.first) {
149+
return exp_ns::unexpected(element.first.error());
150+
}
151+
152+
if (!element.second) {
153+
return exp_ns::unexpected(element.second.error());
150154
}
151155

152-
result.value().push_back(element.value());
156+
result.value().push_back(Path{std::move(element).first.value(), std::move(element).second.value()});
153157
return std::move(result);
154158
});
155159
// clang-format on
@@ -197,7 +201,7 @@ TEST_CASE("Create an adapter mode list", "[morpheus.core.gfx.gl.wgl.adapter_list
197201
*/
198202
DISPLAYCONFIG_PATH_SOURCE_INFO* pSource = NULL; // will contain the answer
199203

200-
auto result = getCurrentDisplayConfig().and_then([](DisplayConfig const& config) { return getTargetDevicesNames(config); });
204+
auto result = getCurrentDisplayConfig().and_then([](DisplayConfig const& config) { return getDevicesPaths(config); });
201205

202206
auto result4 = getCurrentDisplayConfig();
203207
REQUIRE(result4);

0 commit comments

Comments
 (0)