1 //
2 // Copyright 2014 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
7 #ifndef ANGLE_TEST_CONFIGS_H_
8 #define ANGLE_TEST_CONFIGS_H_
9
10 // On Linux EGL/egl.h includes X.h which does defines for some very common
11 // names that are used by gtest (like None and Bool) and causes a lot of
12 // compilation errors. To work around this, even if this file doesn't use it,
13 // we include gtest before EGL so that it compiles fine in other files that
14 // want to use gtest.
15 #include <gtest/gtest.h>
16
17 #include <EGL/egl.h>
18 #include <EGL/eglext.h>
19
20 #include "angle_test_instantiate.h"
21 #include "util/EGLPlatformParameters.h"
22
23 namespace angle
24 {
25
26 struct PlatformParameters
27 {
28 PlatformParameters();
29 PlatformParameters(EGLint majorVersion,
30 EGLint minorVersion,
31 const EGLPlatformParameters &eglPlatformParameters);
32 PlatformParameters(EGLint majorVersion, EGLint minorVersion, GLESDriverType driver);
33
34 EGLint getRenderer() const;
35 EGLint getDeviceType() const;
36 bool isSwiftshader() const;
37 bool isVulkan() const;
38 bool isANGLE() const;
39 bool isMetal() const;
40 bool isWebGPU() const;
41
42 void initDefaultParameters();
43
tiePlatformParameters44 auto tie() const
45 {
46 return std::tie(driver, noFixture, eglParameters, majorVersion, minorVersion);
47 }
48
49 // Helpers to enable and disable ANGLE features. Expects a Feature::* value from
50 // angle_features_autogen.h.
enablePlatformParameters51 PlatformParameters &enable(Feature feature)
52 {
53 eglParameters.enable(feature);
54 return *this;
55 }
disablePlatformParameters56 PlatformParameters &disable(Feature feature)
57 {
58 eglParameters.disable(feature);
59 return *this;
60 }
61 bool isEnableRequested(Feature feature) const;
62 bool isDisableRequested(Feature feature) const;
63
64 GLESDriverType driver;
65 bool noFixture;
66 EGLPlatformParameters eglParameters;
67 EGLint majorVersion;
68 EGLint minorVersion;
69 };
70
71 const char *GetRendererName(EGLint renderer);
72
73 bool operator<(const PlatformParameters &a, const PlatformParameters &b);
74 bool operator==(const PlatformParameters &a, const PlatformParameters &b);
75 std::ostream &operator<<(std::ostream &stream, const PlatformParameters &pp);
76
77 // EGL platforms
78 namespace egl_platform
79 {
80
81 EGLPlatformParameters DEFAULT();
82 EGLPlatformParameters DEFAULT_NULL();
83
84 EGLPlatformParameters D3D9();
85 EGLPlatformParameters D3D9_NULL();
86 EGLPlatformParameters D3D9_REFERENCE();
87
88 EGLPlatformParameters D3D11();
89 EGLPlatformParameters D3D11_PRESENT_PATH_FAST();
90 EGLPlatformParameters D3D11_FL11_1();
91 EGLPlatformParameters D3D11_FL11_0();
92 EGLPlatformParameters D3D11_FL10_1();
93 EGLPlatformParameters D3D11_FL10_0();
94
95 EGLPlatformParameters D3D11_NULL();
96
97 EGLPlatformParameters D3D11_WARP();
98 EGLPlatformParameters D3D11_FL11_1_WARP();
99 EGLPlatformParameters D3D11_FL11_0_WARP();
100 EGLPlatformParameters D3D11_FL10_1_WARP();
101 EGLPlatformParameters D3D11_FL10_0_WARP();
102
103 EGLPlatformParameters D3D11_REFERENCE();
104 EGLPlatformParameters D3D11_FL11_1_REFERENCE();
105 EGLPlatformParameters D3D11_FL11_0_REFERENCE();
106 EGLPlatformParameters D3D11_FL10_1_REFERENCE();
107 EGLPlatformParameters D3D11_FL10_0_REFERENCE();
108
109 EGLPlatformParameters METAL();
110
111 EGLPlatformParameters OPENGL();
112 EGLPlatformParameters OPENGL(EGLint major, EGLint minor);
113 EGLPlatformParameters OPENGL_NULL();
114
115 EGLPlatformParameters OPENGLES();
116 EGLPlatformParameters OPENGLES(EGLint major, EGLint minor);
117 EGLPlatformParameters OPENGLES_NULL();
118
119 EGLPlatformParameters OPENGL_OR_GLES();
120 EGLPlatformParameters OPENGL_OR_GLES(EGLint major, EGLint minor);
121 EGLPlatformParameters OPENGL_OR_GLES_NULL();
122
123 EGLPlatformParameters VULKAN();
124 EGLPlatformParameters VULKAN_NULL();
125 EGLPlatformParameters VULKAN_SWIFTSHADER();
126
127 EGLPlatformParameters WEBGPU();
128
129 } // namespace egl_platform
130
131 // ANGLE tests platforms
132 PlatformParameters ES1_D3D9();
133 PlatformParameters ES2_D3D9();
134
135 PlatformParameters ES1_D3D11();
136 PlatformParameters ES2_D3D11();
137 PlatformParameters ES2_D3D11_PRESENT_PATH_FAST();
138 PlatformParameters ES2_D3D11_FL11_0();
139 PlatformParameters ES2_D3D11_FL10_1();
140 PlatformParameters ES2_D3D11_FL10_0();
141
142 PlatformParameters ES2_D3D11_WARP();
143 PlatformParameters ES2_D3D11_FL11_0_WARP();
144 PlatformParameters ES2_D3D11_FL10_1_WARP();
145 PlatformParameters ES2_D3D11_FL10_0_WARP();
146
147 PlatformParameters ES2_D3D11_REFERENCE();
148 PlatformParameters ES2_D3D11_FL11_0_REFERENCE();
149 PlatformParameters ES2_D3D11_FL10_1_REFERENCE();
150 PlatformParameters ES2_D3D11_FL10_0_REFERENCE();
151
152 PlatformParameters ES3_D3D11();
153 PlatformParameters ES3_D3D11_FL11_1();
154 PlatformParameters ES3_D3D11_FL11_0();
155 PlatformParameters ES3_D3D11_FL10_1();
156 PlatformParameters ES31_D3D11();
157 PlatformParameters ES31_D3D11_FL11_1();
158 PlatformParameters ES31_D3D11_FL11_0();
159
160 PlatformParameters ES3_D3D11_WARP();
161 PlatformParameters ES3_D3D11_FL11_1_WARP();
162 PlatformParameters ES3_D3D11_FL11_0_WARP();
163 PlatformParameters ES3_D3D11_FL10_1_WARP();
164
165 PlatformParameters ES1_OPENGL();
166 PlatformParameters ES2_OPENGL();
167 PlatformParameters ES2_OPENGL(EGLint major, EGLint minor);
168 PlatformParameters ES3_OPENGL();
169 PlatformParameters ES3_OPENGL(EGLint major, EGLint minor);
170 PlatformParameters ES31_OPENGL();
171 PlatformParameters ES31_OPENGL(EGLint major, EGLint minor);
172
173 PlatformParameters ES1_OPENGLES();
174 PlatformParameters ES2_OPENGLES();
175 PlatformParameters ES2_OPENGLES(EGLint major, EGLint minor);
176 PlatformParameters ES3_OPENGLES();
177 PlatformParameters ES3_OPENGLES(EGLint major, EGLint minor);
178 PlatformParameters ES31_OPENGLES();
179 PlatformParameters ES31_OPENGLES(EGLint major, EGLint minor);
180
181 PlatformParameters ES1_NULL();
182 PlatformParameters ES2_NULL();
183 PlatformParameters ES3_NULL();
184 PlatformParameters ES31_NULL();
185
186 PlatformParameters ES1_VULKAN();
187 PlatformParameters ES1_VULKAN_NULL();
188 PlatformParameters ES1_VULKAN_SWIFTSHADER();
189 PlatformParameters ES2_VULKAN();
190 PlatformParameters ES2_VULKAN_NULL();
191 PlatformParameters ES2_VULKAN_SWIFTSHADER();
192 PlatformParameters ES3_VULKAN();
193 PlatformParameters ES3_VULKAN_NULL();
194 PlatformParameters ES3_VULKAN_SWIFTSHADER();
195 PlatformParameters ES31_VULKAN();
196 PlatformParameters ES31_VULKAN_NULL();
197 PlatformParameters ES31_VULKAN_SWIFTSHADER();
198 PlatformParameters ES32_VULKAN();
199 PlatformParameters ES32_VULKAN_NULL();
200 PlatformParameters ES32_VULKAN_SWIFTSHADER();
201
202 PlatformParameters ES1_METAL();
203 PlatformParameters ES2_METAL();
204 PlatformParameters ES3_METAL();
205
206 PlatformParameters ES2_WGL();
207 PlatformParameters ES3_WGL();
208
209 PlatformParameters ES1_EGL();
210 PlatformParameters ES2_EGL();
211 PlatformParameters ES3_EGL();
212 PlatformParameters ES31_EGL();
213 PlatformParameters ES32_EGL();
214
215 PlatformParameters ES1_ANGLE_Vulkan_Secondaries();
216 PlatformParameters ES2_ANGLE_Vulkan_Secondaries();
217 PlatformParameters ES3_ANGLE_Vulkan_Secondaries();
218 PlatformParameters ES31_ANGLE_Vulkan_Secondaries();
219 PlatformParameters ES32_ANGLE_Vulkan_Secondaries();
220
221 PlatformParameters ES2_WEBGPU();
222
223 PlatformParameters ES1_Zink();
224 PlatformParameters ES2_Zink();
225 PlatformParameters ES3_Zink();
226 PlatformParameters ES31_Zink();
227 PlatformParameters ES32_Zink();
228
229 const char *GetNativeEGLLibraryNameWithExtension();
230
WithNoFixture(const PlatformParameters & params)231 inline PlatformParameters WithNoFixture(const PlatformParameters ¶ms)
232 {
233 PlatformParameters withNoFixture = params;
234 withNoFixture.noFixture = true;
235 return withNoFixture;
236 }
237
WithRobustness(const PlatformParameters & params)238 inline PlatformParameters WithRobustness(const PlatformParameters ¶ms)
239 {
240 PlatformParameters withRobustness = params;
241 withRobustness.eglParameters.robustness = EGL_TRUE;
242 return withRobustness;
243 }
244
WithLowPowerGPU(const PlatformParameters & paramsIn)245 inline PlatformParameters WithLowPowerGPU(const PlatformParameters ¶msIn)
246 {
247 PlatformParameters paramsOut = paramsIn;
248 paramsOut.eglParameters.displayPowerPreference = EGL_LOW_POWER_ANGLE;
249 return paramsOut;
250 }
251
WithHighPowerGPU(const PlatformParameters & paramsIn)252 inline PlatformParameters WithHighPowerGPU(const PlatformParameters ¶msIn)
253 {
254 PlatformParameters paramsOut = paramsIn;
255 paramsOut.eglParameters.displayPowerPreference = EGL_HIGH_POWER_ANGLE;
256 return paramsOut;
257 }
258
WithVulkanSecondaries(const PlatformParameters & params)259 inline PlatformParameters WithVulkanSecondaries(const PlatformParameters ¶ms)
260 {
261 PlatformParameters paramsOut = params;
262 paramsOut.driver = GLESDriverType::AngleVulkanSecondariesEGL;
263 return paramsOut;
264 }
265 } // namespace angle
266
267 #endif // ANGLE_TEST_CONFIGS_H_
268