Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtdiag.cpp
Go to the documentation of this file.
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
64
65QTextStream &operator<<(QTextStream &str, const QSize &s)
66{
67 str << s.width() << 'x' << s.height();
68 return str;
69}
70
71QTextStream &operator<<(QTextStream &str, const QSizeF &s)
72{
73 str << s.width() << 'x' << s.height();
74 return str;
75}
76
77QTextStream &operator<<(QTextStream &str, const QDpi &d)
78{
79 str << d.first << ',' << d.second;
80 return str;
81}
82
83QTextStream &operator<<(QTextStream &str, const QRect &r)
84{
85 str << r.size() << Qt::forcesign << r.x() << r.y() << Qt::noforcesign;
86 return str;
87}
88
89QTextStream &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
99QTextStream &operator<<(QTextStream &str, const QFont &f)
100{
101 str << '"' << f.family() << "\" " << f.pointSize();
102 return str;
103}
104
105QTextStream &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
115QTextStream &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
130QTextStream &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
152void 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(&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, &majorVersion);
181 GLint minorVersion;
182 functions.glGetIntegerv(GL_MINOR_VERSION, &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(profile, &context)) {
191 if (f->initializeOpenGLFunctions())
192 str << ", Core (" << openGlVersionFunctionsName << "_Core)";
193 }
194 profile.setProfile(QSurfaceFormat::CompatibilityProfile);
195 if (auto f = QOpenGLVersionFunctionsFactory::get(profile, &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(extensionList.begin(), extensionList.end());
205 str << " \nFound " << extensionList.size() << " extensions:\n";
206 for (const QByteArray &extension : std::as_const(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)
217QVersionNumber vulkanVersion(uint32_t v)
218{
219 return QVersionNumber(VK_VERSION_MAJOR(v), VK_VERSION_MINOR(v), VK_VERSION_PATCH(v));
220}
221
222void 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(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(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
254void 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 { "MultisampleTexture", QRhi::MultisampleTexture },
262 { "MultisampleRenderBuffer", QRhi::MultisampleRenderBuffer },
263 { "DebugMarkers", QRhi::DebugMarkers },
264 { "Timestamps", QRhi::Timestamps },
265 { "Instancing", QRhi::Instancing },
266 { "CustomInstanceStepRate", QRhi::CustomInstanceStepRate },
267 { "PrimitiveRestart", QRhi::PrimitiveRestart },
268 { "NonDynamicUniformBuffers", QRhi::NonDynamicUniformBuffers },
269 { "NonFourAlignedEffectiveIndexBufferOffset", QRhi::NonFourAlignedEffectiveIndexBufferOffset },
270 { "NPOTTextureRepeat", QRhi::NPOTTextureRepeat },
271 { "RedOrAlpha8IsRed", QRhi::RedOrAlpha8IsRed },
272 { "ElementIndexUint", QRhi::ElementIndexUint },
273 { "Compute", QRhi::Compute },
274 { "WideLines", QRhi::WideLines },
275 { "VertexShaderPointSize", QRhi::VertexShaderPointSize },
276 { "BaseVertex", QRhi::BaseVertex },
277 { "BaseInstance", QRhi::BaseInstance },
278 { "TriangleFanTopology", QRhi::TriangleFanTopology },
279 { "ReadBackNonUniformBuffer", QRhi::ReadBackNonUniformBuffer },
280 { "ReadBackNonBaseMipLevel", QRhi::ReadBackNonBaseMipLevel },
281 { "TexelFetch", QRhi::TexelFetch },
282 { "RenderToNonBaseMipLevel", QRhi::RenderToNonBaseMipLevel },
283 { "IntAttributes", QRhi::IntAttributes },
284 { "ScreenSpaceDerivatives", QRhi::ScreenSpaceDerivatives },
285 { "ReadBackAnyTextureFormat", QRhi::ReadBackAnyTextureFormat },
286 { "PipelineCacheDataLoadSave", QRhi::PipelineCacheDataLoadSave },
287 { "ImageDataStride", QRhi::ImageDataStride },
288 { "RenderBufferImport", QRhi::RenderBufferImport },
289 { "ThreeDimensionalTextures", QRhi::ThreeDimensionalTextures },
290 { "RenderTo3DTextureSlice", QRhi::RenderTo3DTextureSlice },
291 { "TextureArrays", QRhi::TextureArrays },
292 { "Tessellation", QRhi::Tessellation },
293 { "GeometryShader", QRhi::GeometryShader },
294 { "TextureArrayRange", QRhi::TextureArrayRange },
295 { "NonFillPolygonMode", QRhi::NonFillPolygonMode },
296 { "OneDimensionalTextures", QRhi::OneDimensionalTextures },
297 { "OneDimensionalTextureMipmaps", QRhi::OneDimensionalTextureMipmaps },
298 { "HalfAttributes", QRhi::HalfAttributes },
299 { "RenderToOneDimensionalTexture", QRhi::RenderToOneDimensionalTexture },
300 { "ThreeDimensionalTextureMipmaps", QRhi::ThreeDimensionalTextureMipmaps },
301
302 { nullptr, QRhi::Feature(0) }
303 };
304 struct RhiTextureFormat {
305 const char *name;
306 QRhiTexture::Format val;
307 };
308 const RhiTextureFormat textureFormats[] = {
309 { "RGBA8", QRhiTexture::RGBA8 },
310 { "BGRA8", QRhiTexture::BGRA8 },
311 { "R8", QRhiTexture::R8 },
312 { "RG8", QRhiTexture::RG8 },
313 { "R16", QRhiTexture::R16 },
314 { "RG16", QRhiTexture::RG16 },
315 { "RED_OR_ALPHA8", QRhiTexture::RED_OR_ALPHA8 },
316 { "RGBA16F", QRhiTexture::RGBA16F },
317 { "RGBA32F", QRhiTexture::RGBA32F },
318 { "R16F", QRhiTexture::R16F },
319 { "R32F", QRhiTexture::R32F },
320 { "RGB10A2", QRhiTexture::RGB10A2 },
321 { "D16", QRhiTexture::D16 },
322 { "D24", QRhiTexture::D24 },
323 { "D24S8", QRhiTexture::D24S8 },
324 { "D32F", QRhiTexture::D32F },
325 { "BC1", QRhiTexture::BC1 },
326 { "BC2", QRhiTexture::BC2 },
327 { "BC3", QRhiTexture::BC3 },
328 { "BC4", QRhiTexture::BC4 },
329 { "BC5", QRhiTexture::BC5 },
330 { "BC6H", QRhiTexture::BC6H },
331 { "BC7", QRhiTexture::BC7 },
332 { "ETC2_RGB8", QRhiTexture::ETC2_RGB8 },
333 { "ETC2_RGB8A1", QRhiTexture::ETC2_RGB8A1 },
334 { "ETC2_RGBA8", QRhiTexture::ETC2_RGBA8 },
335 { "ASTC_4x4", QRhiTexture::ASTC_4x4 },
336 { "ASTC_5x4", QRhiTexture::ASTC_5x4 },
337 { "ASTC_5x5", QRhiTexture::ASTC_5x5 },
338 { "ASTC_6x5", QRhiTexture::ASTC_6x5 },
339 { "ASTC_6x6", QRhiTexture::ASTC_6x6 },
340 { "ASTC_8x5", QRhiTexture::ASTC_8x5 },
341 { "ASTC_8x6", QRhiTexture::ASTC_8x6 },
342 { "ASTC_8x8", QRhiTexture::ASTC_8x8 },
343 { "ASTC_10x5", QRhiTexture::ASTC_10x5 },
344 { "ASTC_10x6", QRhiTexture::ASTC_10x6 },
345 { "ASTC_10x8", QRhiTexture::ASTC_10x8 },
346 { "ASTC_10x10", QRhiTexture::ASTC_10x10 },
347 { "ASTC_12x10", QRhiTexture::ASTC_12x10 },
348 { "ASTC_12x12", QRhiTexture::ASTC_12x12 },
349 { nullptr, QRhiTexture::UnknownFormat }
350 };
351
352 QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
353 if (rhi) {
354 str << name << ":\n";
355 str << " Driver Info: " << rhi->driverInfo() << "\n";
356 str << " Min Texture Size: " << rhi->resourceLimit(QRhi::TextureSizeMin) << "\n";
357 str << " Max Texture Size: " << rhi->resourceLimit(QRhi::TextureSizeMax) << "\n";
358 str << " Max Color Attachments: " << rhi->resourceLimit(QRhi::MaxColorAttachments) << "\n";
359 str << " Frames in Flight: " << rhi->resourceLimit(QRhi::FramesInFlight) << "\n";
360 str << " Async Readback Limit: " << rhi->resourceLimit(QRhi::MaxAsyncReadbackFrames) << "\n";
361 str << " MaxThreadGroupsPerDimension: " << rhi->resourceLimit(QRhi::MaxThreadGroupsPerDimension) << "\n";
362 str << " MaxThreadsPerThreadGroup: " << rhi->resourceLimit(QRhi::MaxThreadsPerThreadGroup) << "\n";
363 str << " MaxThreadGroupX: " << rhi->resourceLimit(QRhi::MaxThreadGroupX) << "\n";
364 str << " MaxThreadGroupY: " << rhi->resourceLimit(QRhi::MaxThreadGroupY) << "\n";
365 str << " MaxThreadGroupZ: " << rhi->resourceLimit(QRhi::MaxThreadGroupZ) << "\n";
366 str << " TextureArraySizeMax: " << rhi->resourceLimit(QRhi::TextureArraySizeMax) << "\n";
367 str << " MaxUniformBufferRange: " << rhi->resourceLimit(QRhi::MaxUniformBufferRange) << "\n";
368 str << " MaxVertexInputs: " << rhi->resourceLimit(QRhi::MaxVertexInputs) << "\n";
369 str << " MaxVertexOutputs: " << rhi->resourceLimit(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(',') << "\n";
375 str << " Features:\n";
376 for (int i = 0; features[i].name; i++) {
377 str << " " << (rhi->isFeatureSupported(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(textureFormats[i].val))
382 str << " " << textureFormats[i].name;
383 }
384 str << "\n";
385 }
386}
387
388void 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, "OpenGL (with default QSurfaceFormat)", QRhi::OpenGLES2, &params);
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, "Vulkan", QRhi::Vulkan, &params);
408 vulkanInstance.destroy();
409 }
410#endif
411
412#ifdef Q_OS_WIN
413 {
414 QRhiD3D11InitParams params;
415 dumpRhiBackendInfo(str, "Direct3D 11", QRhi::D3D11, &params);
416 }
417 {
418 QRhiD3D12InitParams params;
419 dumpRhiBackendInfo(str, "Direct3D 12", QRhi::D3D12, &params);
420 }
421#endif
422
423#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
424 {
425 QRhiMetalInitParams params;
426 dumpRhiBackendInfo(str, "Metal", QRhi::Metal, &params);
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.
436static void dumpStandardLocation(QTextStream &str, QStandardPaths::StandardLocation location)
437{
438 str << '"' << QStandardPaths::displayName(location) << '"';
439 const QStringList directories = QStandardPaths::standardLocations(location);
440 const QString writableDirectory = QStandardPaths::writableLocation(location);
441 const int writableIndex = writableDirectory.isEmpty() ? -1 : directories.indexOf(writableDirectory);
442 for (int i = 0; i < directories.size(); ++i) {
443 str << ' ';
444 if (i == writableIndex)
445 str << '*';
446 str << QDir::toNativeSeparators(directories.at(i));
447 if (i == writableIndex)
448 str << '*';
449 }
450 if (!writableDirectory.isEmpty() && writableIndex < 0)
451 str << " *" << QDir::toNativeSeparators(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.
467template <class 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.
476template <class T>
478{
479 QString result = formatQDebug(t).trimmed();
480 if (result.endsWith(QLatin1Char(')'))) {
481 result.chop(1);
482 result.remove(0, result.indexOf(QLatin1Char('(')) + 1);
483 }
484 return result;
485}
486
487QTextStream &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(QPalette::Active, role);
492 if (color.isValid())
493 str << " " << formatValueQDebug(role) << ": " << color.name(QColor::HexArgb) << '\n';
494 }
495 return str;
496}
497
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("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
561QString 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(QLatin1Char('Q')))
605 continue;
606 if (key.at(1) == 'T' || key.at(1) == '_')
607 str << " " << key << "=\"" << systemEnvironment.value(key) << "\"\n";
608 }
609#endif // QT_CONFIG(process)
610
611 const QByteArrayList features = qtFeatures();
612 if (!features.isEmpty())
613 str << "\nFeatures: " << features.join(' ') << '\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(4) << qSetPadChar('0') << Qt::uppercasedigits << Qt::hex
712 << passwordMaskCharacterUc << Qt::dec << qSetFieldWidth(0);
713 }
714 str << '\n'
715 << " fontSmoothingGamma: " << styleHints->fontSmoothingGamma() << '\n'
716 << " useRtlExtensions: " << styleHints->useRtlExtensions() << '\n'
717 << " setFocusOnTouchRelease: " << styleHints->setFocusOnTouchRelease() << '\n'
718 << " tabFocusBehavior: " << formatQDebug(styleHints->tabFocusBehavior()) << '\n'
719 << " singleClickActivation: " << styleHints->singleClickActivation() << '\n';
720 str << "\nAdditional style hints (QPlatformIntegration):\n"
721 << " ReplayMousePressOutsidePopup: "
722 << platformIntegration->styleHint(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(QPlatformTheme::StyleNames).toStringList()
730 << "\n available : " << QStyleFactory::keys()
731#endif
732 ;
733 const QString iconTheme = platformTheme->themeHint(QPlatformTheme::SystemIconThemeName).toString();
734 if (!iconTheme.isEmpty()) {
735 str << "\n Icon theme : " << iconTheme
736 << ", " << platformTheme->themeHint(QPlatformTheme::SystemIconFallbackThemeName).toString()
737 << " from " << platformTheme->themeHint(QPlatformTheme::IconThemeSearchPaths).toStringList();
738 }
739 if (const QFont *systemFont = platformTheme->font())
740 str << "\n System font : " << *systemFont<< '\n';
741
742 if (platformTheme->usePlatformNativeDialog(QPlatformTheme::FileDialog))
743 str << " Native file dialog\n";
744 if (platformTheme->usePlatformNativeDialog(QPlatformTheme::ColorDialog))
745 str << " Native color dialog\n";
746 if (platformTheme->usePlatformNativeDialog(QPlatformTheme::FontDialog))
747 str << " Native font dialog\n";
748 if (platformTheme->usePlatformNativeDialog(QPlatformTheme::MessageDialog))
749 str << " Native message dialog\n";
750
751 str << "\nFonts:\n General font : " << QFontDatabase::systemFont(QFontDatabase::GeneralFont) << '\n'
752 << " Fixed font : " << QFontDatabase::systemFont(QFontDatabase::FixedFont) << '\n'
753 << " Title font : " << QFontDatabase::systemFont(QFontDatabase::TitleFont) << '\n'
754 << " Smallest font: " << QFontDatabase::systemFont(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(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(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(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(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(QInputDevice::Capability::Position))
827 str << " Position";
828 if (capabilities.testFlag(QInputDevice::Capability::Area))
829 str << " Area";
830 if (capabilities.testFlag(QInputDevice::Capability::Pressure))
831 str << " Pressure";
832 if (capabilities.testFlag(QInputDevice::Capability::Velocity))
833 str << " Velocity";
834 if (capabilities.testFlag(QInputDevice::Capability::NormalizedPosition))
835 str << " NormalizedPosition";
836 if (capabilities.testFlag(QInputDevice::Capability::MouseEmulation))
837 str << " MouseEmulation";
838 if (capabilities.testFlag(QInputDevice::Capability::Scroll))
839 str << " Scroll";
840 if (capabilities.testFlag(QInputDevice::Capability::Hover))
841 str << " Hover";
842 if (capabilities.testFlag(QInputDevice::Capability::Rotation))
843 str << " Rotation";
844 if (capabilities.testFlag(QInputDevice::Capability::XTilt))
845 str << " XTilt";
846 if (capabilities.testFlag(QInputDevice::Capability::YTilt))
847 str << " YTilt";
848 if (capabilities.testFlag(QInputDevice::Capability::TangentialPressure))
849 str << " TangentialPressure";
850 if (capabilities.testFlag(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, 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
904QT_END_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QTextStream)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2464
#define DUMP_LIBRARYPATH(str, loc)
Definition qtdiag.cpp:463
void dumpRhiInfo(QTextStream &str)
Definition qtdiag.cpp:388
void dumpGlInfo(QTextStream &str, bool listExtensions)
Definition qtdiag.cpp:152
static QString formatQDebug(T t)
Definition qtdiag.cpp:468
void dumpRhiBackendInfo(QTextStream &str, const char *name, QRhi::Implementation impl, QRhiInitParams *initParams)
Definition qtdiag.cpp:254
static QString formatValueQDebug(T t)
Definition qtdiag.cpp:477
#define DUMP_STANDARDPATH(str, location)
Definition qtdiag.cpp:458
QString qtDiag(unsigned flags)
Definition qtdiag.cpp:561
static void dumpStandardLocation(QTextStream &str, QStandardPaths::StandardLocation location)
Definition qtdiag.cpp:436
static QByteArrayList qtFeatures()
Definition qtdiag.cpp:498
#define DUMP_CAPABILITY(str, integration, capability)
Definition qtdiag.cpp:431
QTextStream & operator<<(QTextStream &s, QTextStreamFunction f)
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]