KWin
Loading...
Searching...
No Matches
glplatform.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2010 Fredrik Höglund <fredrik@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "effect/globals.h"
13#include "openglcontext.h"
14
15#include <QByteArray>
16#include <QSet>
17#include <memory>
18
19namespace KWin
20{
21// forward declare method
22void cleanupGL();
23
24class Version;
25
26enum class GLFeature {
33
38
43};
44
70
71// clang-format off
73 // Radeon
74 R100 = 0, // GL1.3 DX7 2000
75 R200, // GL1.4 DX8.1 SM 1.4 2001
76 R300, // GL2.0 DX9 SM 2.0 2002
77 R400, // GL2.0 DX9b SM 2.0b 2004
78 R500, // GL2.0 DX9c SM 3.0 2005
79 R600, // GL3.3 DX10 SM 4.0 2006
80 R700, // GL3.3 DX10.1 SM 4.1 2008
81 Evergreen, // GL4.0 CL1.0 DX11 SM 5.0 2009
82 NorthernIslands, // GL4.0 CL1.1 DX11 SM 5.0 2010
83 SouthernIslands, // GL4.5 CL1.2 DX11.1 SM 5.1 2012
84 SeaIslands, // GL4.5 CL2.0 DX12 SM 6.0 2013
85 VolcanicIslands, // GL4.5 CL2.0 DX12 SM 6.0 2015
86 ArcticIslands, // GL4.5 CL2.0 DX12 SM 6.0 2016
87 Vega, // GL4.6 CL2.0 DX12 SM 6.0 2017
88 Navi, // GL4.6 CL2.0 DX12.1 SM 6.4 2019
90
91 // NVIDIA
92 NV10 = 1000, // GL1.2 DX7 1999
93 NV20, // GL1.3 DX8 SM 1.1 2001
94 NV30, // GL1.5 DX9a SM 2.0 2003
95 NV40, // GL2.1 DX9c SM 3.0 2004
96 G80, // GL3.3 DX10 SM 4.0 2006
97 GF100, // GL4.1 CL1.1 DX11 SM 5.0 2010
99
100 // Intel
101 I8XX = 2000, // GL1.3 DX7 2001
102 I915, // GL1.4/1.5 DX9/DX9c SM 2.0 2004
103 I965, // GL2.0/2.1 DX9/DX10 SM 3.0/4.0 2006
104 SandyBridge, // Gen6 GL3.1 CL1.1 DX10.1 SM 4.0 2010
105 IvyBridge, // Gen7 GL4.0 CL1.1 DX11 SM 5.0 2012
106 Haswell, // Gen7 GL4.0 CL1.2 DX11.1 SM 5.0 2013
107 BayTrail, // Gen7 GL4.0 CL1.2 DX11.1 SM 5.0 2013
108 Cherryview, // Gen8 GL4.0 CL1.2 DX11.2 SM 5.0 2013
109 Broadwell, // Gen8 GL4.4 CL2.0 DX11.2 SM 5.0 2014
110 ApolloLake, // Gen9 GL4.6 CL3.0 DX12 SM 6.0 2016
111 Skylake, // Gen9 GL4.6 CL3.0 DX12 SM 6.0 2015
112 GeminiLake, // Gen9 GL4.6 CL3.0 DX12 SM 6.0 2017
113 KabyLake, // Gen9 GL4.6 CL3.0 DX12 SM 6.0 2017
114 CoffeeLake, // Gen9 GL4.6 CL3.0 DX12 SM 6.0 2018
115 WhiskeyLake, // Gen9 GL4.6 GL3.0 DX12 SM 6.0 2018
116 CometLake, // Gen9 GL4.6 GL3.0 DX12 SM 6.0 2019
117 CannonLake, // Gen10 GL4.6 GL3.0 DX12 SM 6.0 2018
118 IceLake, // Gen11 GL4.6 CL3.0 DX12.1 SM 6.0 2019
119 TigerLake, // Gen12 GL4.6 CL3.0 DX12.1 SM 6.0 2020
121
122 // Qualcomm Adreno
123 // from https://en.wikipedia.org/wiki/Adreno
124 Adreno1XX = 3000, // GLES1.1
125 Adreno2XX, // GLES2.0 DX9c
126 Adreno3XX, // GLES3.0 CL1.1 DX11.1
127 Adreno4XX, // GLES3.1 CL1.2 DX11.2
128 Adreno5XX, // GLES3.1 CL2.0 DX11.2
130
131 // Panfrost Mali
132 // from https://docs.mesa3d.org/drivers/panfrost.html
133 MaliT7XX = 4000, // GLES2.0/GLES3.0
134 MaliT8XX, // GLES3.0
135 MaliGXX, // GLES3.0
137
138 // Lima Mali
139 // from https://docs.mesa3d.org/drivers/lima.html
140 Mali400 = 5000,
144
145 // Broadcom VideoCore IV (e.g. Raspberry Pi 0 to 3), GLES 2.0/2.1 with caveats
146 VC4_2_1 = 6000, // Found in Raspberry Pi 3B+
148
149 // Broadcom VideoCore 3D (e.g. Raspberry Pi 4, Raspberry Pi 400)
150 V3D_4_2 = 7000, // Found in Raspberry Pi 400
152
154};
155// clang-format on
156
157class KWIN_EXPORT GLPlatform
158{
159public:
160 ~GLPlatform();
161
165 void detect(OpenGLPlatformInterface platformInterface);
166
170 void printResults() const;
171
175 static GLPlatform *instance();
176
180 bool supports(GLFeature feature) const;
181
185 Version glVersion() const;
186
190 Version glslVersion() const;
191
195 Version mesaVersion() const;
196
202 Version driverVersion() const;
203
207 Driver driver() const;
208
212 ChipClass chipClass() const;
213
217 bool isMesaDriver() const;
218
222 bool isRadeon() const;
223
227 bool isNvidia() const;
228
232 bool isIntel() const;
233
238 bool isVirtualBox() const;
239
244 bool isVMware() const;
245
250 bool isSoftwareEmulation() const;
251
256 bool isVirtualMachine() const;
257
262 bool isAdreno() const;
263
268 bool isVirgl() const;
269
274 bool isPanfrost() const;
275
280 bool isLima() const;
281
286 bool isVideoCore4() const;
287
292 bool isVideoCore3D() const;
293
298 QByteArrayView glVersionString() const;
303 QByteArrayView glRendererString() const;
308 QByteArrayView glVendorString() const;
314 QByteArrayView glShadingLanguageVersionString() const;
319 bool isLooseBinding() const;
323 bool isGLES() const;
324
329 CompositingType recommendedCompositor() const;
330
337 bool preferBufferSubData() const;
338
343 OpenGLPlatformInterface platformInterface() const;
344
350 static QString driverToString(Driver driver);
356 static QByteArray driverToString8(Driver driver);
357
363 static QString chipClassToString(ChipClass chipClass);
369 static QByteArray chipClassToString8(ChipClass chipClass);
370
371private:
372 GLPlatform();
373 friend void KWin::cleanupGL();
374 static void cleanup();
375
376private:
377 QByteArray m_glsl_version;
378 QByteArrayView m_chipset;
379 Driver m_driver;
380 ChipClass m_chipClass;
381 CompositingType m_recommendedCompositor;
382 Version m_glslVersion;
383 Version m_mesaVersion;
384 Version m_driverVersion;
385 bool m_looseBinding : 1;
386 bool m_packInvert : 1;
387 bool m_virtualMachine : 1;
388 bool m_preferBufferSubData : 1;
389 OpenGLPlatformInterface m_platformInterface;
390 std::unique_ptr<OpenGlContext> m_context;
391 static std::unique_ptr<GLPlatform> s_platform;
392};
393
395{
396 if (!s_platform) {
397 s_platform.reset(new GLPlatform());
398 }
399 return s_platform.get();
400}
401
402} // namespace KWin
static GLPlatform * instance()
Definition glplatform.h:394
GLFeature
Definition glplatform.h:26
@ Driver_V3D
Definition glplatform.h:67
@ Driver_R300G
Definition glplatform.h:49
@ Driver_Swrast
Definition glplatform.h:56
@ Driver_Qualcomm
Definition glplatform.h:61
@ Driver_VC4
Definition glplatform.h:66
@ Driver_VMware
Definition glplatform.h:60
@ Driver_VirtualBox
Definition glplatform.h:59
@ Driver_NVidia
Definition glplatform.h:54
@ Driver_Llvmpipe
Definition glplatform.h:58
@ Driver_R600G
Definition glplatform.h:51
@ Driver_RadeonSI
Definition glplatform.h:62
@ Driver_R200
Definition glplatform.h:47
@ Driver_Lima
Definition glplatform.h:65
@ Driver_R100
Definition glplatform.h:46
@ Driver_Virgl
Definition glplatform.h:63
@ Driver_Catalyst
Definition glplatform.h:55
@ Driver_R300C
Definition glplatform.h:48
@ Driver_Panfrost
Definition glplatform.h:64
@ Driver_Unknown
Definition glplatform.h:68
@ Driver_Intel
Definition glplatform.h:53
@ Driver_Nouveau
Definition glplatform.h:52
@ Driver_R600C
Definition glplatform.h:50
@ Driver_Softpipe
Definition glplatform.h:57
void KWIN_EXPORT cleanupGL()
Definition glutils.cpp:122
OpenGLPlatformInterface
Definition globals.h:42
CompositingType
Definition globals.h:28
ChipClass
Definition glplatform.h:72
@ NV40
Definition glplatform.h:95
@ BayTrail
Definition glplatform.h:107
@ NV30
Definition glplatform.h:94
@ UnknownVideoCore3D
Definition glplatform.h:151
@ IceLake
Definition glplatform.h:118
@ Adreno5XX
Definition glplatform.h:128
@ UnknownRadeon
Definition glplatform.h:89
@ CometLake
Definition glplatform.h:116
@ CoffeeLake
Definition glplatform.h:114
@ NV20
Definition glplatform.h:93
@ KabyLake
Definition glplatform.h:113
@ R300
Definition glplatform.h:76
@ VolcanicIslands
Definition glplatform.h:85
@ UnknownChipClass
Definition glplatform.h:153
@ MaliGXX
Definition glplatform.h:135
@ IvyBridge
Definition glplatform.h:105
@ VC4_2_1
Definition glplatform.h:146
@ ApolloLake
Definition glplatform.h:110
@ WhiskeyLake
Definition glplatform.h:115
@ R700
Definition glplatform.h:80
@ Adreno3XX
Definition glplatform.h:126
@ R600
Definition glplatform.h:79
@ UnknownPanfrost
Definition glplatform.h:136
@ Evergreen
Definition glplatform.h:81
@ UnknownVideoCore4
Definition glplatform.h:147
@ ArcticIslands
Definition glplatform.h:86
@ NV10
Definition glplatform.h:92
@ SandyBridge
Definition glplatform.h:104
@ G80
Definition glplatform.h:96
@ Adreno4XX
Definition glplatform.h:127
@ GeminiLake
Definition glplatform.h:112
@ UnknownAdreno
Definition glplatform.h:129
@ Adreno2XX
Definition glplatform.h:125
@ Skylake
Definition glplatform.h:111
@ Mali450
Definition glplatform.h:141
@ GF100
Definition glplatform.h:97
@ SeaIslands
Definition glplatform.h:84
@ MaliT8XX
Definition glplatform.h:134
@ CannonLake
Definition glplatform.h:117
@ R400
Definition glplatform.h:77
@ MaliT7XX
Definition glplatform.h:133
@ UnknownIntel
Definition glplatform.h:120
@ Haswell
Definition glplatform.h:106
@ UnknownLima
Definition glplatform.h:143
@ R100
Definition glplatform.h:74
@ Broadwell
Definition glplatform.h:109
@ Adreno1XX
Definition glplatform.h:124
@ UnknownNVidia
Definition glplatform.h:98
@ R500
Definition glplatform.h:78
@ NorthernIslands
Definition glplatform.h:82
@ SouthernIslands
Definition glplatform.h:83
@ Mali470
Definition glplatform.h:142
@ Mali400
Definition glplatform.h:140
@ Vega
Definition glplatform.h:87
@ Cherryview
Definition glplatform.h:108
@ R200
Definition glplatform.h:75
@ V3D_4_2
Definition glplatform.h:150
@ Navi
Definition glplatform.h:88
@ TigerLake
Definition glplatform.h:119