42void getProcAddressSafe(QOpenGLContext *context,
const char *funcName, FuncType &func)
90 throw EGLException(
"the context is not OpenGL ES");
93 PFNEGLQUERYSTRINGPROC queryString =
nullptr;
94 getProcAddressSafe(
context,
"eglQueryString", queryString);
96 const char* client_extensions = queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
99 if (!extensions.contains(
"EGL_ANGLE_platform_angle_d3d") ||
100 !extensions.contains(
"EGL_ANGLE_device_creation_d3d11")) {
102 throw EGLException(
"the context is not Angle + D3D11");
105 PFNEGLQUERYDISPLAYATTRIBEXTPROC queryDisplayAttribEXT =
nullptr;
106 PFNEGLQUERYDEVICEATTRIBEXTPROC queryDeviceAttribEXT =
nullptr;
108 getProcAddressSafe(
context,
"eglQueryDisplayAttribEXT", queryDisplayAttribEXT);
109 getProcAddressSafe(
context,
"eglQueryDeviceAttribEXT", queryDeviceAttribEXT);
111 QPlatformNativeInterface *nativeInterface = qGuiApp->platformNativeInterface();
112 EGLDisplay display =
reinterpret_cast<EGLDisplay
>(nativeInterface->nativeResourceForContext(
"egldisplay",
context));
116 QString(
"couldn't request EGLDisplay handle, display = 0x%1").arg(uintptr_t(display), 0, 16));
120 EGLBoolean result =
false;
122 result = queryDisplayAttribEXT(display, EGL_DEVICE_EXT, &
value);
124 if (!result ||
value == EGL_NONE) {
126 QString(
"couldn't request EGLDeviceEXT handle, result = 0x%1, value = 0x%2")
127 .arg(result, 0, 16).arg(
value, 0, 16));
130 EGLDeviceEXT device =
reinterpret_cast<EGLDeviceEXT
>(
value);
132 result = queryDeviceAttribEXT(device, EGL_D3D11_DEVICE_ANGLE, &
value);
134 if (!result ||
value == EGL_NONE) {
136 QString(
"couldn't request ID3D11Device pointer, result = 0x%1, value = 0x%2")
137 .arg(result, 0, 16).arg(
value, 0, 16));
139 ID3D11Device *deviceD3D =
reinterpret_cast<ID3D11Device*
>(
value);
144 Microsoft::WRL::ComPtr<IDXGIDevice> dxgiDevice;
145 result = deviceD3D->QueryInterface(__uuidof(IDXGIDevice), (
void**)&dxgiDevice);
147 if (FAILED(result)) {
149 QString(
"couldn't request IDXGIDevice pointer, result = 0x%1").arg(result, 0, 16));
152 Microsoft::WRL::ComPtr<IDXGIAdapter1> dxgiAdapter;
153 result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter1), (
void**)&dxgiAdapter);
155 if (FAILED(result)) {
157 QString(
"couldn't request IDXGIAdapter1 pointer, result = 0x%1").arg(result, 0, 16));
160 this->dxgiAdapter = dxgiAdapter;
164 throw EGLException(
"current platform doesn't support fetching display information");
167 }
catch (EGLException &e) {
171 this->dxgiAdapter.Reset();
196 QPlatformNativeInterface *nativeInterface = qGuiApp->platformNativeInterface();
197 HMONITOR monitor =
reinterpret_cast<HMONITOR
>(nativeInterface->nativeResourceForScreen(
"handle", screen));
200 Microsoft::WRL::ComPtr<IDXGIOutput> currentOutput;
202 while (
m_d->dxgiAdapter->EnumOutputs(i, ¤tOutput) != DXGI_ERROR_NOT_FOUND)
206 Microsoft::WRL::ComPtr<IDXGIOutput6> output6;
207 result = currentOutput.As(&output6);
210 DXGI_OUTPUT_DESC1 desc;
211 result = output6->GetDesc1(&desc);
213 if (desc.Monitor == monitor) {
230 if (desc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709) {
232 }
else if (desc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709) {
236 qWarning(
"WARNING: scRGB display color space is not supported by Qt's build");
238 }
else if (desc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) {
242 qWarning(
"WARNING: bt2020-pq display color space is not supported by Qt's build");
245 qWarning(
"WARNING: unknown display color space! 0x%X", desc.ColorSpace);