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