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 EGLint getAllocateNonZeroMemoryFeature() const;
38
39 void initDefaultParameters();
40
tiePlatformParameters41 auto tie() const
42 {
43 return std::tie(driver, noFixture, eglParameters, majorVersion, minorVersion);
44 }
45
46 GLESDriverType driver;
47 bool noFixture;
48 EGLPlatformParameters eglParameters;
49 EGLint majorVersion;
50 EGLint minorVersion;
51 };
52
53 const char *GetRendererName(EGLint renderer);
54
55 bool operator<(const PlatformParameters &a, const PlatformParameters &b);
56 bool operator==(const PlatformParameters &a, const PlatformParameters &b);
57 std::ostream &operator<<(std::ostream &stream, const PlatformParameters &pp);
58
59 // EGL platforms
60 namespace egl_platform
61 {
62
63 EGLPlatformParameters DEFAULT();
64 EGLPlatformParameters DEFAULT_NULL();
65
66 EGLPlatformParameters D3D9();
67 EGLPlatformParameters D3D9_NULL();
68 EGLPlatformParameters D3D9_REFERENCE();
69
70 EGLPlatformParameters D3D11();
71 EGLPlatformParameters D3D11_PRESENT_PATH_FAST();
72 EGLPlatformParameters D3D11_FL11_1();
73 EGLPlatformParameters D3D11_FL11_0();
74 EGLPlatformParameters D3D11_FL10_1();
75 EGLPlatformParameters D3D11_FL10_0();
76 EGLPlatformParameters D3D11_FL9_3();
77
78 EGLPlatformParameters D3D11_NULL();
79
80 EGLPlatformParameters D3D11_WARP();
81 EGLPlatformParameters D3D11_FL11_1_WARP();
82 EGLPlatformParameters D3D11_FL11_0_WARP();
83 EGLPlatformParameters D3D11_FL10_1_WARP();
84 EGLPlatformParameters D3D11_FL10_0_WARP();
85 EGLPlatformParameters D3D11_FL9_3_WARP();
86
87 EGLPlatformParameters D3D11_REFERENCE();
88 EGLPlatformParameters D3D11_FL11_1_REFERENCE();
89 EGLPlatformParameters D3D11_FL11_0_REFERENCE();
90 EGLPlatformParameters D3D11_FL10_1_REFERENCE();
91 EGLPlatformParameters D3D11_FL10_0_REFERENCE();
92 EGLPlatformParameters D3D11_FL9_3_REFERENCE();
93
94 EGLPlatformParameters OPENGL();
95 EGLPlatformParameters OPENGL(EGLint major, EGLint minor);
96 EGLPlatformParameters OPENGL_NULL();
97
98 EGLPlatformParameters OPENGLES();
99 EGLPlatformParameters OPENGLES(EGLint major, EGLint minor);
100 EGLPlatformParameters OPENGLES_NULL();
101
102 EGLPlatformParameters OPENGL_OR_GLES();
103 EGLPlatformParameters OPENGL_OR_GLES(EGLint major, EGLint minor);
104 EGLPlatformParameters OPENGL_OR_GLES_NULL();
105
106 EGLPlatformParameters VULKAN();
107 EGLPlatformParameters VULKAN_NULL();
108 EGLPlatformParameters VULKAN_SWIFTSHADER();
109
110 } // namespace egl_platform
111
112 // ANGLE tests platforms
113 PlatformParameters ES1_D3D9();
114 PlatformParameters ES2_D3D9();
115
116 PlatformParameters ES1_D3D11();
117 PlatformParameters ES2_D3D11();
118 PlatformParameters ES2_D3D11_PRESENT_PATH_FAST();
119 PlatformParameters ES2_D3D11_FL11_0();
120 PlatformParameters ES2_D3D11_FL10_1();
121 PlatformParameters ES2_D3D11_FL10_0();
122 PlatformParameters ES2_D3D11_FL9_3();
123
124 PlatformParameters ES2_D3D11_WARP();
125 PlatformParameters ES2_D3D11_FL11_0_WARP();
126 PlatformParameters ES2_D3D11_FL10_1_WARP();
127 PlatformParameters ES2_D3D11_FL10_0_WARP();
128 PlatformParameters ES2_D3D11_FL9_3_WARP();
129
130 PlatformParameters ES2_D3D11_REFERENCE();
131 PlatformParameters ES2_D3D11_FL11_0_REFERENCE();
132 PlatformParameters ES2_D3D11_FL10_1_REFERENCE();
133 PlatformParameters ES2_D3D11_FL10_0_REFERENCE();
134 PlatformParameters ES2_D3D11_FL9_3_REFERENCE();
135
136 PlatformParameters ES3_D3D11();
137 PlatformParameters ES3_D3D11_FL11_1();
138 PlatformParameters ES3_D3D11_FL11_0();
139 PlatformParameters ES3_D3D11_FL10_1();
140 PlatformParameters ES31_D3D11();
141 PlatformParameters ES31_D3D11_FL11_1();
142 PlatformParameters ES31_D3D11_FL11_0();
143
144 PlatformParameters ES3_D3D11_WARP();
145 PlatformParameters ES3_D3D11_FL11_1_WARP();
146 PlatformParameters ES3_D3D11_FL11_0_WARP();
147 PlatformParameters ES3_D3D11_FL10_1_WARP();
148
149 PlatformParameters ES1_OPENGL();
150 PlatformParameters ES2_OPENGL();
151 PlatformParameters ES2_OPENGL(EGLint major, EGLint minor);
152 PlatformParameters ES3_OPENGL();
153 PlatformParameters ES3_OPENGL(EGLint major, EGLint minor);
154 PlatformParameters ES31_OPENGL();
155 PlatformParameters ES31_OPENGL(EGLint major, EGLint minor);
156
157 PlatformParameters ES1_OPENGLES();
158 PlatformParameters ES2_OPENGLES();
159 PlatformParameters ES2_OPENGLES(EGLint major, EGLint minor);
160 PlatformParameters ES3_OPENGLES();
161 PlatformParameters ES3_OPENGLES(EGLint major, EGLint minor);
162 PlatformParameters ES31_OPENGLES();
163 PlatformParameters ES31_OPENGLES(EGLint major, EGLint minor);
164
165 PlatformParameters ES1_NULL();
166 PlatformParameters ES2_NULL();
167 PlatformParameters ES3_NULL();
168 PlatformParameters ES31_NULL();
169
170 PlatformParameters ES1_VULKAN();
171 PlatformParameters ES1_VULKAN_NULL();
172 PlatformParameters ES1_VULKAN_SWIFTSHADER();
173 PlatformParameters ES2_VULKAN();
174 PlatformParameters ES2_VULKAN_NULL();
175 PlatformParameters ES2_VULKAN_SWIFTSHADER();
176 PlatformParameters ES3_VULKAN();
177 PlatformParameters ES3_VULKAN_NULL();
178 PlatformParameters ES3_VULKAN_SWIFTSHADER();
179 PlatformParameters ES31_VULKAN();
180 PlatformParameters ES31_VULKAN_NULL();
181 PlatformParameters ES31_VULKAN_SWIFTSHADER();
182 PlatformParameters ES32_VULKAN();
183 PlatformParameters ES32_VULKAN_NULL();
184 PlatformParameters ES32_VULKAN_SWIFTSHADER();
185
186 PlatformParameters ES1_METAL();
187 PlatformParameters ES2_METAL();
188 PlatformParameters ES3_METAL();
189
190 PlatformParameters ES2_WGL();
191 PlatformParameters ES3_WGL();
192
193 PlatformParameters ES2_EGL();
194 PlatformParameters ES3_EGL();
195
196 const char *GetNativeEGLLibraryNameWithExtension();
197
WithNoVirtualContexts(const PlatformParameters & params)198 inline PlatformParameters WithNoVirtualContexts(const PlatformParameters ¶ms)
199 {
200 PlatformParameters withNoVirtualContexts = params;
201 withNoVirtualContexts.eglParameters.contextVirtualization = EGL_FALSE;
202 return withNoVirtualContexts;
203 }
204
WithNoFixture(const PlatformParameters & params)205 inline PlatformParameters WithNoFixture(const PlatformParameters ¶ms)
206 {
207 PlatformParameters withNoFixture = params;
208 withNoFixture.noFixture = true;
209 return withNoFixture;
210 }
211
WithNoTransformFeedback(const PlatformParameters & params)212 inline PlatformParameters WithNoTransformFeedback(const PlatformParameters ¶ms)
213 {
214 PlatformParameters withNoTransformFeedback = params;
215 withNoTransformFeedback.eglParameters.transformFeedbackFeature = EGL_FALSE;
216 return withNoTransformFeedback;
217 }
218
WithAllocateNonZeroMemory(const PlatformParameters & params)219 inline PlatformParameters WithAllocateNonZeroMemory(const PlatformParameters ¶ms)
220 {
221 PlatformParameters allocateNonZero = params;
222 allocateNonZero.eglParameters.allocateNonZeroMemoryFeature = EGL_TRUE;
223 return allocateNonZero;
224 }
225
WithEmulateCopyTexImage2DFromRenderbuffers(const PlatformParameters & params)226 inline PlatformParameters WithEmulateCopyTexImage2DFromRenderbuffers(
227 const PlatformParameters ¶ms)
228 {
229 PlatformParameters p = params;
230 p.eglParameters.emulateCopyTexImage2DFromRenderbuffers = EGL_TRUE;
231 return p;
232 }
233
WithNoShaderStencilOutput(const PlatformParameters & params)234 inline PlatformParameters WithNoShaderStencilOutput(const PlatformParameters ¶ms)
235 {
236 PlatformParameters re = params;
237 re.eglParameters.shaderStencilOutputFeature = EGL_FALSE;
238 return re;
239 }
240
WithNoGenMultipleMipsPerPass(const PlatformParameters & params)241 inline PlatformParameters WithNoGenMultipleMipsPerPass(const PlatformParameters ¶ms)
242 {
243 PlatformParameters re = params;
244 re.eglParameters.genMultipleMipsPerPassFeature = EGL_FALSE;
245 return re;
246 }
247
WithMetalMemoryBarrierAndCheapRenderPass(const PlatformParameters & params,bool hasBarrier,bool cheapRenderPass)248 inline PlatformParameters WithMetalMemoryBarrierAndCheapRenderPass(const PlatformParameters ¶ms,
249 bool hasBarrier,
250 bool cheapRenderPass)
251 {
252 PlatformParameters re = params;
253 re.eglParameters.hasExplicitMemBarrierFeatureMtl = hasBarrier ? EGL_TRUE : EGL_FALSE;
254 re.eglParameters.hasCheapRenderPassFeatureMtl = cheapRenderPass ? EGL_TRUE : EGL_FALSE;
255 return re;
256 }
257
WithMetalForcedBufferGPUStorage(const PlatformParameters & params)258 inline PlatformParameters WithMetalForcedBufferGPUStorage(const PlatformParameters ¶ms)
259 {
260 PlatformParameters re = params;
261 re.eglParameters.forceBufferGPUStorageFeatureMtl = EGL_TRUE;
262 return re;
263 }
264
WithRobustness(const PlatformParameters & params)265 inline PlatformParameters WithRobustness(const PlatformParameters ¶ms)
266 {
267 PlatformParameters withRobustness = params;
268 withRobustness.eglParameters.robustness = EGL_TRUE;
269 return withRobustness;
270 }
271
WithEmulatedPrerotation(const PlatformParameters & params,EGLint rotation)272 inline PlatformParameters WithEmulatedPrerotation(const PlatformParameters ¶ms, EGLint rotation)
273 {
274 PlatformParameters prerotation = params;
275 prerotation.eglParameters.emulatedPrerotation = rotation;
276 return prerotation;
277 }
278
WithAsyncCommandQueueFeatureVulkan(const PlatformParameters & params)279 inline PlatformParameters WithAsyncCommandQueueFeatureVulkan(const PlatformParameters ¶ms)
280 {
281 PlatformParameters withAsyncCommandQueue = params;
282 withAsyncCommandQueue.eglParameters.asyncCommandQueueFeatureVulkan = EGL_TRUE;
283 return withAsyncCommandQueue;
284 }
285
WithNoVulkanViewportFlip(const PlatformParameters & params)286 inline PlatformParameters WithNoVulkanViewportFlip(const PlatformParameters ¶ms)
287 {
288 PlatformParameters withoutVulkanViewportFlip = params;
289 withoutVulkanViewportFlip.eglParameters.supportsVulkanViewportFlip = EGL_FALSE;
290 return withoutVulkanViewportFlip;
291 }
292
WithEmulatedVAOs(const PlatformParameters & params)293 inline PlatformParameters WithEmulatedVAOs(const PlatformParameters ¶ms)
294 {
295 PlatformParameters emualtedVAOParams = params;
296 emualtedVAOParams.eglParameters.emulatedVAOs = EGL_TRUE;
297 return emualtedVAOParams;
298 }
299
WithDirectSPIRVGeneration(const PlatformParameters & params)300 inline PlatformParameters WithDirectSPIRVGeneration(const PlatformParameters ¶ms)
301 {
302 PlatformParameters directSPIRVGeneration = params;
303 directSPIRVGeneration.eglParameters.directSPIRVGeneration = EGL_TRUE;
304 return directSPIRVGeneration;
305 }
306 } // namespace angle
307
308 #endif // ANGLE_TEST_CONFIGS_H_
309