| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #include "qtdiag.h" |
| 5 | |
| 6 | #include <QtGui/QGuiApplication> |
| 7 | #include <QtGui/QStyleHints> |
| 8 | #include <QtGui/QScreen> |
| 9 | #include <QtGui/QFont> |
| 10 | #include <QtGui/QFontDatabase> |
| 11 | #include <QtGui/QPalette> |
| 12 | #ifndef QT_NO_OPENGL |
| 13 | # include <QtGui/QOpenGLContext> |
| 14 | # include <QtGui/QOpenGLFunctions> |
| 15 | # include <QtOpenGL/QOpenGLVersionProfile> |
| 16 | # include <QtOpenGL/QOpenGLVersionFunctions> |
| 17 | # include <QtOpenGL/QOpenGLVersionFunctionsFactory> |
| 18 | #endif // QT_NO_OPENGL |
| 19 | #if QT_CONFIG(vulkan) |
| 20 | # include <QtGui/QVulkanInstance> |
| 21 | # include <QtGui/QVulkanWindow> |
| 22 | #endif // vulkan |
| 23 | #include <QtGui/QWindow> |
| 24 | #include <QtGui/QInputDevice> |
| 25 | |
| 26 | #ifdef NETWORK_DIAG |
| 27 | # include <QSslSocket> |
| 28 | #endif |
| 29 | |
| 30 | #include <QtCore/QLibraryInfo> |
| 31 | #include <QtCore/QStringList> |
| 32 | #include <QtCore/QVariant> |
| 33 | #include <QtCore/QSysInfo> |
| 34 | #include <QtCore/QLibraryInfo> |
| 35 | #if QT_CONFIG(processenvironment) |
| 36 | # include <QtCore/QProcessEnvironment> |
| 37 | #endif |
| 38 | #include <QtCore/QTextStream> |
| 39 | #include <QtCore/QStandardPaths> |
| 40 | #include <QtCore/QDir> |
| 41 | #include <QtCore/QFileSelector> |
| 42 | #include <QtCore/QDebug> |
| 43 | #include <QtCore/QVersionNumber> |
| 44 | |
| 45 | #include <private/qsimd_p.h> |
| 46 | #include <private/qguiapplication_p.h> |
| 47 | #include <qpa/qplatformintegration.h> |
| 48 | #include <qpa/qplatformscreen.h> |
| 49 | #include <qpa/qplatformtheme.h> |
| 50 | #include <qpa/qplatformthemefactory_p.h> |
| 51 | #include <qpa/qplatformintegration.h> |
| 52 | #include <private/qhighdpiscaling_p.h> |
| 53 | |
| 54 | #include <QtGui/QOffscreenSurface> |
| 55 | #include <rhi/qrhi.h> |
| 56 | |
| 57 | #ifdef QT_WIDGETS_LIB |
| 58 | # include <QtWidgets/QStyleFactory> |
| 59 | #endif |
| 60 | |
| 61 | #include <algorithm> |
| 62 | |
| 63 | QT_BEGIN_NAMESPACE |
| 64 | |
| 65 | QTextStream &operator<<(QTextStream &str, const QSize &s) |
| 66 | { |
| 67 | str << s.width() << 'x' << s.height(); |
| 68 | return str; |
| 69 | } |
| 70 | |
| 71 | QTextStream &operator<<(QTextStream &str, const QSizeF &s) |
| 72 | { |
| 73 | str << s.width() << 'x' << s.height(); |
| 74 | return str; |
| 75 | } |
| 76 | |
| 77 | QTextStream &operator<<(QTextStream &str, const QDpi &d) |
| 78 | { |
| 79 | str << d.first << ',' << d.second; |
| 80 | return str; |
| 81 | } |
| 82 | |
| 83 | QTextStream &operator<<(QTextStream &str, const QRect &r) |
| 84 | { |
| 85 | str << r.size() << Qt::forcesign << r.x() << r.y() << Qt::noforcesign; |
| 86 | return str; |
| 87 | } |
| 88 | |
| 89 | QTextStream &operator<<(QTextStream &str, const QStringList &l) |
| 90 | { |
| 91 | for (int i = 0; i < l.size(); ++i) { |
| 92 | if (i) |
| 93 | str << ','; |
| 94 | str << l.at(i); |
| 95 | } |
| 96 | return str; |
| 97 | } |
| 98 | |
| 99 | QTextStream &operator<<(QTextStream &str, const QFont &f) |
| 100 | { |
| 101 | str << '"' << f.family() << "\" " << f.pointSize(); |
| 102 | return str; |
| 103 | } |
| 104 | |
| 105 | QTextStream &operator<<(QTextStream &str, QPlatformScreen::SubpixelAntialiasingType st) |
| 106 | { |
| 107 | static const char *enumValues[] = { |
| 108 | "Subpixel_None" , "Subpixel_RGB" , "Subpixel_BGR" , "Subpixel_VRGB" , "Subpixel_VBGR" |
| 109 | }; |
| 110 | str << (size_t(st) < sizeof(enumValues) / sizeof(enumValues[0]) |
| 111 | ? enumValues[st] : "<Unknown>" ); |
| 112 | return str; |
| 113 | } |
| 114 | |
| 115 | QTextStream &operator<<(QTextStream &str, const QRhiDriverInfo &info) |
| 116 | { |
| 117 | static const char *enumValues[] = { |
| 118 | "Unknown" , "Integrated" , "Discrete" , "External" , "Virtual" , "Cpu" |
| 119 | }; |
| 120 | str << "Device: " << info.deviceName |
| 121 | << " Device ID: 0x" << Qt::hex << info.deviceId |
| 122 | << " Vendor ID: 0x" << info.vendorId << Qt::dec |
| 123 | << " Device type: " << (size_t(info.deviceType) < sizeof(enumValues) / sizeof(enumValues[0]) |
| 124 | ? enumValues[info.deviceType] : "<Unknown>" ); |
| 125 | return str; |
| 126 | } |
| 127 | |
| 128 | #ifndef QT_NO_OPENGL |
| 129 | |
| 130 | QTextStream &operator<<(QTextStream &str, const QSurfaceFormat &format) |
| 131 | { |
| 132 | str << "Version: " << format.majorVersion() << '.' |
| 133 | << format.minorVersion() << " Profile: " << format.profile() |
| 134 | << " Swap behavior: " << format.swapBehavior() |
| 135 | << " Buffer size (RGB" ; |
| 136 | if (format.hasAlpha()) |
| 137 | str << 'A'; |
| 138 | str << "): " << format.redBufferSize() << ',' << format.greenBufferSize() |
| 139 | << ',' << format.blueBufferSize(); |
| 140 | if (format.hasAlpha()) |
| 141 | str << ',' << format.alphaBufferSize(); |
| 142 | if (const int dbs = format.depthBufferSize()) |
| 143 | str << " Depth buffer: " << dbs; |
| 144 | if (const int sbs = format.stencilBufferSize()) |
| 145 | str << " Stencil buffer: " << sbs; |
| 146 | const int samples = format.samples(); |
| 147 | if (samples > 0) |
| 148 | str << " Samples: " << samples; |
| 149 | return str; |
| 150 | } |
| 151 | |
| 152 | void dumpGlInfo(QTextStream &str, bool listExtensions) |
| 153 | { |
| 154 | QOpenGLContext context; |
| 155 | if (context.create()) { |
| 156 | # ifdef QT_OPENGL_DYNAMIC |
| 157 | str << "Dynamic GL " ; |
| 158 | # endif |
| 159 | switch (context.openGLModuleType()) { |
| 160 | case QOpenGLContext::LibGL: |
| 161 | str << "LibGL" ; |
| 162 | break; |
| 163 | case QOpenGLContext::LibGLES: |
| 164 | str << "LibGLES" ; |
| 165 | break; |
| 166 | } |
| 167 | QWindow window; |
| 168 | window.setSurfaceType(QSurface::OpenGLSurface); |
| 169 | window.create(); |
| 170 | context.makeCurrent(surface: &window); |
| 171 | QOpenGLFunctions functions(&context); |
| 172 | |
| 173 | str << " Vendor: " << reinterpret_cast<const char *>(functions.glGetString(GL_VENDOR)) |
| 174 | << "\nRenderer: " << reinterpret_cast<const char *>(functions.glGetString(GL_RENDERER)) |
| 175 | << "\nVersion: " << reinterpret_cast<const char *>(functions.glGetString(GL_VERSION)) |
| 176 | << "\nShading language: " << reinterpret_cast<const char *>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION)) |
| 177 | << "\nFormat: " << context.format(); |
| 178 | # if !QT_CONFIG(opengles2) |
| 179 | GLint majorVersion; |
| 180 | functions.glGetIntegerv(GL_MAJOR_VERSION, params: &majorVersion); |
| 181 | GLint minorVersion; |
| 182 | functions.glGetIntegerv(GL_MINOR_VERSION, params: &minorVersion); |
| 183 | const QByteArray openGlVersionFunctionsName = "QOpenGLFunctions_" |
| 184 | + QByteArray::number(majorVersion) + '_' + QByteArray::number(minorVersion); |
| 185 | str << "\nProfile: None (" << openGlVersionFunctionsName << ')'; |
| 186 | if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 1)) { |
| 187 | QOpenGLVersionProfile profile; |
| 188 | profile.setVersion(majorVersion, minorVersion); |
| 189 | profile.setProfile(QSurfaceFormat::CoreProfile); |
| 190 | if (auto f = QOpenGLVersionFunctionsFactory::get(versionProfile: profile, context: &context)) { |
| 191 | if (f->initializeOpenGLFunctions()) |
| 192 | str << ", Core (" << openGlVersionFunctionsName << "_Core)" ; |
| 193 | } |
| 194 | profile.setProfile(QSurfaceFormat::CompatibilityProfile); |
| 195 | if (auto f = QOpenGLVersionFunctionsFactory::get(versionProfile: profile, context: &context)) { |
| 196 | if (f->initializeOpenGLFunctions()) |
| 197 | str << ", Compatibility (" << openGlVersionFunctionsName << "_Compatibility)" ; |
| 198 | } |
| 199 | } |
| 200 | str << '\n'; |
| 201 | # endif // !QT_CONFIG(opengles2) |
| 202 | if (listExtensions) { |
| 203 | QByteArrayList extensionList = context.extensions().values(); |
| 204 | std::sort(first: extensionList.begin(), last: extensionList.end()); |
| 205 | str << " \nFound " << extensionList.size() << " extensions:\n" ; |
| 206 | for (const QByteArray &extension : std::as_const(t&: extensionList)) |
| 207 | str << " " << extension << '\n'; |
| 208 | } |
| 209 | } else { |
| 210 | str << "Unable to create an Open GL context.\n" ; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | #endif // !QT_NO_OPENGL |
| 215 | |
| 216 | #if QT_CONFIG(vulkan) |
| 217 | QVersionNumber vulkanVersion(uint32_t v) |
| 218 | { |
| 219 | return QVersionNumber(VK_VERSION_MAJOR(v), VK_VERSION_MINOR(v), VK_VERSION_PATCH(v)); |
| 220 | } |
| 221 | |
| 222 | void dumpVkInfo(QTextStream &str) |
| 223 | { |
| 224 | QVulkanInstance inst; |
| 225 | if (inst.create()) { |
| 226 | str << "Vulkan instance available\n" ; |
| 227 | str << "Supported instance extensions:\n" ; |
| 228 | for (const QVulkanExtension &ext : inst.supportedExtensions()) |
| 229 | str << " " << ext.name << ", version " << ext.version << "\n" ; |
| 230 | str << "Supported layers:\n" ; |
| 231 | for (const QVulkanLayer &layer : inst.supportedLayers()) |
| 232 | str << " " << layer.name << ", version " << layer.version |
| 233 | << ", spec version " << layer.specVersion.toString() |
| 234 | << ", " << layer.description << "\n" ; |
| 235 | // Show at least the available physical devices. Anything additional |
| 236 | // needs lots of initialization, or, if done through QVulkanWindow, an |
| 237 | // exposed window. None of these are very tempting right now. |
| 238 | str << "Available physical devices:\n" ; |
| 239 | QVulkanWindow window; |
| 240 | window.setVulkanInstance(&inst); |
| 241 | for (const VkPhysicalDeviceProperties &props : window.availablePhysicalDevices()) { |
| 242 | str << " API version " << vulkanVersion(v: props.apiVersion).toString() |
| 243 | << Qt::hex << ", vendor 0x" << props.vendorID |
| 244 | << ", device 0x" << props.deviceID << ", " << props.deviceName |
| 245 | << Qt::dec << ", type " << props.deviceType |
| 246 | << ", driver version " << vulkanVersion(v: props.driverVersion).toString(); |
| 247 | } |
| 248 | } else { |
| 249 | str << "Unable to create a Vulkan instance, error code is" << inst.errorCode() << "\n" ; |
| 250 | } |
| 251 | } |
| 252 | #endif // vulkan |
| 253 | |
| 254 | void dumpRhiBackendInfo(QTextStream &str, const char *name, QRhi::Implementation impl, QRhiInitParams *initParams) |
| 255 | { |
| 256 | struct RhiFeature { |
| 257 | const char *name; |
| 258 | QRhi::Feature val; |
| 259 | }; |
| 260 | const RhiFeature features[] = { |
| 261 | { .name: "MultisampleTexture" , .val: QRhi::MultisampleTexture }, |
| 262 | { .name: "MultisampleRenderBuffer" , .val: QRhi::MultisampleRenderBuffer }, |
| 263 | { .name: "DebugMarkers" , .val: QRhi::DebugMarkers }, |
| 264 | { .name: "Timestamps" , .val: QRhi::Timestamps }, |
| 265 | { .name: "Instancing" , .val: QRhi::Instancing }, |
| 266 | { .name: "CustomInstanceStepRate" , .val: QRhi::CustomInstanceStepRate }, |
| 267 | { .name: "PrimitiveRestart" , .val: QRhi::PrimitiveRestart }, |
| 268 | { .name: "NonDynamicUniformBuffers" , .val: QRhi::NonDynamicUniformBuffers }, |
| 269 | { .name: "NonFourAlignedEffectiveIndexBufferOffset" , .val: QRhi::NonFourAlignedEffectiveIndexBufferOffset }, |
| 270 | { .name: "NPOTTextureRepeat" , .val: QRhi::NPOTTextureRepeat }, |
| 271 | { .name: "RedOrAlpha8IsRed" , .val: QRhi::RedOrAlpha8IsRed }, |
| 272 | { .name: "ElementIndexUint" , .val: QRhi::ElementIndexUint }, |
| 273 | { .name: "Compute" , .val: QRhi::Compute }, |
| 274 | { .name: "WideLines" , .val: QRhi::WideLines }, |
| 275 | { .name: "VertexShaderPointSize" , .val: QRhi::VertexShaderPointSize }, |
| 276 | { .name: "BaseVertex" , .val: QRhi::BaseVertex }, |
| 277 | { .name: "BaseInstance" , .val: QRhi::BaseInstance }, |
| 278 | { .name: "TriangleFanTopology" , .val: QRhi::TriangleFanTopology }, |
| 279 | { .name: "ReadBackNonUniformBuffer" , .val: QRhi::ReadBackNonUniformBuffer }, |
| 280 | { .name: "ReadBackNonBaseMipLevel" , .val: QRhi::ReadBackNonBaseMipLevel }, |
| 281 | { .name: "TexelFetch" , .val: QRhi::TexelFetch }, |
| 282 | { .name: "RenderToNonBaseMipLevel" , .val: QRhi::RenderToNonBaseMipLevel }, |
| 283 | { .name: "IntAttributes" , .val: QRhi::IntAttributes }, |
| 284 | { .name: "ScreenSpaceDerivatives" , .val: QRhi::ScreenSpaceDerivatives }, |
| 285 | { .name: "ReadBackAnyTextureFormat" , .val: QRhi::ReadBackAnyTextureFormat }, |
| 286 | { .name: "PipelineCacheDataLoadSave" , .val: QRhi::PipelineCacheDataLoadSave }, |
| 287 | { .name: "ImageDataStride" , .val: QRhi::ImageDataStride }, |
| 288 | { .name: "RenderBufferImport" , .val: QRhi::RenderBufferImport }, |
| 289 | { .name: "ThreeDimensionalTextures" , .val: QRhi::ThreeDimensionalTextures }, |
| 290 | { .name: "RenderTo3DTextureSlice" , .val: QRhi::RenderTo3DTextureSlice }, |
| 291 | { .name: "TextureArrays" , .val: QRhi::TextureArrays }, |
| 292 | { .name: "Tessellation" , .val: QRhi::Tessellation }, |
| 293 | { .name: "GeometryShader" , .val: QRhi::GeometryShader }, |
| 294 | { .name: "TextureArrayRange" , .val: QRhi::TextureArrayRange }, |
| 295 | { .name: "NonFillPolygonMode" , .val: QRhi::NonFillPolygonMode }, |
| 296 | { .name: "OneDimensionalTextures" , .val: QRhi::OneDimensionalTextures }, |
| 297 | { .name: "OneDimensionalTextureMipmaps" , .val: QRhi::OneDimensionalTextureMipmaps }, |
| 298 | { .name: "HalfAttributes" , .val: QRhi::HalfAttributes }, |
| 299 | { .name: "RenderToOneDimensionalTexture" , .val: QRhi::RenderToOneDimensionalTexture }, |
| 300 | { .name: "ThreeDimensionalTextureMipmaps" , .val: QRhi::ThreeDimensionalTextureMipmaps }, |
| 301 | |
| 302 | { .name: nullptr, .val: QRhi::Feature(0) } |
| 303 | }; |
| 304 | struct RhiTextureFormat { |
| 305 | const char *name; |
| 306 | QRhiTexture::Format val; |
| 307 | }; |
| 308 | const RhiTextureFormat textureFormats[] = { |
| 309 | { .name: "RGBA8" , .val: QRhiTexture::RGBA8 }, |
| 310 | { .name: "BGRA8" , .val: QRhiTexture::BGRA8 }, |
| 311 | { .name: "R8" , .val: QRhiTexture::R8 }, |
| 312 | { .name: "RG8" , .val: QRhiTexture::RG8 }, |
| 313 | { .name: "R16" , .val: QRhiTexture::R16 }, |
| 314 | { .name: "RG16" , .val: QRhiTexture::RG16 }, |
| 315 | { .name: "RED_OR_ALPHA8" , .val: QRhiTexture::RED_OR_ALPHA8 }, |
| 316 | { .name: "RGBA16F" , .val: QRhiTexture::RGBA16F }, |
| 317 | { .name: "RGBA32F" , .val: QRhiTexture::RGBA32F }, |
| 318 | { .name: "R16F" , .val: QRhiTexture::R16F }, |
| 319 | { .name: "R32F" , .val: QRhiTexture::R32F }, |
| 320 | { .name: "RGB10A2" , .val: QRhiTexture::RGB10A2 }, |
| 321 | { .name: "D16" , .val: QRhiTexture::D16 }, |
| 322 | { .name: "D24" , .val: QRhiTexture::D24 }, |
| 323 | { .name: "D24S8" , .val: QRhiTexture::D24S8 }, |
| 324 | { .name: "D32F" , .val: QRhiTexture::D32F }, |
| 325 | { .name: "BC1" , .val: QRhiTexture::BC1 }, |
| 326 | { .name: "BC2" , .val: QRhiTexture::BC2 }, |
| 327 | { .name: "BC3" , .val: QRhiTexture::BC3 }, |
| 328 | { .name: "BC4" , .val: QRhiTexture::BC4 }, |
| 329 | { .name: "BC5" , .val: QRhiTexture::BC5 }, |
| 330 | { .name: "BC6H" , .val: QRhiTexture::BC6H }, |
| 331 | { .name: "BC7" , .val: QRhiTexture::BC7 }, |
| 332 | { .name: "ETC2_RGB8" , .val: QRhiTexture::ETC2_RGB8 }, |
| 333 | { .name: "ETC2_RGB8A1" , .val: QRhiTexture::ETC2_RGB8A1 }, |
| 334 | { .name: "ETC2_RGBA8" , .val: QRhiTexture::ETC2_RGBA8 }, |
| 335 | { .name: "ASTC_4x4" , .val: QRhiTexture::ASTC_4x4 }, |
| 336 | { .name: "ASTC_5x4" , .val: QRhiTexture::ASTC_5x4 }, |
| 337 | { .name: "ASTC_5x5" , .val: QRhiTexture::ASTC_5x5 }, |
| 338 | { .name: "ASTC_6x5" , .val: QRhiTexture::ASTC_6x5 }, |
| 339 | { .name: "ASTC_6x6" , .val: QRhiTexture::ASTC_6x6 }, |
| 340 | { .name: "ASTC_8x5" , .val: QRhiTexture::ASTC_8x5 }, |
| 341 | { .name: "ASTC_8x6" , .val: QRhiTexture::ASTC_8x6 }, |
| 342 | { .name: "ASTC_8x8" , .val: QRhiTexture::ASTC_8x8 }, |
| 343 | { .name: "ASTC_10x5" , .val: QRhiTexture::ASTC_10x5 }, |
| 344 | { .name: "ASTC_10x6" , .val: QRhiTexture::ASTC_10x6 }, |
| 345 | { .name: "ASTC_10x8" , .val: QRhiTexture::ASTC_10x8 }, |
| 346 | { .name: "ASTC_10x10" , .val: QRhiTexture::ASTC_10x10 }, |
| 347 | { .name: "ASTC_12x10" , .val: QRhiTexture::ASTC_12x10 }, |
| 348 | { .name: "ASTC_12x12" , .val: QRhiTexture::ASTC_12x12 }, |
| 349 | { .name: nullptr, .val: QRhiTexture::UnknownFormat } |
| 350 | }; |
| 351 | |
| 352 | QScopedPointer<QRhi> rhi(QRhi::create(impl, params: initParams, flags: QRhi::Flags(), importDevice: nullptr)); |
| 353 | if (rhi) { |
| 354 | str << name << ":\n" ; |
| 355 | str << " Driver Info: " << rhi->driverInfo() << "\n" ; |
| 356 | str << " Min Texture Size: " << rhi->resourceLimit(limit: QRhi::TextureSizeMin) << "\n" ; |
| 357 | str << " Max Texture Size: " << rhi->resourceLimit(limit: QRhi::TextureSizeMax) << "\n" ; |
| 358 | str << " Max Color Attachments: " << rhi->resourceLimit(limit: QRhi::MaxColorAttachments) << "\n" ; |
| 359 | str << " Frames in Flight: " << rhi->resourceLimit(limit: QRhi::FramesInFlight) << "\n" ; |
| 360 | str << " Async Readback Limit: " << rhi->resourceLimit(limit: QRhi::MaxAsyncReadbackFrames) << "\n" ; |
| 361 | str << " MaxThreadGroupsPerDimension: " << rhi->resourceLimit(limit: QRhi::MaxThreadGroupsPerDimension) << "\n" ; |
| 362 | str << " MaxThreadsPerThreadGroup: " << rhi->resourceLimit(limit: QRhi::MaxThreadsPerThreadGroup) << "\n" ; |
| 363 | str << " MaxThreadGroupX: " << rhi->resourceLimit(limit: QRhi::MaxThreadGroupX) << "\n" ; |
| 364 | str << " MaxThreadGroupY: " << rhi->resourceLimit(limit: QRhi::MaxThreadGroupY) << "\n" ; |
| 365 | str << " MaxThreadGroupZ: " << rhi->resourceLimit(limit: QRhi::MaxThreadGroupZ) << "\n" ; |
| 366 | str << " TextureArraySizeMax: " << rhi->resourceLimit(limit: QRhi::TextureArraySizeMax) << "\n" ; |
| 367 | str << " MaxUniformBufferRange: " << rhi->resourceLimit(limit: QRhi::MaxUniformBufferRange) << "\n" ; |
| 368 | str << " MaxVertexInputs: " << rhi->resourceLimit(limit: QRhi::MaxVertexInputs) << "\n" ; |
| 369 | str << " MaxVertexOutputs: " << rhi->resourceLimit(limit: QRhi::MaxVertexOutputs) << "\n" ; |
| 370 | str << " Uniform Buffer Alignment: " << rhi->ubufAlignment() << "\n" ; |
| 371 | QByteArrayList supportedSampleCounts; |
| 372 | for (int s : rhi->supportedSampleCounts()) |
| 373 | supportedSampleCounts << QByteArray::number(s); |
| 374 | str << " Supported MSAA sample counts: " << supportedSampleCounts.join(sep: ',') << "\n" ; |
| 375 | str << " Features:\n" ; |
| 376 | for (int i = 0; features[i].name; i++) { |
| 377 | str << " " << (rhi->isFeatureSupported(feature: features[i].val) ? "v" : "-" ) << " " << features[i].name << "\n" ; |
| 378 | } |
| 379 | str << " Texture formats:" ; |
| 380 | for (int i = 0; textureFormats[i].name; i++) { |
| 381 | if (rhi->isTextureFormatSupported(format: textureFormats[i].val)) |
| 382 | str << " " << textureFormats[i].name; |
| 383 | } |
| 384 | str << "\n" ; |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | void dumpRhiInfo(QTextStream &str) |
| 389 | { |
| 390 | str << "Qt Rendering Hardware Interface supported backends:\n" ; |
| 391 | |
| 392 | #if QT_CONFIG(opengl) |
| 393 | { |
| 394 | QRhiGles2InitParams params; |
| 395 | params.fallbackSurface = QRhiGles2InitParams::newFallbackSurface(); |
| 396 | dumpRhiBackendInfo(str, name: "OpenGL (with default QSurfaceFormat)" , impl: QRhi::OpenGLES2, initParams: ¶ms); |
| 397 | delete params.fallbackSurface; |
| 398 | } |
| 399 | #endif |
| 400 | |
| 401 | #if QT_CONFIG(vulkan) |
| 402 | { |
| 403 | QVulkanInstance vulkanInstance; |
| 404 | vulkanInstance.create(); |
| 405 | QRhiVulkanInitParams params; |
| 406 | params.inst = &vulkanInstance; |
| 407 | dumpRhiBackendInfo(str, name: "Vulkan" , impl: QRhi::Vulkan, initParams: ¶ms); |
| 408 | vulkanInstance.destroy(); |
| 409 | } |
| 410 | #endif |
| 411 | |
| 412 | #ifdef Q_OS_WIN |
| 413 | { |
| 414 | QRhiD3D11InitParams params; |
| 415 | dumpRhiBackendInfo(str, "Direct3D 11" , QRhi::D3D11, ¶ms); |
| 416 | } |
| 417 | { |
| 418 | QRhiD3D12InitParams params; |
| 419 | dumpRhiBackendInfo(str, "Direct3D 12" , QRhi::D3D12, ¶ms); |
| 420 | } |
| 421 | #endif |
| 422 | |
| 423 | #if defined(Q_OS_MACOS) || defined(Q_OS_IOS) |
| 424 | { |
| 425 | QRhiMetalInitParams params; |
| 426 | dumpRhiBackendInfo(str, "Metal" , QRhi::Metal, ¶ms); |
| 427 | } |
| 428 | #endif |
| 429 | } |
| 430 | |
| 431 | #define DUMP_CAPABILITY(str, integration, capability) \ |
| 432 | if (platformIntegration->hasCapability(QPlatformIntegration::capability)) \ |
| 433 | str << ' ' << #capability; |
| 434 | |
| 435 | // Dump values of QStandardPaths, indicate writable locations by asterisk. |
| 436 | static void dumpStandardLocation(QTextStream &str, QStandardPaths::StandardLocation location) |
| 437 | { |
| 438 | str << '"' << QStandardPaths::displayName(type: location) << '"'; |
| 439 | const QStringList directories = QStandardPaths::standardLocations(type: location); |
| 440 | const QString writableDirectory = QStandardPaths::writableLocation(type: location); |
| 441 | const int writableIndex = writableDirectory.isEmpty() ? -1 : directories.indexOf(str: writableDirectory); |
| 442 | for (int i = 0; i < directories.size(); ++i) { |
| 443 | str << ' '; |
| 444 | if (i == writableIndex) |
| 445 | str << '*'; |
| 446 | str << QDir::toNativeSeparators(pathName: directories.at(i)); |
| 447 | if (i == writableIndex) |
| 448 | str << '*'; |
| 449 | } |
| 450 | if (!writableDirectory.isEmpty() && writableIndex < 0) |
| 451 | str << " *" << QDir::toNativeSeparators(pathName: writableDirectory) << '*'; |
| 452 | } |
| 453 | |
| 454 | #define DUMP_CPU_FEATURE(feature, name) \ |
| 455 | if (qCpuHasFeature(feature)) \ |
| 456 | str << " " name |
| 457 | |
| 458 | #define DUMP_STANDARDPATH(str, location) \ |
| 459 | str << " " << #location << ": "; \ |
| 460 | dumpStandardLocation(str, QStandardPaths::location); \ |
| 461 | str << '\n'; |
| 462 | |
| 463 | #define DUMP_LIBRARYPATH(str, loc) \ |
| 464 | str << " " << #loc << ": " << QDir::toNativeSeparators(QLibraryInfo::path(QLibraryInfo::loc)) << '\n'; |
| 465 | |
| 466 | // Helper to format a type via QDebug to be used for QFlags/Q_ENUM. |
| 467 | template <class T> |
| 468 | static QString formatQDebug(T t) |
| 469 | { |
| 470 | QString result; |
| 471 | QDebug(&result) << t; |
| 472 | return result; |
| 473 | } |
| 474 | |
| 475 | // Helper to format a type via QDebug, stripping the class name. |
| 476 | template <class T> |
| 477 | static QString formatValueQDebug(T t) |
| 478 | { |
| 479 | QString result = formatQDebug(t).trimmed(); |
| 480 | if (result.endsWith(c: QLatin1Char(')'))) { |
| 481 | result.chop(n: 1); |
| 482 | result.remove(i: 0, len: result.indexOf(ch: QLatin1Char('(')) + 1); |
| 483 | } |
| 484 | return result; |
| 485 | } |
| 486 | |
| 487 | QTextStream &operator<<(QTextStream &str, const QPalette &palette) |
| 488 | { |
| 489 | for (int r = 0; r < int(QPalette::NColorRoles); ++r) { |
| 490 | const QPalette::ColorRole role = static_cast< QPalette::ColorRole>(r); |
| 491 | const QColor color = palette.color(cg: QPalette::Active, cr: role); |
| 492 | if (color.isValid()) |
| 493 | str << " " << formatValueQDebug(t: role) << ": " << color.name(format: QColor::HexArgb) << '\n'; |
| 494 | } |
| 495 | return str; |
| 496 | } |
| 497 | |
| 498 | static inline QByteArrayList qtFeatures() |
| 499 | { |
| 500 | QByteArrayList result; |
| 501 | #ifdef QT_NO_CLIPBOARD |
| 502 | result.append("QT_NO_CLIPBOARD" ); |
| 503 | #endif |
| 504 | #ifdef QT_NO_CONTEXTMENU |
| 505 | result.append("QT_NO_CONTEXTMENU" ); |
| 506 | #endif |
| 507 | #ifdef QT_NO_CURSOR |
| 508 | result.append("QT_NO_CURSOR" ); |
| 509 | #endif |
| 510 | #ifdef QT_NO_DRAGANDDROP |
| 511 | result.append("QT_NO_DRAGANDDROP" ); |
| 512 | #endif |
| 513 | #ifdef QT_NO_EXCEPTIONS |
| 514 | result.append(t: "QT_NO_EXCEPTIONS" ); |
| 515 | #endif |
| 516 | #ifdef QT_NO_LIBRARY |
| 517 | result.append("QT_NO_LIBRARY" ); |
| 518 | #endif |
| 519 | #ifdef QT_NO_NETWORK |
| 520 | result.append("QT_NO_NETWORK" ); |
| 521 | #endif |
| 522 | #ifdef QT_NO_OPENGL |
| 523 | result.append("QT_NO_OPENGL" ); |
| 524 | #endif |
| 525 | #ifdef QT_NO_OPENSSL |
| 526 | result.append("QT_NO_OPENSSL" ); |
| 527 | #endif |
| 528 | #ifdef QT_NO_PROCESS |
| 529 | result.append("QT_NO_PROCESS" ); |
| 530 | #endif |
| 531 | #ifdef QT_NO_PRINTER |
| 532 | result.append("QT_NO_PRINTER" ); |
| 533 | #endif |
| 534 | #ifdef QT_NO_SESSIONMANAGER |
| 535 | result.append("QT_NO_SESSIONMANAGER" ); |
| 536 | #endif |
| 537 | #ifdef QT_NO_SETTINGS |
| 538 | result.append("QT_NO_SETTINGS" ); |
| 539 | #endif |
| 540 | #ifdef QT_NO_SHORTCUT |
| 541 | result.append("QT_NO_SHORTCUT" ); |
| 542 | #endif |
| 543 | #ifdef QT_NO_SYSTEMTRAYICON |
| 544 | result.append("QT_NO_SYSTEMTRAYICON" ); |
| 545 | #endif |
| 546 | #ifdef QT_NO_QTHREAD |
| 547 | result.append("QT_NO_QTHREAD" ); |
| 548 | #endif |
| 549 | #ifdef QT_NO_WHATSTHIS |
| 550 | result.append("QT_NO_WHATSTHIS" ); |
| 551 | #endif |
| 552 | #ifdef QT_NO_WIDGETS |
| 553 | result.append("QT_NO_WIDGETS" ); |
| 554 | #endif |
| 555 | #ifdef QT_NO_ZLIB |
| 556 | result.append("QT_NO_ZLIB" ); |
| 557 | #endif |
| 558 | return result; |
| 559 | } |
| 560 | |
| 561 | QString qtDiag(unsigned flags) |
| 562 | { |
| 563 | QString result; |
| 564 | QTextStream str(&result); |
| 565 | |
| 566 | const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); |
| 567 | str << QLibraryInfo::build() << " on \"" << QGuiApplication::platformName() << "\" " |
| 568 | << '\n' |
| 569 | << "OS: " << QSysInfo::prettyProductName() |
| 570 | << " [" << QSysInfo::kernelType() << " version " << QSysInfo::kernelVersion() << "]\n" ; |
| 571 | |
| 572 | str << "\nArchitecture: " << QSysInfo::currentCpuArchitecture() << "; features:" ; |
| 573 | #if defined(Q_PROCESSOR_X86) |
| 574 | DUMP_CPU_FEATURE(HYBRID, "hybrid" ); |
| 575 | DUMP_CPU_FEATURE(SSE2, "SSE2" ); |
| 576 | DUMP_CPU_FEATURE(SSE3, "SSE3" ); |
| 577 | DUMP_CPU_FEATURE(SSSE3, "SSSE3" ); |
| 578 | DUMP_CPU_FEATURE(SSE4_1, "SSE4.1" ); |
| 579 | DUMP_CPU_FEATURE(SSE4_2, "SSE4.2" ); |
| 580 | DUMP_CPU_FEATURE(AVX, "AVX" ); |
| 581 | DUMP_CPU_FEATURE(AVX2, "AVX2" ); |
| 582 | DUMP_CPU_FEATURE(AVX512F, "AVX512F" ); |
| 583 | DUMP_CPU_FEATURE(AVX512IFMA, "AVX512IFMA" ); |
| 584 | DUMP_CPU_FEATURE(AVX512VBMI2, "AVX512VBMI2" ); |
| 585 | DUMP_CPU_FEATURE(AVX512FP16, "AVX512FP16" ); |
| 586 | DUMP_CPU_FEATURE(RDRND, "RDRAND" ); |
| 587 | DUMP_CPU_FEATURE(RDSEED, "RDSEED" ); |
| 588 | DUMP_CPU_FEATURE(AES, "AES" ); |
| 589 | DUMP_CPU_FEATURE(VAES, "VAES" ); |
| 590 | DUMP_CPU_FEATURE(SHA, "SHA" ); |
| 591 | #elif defined(Q_PROCESSOR_ARM) |
| 592 | DUMP_CPU_FEATURE(ARM_NEON, "Neon" ); |
| 593 | #elif defined(Q_PROCESSOR_MIPS) |
| 594 | DUMP_CPU_FEATURE(DSP, "DSP" ); |
| 595 | DUMP_CPU_FEATURE(DSPR2, "DSPR2" ); |
| 596 | #endif |
| 597 | str << '\n'; |
| 598 | |
| 599 | #if QT_CONFIG(process) |
| 600 | const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment(); |
| 601 | str << "\nEnvironment:\n" ; |
| 602 | const QStringList keys = systemEnvironment.keys(); |
| 603 | for (const QString &key : keys) { |
| 604 | if (key.size() < 2 || !key.startsWith(c: QLatin1Char('Q'))) |
| 605 | continue; |
| 606 | if (key.at(i: 1) == 'T' || key.at(i: 1) == '_') |
| 607 | str << " " << key << "=\"" << systemEnvironment.value(name: key) << "\"\n" ; |
| 608 | } |
| 609 | #endif // QT_CONFIG(process) |
| 610 | |
| 611 | const QByteArrayList features = qtFeatures(); |
| 612 | if (!features.isEmpty()) |
| 613 | str << "\nFeatures: " << features.join(sep: ' ') << '\n'; |
| 614 | |
| 615 | str << "\nLibrary info:\n" ; |
| 616 | DUMP_LIBRARYPATH(str, PrefixPath) |
| 617 | DUMP_LIBRARYPATH(str, DocumentationPath) |
| 618 | DUMP_LIBRARYPATH(str, HeadersPath) |
| 619 | DUMP_LIBRARYPATH(str, LibrariesPath) |
| 620 | DUMP_LIBRARYPATH(str, LibraryExecutablesPath) |
| 621 | DUMP_LIBRARYPATH(str, BinariesPath) |
| 622 | DUMP_LIBRARYPATH(str, PluginsPath) |
| 623 | DUMP_LIBRARYPATH(str, QmlImportsPath) |
| 624 | DUMP_LIBRARYPATH(str, ArchDataPath) |
| 625 | DUMP_LIBRARYPATH(str, DataPath) |
| 626 | DUMP_LIBRARYPATH(str, TranslationsPath) |
| 627 | DUMP_LIBRARYPATH(str, ExamplesPath) |
| 628 | DUMP_LIBRARYPATH(str, TestsPath) |
| 629 | DUMP_LIBRARYPATH(str, SettingsPath) |
| 630 | |
| 631 | str << "\nStandard paths [*...* denote writable entry]:\n" ; |
| 632 | DUMP_STANDARDPATH(str, DesktopLocation) |
| 633 | DUMP_STANDARDPATH(str, DocumentsLocation) |
| 634 | DUMP_STANDARDPATH(str, FontsLocation) |
| 635 | DUMP_STANDARDPATH(str, ApplicationsLocation) |
| 636 | DUMP_STANDARDPATH(str, MusicLocation) |
| 637 | DUMP_STANDARDPATH(str, MoviesLocation) |
| 638 | DUMP_STANDARDPATH(str, PicturesLocation) |
| 639 | DUMP_STANDARDPATH(str, TempLocation) |
| 640 | DUMP_STANDARDPATH(str, HomeLocation) |
| 641 | DUMP_STANDARDPATH(str, AppLocalDataLocation) |
| 642 | DUMP_STANDARDPATH(str, CacheLocation) |
| 643 | DUMP_STANDARDPATH(str, GenericDataLocation) |
| 644 | DUMP_STANDARDPATH(str, RuntimeLocation) |
| 645 | DUMP_STANDARDPATH(str, ConfigLocation) |
| 646 | DUMP_STANDARDPATH(str, DownloadLocation) |
| 647 | DUMP_STANDARDPATH(str, GenericCacheLocation) |
| 648 | DUMP_STANDARDPATH(str, GenericConfigLocation) |
| 649 | DUMP_STANDARDPATH(str, AppDataLocation) |
| 650 | DUMP_STANDARDPATH(str, AppConfigLocation) |
| 651 | |
| 652 | str << "\nFile selectors (increasing order of precedence):\n " ; |
| 653 | const QStringList allSelectors = QFileSelector().allSelectors(); |
| 654 | for (const QString &s : allSelectors) |
| 655 | str << ' ' << s; |
| 656 | |
| 657 | str << "\n\nNetwork:\n " ; |
| 658 | #ifdef NETWORK_DIAG |
| 659 | # ifndef QT_NO_SSL |
| 660 | if (QSslSocket::supportsSsl()) { |
| 661 | str << "Using \"" << QSslSocket::sslLibraryVersionString() << "\", version: 0x" |
| 662 | << Qt::hex << QSslSocket::sslLibraryVersionNumber() << Qt::dec; |
| 663 | } else { |
| 664 | str << "\nSSL is not supported." ; |
| 665 | } |
| 666 | # else // !QT_NO_SSL |
| 667 | str << "SSL is not available." ; |
| 668 | # endif // QT_NO_SSL |
| 669 | #else |
| 670 | str << "Qt Network module is not available." ; |
| 671 | #endif // NETWORK_DIAG |
| 672 | |
| 673 | str << "\n\nPlatform capabilities:" ; |
| 674 | DUMP_CAPABILITY(str, platformIntegration, ThreadedPixmaps) |
| 675 | DUMP_CAPABILITY(str, platformIntegration, OpenGL) |
| 676 | DUMP_CAPABILITY(str, platformIntegration, ThreadedOpenGL) |
| 677 | DUMP_CAPABILITY(str, platformIntegration, SharedGraphicsCache) |
| 678 | DUMP_CAPABILITY(str, platformIntegration, BufferQueueingOpenGL) |
| 679 | DUMP_CAPABILITY(str, platformIntegration, WindowMasks) |
| 680 | DUMP_CAPABILITY(str, platformIntegration, MultipleWindows) |
| 681 | DUMP_CAPABILITY(str, platformIntegration, ApplicationState) |
| 682 | DUMP_CAPABILITY(str, platformIntegration, ForeignWindows) |
| 683 | DUMP_CAPABILITY(str, platformIntegration, NonFullScreenWindows) |
| 684 | DUMP_CAPABILITY(str, platformIntegration, NativeWidgets) |
| 685 | DUMP_CAPABILITY(str, platformIntegration, WindowManagement) |
| 686 | DUMP_CAPABILITY(str, platformIntegration, SyncState) |
| 687 | DUMP_CAPABILITY(str, platformIntegration, RasterGLSurface) |
| 688 | DUMP_CAPABILITY(str, platformIntegration, AllGLFunctionsQueryable) |
| 689 | DUMP_CAPABILITY(str, platformIntegration, ApplicationIcon) |
| 690 | DUMP_CAPABILITY(str, platformIntegration, SwitchableWidgetComposition) |
| 691 | str << '\n'; |
| 692 | |
| 693 | const QStyleHints *styleHints = QGuiApplication::styleHints(); |
| 694 | const QChar passwordMaskCharacter = styleHints->passwordMaskCharacter(); |
| 695 | str << "\nStyle hints:\n mouseDoubleClickInterval: " << styleHints->mouseDoubleClickInterval() << '\n' |
| 696 | << " mousePressAndHoldInterval: " << styleHints->mousePressAndHoldInterval() << '\n' |
| 697 | << " startDragDistance: " << styleHints->startDragDistance() << '\n' |
| 698 | << " startDragTime: " << styleHints->startDragTime() << '\n' |
| 699 | << " startDragVelocity: " << styleHints->startDragVelocity() << '\n' |
| 700 | << " keyboardInputInterval: " << styleHints->keyboardInputInterval() << '\n' |
| 701 | << " keyboardAutoRepeatRateF: " << styleHints->keyboardAutoRepeatRateF() << '\n' |
| 702 | << " cursorFlashTime: " << styleHints->cursorFlashTime() << '\n' |
| 703 | << " showIsFullScreen: " << styleHints->showIsFullScreen() << '\n' |
| 704 | << " showIsMaximized: " << styleHints->showIsMaximized() << '\n' |
| 705 | << " passwordMaskDelay: " << styleHints->passwordMaskDelay() << '\n' |
| 706 | << " passwordMaskCharacter: " ; |
| 707 | const int passwordMaskCharacterUc = passwordMaskCharacter.unicode(); |
| 708 | if (passwordMaskCharacterUc >= 32 && passwordMaskCharacterUc < 128) { |
| 709 | str << '\'' << passwordMaskCharacter << '\''; |
| 710 | } else { |
| 711 | str << "U+" << qSetFieldWidth(width: 4) << qSetPadChar(ch: '0') << Qt::uppercasedigits << Qt::hex |
| 712 | << passwordMaskCharacterUc << Qt::dec << qSetFieldWidth(width: 0); |
| 713 | } |
| 714 | str << '\n' |
| 715 | << " fontSmoothingGamma: " << styleHints->fontSmoothingGamma() << '\n' |
| 716 | << " useRtlExtensions: " << styleHints->useRtlExtensions() << '\n' |
| 717 | << " setFocusOnTouchRelease: " << styleHints->setFocusOnTouchRelease() << '\n' |
| 718 | << " tabFocusBehavior: " << formatQDebug(t: styleHints->tabFocusBehavior()) << '\n' |
| 719 | << " singleClickActivation: " << styleHints->singleClickActivation() << '\n'; |
| 720 | str << "\nAdditional style hints (QPlatformIntegration):\n" |
| 721 | << " ReplayMousePressOutsidePopup: " |
| 722 | << platformIntegration->styleHint(hint: QPlatformIntegration::ReplayMousePressOutsidePopup).toBool() << '\n'; |
| 723 | |
| 724 | const QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme(); |
| 725 | str << "\nTheme:" |
| 726 | "\n Platforms requested : " << platformIntegration->themeNames() |
| 727 | << "\n available : " << QPlatformThemeFactory::keys() |
| 728 | #ifdef QT_WIDGETS_LIB |
| 729 | << "\n Styles requested : " << platformTheme->themeHint(hint: QPlatformTheme::StyleNames).toStringList() |
| 730 | << "\n available : " << QStyleFactory::keys() |
| 731 | #endif |
| 732 | ; |
| 733 | const QString iconTheme = platformTheme->themeHint(hint: QPlatformTheme::SystemIconThemeName).toString(); |
| 734 | if (!iconTheme.isEmpty()) { |
| 735 | str << "\n Icon theme : " << iconTheme |
| 736 | << ", " << platformTheme->themeHint(hint: QPlatformTheme::SystemIconFallbackThemeName).toString() |
| 737 | << " from " << platformTheme->themeHint(hint: QPlatformTheme::IconThemeSearchPaths).toStringList(); |
| 738 | } |
| 739 | if (const QFont *systemFont = platformTheme->font()) |
| 740 | str << "\n System font : " << *systemFont<< '\n'; |
| 741 | |
| 742 | if (platformTheme->usePlatformNativeDialog(type: QPlatformTheme::FileDialog)) |
| 743 | str << " Native file dialog\n" ; |
| 744 | if (platformTheme->usePlatformNativeDialog(type: QPlatformTheme::ColorDialog)) |
| 745 | str << " Native color dialog\n" ; |
| 746 | if (platformTheme->usePlatformNativeDialog(type: QPlatformTheme::FontDialog)) |
| 747 | str << " Native font dialog\n" ; |
| 748 | if (platformTheme->usePlatformNativeDialog(type: QPlatformTheme::MessageDialog)) |
| 749 | str << " Native message dialog\n" ; |
| 750 | |
| 751 | str << "\nFonts:\n General font : " << QFontDatabase::systemFont(type: QFontDatabase::GeneralFont) << '\n' |
| 752 | << " Fixed font : " << QFontDatabase::systemFont(type: QFontDatabase::FixedFont) << '\n' |
| 753 | << " Title font : " << QFontDatabase::systemFont(type: QFontDatabase::TitleFont) << '\n' |
| 754 | << " Smallest font: " << QFontDatabase::systemFont(type: QFontDatabase::SmallestReadableFont) << '\n'; |
| 755 | if (flags & QtDiagFonts) { |
| 756 | const QStringList families = QFontDatabase::families(); |
| 757 | str << "\n Families (" << families.size() << "):\n" ; |
| 758 | for (int i = 0, count = families.size(); i < count; ++i) |
| 759 | str << " " << families.at(i) << '\n'; |
| 760 | |
| 761 | const QList<int> standardSizes = QFontDatabase::standardSizes(); |
| 762 | str << "\n Standard Sizes:" ; |
| 763 | for (int i = 0, count = standardSizes.size(); i < count; ++i) |
| 764 | str << ' ' << standardSizes.at(i); |
| 765 | QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase::writingSystems(); |
| 766 | str << "\n\n Writing systems:\n" ; |
| 767 | for (int i = 0, count = writingSystems.size(); i < count; ++i) |
| 768 | str << " " << formatValueQDebug(t: writingSystems.at(i)) << '\n'; |
| 769 | } |
| 770 | |
| 771 | str << "\nPalette:\n" << QGuiApplication::palette(); |
| 772 | |
| 773 | const QList<QScreen*> screens = QGuiApplication::screens(); |
| 774 | const int screenCount = screens.size(); |
| 775 | str << "\nScreens: " << screenCount << ", High DPI scaling: " |
| 776 | << (QHighDpiScaling::isActive() ? "active" : "inactive" ) << '\n'; |
| 777 | for (int s = 0; s < screenCount; ++s) { |
| 778 | const QScreen *screen = screens.at(i: s); |
| 779 | const QPlatformScreen *platformScreen = screen->handle(); |
| 780 | const QRect geometry = screen->geometry(); |
| 781 | const QDpi dpi(screen->logicalDotsPerInchX(), screen->logicalDotsPerInchY()); |
| 782 | const QDpi nativeDpi = platformScreen->logicalDpi(); |
| 783 | const QRect nativeGeometry = platformScreen->geometry(); |
| 784 | str << '#' << ' ' << s << " \"" << screen->name() << '"' |
| 785 | << " Depth: " << screen->depth() |
| 786 | << " Primary: " << (screen == QGuiApplication::primaryScreen() ? "yes" : "no" ) |
| 787 | << "\n Manufacturer: " << screen->manufacturer() |
| 788 | << "\n Model: " << screen->model() |
| 789 | << "\n Serial number: " << screen->serialNumber() |
| 790 | << "\n Geometry: " << geometry; |
| 791 | if (geometry != nativeGeometry) |
| 792 | str << " (native: " << nativeGeometry << ')'; |
| 793 | str << " Available: " << screen->availableGeometry(); |
| 794 | if (geometry != screen->virtualGeometry()) |
| 795 | str << "\n Virtual geometry: " << screen->virtualGeometry() << " Available: " << screen->availableVirtualGeometry(); |
| 796 | if (screen->virtualSiblings().size() > 1) |
| 797 | str << "\n " << screen->virtualSiblings().size() << " virtual siblings" ; |
| 798 | str << "\n Physical size: " << screen->physicalSize() << " mm" |
| 799 | << " Refresh: " << screen->refreshRate() << " Hz" |
| 800 | << " Power state: " << platformScreen->powerState(); |
| 801 | str << "\n Physical DPI: " << screen->physicalDotsPerInchX() |
| 802 | << ',' << screen->physicalDotsPerInchY() |
| 803 | << " Logical DPI: " << dpi; |
| 804 | if (dpi != nativeDpi) |
| 805 | str << " (native: " << nativeDpi << ')'; |
| 806 | str << ' ' << platformScreen->subpixelAntialiasingTypeHint() << "\n " ; |
| 807 | if (QHighDpiScaling::isActive()) |
| 808 | str << "High DPI scaling factor: " << QHighDpiScaling::factor(context: screen) << ' '; |
| 809 | str << "DevicePixelRatio: " << screen->devicePixelRatio(); |
| 810 | str << "\n Primary orientation: " << screen->primaryOrientation() |
| 811 | << " Orientation: " << screen->orientation() |
| 812 | << " Native orientation: " << screen->nativeOrientation() |
| 813 | << "\n\n" ; |
| 814 | } |
| 815 | |
| 816 | const auto inputDevices = QInputDevice::devices(); |
| 817 | if (!inputDevices.isEmpty()) { |
| 818 | str << "Input devices: " << inputDevices.size() << '\n'; |
| 819 | for (auto device : inputDevices) { |
| 820 | str << " " << formatValueQDebug(t: device->type()) |
| 821 | << " \"" << device->name() << "\"," ; |
| 822 | if (!device->seatName().isEmpty()) |
| 823 | str << " seat: \"" << device->seatName() << '"'; |
| 824 | str << " capabilities:" ; |
| 825 | const auto capabilities = device->capabilities(); |
| 826 | if (capabilities.testFlag(flag: QInputDevice::Capability::Position)) |
| 827 | str << " Position" ; |
| 828 | if (capabilities.testFlag(flag: QInputDevice::Capability::Area)) |
| 829 | str << " Area" ; |
| 830 | if (capabilities.testFlag(flag: QInputDevice::Capability::Pressure)) |
| 831 | str << " Pressure" ; |
| 832 | if (capabilities.testFlag(flag: QInputDevice::Capability::Velocity)) |
| 833 | str << " Velocity" ; |
| 834 | if (capabilities.testFlag(flag: QInputDevice::Capability::NormalizedPosition)) |
| 835 | str << " NormalizedPosition" ; |
| 836 | if (capabilities.testFlag(flag: QInputDevice::Capability::MouseEmulation)) |
| 837 | str << " MouseEmulation" ; |
| 838 | if (capabilities.testFlag(flag: QInputDevice::Capability::Scroll)) |
| 839 | str << " Scroll" ; |
| 840 | if (capabilities.testFlag(flag: QInputDevice::Capability::Hover)) |
| 841 | str << " Hover" ; |
| 842 | if (capabilities.testFlag(flag: QInputDevice::Capability::Rotation)) |
| 843 | str << " Rotation" ; |
| 844 | if (capabilities.testFlag(flag: QInputDevice::Capability::XTilt)) |
| 845 | str << " XTilt" ; |
| 846 | if (capabilities.testFlag(flag: QInputDevice::Capability::YTilt)) |
| 847 | str << " YTilt" ; |
| 848 | if (capabilities.testFlag(flag: QInputDevice::Capability::TangentialPressure)) |
| 849 | str << " TangentialPressure" ; |
| 850 | if (capabilities.testFlag(flag: QInputDevice::Capability::ZPosition)) |
| 851 | str << " ZPosition" ; |
| 852 | if (!device->availableVirtualGeometry().isNull()) { |
| 853 | const auto r = device->availableVirtualGeometry(); |
| 854 | str << " availableVirtualGeometry: " << r.width() << 'x' << r.height() |
| 855 | << Qt::forcesign << r.x() << r.y() << Qt::noforcesign; |
| 856 | } |
| 857 | str << '\n'; |
| 858 | } |
| 859 | str << "\n\n" ; |
| 860 | } |
| 861 | |
| 862 | #ifndef QT_NO_OPENGL |
| 863 | if (flags & QtDiagGl) { |
| 864 | dumpGlInfo(str, listExtensions: flags & QtDiagGlExtensions); |
| 865 | str << "\n" ; |
| 866 | } |
| 867 | #else |
| 868 | Q_UNUSED(flags); |
| 869 | #endif // !QT_NO_OPENGL |
| 870 | |
| 871 | #if QT_CONFIG(vulkan) |
| 872 | if (flags & QtDiagVk) { |
| 873 | dumpVkInfo(str); |
| 874 | str << "\n\n" ; |
| 875 | } |
| 876 | #endif // vulkan |
| 877 | |
| 878 | #ifdef Q_OS_WIN |
| 879 | // On Windows, this will provide addition GPU info similar to the output of dxdiag. |
| 880 | using QWindowsApplication = QNativeInterface::Private::QWindowsApplication; |
| 881 | if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) { |
| 882 | const QVariant gpuInfoV = nativeWindowsApp->gpuList(); |
| 883 | if (gpuInfoV.typeId() == QMetaType::QVariantList) { |
| 884 | const auto gpuList = gpuInfoV.toList(); |
| 885 | for (int i = 0; i < gpuList.size(); ++i) { |
| 886 | const QString description = |
| 887 | gpuList.at(i).toMap().value(QStringLiteral("printable" )).toString(); |
| 888 | if (!description.isEmpty()) |
| 889 | str << "\nGPU #" << (i + 1) << ":\n" << description << '\n'; |
| 890 | } |
| 891 | str << "\n" ; |
| 892 | } |
| 893 | } |
| 894 | #endif // Q_OS_WIN |
| 895 | |
| 896 | if (flags & QtDiagRhi) { |
| 897 | dumpRhiInfo(str); |
| 898 | str << "\n" ; |
| 899 | } |
| 900 | |
| 901 | return result; |
| 902 | } |
| 903 | |
| 904 | QT_END_NAMESPACE |
| 905 | |