xref: /aosp_15_r20/external/angle/util/EGLPlatformParameters.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker // EGLPlatformParameters: Basic description of an EGL device.
7*8975f5c5SAndroid Build Coastguard Worker 
8*8975f5c5SAndroid Build Coastguard Worker #ifndef UTIL_EGLPLATFORMPARAMETERS_H_
9*8975f5c5SAndroid Build Coastguard Worker #define UTIL_EGLPLATFORMPARAMETERS_H_
10*8975f5c5SAndroid Build Coastguard Worker 
11*8975f5c5SAndroid Build Coastguard Worker #include "util/util_gl.h"
12*8975f5c5SAndroid Build Coastguard Worker 
13*8975f5c5SAndroid Build Coastguard Worker #include "autogen/angle_features_autogen.h"
14*8975f5c5SAndroid Build Coastguard Worker 
15*8975f5c5SAndroid Build Coastguard Worker #include <string>
16*8975f5c5SAndroid Build Coastguard Worker #include <tuple>
17*8975f5c5SAndroid Build Coastguard Worker #include <vector>
18*8975f5c5SAndroid Build Coastguard Worker 
19*8975f5c5SAndroid Build Coastguard Worker namespace angle
20*8975f5c5SAndroid Build Coastguard Worker {
21*8975f5c5SAndroid Build Coastguard Worker struct PlatformMethods;
22*8975f5c5SAndroid Build Coastguard Worker 
23*8975f5c5SAndroid Build Coastguard Worker // The GLES driver type determines what shared object we use to load the GLES entry points.
24*8975f5c5SAndroid Build Coastguard Worker // AngleEGL loads from ANGLE's version of libEGL, libGLESv2, and libGLESv1_CM.
25*8975f5c5SAndroid Build Coastguard Worker // SystemEGL uses the system copies of libEGL, libGLESv2, and libGLESv1_CM.
26*8975f5c5SAndroid Build Coastguard Worker // SystemWGL loads Windows GL with the GLES compatibility extensions. See util/WGLWindow.h.
27*8975f5c5SAndroid Build Coastguard Worker enum class GLESDriverType
28*8975f5c5SAndroid Build Coastguard Worker {
29*8975f5c5SAndroid Build Coastguard Worker     AngleEGL,
30*8975f5c5SAndroid Build Coastguard Worker     AngleVulkanSecondariesEGL,
31*8975f5c5SAndroid Build Coastguard Worker     SystemEGL,
32*8975f5c5SAndroid Build Coastguard Worker     SystemWGL,
33*8975f5c5SAndroid Build Coastguard Worker     ZinkEGL,
34*8975f5c5SAndroid Build Coastguard Worker };
35*8975f5c5SAndroid Build Coastguard Worker 
IsANGLE(angle::GLESDriverType driverType)36*8975f5c5SAndroid Build Coastguard Worker inline bool IsANGLE(angle::GLESDriverType driverType)
37*8975f5c5SAndroid Build Coastguard Worker {
38*8975f5c5SAndroid Build Coastguard Worker     return driverType == angle::GLESDriverType::AngleEGL ||
39*8975f5c5SAndroid Build Coastguard Worker            driverType == angle::GLESDriverType::AngleVulkanSecondariesEGL;
40*8975f5c5SAndroid Build Coastguard Worker }
41*8975f5c5SAndroid Build Coastguard Worker 
42*8975f5c5SAndroid Build Coastguard Worker GLESDriverType GetDriverTypeFromString(const char *driverName, GLESDriverType defaultDriverType);
43*8975f5c5SAndroid Build Coastguard Worker }  // namespace angle
44*8975f5c5SAndroid Build Coastguard Worker 
45*8975f5c5SAndroid Build Coastguard Worker struct EGLPlatformParameters
46*8975f5c5SAndroid Build Coastguard Worker {
47*8975f5c5SAndroid Build Coastguard Worker     EGLPlatformParameters() = default;
48*8975f5c5SAndroid Build Coastguard Worker 
EGLPlatformParametersEGLPlatformParameters49*8975f5c5SAndroid Build Coastguard Worker     explicit EGLPlatformParameters(EGLint renderer) : renderer(renderer) {}
50*8975f5c5SAndroid Build Coastguard Worker 
EGLPlatformParametersEGLPlatformParameters51*8975f5c5SAndroid Build Coastguard Worker     EGLPlatformParameters(EGLint renderer,
52*8975f5c5SAndroid Build Coastguard Worker                           EGLint majorVersion,
53*8975f5c5SAndroid Build Coastguard Worker                           EGLint minorVersion,
54*8975f5c5SAndroid Build Coastguard Worker                           EGLint deviceType)
55*8975f5c5SAndroid Build Coastguard Worker         : renderer(renderer),
56*8975f5c5SAndroid Build Coastguard Worker           majorVersion(majorVersion),
57*8975f5c5SAndroid Build Coastguard Worker           minorVersion(minorVersion),
58*8975f5c5SAndroid Build Coastguard Worker           deviceType(deviceType)
59*8975f5c5SAndroid Build Coastguard Worker     {}
60*8975f5c5SAndroid Build Coastguard Worker 
EGLPlatformParametersEGLPlatformParameters61*8975f5c5SAndroid Build Coastguard Worker     EGLPlatformParameters(EGLint renderer,
62*8975f5c5SAndroid Build Coastguard Worker                           EGLint majorVersion,
63*8975f5c5SAndroid Build Coastguard Worker                           EGLint minorVersion,
64*8975f5c5SAndroid Build Coastguard Worker                           EGLint deviceType,
65*8975f5c5SAndroid Build Coastguard Worker                           EGLint presentPath)
66*8975f5c5SAndroid Build Coastguard Worker         : renderer(renderer),
67*8975f5c5SAndroid Build Coastguard Worker           majorVersion(majorVersion),
68*8975f5c5SAndroid Build Coastguard Worker           minorVersion(minorVersion),
69*8975f5c5SAndroid Build Coastguard Worker           deviceType(deviceType),
70*8975f5c5SAndroid Build Coastguard Worker           presentPath(presentPath)
71*8975f5c5SAndroid Build Coastguard Worker     {}
72*8975f5c5SAndroid Build Coastguard Worker 
tieEGLPlatformParameters73*8975f5c5SAndroid Build Coastguard Worker     auto tie() const
74*8975f5c5SAndroid Build Coastguard Worker     {
75*8975f5c5SAndroid Build Coastguard Worker         return std::tie(renderer, majorVersion, minorVersion, deviceType, presentPath,
76*8975f5c5SAndroid Build Coastguard Worker                         debugLayersEnabled, robustness, displayPowerPreference,
77*8975f5c5SAndroid Build Coastguard Worker                         disabledFeatureOverrides, enabledFeatureOverrides, platformMethods);
78*8975f5c5SAndroid Build Coastguard Worker     }
79*8975f5c5SAndroid Build Coastguard Worker 
80*8975f5c5SAndroid Build Coastguard Worker     // Helpers to enable and disable ANGLE features.  Expects a kFeature* value from
81*8975f5c5SAndroid Build Coastguard Worker     // angle_features_autogen.h.
enableEGLPlatformParameters82*8975f5c5SAndroid Build Coastguard Worker     EGLPlatformParameters &enable(angle::Feature feature)
83*8975f5c5SAndroid Build Coastguard Worker     {
84*8975f5c5SAndroid Build Coastguard Worker         enabledFeatureOverrides.push_back(feature);
85*8975f5c5SAndroid Build Coastguard Worker         return *this;
86*8975f5c5SAndroid Build Coastguard Worker     }
disableEGLPlatformParameters87*8975f5c5SAndroid Build Coastguard Worker     EGLPlatformParameters &disable(angle::Feature feature)
88*8975f5c5SAndroid Build Coastguard Worker     {
89*8975f5c5SAndroid Build Coastguard Worker         disabledFeatureOverrides.push_back(feature);
90*8975f5c5SAndroid Build Coastguard Worker         return *this;
91*8975f5c5SAndroid Build Coastguard Worker     }
92*8975f5c5SAndroid Build Coastguard Worker 
93*8975f5c5SAndroid Build Coastguard Worker     EGLint renderer               = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
94*8975f5c5SAndroid Build Coastguard Worker     EGLint majorVersion           = EGL_DONT_CARE;
95*8975f5c5SAndroid Build Coastguard Worker     EGLint minorVersion           = EGL_DONT_CARE;
96*8975f5c5SAndroid Build Coastguard Worker     EGLint deviceType             = EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE;
97*8975f5c5SAndroid Build Coastguard Worker     EGLint presentPath            = EGL_DONT_CARE;
98*8975f5c5SAndroid Build Coastguard Worker     EGLint debugLayersEnabled     = EGL_DONT_CARE;
99*8975f5c5SAndroid Build Coastguard Worker     EGLint robustness             = EGL_DONT_CARE;
100*8975f5c5SAndroid Build Coastguard Worker     EGLint displayPowerPreference = EGL_DONT_CARE;
101*8975f5c5SAndroid Build Coastguard Worker 
102*8975f5c5SAndroid Build Coastguard Worker     std::vector<angle::Feature> enabledFeatureOverrides;
103*8975f5c5SAndroid Build Coastguard Worker     std::vector<angle::Feature> disabledFeatureOverrides;
104*8975f5c5SAndroid Build Coastguard Worker 
105*8975f5c5SAndroid Build Coastguard Worker     angle::PlatformMethods *platformMethods = nullptr;
106*8975f5c5SAndroid Build Coastguard Worker };
107*8975f5c5SAndroid Build Coastguard Worker 
108*8975f5c5SAndroid Build Coastguard Worker inline bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b)
109*8975f5c5SAndroid Build Coastguard Worker {
110*8975f5c5SAndroid Build Coastguard Worker     return a.tie() < b.tie();
111*8975f5c5SAndroid Build Coastguard Worker }
112*8975f5c5SAndroid Build Coastguard Worker 
113*8975f5c5SAndroid Build Coastguard Worker inline bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b)
114*8975f5c5SAndroid Build Coastguard Worker {
115*8975f5c5SAndroid Build Coastguard Worker     return a.tie() == b.tie();
116*8975f5c5SAndroid Build Coastguard Worker }
117*8975f5c5SAndroid Build Coastguard Worker 
118*8975f5c5SAndroid Build Coastguard Worker inline bool operator!=(const EGLPlatformParameters &a, const EGLPlatformParameters &b)
119*8975f5c5SAndroid Build Coastguard Worker {
120*8975f5c5SAndroid Build Coastguard Worker     return a.tie() != b.tie();
121*8975f5c5SAndroid Build Coastguard Worker }
122*8975f5c5SAndroid Build Coastguard Worker 
123*8975f5c5SAndroid Build Coastguard Worker #endif  // UTIL_EGLPLATFORMPARAMETERS_H_
124