@@ -1071,46 +1071,48 @@ void D3D12HDR::CheckDisplayHDRSupport()
10711071 // intersection with the app window bounds. Then, use the DXGI output found in previous step to determine if the
10721072 // app is on a HDR capable display.
10731073
1074- // Retrieve the current default adapter.
1075- ComPtr<IDXGIAdapter1> dxgiAdapter;
1076- ThrowIfFailed (m_dxgiFactory->EnumAdapters1 (0 , &dxgiAdapter));
1077-
1078- // Iterate through the DXGI outputs associated with the DXGI adapter,
1079- // and find the output whose bounds have the greatest overlap with the
1080- // app window (i.e. the output for which the intersection area is the
1081- // greatest).
1082-
1083- UINT i = 0 ;
1074+ UINT adapterI = 0 ;
10841075 ComPtr<IDXGIOutput> currentOutput;
10851076 ComPtr<IDXGIOutput> bestOutput;
10861077 float bestIntersectArea = -1 ;
10871078
1088- while (dxgiAdapter->EnumOutputs (i, ¤tOutput) != DXGI_ERROR_NOT_FOUND)
1089- {
1090- // Get the retangle bounds of the app window
1091- int ax1 = m_windowBounds.left ;
1092- int ay1 = m_windowBounds.top ;
1093- int ax2 = m_windowBounds.right ;
1094- int ay2 = m_windowBounds.bottom ;
1095-
1096- // Get the rectangle bounds of current output
1097- DXGI_OUTPUT_DESC desc;
1098- ThrowIfFailed (currentOutput->GetDesc (&desc));
1099- RECT r = desc.DesktopCoordinates ;
1100- int bx1 = r.left ;
1101- int by1 = r.top ;
1102- int bx2 = r.right ;
1103- int by2 = r.bottom ;
1104-
1105- // Compute the intersection
1106- int intersectArea = ComputeIntersectionArea (ax1, ay1, ax2, ay2, bx1, by1, bx2, by2);
1107- if (intersectArea > bestIntersectArea)
1079+ // Iterate through all adapters
1080+ ComPtr<IDXGIAdapter1> dxgiAdapter;
1081+ while (m_dxgiFactory->EnumAdapters1 (adapterI, &dxgiAdapter) == S_OK) {
1082+ // Iterate through the DXGI outputs associated with the DXGI adapter,
1083+ // and find the output whose bounds have the greatest overlap with the
1084+ // app window (i.e. the output for which the intersection area is the
1085+ // greatest).
1086+
1087+ UINT outputI = 0 ;
1088+ while (dxgiAdapter->EnumOutputs (outputI, ¤tOutput) != DXGI_ERROR_NOT_FOUND)
11081089 {
1109- bestOutput = currentOutput;
1110- bestIntersectArea = static_cast <float >(intersectArea);
1111- }
1090+ // Get the retangle bounds of the app window
1091+ int ax1 = m_windowBounds.left ;
1092+ int ay1 = m_windowBounds.top ;
1093+ int ax2 = m_windowBounds.right ;
1094+ int ay2 = m_windowBounds.bottom ;
1095+
1096+ // Get the rectangle bounds of current output
1097+ DXGI_OUTPUT_DESC desc;
1098+ ThrowIfFailed (currentOutput->GetDesc (&desc));
1099+ RECT r = desc.DesktopCoordinates ;
1100+ int bx1 = r.left ;
1101+ int by1 = r.top ;
1102+ int bx2 = r.right ;
1103+ int by2 = r.bottom ;
1104+
1105+ // Compute the intersection
1106+ int intersectArea = ComputeIntersectionArea (ax1, ay1, ax2, ay2, bx1, by1, bx2, by2);
1107+ if (intersectArea > bestIntersectArea)
1108+ {
1109+ bestOutput = currentOutput;
1110+ bestIntersectArea = static_cast <float >(intersectArea);
1111+ }
11121112
1113- i++;
1113+ outputI++;
1114+ }
1115+ adapterI++;
11141116 }
11151117
11161118 // Having determined the output (display) upon which the app is primarily being
0 commit comments