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 <tuple>
14 
15 namespace angle
16 {
17 struct PlatformMethods;
18 
19 // The GLES driver type determines what shared object we use to load the GLES entry points.
20 // AngleEGL loads from ANGLE's version of libEGL, libGLESv2, and libGLESv1_CM.
21 // SystemEGL uses the system copies of libEGL, libGLESv2, and libGLESv1_CM.
22 // SystemWGL loads Windows GL with the GLES compatiblity extensions. See util/WGLWindow.h.
23 enum class GLESDriverType
24 {
25     AngleEGL,
26     SystemEGL,
27     SystemWGL,
28 };
29 }  // namespace angle
30 
31 struct EGLPlatformParameters
32 {
33     EGLPlatformParameters() = default;
34 
EGLPlatformParametersEGLPlatformParameters35     explicit EGLPlatformParameters(EGLint renderer) : renderer(renderer) {}
36 
EGLPlatformParametersEGLPlatformParameters37     EGLPlatformParameters(EGLint renderer,
38                           EGLint majorVersion,
39                           EGLint minorVersion,
40                           EGLint deviceType)
41         : renderer(renderer),
42           majorVersion(majorVersion),
43           minorVersion(minorVersion),
44           deviceType(deviceType)
45     {}
46 
EGLPlatformParametersEGLPlatformParameters47     EGLPlatformParameters(EGLint renderer,
48                           EGLint majorVersion,
49                           EGLint minorVersion,
50                           EGLint deviceType,
51                           EGLint presentPath)
52         : renderer(renderer),
53           majorVersion(majorVersion),
54           minorVersion(minorVersion),
55           deviceType(deviceType),
56           presentPath(presentPath)
57     {}
58 
tieEGLPlatformParameters59     auto tie() const
60     {
61         return std::tie(renderer, majorVersion, minorVersion, deviceType, presentPath,
62                         debugLayersEnabled, contextVirtualization, transformFeedbackFeature,
63                         allocateNonZeroMemoryFeature, emulateCopyTexImage2DFromRenderbuffers,
64                         shaderStencilOutputFeature, genMultipleMipsPerPassFeature, platformMethods,
65                         robustness, emulatedPrerotation, asyncCommandQueueFeatureVulkan,
66                         hasExplicitMemBarrierFeatureMtl, hasCheapRenderPassFeatureMtl,
67                         forceBufferGPUStorageFeatureMtl, supportsVulkanViewportFlip, emulatedVAOs,
68                         directSPIRVGeneration);
69     }
70 
71     EGLint renderer                               = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
72     EGLint majorVersion                           = EGL_DONT_CARE;
73     EGLint minorVersion                           = EGL_DONT_CARE;
74     EGLint deviceType                             = EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE;
75     EGLint presentPath                            = EGL_DONT_CARE;
76     EGLint debugLayersEnabled                     = EGL_DONT_CARE;
77     EGLint contextVirtualization                  = EGL_DONT_CARE;
78     EGLint robustness                             = EGL_DONT_CARE;
79     EGLint transformFeedbackFeature               = EGL_DONT_CARE;
80     EGLint allocateNonZeroMemoryFeature           = EGL_DONT_CARE;
81     EGLint emulateCopyTexImage2DFromRenderbuffers = EGL_DONT_CARE;
82     EGLint shaderStencilOutputFeature             = EGL_DONT_CARE;
83     EGLint genMultipleMipsPerPassFeature          = EGL_DONT_CARE;
84     uint32_t emulatedPrerotation                  = 0;  // Can be 0, 90, 180 or 270
85     EGLint asyncCommandQueueFeatureVulkan         = EGL_DONT_CARE;
86     EGLint hasExplicitMemBarrierFeatureMtl        = EGL_DONT_CARE;
87     EGLint hasCheapRenderPassFeatureMtl           = EGL_DONT_CARE;
88     EGLint forceBufferGPUStorageFeatureMtl        = EGL_DONT_CARE;
89     EGLint supportsVulkanViewportFlip             = EGL_DONT_CARE;
90     EGLint emulatedVAOs                           = EGL_DONT_CARE;
91     EGLint directSPIRVGeneration                  = EGL_DONT_CARE;
92     angle::PlatformMethods *platformMethods       = nullptr;
93 };
94 
95 inline bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b)
96 {
97     return a.tie() < b.tie();
98 }
99 
100 inline bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b)
101 {
102     return a.tie() == b.tie();
103 }
104 
105 inline bool operator!=(const EGLPlatformParameters &a, const EGLPlatformParameters &b)
106 {
107     return a.tie() != b.tie();
108 }
109 
110 #endif  // UTIL_EGLPLATFORMPARAMETERS_H_
111