blob: 310beb5de63af1c17bd8ee127a616ab837328f39 [file] [log] [blame]
Jamie Madillfa05f602015-05-07 13:47:11 -04001//
2// Copyright 2015 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// RendererTest:
7// These tests are designed to ensure that the various configurations of the test fixtures work as expected.
8// If one of these tests fails, then it is likely that some of the other tests are being configured incorrectly.
9// For example, they might be using the D3D11 renderer when the test is meant to be using the D3D9 renderer.
10
Corentin Wallezd3970de2015-05-14 11:07:48 -040011#include "test_utils/ANGLETest.h"
Austin Kinross18b931d2014-09-29 12:58:31 -070012
Jamie Madillef97c612017-09-09 23:34:18 -040013#include "common/string_utils.h"
14
Jamie Madillfa05f602015-05-07 13:47:11 -040015using namespace angle;
Austin Kinross18b931d2014-09-29 12:58:31 -070016
Jamie Madillfa05f602015-05-07 13:47:11 -040017namespace
18{
Geoff Lang7825f612014-11-26 16:19:41 -050019
Austin Kinross18b931d2014-09-29 12:58:31 -070020class RendererTest : public ANGLETest
21{
22 protected:
Jamie Madillfa05f602015-05-07 13:47:11 -040023 RendererTest()
Austin Kinross18b931d2014-09-29 12:58:31 -070024 {
25 setWindowWidth(128);
26 setWindowHeight(128);
27 }
Austin Kinross18b931d2014-09-29 12:58:31 -070028};
29
Jamie Madillfa05f602015-05-07 13:47:11 -040030TEST_P(RendererTest, RequestedRendererCreated)
Austin Kinross18b931d2014-09-29 12:58:31 -070031{
32 std::string rendererString = std::string(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
Jamie Madillef97c612017-09-09 23:34:18 -040033 angle::ToLower(&rendererString);
Austin Kinross18b931d2014-09-29 12:58:31 -070034
35 std::string versionString = std::string(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
Jamie Madillef97c612017-09-09 23:34:18 -040036 angle::ToLower(&versionString);
Austin Kinross18b931d2014-09-29 12:58:31 -070037
Geoff Langdd323e92015-06-09 15:16:31 -040038 const EGLPlatformParameters &platform = GetParam().eglParameters;
Geoff Lang0d3683c2014-10-23 11:08:16 -040039
Austin Kinross18b931d2014-09-29 12:58:31 -070040 // Ensure that the renderer string contains D3D11, if we requested a D3D11 renderer.
Geoff Lang0d3683c2014-10-23 11:08:16 -040041 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
Austin Kinross18b931d2014-09-29 12:58:31 -070042 {
43 ASSERT_NE(rendererString.find(std::string("direct3d11")), std::string::npos);
44 }
45
46 // Ensure that the renderer string contains D3D9, if we requested a D3D9 renderer.
Geoff Lang0d3683c2014-10-23 11:08:16 -040047 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
Austin Kinross18b931d2014-09-29 12:58:31 -070048 {
49 ASSERT_NE(rendererString.find(std::string("direct3d9")), std::string::npos);
50 }
51
Geoff Lang0d3683c2014-10-23 11:08:16 -040052 // Ensure that the major and minor versions trigger expected behavior in D3D11
53 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
54 {
Geoff Lang7825f612014-11-26 16:19:41 -050055 // Ensure that the renderer uses WARP, if we requested it.
56 if (platform.deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE)
57 {
58 auto basicRenderPos = rendererString.find(std::string("microsoft basic render"));
59 auto softwareAdapterPos = rendererString.find(std::string("software adapter"));
60 ASSERT_TRUE(basicRenderPos != std::string::npos || softwareAdapterPos != std::string::npos);
61 }
62
Geoff Lang0d3683c2014-10-23 11:08:16 -040063 std::vector<std::string> acceptableShaderModels;
64
65 // When no specific major/minor version is requested, then ANGLE should return the highest possible feature level by default.
66 // The current hardware driver might not support Feature Level 11_0, but WARP always does.
67 // Therefore if WARP is specified but no major/minor version is specified, then we test to check that ANGLE returns FL11_0.
68 if (platform.majorVersion >= 11 || platform.majorVersion == EGL_DONT_CARE)
69 {
70 // Feature Level 10_0 corresponds to shader model 5_0
71 acceptableShaderModels.push_back("ps_5_0");
72 }
73
74 if (platform.majorVersion >= 10 || platform.majorVersion == EGL_DONT_CARE)
75 {
76 if (platform.minorVersion >= 1 || platform.minorVersion == EGL_DONT_CARE)
77 {
78 // Feature Level 10_1 corresponds to shader model 4_1
79 acceptableShaderModels.push_back("ps_4_1");
80 }
81
82 if (platform.minorVersion >= 0 || platform.minorVersion == EGL_DONT_CARE)
83 {
84 // Feature Level 10_0 corresponds to shader model 4_0
85 acceptableShaderModels.push_back("ps_4_0");
86 }
87 }
88
Austin Kinross0dbda052014-12-04 18:13:04 -080089 if (platform.majorVersion == 9 && platform.minorVersion == 3)
90 {
91 acceptableShaderModels.push_back("ps_4_0_level_9_3");
92 }
93
Geoff Lang0d3683c2014-10-23 11:08:16 -040094 bool found = false;
95 for (size_t i = 0; i < acceptableShaderModels.size(); i++)
96 {
97 if (rendererString.find(acceptableShaderModels[i]) != std::string::npos)
98 {
99 found = true;
100 }
101 }
102
103 ASSERT_TRUE(found);
104 }
105
Geoff Lang76cdbd52016-09-23 16:51:04 -0400106 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)
107 {
108 ASSERT_TRUE(IsNULL());
109 }
110
Jamie Madille09bd5d2016-11-29 16:20:35 -0500111 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
112 {
113 ASSERT_TRUE(IsVulkan());
114 }
115
Geoff Langdd323e92015-06-09 15:16:31 -0400116 EGLint glesMajorVersion = GetParam().majorVersion;
Geoff Langc339c4e2016-11-29 10:37:36 -0500117 EGLint glesMinorVersion = GetParam().minorVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400118
Geoff Langc339c4e2016-11-29 10:37:36 -0500119 // Ensure that the renderer string contains the requested version number
120 if (glesMajorVersion == 3 && glesMinorVersion == 1)
121 {
122 ASSERT_NE(versionString.find(std::string("es 3.1")), std::string::npos);
123 }
124 else if (glesMajorVersion == 3 && glesMinorVersion == 0)
Austin Kinross18b931d2014-09-29 12:58:31 -0700125 {
126 ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos);
127 }
Geoff Langc339c4e2016-11-29 10:37:36 -0500128 else if (glesMajorVersion == 2 && glesMinorVersion == 0)
Austin Kinross18b931d2014-09-29 12:58:31 -0700129 {
130 ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos);
131 }
Geoff Langc339c4e2016-11-29 10:37:36 -0500132 else
133 {
134 FAIL() << "Unhandled GL ES client version.";
135 }
Jamie Madille09bd5d2016-11-29 16:20:35 -0500136
137 ASSERT_GL_NO_ERROR();
138 ASSERT_EGL_SUCCESS();
Austin Kinross18b931d2014-09-29 12:58:31 -0700139}
Geoff Lang7825f612014-11-26 16:19:41 -0500140
141// Perform a simple operation (clear and read pixels) to verify the device is working
Jamie Madillfa05f602015-05-07 13:47:11 -0400142TEST_P(RendererTest, SimpleOperation)
Geoff Lang7825f612014-11-26 16:19:41 -0500143{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400144 if (IsNULL())
145 {
146 std::cout << "ANGLE NULL backend clears are not functional" << std::endl;
147 return;
148 }
149
Geoff Lang7825f612014-11-26 16:19:41 -0500150 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
151 glClear(GL_COLOR_BUFFER_BIT);
152 EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500153
154 ASSERT_GL_NO_ERROR();
Geoff Lang7825f612014-11-26 16:19:41 -0500155}
Jamie Madillfa05f602015-05-07 13:47:11 -0400156
157// Select configurations (e.g. which renderer, which GLES major version) these tests should be run against.
158
159ANGLE_INSTANTIATE_TEST(RendererTest,
Geoff Lange0cc2a42016-01-20 10:58:17 -0500160 // ES2 on top of D3D9
161 ES2_D3D9(),
162 ES2_D3D9_REFERENCE(),
Jamie Madillfa05f602015-05-07 13:47:11 -0400163
Geoff Lange0cc2a42016-01-20 10:58:17 -0500164 // ES2 on top of D3D11 feature level 9.3 to 11.0
165 ES2_D3D11(),
166 ES2_D3D11_FL11_0(),
167 ES2_D3D11_FL10_1(),
168 ES2_D3D11_FL10_0(),
169 ES2_D3D11_FL9_3(),
170
171 // ES2 on top of D3D11 WARP feature level 9.3 to 11.0
172 ES2_D3D11_WARP(),
173 ES2_D3D11_FL11_0_WARP(),
174 ES2_D3D11_FL10_1_WARP(),
175 ES2_D3D11_FL10_0_WARP(),
176 ES2_D3D11_FL9_3_WARP(),
177
178 // ES2 on top of D3D11 reference feature level 9.3 to 11.0
179 ES2_D3D11_REFERENCE(),
180 ES2_D3D11_FL11_0_REFERENCE(),
181 ES2_D3D11_FL10_1_REFERENCE(),
182 ES2_D3D11_FL10_0_REFERENCE(),
183 ES2_D3D11_FL9_3_REFERENCE(),
184
Jamie Madill1754ba02017-01-02 16:28:43 -0500185 // ES3 on top of D3D11.
Geoff Lange0cc2a42016-01-20 10:58:17 -0500186 ES3_D3D11(),
187 ES3_D3D11_FL11_0(),
188 ES3_D3D11_FL10_1(),
Geoff Lange0cc2a42016-01-20 10:58:17 -0500189
Jamie Madill1754ba02017-01-02 16:28:43 -0500190 // ES3 on top of D3D11 WARP.
Geoff Lange0cc2a42016-01-20 10:58:17 -0500191 ES3_D3D11_WARP(),
192 ES3_D3D11_FL11_0_WARP(),
193 ES3_D3D11_FL10_1_WARP(),
Geoff Lange0cc2a42016-01-20 10:58:17 -0500194
Jamie Madill1754ba02017-01-02 16:28:43 -0500195 // ES3 on top of the D3D11 reference rasterizer.
Geoff Lange0cc2a42016-01-20 10:58:17 -0500196 ES3_D3D11_REFERENCE(),
197 ES3_D3D11_FL11_0_REFERENCE(),
198 ES3_D3D11_FL10_1_REFERENCE(),
Geoff Lange0cc2a42016-01-20 10:58:17 -0500199
200 // ES2 on top of desktop OpenGL versions 2.1 to 4.5
201 ES2_OPENGL(),
202 ES2_OPENGL(2, 1),
203 ES2_OPENGL(3, 0),
204 ES2_OPENGL(3, 1),
205 ES2_OPENGL(3, 2),
206 ES2_OPENGL(3, 3),
207 ES2_OPENGL(4, 0),
208 ES2_OPENGL(4, 1),
209 ES2_OPENGL(4, 2),
210 ES2_OPENGL(4, 3),
211 ES2_OPENGL(4, 4),
212 ES2_OPENGL(4, 5),
213
214 // ES2 on top of desktop OpenGL versions 3.2 to 4.5
215 ES3_OPENGL(),
216 ES3_OPENGL(3, 2),
217 ES3_OPENGL(3, 3),
218 ES3_OPENGL(4, 0),
219 ES3_OPENGL(4, 1),
220 ES3_OPENGL(4, 2),
221 ES3_OPENGL(4, 3),
222 ES3_OPENGL(4, 4),
223 ES3_OPENGL(4, 5),
224
225 // ES2 on top of OpenGL ES 2.0 to 3.2
226 ES2_OPENGLES(),
227 ES2_OPENGLES(2, 0),
228 ES2_OPENGLES(3, 0),
229 ES2_OPENGLES(3, 1),
230 ES2_OPENGLES(3, 2),
231
232 // ES2 on top of OpenGL ES 3.0 to 3.2
233 ES3_OPENGLES(),
234 ES3_OPENGLES(3, 0),
235 ES3_OPENGLES(3, 1),
Geoff Lang76cdbd52016-09-23 16:51:04 -0400236 ES3_OPENGLES(3, 2),
237
238 // All ES version on top of the NULL backend
239 ES2_NULL(),
240 ES3_NULL(),
Jamie Madille09bd5d2016-11-29 16:20:35 -0500241 ES31_NULL(),
242
243 // ES on top of Vulkan
Jamie Madill1754ba02017-01-02 16:28:43 -0500244 ES2_VULKAN());
Jamie Madille09bd5d2016-11-29 16:20:35 -0500245} // anonymous namespace