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
40 void initDefaultParameters();
41
tiePlatformParameters42 auto tie() const
43 {
44 return std::tie(driver, noFixture, eglParameters, majorVersion, minorVersion);
45 }
46
47 // Helpers to enable and disable ANGLE features. Expects a Feature::* value from
48 // angle_features_autogen.h.
enablePlatformParameters49 PlatformParameters &enable(Feature feature)
50 {
51 eglParameters.enable(feature);
52 return *this;
53 }
disablePlatformParameters54 PlatformParameters &disable(Feature feature)
55 {
56 eglParameters.disable(feature);
57 return *this;
58 }
59 bool isEnabled(Feature feature) const;
60 bool isDisabled(Feature feature) const;
61
62 GLESDriverType driver;
63 bool noFixture;
64 EGLPlatformParameters eglParameters;
65 EGLint majorVersion;
66 EGLint minorVersion;
67 };
68
69 const char *GetRendererName(EGLint renderer);
70
71 bool operator<(const PlatformParameters &a, const PlatformParameters &b);
72 bool operator==(const PlatformParameters &a, const PlatformParameters &b);
73 std::ostream &operator<<(std::ostream &stream, const PlatformParameters &pp);
74
75 // EGL platforms
76 namespace egl_platform
77 {
78
79 EGLPlatformParameters DEFAULT();
80 EGLPlatformParameters DEFAULT_NULL();
81
82 EGLPlatformParameters D3D9();
83 EGLPlatformParameters D3D9_NULL();
84 EGLPlatformParameters D3D9_REFERENCE();
85
86 EGLPlatformParameters D3D11();
87 EGLPlatformParameters D3D11_PRESENT_PATH_FAST();
88 EGLPlatformParameters D3D11_FL11_1();
89 EGLPlatformParameters D3D11_FL11_0();
90 EGLPlatformParameters D3D11_FL10_1();
91 EGLPlatformParameters D3D11_FL10_0();
92
93 EGLPlatformParameters D3D11_NULL();
94
95 EGLPlatformParameters D3D11_WARP();
96 EGLPlatformParameters D3D11_FL11_1_WARP();
97 EGLPlatformParameters D3D11_FL11_0_WARP();
98 EGLPlatformParameters D3D11_FL10_1_WARP();
99 EGLPlatformParameters D3D11_FL10_0_WARP();
100
101 EGLPlatformParameters D3D11_REFERENCE();
102 EGLPlatformParameters D3D11_FL11_1_REFERENCE();
103 EGLPlatformParameters D3D11_FL11_0_REFERENCE();
104 EGLPlatformParameters D3D11_FL10_1_REFERENCE();
105 EGLPlatformParameters D3D11_FL10_0_REFERENCE();
106
107 EGLPlatformParameters OPENGL();
108 EGLPlatformParameters OPENGL(EGLint major, EGLint minor);
109 EGLPlatformParameters OPENGL_NULL();
110
111 EGLPlatformParameters OPENGLES();
112 EGLPlatformParameters OPENGLES(EGLint major, EGLint minor);
113 EGLPlatformParameters OPENGLES_NULL();
114
115 EGLPlatformParameters OPENGL_OR_GLES();
116 EGLPlatformParameters OPENGL_OR_GLES(EGLint major, EGLint minor);
117 EGLPlatformParameters OPENGL_OR_GLES_NULL();
118
119 EGLPlatformParameters VULKAN();
120 EGLPlatformParameters VULKAN_NULL();
121 EGLPlatformParameters VULKAN_SWIFTSHADER();
122
123 } // namespace egl_platform
124
125 // ANGLE tests platforms
126 PlatformParameters ES1_D3D9();
127 PlatformParameters ES2_D3D9();
128
129 PlatformParameters ES1_D3D11();
130 PlatformParameters ES2_D3D11();
131 PlatformParameters ES2_D3D11_PRESENT_PATH_FAST();
132 PlatformParameters ES2_D3D11_FL11_0();
133 PlatformParameters ES2_D3D11_FL10_1();
134 PlatformParameters ES2_D3D11_FL10_0();
135
136 PlatformParameters ES2_D3D11_WARP();
137 PlatformParameters ES2_D3D11_FL11_0_WARP();
138 PlatformParameters ES2_D3D11_FL10_1_WARP();
139 PlatformParameters ES2_D3D11_FL10_0_WARP();
140
141 PlatformParameters ES2_D3D11_REFERENCE();
142 PlatformParameters ES2_D3D11_FL11_0_REFERENCE();
143 PlatformParameters ES2_D3D11_FL10_1_REFERENCE();
144 PlatformParameters ES2_D3D11_FL10_0_REFERENCE();
145
146 PlatformParameters ES3_D3D11();
147 PlatformParameters ES3_D3D11_FL11_1();
148 PlatformParameters ES3_D3D11_FL11_0();
149 PlatformParameters ES3_D3D11_FL10_1();
150 PlatformParameters ES31_D3D11();
151 PlatformParameters ES31_D3D11_FL11_1();
152 PlatformParameters ES31_D3D11_FL11_0();
153
154 PlatformParameters ES3_D3D11_WARP();
155 PlatformParameters ES3_D3D11_FL11_1_WARP();
156 PlatformParameters ES3_D3D11_FL11_0_WARP();
157 PlatformParameters ES3_D3D11_FL10_1_WARP();
158
159 PlatformParameters ES1_OPENGL();
160 PlatformParameters ES2_OPENGL();
161 PlatformParameters ES2_OPENGL(EGLint major, EGLint minor);
162 PlatformParameters ES3_OPENGL();
163 PlatformParameters ES3_OPENGL(EGLint major, EGLint minor);
164 PlatformParameters ES31_OPENGL();
165 PlatformParameters ES31_OPENGL(EGLint major, EGLint minor);
166
167 PlatformParameters ES1_OPENGLES();
168 PlatformParameters ES2_OPENGLES();
169 PlatformParameters ES2_OPENGLES(EGLint major, EGLint minor);
170 PlatformParameters ES3_OPENGLES();
171 PlatformParameters ES3_OPENGLES(EGLint major, EGLint minor);
172 PlatformParameters ES31_OPENGLES();
173 PlatformParameters ES31_OPENGLES(EGLint major, EGLint minor);
174
175 PlatformParameters ES1_NULL();
176 PlatformParameters ES2_NULL();
177 PlatformParameters ES3_NULL();
178 PlatformParameters ES31_NULL();
179
180 PlatformParameters ES1_VULKAN();
181 PlatformParameters ES1_VULKAN_NULL();
182 PlatformParameters ES1_VULKAN_SWIFTSHADER();
183 PlatformParameters ES2_VULKAN();
184 PlatformParameters ES2_VULKAN_NULL();
185 PlatformParameters ES2_VULKAN_SWIFTSHADER();
186 PlatformParameters ES3_VULKAN();
187 PlatformParameters ES3_VULKAN_NULL();
188 PlatformParameters ES3_VULKAN_SWIFTSHADER();
189 PlatformParameters ES31_VULKAN();
190 PlatformParameters ES31_VULKAN_NULL();
191 PlatformParameters ES31_VULKAN_SWIFTSHADER();
192 PlatformParameters ES32_VULKAN();
193 PlatformParameters ES32_VULKAN_NULL();
194 PlatformParameters ES32_VULKAN_SWIFTSHADER();
195
196 PlatformParameters ES1_METAL();
197 PlatformParameters ES2_METAL();
198 PlatformParameters ES3_METAL();
199
200 PlatformParameters ES2_WGL();
201 PlatformParameters ES3_WGL();
202
203 PlatformParameters ES2_EGL();
204 PlatformParameters ES3_EGL();
205
206 const char *GetNativeEGLLibraryNameWithExtension();
207
WithNoFixture(const PlatformParameters & params)208 inline PlatformParameters WithNoFixture(const PlatformParameters ¶ms)
209 {
210 PlatformParameters withNoFixture = params;
211 withNoFixture.noFixture = true;
212 return withNoFixture;
213 }
214
WithRobustness(const PlatformParameters & params)215 inline PlatformParameters WithRobustness(const PlatformParameters ¶ms)
216 {
217 PlatformParameters withRobustness = params;
218 withRobustness.eglParameters.robustness = EGL_TRUE;
219 return withRobustness;
220 }
221
WithLowPowerGPU(const PlatformParameters & paramsIn)222 inline PlatformParameters WithLowPowerGPU(const PlatformParameters ¶msIn)
223 {
224 PlatformParameters paramsOut = paramsIn;
225 paramsOut.eglParameters.displayPowerPreference = EGL_LOW_POWER_ANGLE;
226 return paramsOut;
227 }
228
WithHighPowerGPU(const PlatformParameters & paramsIn)229 inline PlatformParameters WithHighPowerGPU(const PlatformParameters ¶msIn)
230 {
231 PlatformParameters paramsOut = paramsIn;
232 paramsOut.eglParameters.displayPowerPreference = EGL_HIGH_POWER_ANGLE;
233 return paramsOut;
234 }
235 } // namespace angle
236
237 #endif // ANGLE_TEST_CONFIGS_H_
238