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 { "MultiView", QRhi::MultiView },
302 { "TextureViewFormat", QRhi::TextureViewFormat },
303 { "ResolveDepthStencil", QRhi::ResolveDepthStencil },
304 { "VariableRateShading", QRhi::VariableRateShading },
305 { "VariableRateShadingMap", QRhi::VariableRateShadingMap },
306 { "VariableRateShadingMapWithTexture", QRhi::VariableRateShadingMapWithTexture },
307 { "PerRenderTargetBlending", QRhi::PerRenderTargetBlending },
308 { "SampleVariables", QRhi::SampleVariables },
309 { "InstanceIndexIncludesBaseInstance", QRhi::InstanceIndexIncludesBaseInstance },
310 { "DepthClamp", QRhi::DepthClamp },
311 { "DrawIndirect", QRhi::DrawIndirect },
312 { "DrawIndirectMulti", QRhi::DrawIndirectMulti },
313
314 { nullptr, QRhi::Feature(0) }
315 };
316 struct RhiTextureFormat {
317 const char *name;
318 QRhiTexture::Format val;
319 };
320 const RhiTextureFormat textureFormats[] = {
321 { "RGBA8", QRhiTexture::RGBA8 },
322 { "BGRA8", QRhiTexture::BGRA8 },
323 { "R8", QRhiTexture::R8 },
324 { "RG8", QRhiTexture::RG8 },
325 { "R16", QRhiTexture::R16 },
326 { "RG16", QRhiTexture::RG16 },
327 { "RED_OR_ALPHA8", QRhiTexture::RED_OR_ALPHA8 },
328 { "RGBA16F", QRhiTexture::RGBA16F },
329 { "RGBA32F", QRhiTexture::RGBA32F },
330 { "R16F", QRhiTexture::R16F },
331 { "R32F", QRhiTexture::R32F },
332 { "RGB10A2", QRhiTexture::RGB10A2 },
333 { "D16", QRhiTexture::D16 },
334 { "D24", QRhiTexture::D24 },
335 { "D24S8", QRhiTexture::D24S8 },
336 { "D32F", QRhiTexture::D32F },
337 { "BC1", QRhiTexture::BC1 },
338 { "BC2", QRhiTexture::BC2 },
339 { "BC3", QRhiTexture::BC3 },
340 { "BC4", QRhiTexture::BC4 },
341 { "BC5", QRhiTexture::BC5 },
342 { "BC6H", QRhiTexture::BC6H },
343 { "BC7", QRhiTexture::BC7 },
344 { "ETC2_RGB8", QRhiTexture::ETC2_RGB8 },
345 { "ETC2_RGB8A1", QRhiTexture::ETC2_RGB8A1 },
346 { "ETC2_RGBA8", QRhiTexture::ETC2_RGBA8 },
347 { "ASTC_4x4", QRhiTexture::ASTC_4x4 },
348 { "ASTC_5x4", QRhiTexture::ASTC_5x4 },
349 { "ASTC_5x5", QRhiTexture::ASTC_5x5 },
350 { "ASTC_6x5", QRhiTexture::ASTC_6x5 },
351 { "ASTC_6x6", QRhiTexture::ASTC_6x6 },
352 { "ASTC_8x5", QRhiTexture::ASTC_8x5 },
353 { "ASTC_8x6", QRhiTexture::ASTC_8x6 },
354 { "ASTC_8x8", QRhiTexture::ASTC_8x8 },
355 { "ASTC_10x5", QRhiTexture::ASTC_10x5 },
356 { "ASTC_10x6", QRhiTexture::ASTC_10x6 },
357 { "ASTC_10x8", QRhiTexture::ASTC_10x8 },
358 { "ASTC_10x10", QRhiTexture::ASTC_10x10 },
359 { "ASTC_12x10", QRhiTexture::ASTC_12x10 },
360 { "ASTC_12x12", QRhiTexture::ASTC_12x12 },
361 { nullptr, QRhiTexture::UnknownFormat }
362 };
363
364 QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
365 if (rhi) {
366 str << name << ":\n";
367 str << " Driver Info: " << rhi->driverInfo() << "\n";
368 str << " Min Texture Size: " << rhi->resourceLimit(QRhi::TextureSizeMin) << "\n";
369 str << " Max Texture Size: " << rhi->resourceLimit(QRhi::TextureSizeMax) << "\n";
370 str << " Max Color Attachments: " << rhi->resourceLimit(QRhi::MaxColorAttachments) << "\n";
371 str << " Frames in Flight: " << rhi->resourceLimit(QRhi::FramesInFlight) << "\n";
372 str << " Async Readback Limit: " << rhi->resourceLimit(QRhi::MaxAsyncReadbackFrames) << "\n";
373 str << " MaxThreadGroupsPerDimension: " << rhi->resourceLimit(QRhi::MaxThreadGroupsPerDimension) << "\n";
374 str << " MaxThreadsPerThreadGroup: " << rhi->resourceLimit(QRhi::MaxThreadsPerThreadGroup) << "\n";
375 str << " MaxThreadGroupX: " << rhi->resourceLimit(QRhi::MaxThreadGroupX) << "\n";
376 str << " MaxThreadGroupY: " << rhi->resourceLimit(QRhi::MaxThreadGroupY) << "\n";
377 str << " MaxThreadGroupZ: " << rhi->resourceLimit(QRhi::MaxThreadGroupZ) << "\n";
378 str << " TextureArraySizeMax: " << rhi->resourceLimit(QRhi::TextureArraySizeMax) << "\n";
379 str << " MaxUniformBufferRange: " << rhi->resourceLimit(QRhi::MaxUniformBufferRange) << "\n";
380 str << " MaxVertexInputs: " << rhi->resourceLimit(QRhi::MaxVertexInputs) << "\n";
381 str << " MaxVertexOutputs: " << rhi->resourceLimit(QRhi::MaxVertexOutputs) << "\n";
382 str << " Uniform Buffer Alignment: " << rhi->ubufAlignment() << "\n";
383 QByteArrayList supportedSampleCounts;
384 for (int s : rhi->supportedSampleCounts())
385 supportedSampleCounts << QByteArray::number(s);
386 str << " Supported MSAA sample counts: " << supportedSampleCounts.join(',') << "\n";
387 str << " Features:\n";
388 for (int i = 0; features[i].name; i++) {
389 str << " " << (rhi->isFeatureSupported(features[i].val) ? "v" : "-") << " " << features[i].name << "\n";
390 }
391 str << " Texture formats:";
392 for (int i = 0; textureFormats[i].name; i++) {
393 if (rhi->isTextureFormatSupported(textureFormats[i].val))
394 str << " " << textureFormats[i].name;
395 }
396 str << "\n";
397 }
398}
399
400void dumpRhiInfo(QTextStream &str)
401{
402 str << "Qt Rendering Hardware Interface supported backends:\n";
403
404#if QT_CONFIG(opengl)
405 {
406 QRhiGles2InitParams params;
407 params.fallbackSurface = QRhiGles2InitParams::newFallbackSurface();
408 dumpRhiBackendInfo(str, "OpenGL (with default QSurfaceFormat)", QRhi::OpenGLES2, &params);
409 delete params.fallbackSurface;
410 }
411#endif
412
413#if QT_CONFIG(vulkan)
414 {
415 QVulkanInstance vulkanInstance;
416 vulkanInstance.create();
417 QRhiVulkanInitParams params;
418 params.inst = &vulkanInstance;
419 dumpRhiBackendInfo(str, "Vulkan", QRhi::Vulkan, &params);
420 vulkanInstance.destroy();
421 }
422#endif
423
424#ifdef Q_OS_WIN
425 {
426 QRhiD3D11InitParams params;
427 dumpRhiBackendInfo(str, "Direct3D 11", QRhi::D3D11, &params);
428 }
429 {
430 QRhiD3D12InitParams params;
431 dumpRhiBackendInfo(str, "Direct3D 12", QRhi::D3D12, &params);
432 }
433#endif
434
435#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
436 {
437 QRhiMetalInitParams params;
438 dumpRhiBackendInfo(str, "Metal", QRhi::Metal, &params);
439 }
440#endif
441}
442
443#define DUMP_CAPABILITY(str, integration, capability)
444 if (platformIntegration->hasCapability(QPlatformIntegration::capability))
445 str << ' ' << #capability;
446
447// Dump values of QStandardPaths, indicate writable locations by asterisk.
448static void dumpStandardLocation(QTextStream &str, QStandardPaths::StandardLocation location)
449{
450 str << '"' << QStandardPaths::displayName(location) << '"';
451 const QStringList directories = QStandardPaths::standardLocations(location);
452 const QString writableDirectory = QStandardPaths::writableLocation(location);
453 const int writableIndex = writableDirectory.isEmpty() ? -1 : directories.indexOf(writableDirectory);
454 for (int i = 0; i < directories.size(); ++i) {
455 str << ' ';
456 if (i == writableIndex)
457 str << '*';
458 str << QDir::toNativeSeparators(directories.at(i));
459 if (i == writableIndex)
460 str << '*';
461 }
462 if (!writableDirectory.isEmpty() && writableIndex < 0)
463 str << " *" << QDir::toNativeSeparators(writableDirectory) << '*';
464}
465
466#define DUMP_CPU_FEATURE(feature, name)
467 if (qCpuHasFeature(feature))
468 str << " " name
469
470#define DUMP_STANDARDPATH(str, location)
471 str << " " << #location << ": ";
472 dumpStandardLocation(str, QStandardPaths::location);
473 str << '\n';
474
475#define DUMP_LIBRARYPATH(str, loc)
476 str << " " << #loc << ": " << QDir::toNativeSeparators(QLibraryInfo::path(QLibraryInfo::loc)) << '\n';
477
478// Helper to format a type via QDebug to be used for QFlags/Q_ENUM.
479template <class T>
481{
482 QString result;
483 QDebug(&result) << t;
484 return result;
485}
486
487// Helper to format a type via QDebug, stripping the class name.
488template <class T>
490{
491 QString result = formatQDebug(t).trimmed();
492 if (result.endsWith(QLatin1Char(')'))) {
493 result.chop(1);
494 result.remove(0, result.indexOf(QLatin1Char('(')) + 1);
495 }
496 return result;
497}
498
499QTextStream &operator<<(QTextStream &str, const QPalette &palette)
500{
501 for (int r = 0; r < int(QPalette::NColorRoles); ++r) {
502 const QPalette::ColorRole role = static_cast< QPalette::ColorRole>(r);
503 const QColor color = palette.color(QPalette::Active, role);
504 if (color.isValid())
505 str << " " << formatValueQDebug(role) << ": " << color.name(QColor::HexArgb) << '\n';
506 }
507 return str;
508}
509
511{
512 QByteArrayList result;
513#ifdef QT_NO_CLIPBOARD
514 result.append("QT_NO_CLIPBOARD");
515#endif
516#ifdef QT_NO_CONTEXTMENU
517 result.append("QT_NO_CONTEXTMENU");
518#endif
519#ifdef QT_NO_CURSOR
520 result.append("QT_NO_CURSOR");
521#endif
522#ifdef QT_NO_DRAGANDDROP
523 result.append("QT_NO_DRAGANDDROP");
524#endif
525#ifdef QT_NO_EXCEPTIONS
526 result.append("QT_NO_EXCEPTIONS");
527#endif
528#ifdef QT_NO_LIBRARY
529 result.append("QT_NO_LIBRARY");
530#endif
531#ifdef QT_NO_NETWORK
532 result.append("QT_NO_NETWORK");
533#endif
534#ifdef QT_NO_OPENGL
535 result.append("QT_NO_OPENGL");
536#endif
537#ifdef QT_NO_OPENSSL
538 result.append("QT_NO_OPENSSL");
539#endif
540#ifdef QT_NO_PROCESS
541 result.append("QT_NO_PROCESS");
542#endif
543#ifdef QT_NO_PRINTER
544 result.append("QT_NO_PRINTER");
545#endif
546#ifdef QT_NO_SESSIONMANAGER
547 result.append("QT_NO_SESSIONMANAGER");
548#endif
549#ifdef QT_NO_SETTINGS
550 result.append("QT_NO_SETTINGS");
551#endif
552#ifdef QT_NO_SHORTCUT
553 result.append("QT_NO_SHORTCUT");
554#endif
555#ifdef QT_NO_SYSTEMTRAYICON
556 result.append("QT_NO_SYSTEMTRAYICON");
557#endif
558#ifdef QT_NO_QTHREAD
559 result.append("QT_NO_QTHREAD");
560#endif
561#ifdef QT_NO_WHATSTHIS
562 result.append("QT_NO_WHATSTHIS");
563#endif
564#ifdef QT_NO_WIDGETS
565 result.append("QT_NO_WIDGETS");
566#endif
567#ifdef QT_NO_ZLIB
568 result.append("QT_NO_ZLIB");
569#endif
570 return result;
571}
572
573QString qtDiag(unsigned flags)
574{
575 QString result;
576 QTextStream str(&result);
577
578 const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
579 str << QLibraryInfo::build() << " on \"" << QGuiApplication::platformName() << "\" "
580 << '\n'
581 << "OS: " << QSysInfo::prettyProductName()
582 << " [" << QSysInfo::kernelType() << " version " << QSysInfo::kernelVersion() << "]\n";
583
584 str << "\nArchitecture: " << QSysInfo::currentCpuArchitecture() << "; features:";
585#if defined(Q_PROCESSOR_X86)
586 DUMP_CPU_FEATURE(HYBRID, "hybrid");
587 DUMP_CPU_FEATURE(SSE2, "SSE2");
588 DUMP_CPU_FEATURE(SSE3, "SSE3");
589 DUMP_CPU_FEATURE(SSSE3, "SSSE3");
590 DUMP_CPU_FEATURE(SSE4_1, "SSE4.1");
591 DUMP_CPU_FEATURE(SSE4_2, "SSE4.2");
592 DUMP_CPU_FEATURE(AVX, "AVX");
593 DUMP_CPU_FEATURE(AVX2, "AVX2");
594 DUMP_CPU_FEATURE(AVX512F, "AVX512F");
595 DUMP_CPU_FEATURE(AVX512IFMA, "AVX512IFMA");
596 DUMP_CPU_FEATURE(AVX512VBMI2, "AVX512VBMI2");
597 DUMP_CPU_FEATURE(AVX512FP16, "AVX512FP16");
598 DUMP_CPU_FEATURE(AES, "AES");
599 DUMP_CPU_FEATURE(VAES, "VAES");
600 DUMP_CPU_FEATURE(SHA, "SHA");
601#elif defined(Q_PROCESSOR_ARM)
602 DUMP_CPU_FEATURE(ARM_NEON, "Neon");
603#elif defined(Q_PROCESSOR_MIPS)
604 DUMP_CPU_FEATURE(DSP, "DSP");
605 DUMP_CPU_FEATURE(DSPR2, "DSPR2");
606#endif
607 str << '\n';
608
609#if QT_CONFIG(process)
610 const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment();
611 str << "\nEnvironment:\n";
612 const QStringList keys = systemEnvironment.keys();
613 for (const QString &key : keys) {
614 if (key.size() < 2 || !key.startsWith(QLatin1Char('Q')))
615 continue;
616 if (key.at(1) == 'T' || key.at(1) == '_')
617 str << " " << key << "=\"" << systemEnvironment.value(key) << "\"\n";
618 }
619#endif // QT_CONFIG(process)
620
621 const QByteArrayList features = qtFeatures();
622 if (!features.isEmpty())
623 str << "\nFeatures: " << features.join(' ') << '\n';
624
625 str << "\nLibrary info:\n";
626 DUMP_LIBRARYPATH(str, PrefixPath)
627 DUMP_LIBRARYPATH(str, DocumentationPath)
628 DUMP_LIBRARYPATH(str, HeadersPath)
629 DUMP_LIBRARYPATH(str, LibrariesPath)
630 DUMP_LIBRARYPATH(str, LibraryExecutablesPath)
631 DUMP_LIBRARYPATH(str, BinariesPath)
632 DUMP_LIBRARYPATH(str, PluginsPath)
633 DUMP_LIBRARYPATH(str, QmlImportsPath)
634 DUMP_LIBRARYPATH(str, ArchDataPath)
635 DUMP_LIBRARYPATH(str, DataPath)
636 DUMP_LIBRARYPATH(str, TranslationsPath)
637 DUMP_LIBRARYPATH(str, ExamplesPath)
638 DUMP_LIBRARYPATH(str, TestsPath)
639 DUMP_LIBRARYPATH(str, SettingsPath)
640
641 str << "\nStandard paths [*...* denote writable entry]:\n";
642 DUMP_STANDARDPATH(str, DesktopLocation)
643 DUMP_STANDARDPATH(str, DocumentsLocation)
644 DUMP_STANDARDPATH(str, FontsLocation)
645 DUMP_STANDARDPATH(str, ApplicationsLocation)
646 DUMP_STANDARDPATH(str, MusicLocation)
647 DUMP_STANDARDPATH(str, MoviesLocation)
648 DUMP_STANDARDPATH(str, PicturesLocation)
649 DUMP_STANDARDPATH(str, TempLocation)
650 DUMP_STANDARDPATH(str, HomeLocation)
651 DUMP_STANDARDPATH(str, AppLocalDataLocation)
652 DUMP_STANDARDPATH(str, CacheLocation)
653 DUMP_STANDARDPATH(str, GenericDataLocation)
654 DUMP_STANDARDPATH(str, RuntimeLocation)
655 DUMP_STANDARDPATH(str, ConfigLocation)
656 DUMP_STANDARDPATH(str, DownloadLocation)
657 DUMP_STANDARDPATH(str, GenericCacheLocation)
658 DUMP_STANDARDPATH(str, GenericConfigLocation)
659 DUMP_STANDARDPATH(str, AppDataLocation)
660 DUMP_STANDARDPATH(str, AppConfigLocation)
661
662 str << "\nFile selectors (increasing order of precedence):\n ";
663 const QStringList allSelectors = QFileSelector().allSelectors();
664 for (const QString &s : allSelectors)
665 str << ' ' << s;
666
667 str << "\n\nNetwork:\n ";
668#ifdef NETWORK_DIAG
669# ifndef QT_NO_SSL
670 if (QSslSocket::supportsSsl()) {
671 str << "Using \"" << QSslSocket::sslLibraryVersionString() << "\", version: 0x"
672 << Qt::hex << QSslSocket::sslLibraryVersionNumber() << Qt::dec;
673 } else {
674 str << "\nSSL is not supported.";
675 }
676# else // !QT_NO_SSL
677 str << "SSL is not available.";
678# endif // QT_NO_SSL
679#else
680 str << "Qt Network module is not available.";
681#endif // NETWORK_DIAG
682
683 str << "\n\nPlatform capabilities:";
684 DUMP_CAPABILITY(str, platformIntegration, ThreadedPixmaps)
685 DUMP_CAPABILITY(str, platformIntegration, OpenGL)
686 DUMP_CAPABILITY(str, platformIntegration, ThreadedOpenGL)
687 DUMP_CAPABILITY(str, platformIntegration, SharedGraphicsCache)
688 DUMP_CAPABILITY(str, platformIntegration, BufferQueueingOpenGL)
689 DUMP_CAPABILITY(str, platformIntegration, WindowMasks)
690 DUMP_CAPABILITY(str, platformIntegration, MultipleWindows)
691 DUMP_CAPABILITY(str, platformIntegration, ApplicationState)
692 DUMP_CAPABILITY(str, platformIntegration, ForeignWindows)
693 DUMP_CAPABILITY(str, platformIntegration, NonFullScreenWindows)
694 DUMP_CAPABILITY(str, platformIntegration, NativeWidgets)
695 DUMP_CAPABILITY(str, platformIntegration, WindowManagement)
696 DUMP_CAPABILITY(str, platformIntegration, SyncState)
697 DUMP_CAPABILITY(str, platformIntegration, AllGLFunctionsQueryable)
698 DUMP_CAPABILITY(str, platformIntegration, ApplicationIcon)
699 DUMP_CAPABILITY(str, platformIntegration, SwitchableWidgetComposition)
700 str << '\n';
701
702 const QStyleHints *styleHints = QGuiApplication::styleHints();
703 const QChar passwordMaskCharacter = styleHints->passwordMaskCharacter();
704 str << "\nStyle hints:\n mouseDoubleClickInterval: " << styleHints->mouseDoubleClickInterval() << '\n'
705 << " mousePressAndHoldInterval: " << styleHints->mousePressAndHoldInterval() << '\n'
706 << " startDragDistance: " << styleHints->startDragDistance() << '\n'
707 << " startDragTime: " << styleHints->startDragTime() << '\n'
708 << " startDragVelocity: " << styleHints->startDragVelocity() << '\n'
709 << " keyboardInputInterval: " << styleHints->keyboardInputInterval() << '\n'
710 << " keyboardAutoRepeatRateF: " << styleHints->keyboardAutoRepeatRateF() << '\n'
711 << " cursorFlashTime: " << styleHints->cursorFlashTime() << '\n'
712 << " showIsFullScreen: " << styleHints->showIsFullScreen() << '\n'
713 << " showIsMaximized: " << styleHints->showIsMaximized() << '\n'
714 << " passwordMaskDelay: " << styleHints->passwordMaskDelay() << '\n'
715 << " passwordMaskCharacter: ";
716 const int passwordMaskCharacterUc = passwordMaskCharacter.unicode();
717 if (passwordMaskCharacterUc >= 32 && passwordMaskCharacterUc < 128) {
718 str << '\'' << passwordMaskCharacter << '\'';
719 } else {
720 str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << Qt::uppercasedigits << Qt::hex
721 << passwordMaskCharacterUc << Qt::dec << qSetFieldWidth(0);
722 }
723 str << '\n'
724 << " fontSmoothingGamma: " << styleHints->fontSmoothingGamma() << '\n'
725 << " useRtlExtensions: " << styleHints->useRtlExtensions() << '\n'
726 << " setFocusOnTouchRelease: " << styleHints->setFocusOnTouchRelease() << '\n'
727 << " tabFocusBehavior: " << formatQDebug(styleHints->tabFocusBehavior()) << '\n'
728 << " singleClickActivation: " << styleHints->singleClickActivation() << '\n';
729 str << "\nAdditional style hints (QPlatformIntegration):\n"
730 << " ReplayMousePressOutsidePopup: "
731 << platformIntegration->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool() << '\n';
732
733 const QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme();
734 str << "\nTheme:"
735 "\n Platforms requested : " << platformIntegration->themeNames()
736 << "\n available : " << QPlatformThemeFactory::keys()
737#ifdef QT_WIDGETS_LIB
738 << "\n Styles requested : " << platformTheme->themeHint(QPlatformTheme::StyleNames).toStringList()
739 << "\n available : " << QStyleFactory::keys()
740#endif
741 ;
742 const QString iconTheme = platformTheme->themeHint(QPlatformTheme::SystemIconThemeName).toString();
743 if (!iconTheme.isEmpty()) {
744 str << "\n Icon theme : " << iconTheme
745 << ", " << platformTheme->themeHint(QPlatformTheme::SystemIconFallbackThemeName).toString()
746 << " from " << platformTheme->themeHint(QPlatformTheme::IconThemeSearchPaths).toStringList();
747 }
748 if (const QFont *systemFont = platformTheme->font())
749 str << "\n System font : " << *systemFont<< '\n';
750
751 if (platformTheme->usePlatformNativeDialog(QPlatformTheme::FileDialog))
752 str << " Native file dialog\n";
753 if (platformTheme->usePlatformNativeDialog(QPlatformTheme::ColorDialog))
754 str << " Native color dialog\n";
755 if (platformTheme->usePlatformNativeDialog(QPlatformTheme::FontDialog))
756 str << " Native font dialog\n";
757 if (platformTheme->usePlatformNativeDialog(QPlatformTheme::MessageDialog))
758 str << " Native message dialog\n";
759
760 str << "\nFonts:\n General font : " << QFontDatabase::systemFont(QFontDatabase::GeneralFont) << '\n'
761 << " Fixed font : " << QFontDatabase::systemFont(QFontDatabase::FixedFont) << '\n'
762 << " Title font : " << QFontDatabase::systemFont(QFontDatabase::TitleFont) << '\n'
763 << " Smallest font: " << QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont) << '\n';
764 if (flags & QtDiagFonts) {
765 const QStringList families = QFontDatabase::families();
766 str << "\n Families (" << families.size() << "):\n";
767 for (int i = 0, count = families.size(); i < count; ++i)
768 str << " " << families.at(i) << '\n';
769
770 const QList<int> standardSizes = QFontDatabase::standardSizes();
771 str << "\n Standard Sizes:";
772 for (int i = 0, count = standardSizes.size(); i < count; ++i)
773 str << ' ' << standardSizes.at(i);
774 QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase::writingSystems();
775 str << "\n\n Writing systems:\n";
776 for (int i = 0, count = writingSystems.size(); i < count; ++i)
777 str << " " << formatValueQDebug(writingSystems.at(i)) << '\n';
778 }
779
780 str << "\nPalette:\n" << QGuiApplication::palette();
781
782 const QList<QScreen*> screens = QGuiApplication::screens();
783 const int screenCount = screens.size();
784 str << "\nScreens: " << screenCount << ", High DPI scaling: "
785 << (QHighDpiScaling::isActive() ? "active" : "inactive") << '\n';
786 for (int s = 0; s < screenCount; ++s) {
787 const QScreen *screen = screens.at(s);
788 const QPlatformScreen *platformScreen = screen->handle();
789 const QRect geometry = screen->geometry();
790 const QDpi dpi(screen->logicalDotsPerInchX(), screen->logicalDotsPerInchY());
791 const QDpi nativeDpi = platformScreen->logicalDpi();
792 const QRect nativeGeometry = platformScreen->geometry();
793 str << '#' << ' ' << s << " \"" << screen->name() << '"'
794 << " Depth: " << screen->depth()
795 << " Primary: " << (screen == QGuiApplication::primaryScreen() ? "yes" : "no")
796 << "\n Manufacturer: " << screen->manufacturer()
797 << "\n Model: " << screen->model()
798 << "\n Serial number: " << screen->serialNumber()
799 << "\n Geometry: " << geometry;
800 if (geometry != nativeGeometry)
801 str << " (native: " << nativeGeometry << ')';
802 str << " Available: " << screen->availableGeometry();
803 if (geometry != screen->virtualGeometry())
804 str << "\n Virtual geometry: " << screen->virtualGeometry() << " Available: " << screen->availableVirtualGeometry();
805 if (screen->virtualSiblings().size() > 1)
806 str << "\n " << screen->virtualSiblings().size() << " virtual siblings";
807 str << "\n Physical size: " << screen->physicalSize() << " mm"
808 << " Refresh: " << screen->refreshRate() << " Hz"
809 << " Power state: " << platformScreen->powerState();
810 str << "\n Physical DPI: " << screen->physicalDotsPerInchX()
811 << ',' << screen->physicalDotsPerInchY()
812 << " Logical DPI: " << dpi;
813 if (dpi != nativeDpi)
814 str << " (native: " << nativeDpi << ')';
815 str << ' ' << platformScreen->subpixelAntialiasingTypeHint() << "\n ";
816 if (QHighDpiScaling::isActive())
817 str << "High DPI scaling factor: " << QHighDpiScaling::factor(screen) << ' ';
818 str << "DevicePixelRatio: " << screen->devicePixelRatio();
819 str << "\n Primary orientation: " << screen->primaryOrientation()
820 << " Orientation: " << screen->orientation()
821 << " Native orientation: " << screen->nativeOrientation()
822 << "\n\n";
823 }
824
825 const auto inputDevices = QInputDevice::devices();
826 if (!inputDevices.isEmpty()) {
827 str << "Input devices: " << inputDevices.size() << '\n';
828 for (auto device : inputDevices) {
829 str << " " << formatValueQDebug(device->type())
830 << " \"" << device->name() << "\",";
831 if (!device->seatName().isEmpty())
832 str << " seat: \"" << device->seatName() << '"';
833 str << " capabilities:";
834 const auto capabilities = device->capabilities();
835 if (capabilities.testFlag(QInputDevice::Capability::Position))
836 str << " Position";
837 if (capabilities.testFlag(QInputDevice::Capability::Area))
838 str << " Area";
839 if (capabilities.testFlag(QInputDevice::Capability::Pressure))
840 str << " Pressure";
841 if (capabilities.testFlag(QInputDevice::Capability::Velocity))
842 str << " Velocity";
843 if (capabilities.testFlag(QInputDevice::Capability::NormalizedPosition))
844 str << " NormalizedPosition";
845 if (capabilities.testFlag(QInputDevice::Capability::MouseEmulation))
846 str << " MouseEmulation";
847 if (capabilities.testFlag(QInputDevice::Capability::Scroll))
848 str << " Scroll";
849 if (capabilities.testFlag(QInputDevice::Capability::Hover))
850 str << " Hover";
851 if (capabilities.testFlag(QInputDevice::Capability::Rotation))
852 str << " Rotation";
853 if (capabilities.testFlag(QInputDevice::Capability::XTilt))
854 str << " XTilt";
855 if (capabilities.testFlag(QInputDevice::Capability::YTilt))
856 str << " YTilt";
857 if (capabilities.testFlag(QInputDevice::Capability::TangentialPressure))
858 str << " TangentialPressure";
859 if (capabilities.testFlag(QInputDevice::Capability::ZPosition))
860 str << " ZPosition";
861 if (!device->availableVirtualGeometry().isNull()) {
862 const auto r = device->availableVirtualGeometry();
863 str << " availableVirtualGeometry: " << r.width() << 'x' << r.height()
864 << Qt::forcesign << r.x() << r.y() << Qt::noforcesign;
865 }
866 str << '\n';
867 }
868 str << "\n\n";
869 }
870
871#ifndef QT_NO_OPENGL
872 if (flags & QtDiagGl) {
873 dumpGlInfo(str, flags & QtDiagGlExtensions);
874 str << "\n";
875 }
876#else
877 Q_UNUSED(flags);
878#endif // !QT_NO_OPENGL
879
880#if QT_CONFIG(vulkan)
881 if (flags & QtDiagVk) {
882 dumpVkInfo(str);
883 str << "\n\n";
884 }
885#endif // vulkan
886
887#ifdef Q_OS_WIN
888 // On Windows, this will provide addition GPU info similar to the output of dxdiag.
889 using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
890 if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) {
891 const QVariant gpuInfoV = nativeWindowsApp->gpuList();
892 if (gpuInfoV.typeId() == QMetaType::QVariantList) {
893 const auto gpuList = gpuInfoV.toList();
894 for (int i = 0; i < gpuList.size(); ++i) {
895 const QString description =
896 gpuList.at(i).toMap().value(QStringLiteral("printable")).toString();
897 if (!description.isEmpty())
898 str << "\nGPU #" << (i + 1) << ":\n" << description << '\n';
899 }
900 str << "\n";
901 }
902 }
903#endif // Q_OS_WIN
904
905 if (flags & QtDiagRhi) {
906 dumpRhiInfo(str);
907 str << "\n";
908 }
909
910 return result;
911}
912
913QT_END_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QTextStream)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582
#define DUMP_LIBRARYPATH(str, loc)
Definition qtdiag.cpp:475
void dumpRhiInfo(QTextStream &str)
Definition qtdiag.cpp:400
void dumpGlInfo(QTextStream &str, bool listExtensions)
Definition qtdiag.cpp:152
static QString formatQDebug(T t)
Definition qtdiag.cpp:480
void dumpRhiBackendInfo(QTextStream &str, const char *name, QRhi::Implementation impl, QRhiInitParams *initParams)
Definition qtdiag.cpp:254
static QString formatValueQDebug(T t)
Definition qtdiag.cpp:489
#define DUMP_STANDARDPATH(str, location)
Definition qtdiag.cpp:470
QString qtDiag(unsigned flags)
Definition qtdiag.cpp:573
static void dumpStandardLocation(QTextStream &str, QStandardPaths::StandardLocation location)
Definition qtdiag.cpp:448
static QByteArrayList qtFeatures()
Definition qtdiag.cpp:510
#define DUMP_CAPABILITY(str, integration, capability)
Definition qtdiag.cpp:443
QTextStream & operator<<(QTextStream &s, QTextStreamFunction f)
QDataStream & operator<<(QDataStream &stream, const QImage &image)
[0]
Definition qimage.cpp:4010