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