blob: 3051ff26a67f3e7ec9a4929c45839da2eadec1ef [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 Madillfa05f602015-05-07 13:47:11 -040013using namespace angle;
Austin Kinross18b931d2014-09-29 12:58:31 -070014
Jamie Madillfa05f602015-05-07 13:47:11 -040015namespace
16{
Geoff Lang7825f612014-11-26 16:19:41 -050017
Austin Kinross18b931d2014-09-29 12:58:31 -070018class RendererTest : public ANGLETest
19{
20 protected:
Jamie Madillfa05f602015-05-07 13:47:11 -040021 RendererTest()
Austin Kinross18b931d2014-09-29 12:58:31 -070022 {
23 setWindowWidth(128);
24 setWindowHeight(128);
25 }
Austin Kinross18b931d2014-09-29 12:58:31 -070026};
27
Jamie Madillfa05f602015-05-07 13:47:11 -040028TEST_P(RendererTest, RequestedRendererCreated)
Austin Kinross18b931d2014-09-29 12:58:31 -070029{
30 std::string rendererString = std::string(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
31 std::transform(rendererString.begin(), rendererString.end(), rendererString.begin(), ::tolower);
32
33 std::string versionString = std::string(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
34 std::transform(versionString.begin(), versionString.end(), versionString.begin(), ::tolower);
35
Geoff Langdd323e92015-06-09 15:16:31 -040036 const EGLPlatformParameters &platform = GetParam().eglParameters;
Geoff Lang0d3683c2014-10-23 11:08:16 -040037
Austin Kinross18b931d2014-09-29 12:58:31 -070038 // Ensure that the renderer string contains D3D11, if we requested a D3D11 renderer.
Geoff Lang0d3683c2014-10-23 11:08:16 -040039 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
Austin Kinross18b931d2014-09-29 12:58:31 -070040 {
41 ASSERT_NE(rendererString.find(std::string("direct3d11")), std::string::npos);
42 }
43
44 // Ensure that the renderer string contains D3D9, if we requested a D3D9 renderer.
Geoff Lang0d3683c2014-10-23 11:08:16 -040045 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
Austin Kinross18b931d2014-09-29 12:58:31 -070046 {
47 ASSERT_NE(rendererString.find(std::string("direct3d9")), std::string::npos);
48 }
49
Geoff Lang0d3683c2014-10-23 11:08:16 -040050 // Ensure that the major and minor versions trigger expected behavior in D3D11
51 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
52 {
Geoff Lang7825f612014-11-26 16:19:41 -050053 // Ensure that the renderer uses WARP, if we requested it.
54 if (platform.deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE)
55 {
56 auto basicRenderPos = rendererString.find(std::string("microsoft basic render"));
57 auto softwareAdapterPos = rendererString.find(std::string("software adapter"));
58 ASSERT_TRUE(basicRenderPos != std::string::npos || softwareAdapterPos != std::string::npos);
59 }
60
Geoff Lang0d3683c2014-10-23 11:08:16 -040061 std::vector<std::string> acceptableShaderModels;
62
63 // When no specific major/minor version is requested, then ANGLE should return the highest possible feature level by default.
64 // The current hardware driver might not support Feature Level 11_0, but WARP always does.
65 // Therefore if WARP is specified but no major/minor version is specified, then we test to check that ANGLE returns FL11_0.
66 if (platform.majorVersion >= 11 || platform.majorVersion == EGL_DONT_CARE)
67 {
68 // Feature Level 10_0 corresponds to shader model 5_0
69 acceptableShaderModels.push_back("ps_5_0");
70 }
71
72 if (platform.majorVersion >= 10 || platform.majorVersion == EGL_DONT_CARE)
73 {
74 if (platform.minorVersion >= 1 || platform.minorVersion == EGL_DONT_CARE)
75 {
76 // Feature Level 10_1 corresponds to shader model 4_1
77 acceptableShaderModels.push_back("ps_4_1");
78 }
79
80 if (platform.minorVersion >= 0 || platform.minorVersion == EGL_DONT_CARE)
81 {
82 // Feature Level 10_0 corresponds to shader model 4_0
83 acceptableShaderModels.push_back("ps_4_0");
84 }
85 }
86
Austin Kinross0dbda052014-12-04 18:13:04 -080087 if (platform.majorVersion == 9 && platform.minorVersion == 3)
88 {
89 acceptableShaderModels.push_back("ps_4_0_level_9_3");
90 }
91
Geoff Lang0d3683c2014-10-23 11:08:16 -040092 bool found = false;
93 for (size_t i = 0; i < acceptableShaderModels.size(); i++)
94 {
95 if (rendererString.find(acceptableShaderModels[i]) != std::string::npos)
96 {
97 found = true;
98 }
99 }
100
101 ASSERT_TRUE(found);
102 }
103
Geoff Lang76cdbd52016-09-23 16:51:04 -0400104 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)
105 {
106 ASSERT_TRUE(IsNULL());
107 }
108
Geoff Langdd323e92015-06-09 15:16:31 -0400109 EGLint glesMajorVersion = GetParam().majorVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400110
Austin Kinross18b931d2014-09-29 12:58:31 -0700111 // Ensure that the renderer string contains GL ES 3.0, if we requested a GL ES 3.0
Geoff Lang0d3683c2014-10-23 11:08:16 -0400112 if (glesMajorVersion == 3)
Austin Kinross18b931d2014-09-29 12:58:31 -0700113 {
114 ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos);
115 }
116
117 // Ensure that the version string contains GL ES 2.0, if we requested GL ES 2.0
Geoff Lang0d3683c2014-10-23 11:08:16 -0400118 if (glesMajorVersion == 2)
Austin Kinross18b931d2014-09-29 12:58:31 -0700119 {
120 ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos);
121 }
122}
Geoff Lang7825f612014-11-26 16:19:41 -0500123
124// Perform a simple operation (clear and read pixels) to verify the device is working
Jamie Madillfa05f602015-05-07 13:47:11 -0400125TEST_P(RendererTest, SimpleOperation)
Geoff Lang7825f612014-11-26 16:19:41 -0500126{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400127 if (IsNULL())
128 {
129 std::cout << "ANGLE NULL backend clears are not functional" << std::endl;
130 return;
131 }
132
Geoff Lang7825f612014-11-26 16:19:41 -0500133 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
134 glClear(GL_COLOR_BUFFER_BIT);
135 EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
136}
Jamie Madillfa05f602015-05-07 13:47:11 -0400137
138// Select configurations (e.g. which renderer, which GLES major version) these tests should be run against.
139
140ANGLE_INSTANTIATE_TEST(RendererTest,
Geoff Lange0cc2a42016-01-20 10:58:17 -0500141 // ES2 on top of D3D9
142 ES2_D3D9(),
143 ES2_D3D9_REFERENCE(),
Jamie Madillfa05f602015-05-07 13:47:11 -0400144
Geoff Lange0cc2a42016-01-20 10:58:17 -0500145 // ES2 on top of D3D11 feature level 9.3 to 11.0
146 ES2_D3D11(),
147 ES2_D3D11_FL11_0(),
148 ES2_D3D11_FL10_1(),
149 ES2_D3D11_FL10_0(),
150 ES2_D3D11_FL9_3(),
151
152 // ES2 on top of D3D11 WARP feature level 9.3 to 11.0
153 ES2_D3D11_WARP(),
154 ES2_D3D11_FL11_0_WARP(),
155 ES2_D3D11_FL10_1_WARP(),
156 ES2_D3D11_FL10_0_WARP(),
157 ES2_D3D11_FL9_3_WARP(),
158
159 // ES2 on top of D3D11 reference feature level 9.3 to 11.0
160 ES2_D3D11_REFERENCE(),
161 ES2_D3D11_FL11_0_REFERENCE(),
162 ES2_D3D11_FL10_1_REFERENCE(),
163 ES2_D3D11_FL10_0_REFERENCE(),
164 ES2_D3D11_FL9_3_REFERENCE(),
165
166 // ES3 on top of D3D11 feature level 9.3 to 11.0
167 ES3_D3D11(),
168 ES3_D3D11_FL11_0(),
169 ES3_D3D11_FL10_1(),
170 ES3_D3D11_FL10_0(),
171
172 // ES3 on top of D3D11 WARP feature level 9.3 to 11.0
173 ES3_D3D11_WARP(),
174 ES3_D3D11_FL11_0_WARP(),
175 ES3_D3D11_FL10_1_WARP(),
176 ES3_D3D11_FL10_0_WARP(),
177
178 // ES3 on top of D3D11 reference feature level 9.3 to 11.0
179 ES3_D3D11_REFERENCE(),
180 ES3_D3D11_FL11_0_REFERENCE(),
181 ES3_D3D11_FL10_1_REFERENCE(),
182 ES3_D3D11_FL10_0_REFERENCE(),
183
184 // ES2 on top of desktop OpenGL versions 2.1 to 4.5
185 ES2_OPENGL(),
186 ES2_OPENGL(2, 1),
187 ES2_OPENGL(3, 0),
188 ES2_OPENGL(3, 1),
189 ES2_OPENGL(3, 2),
190 ES2_OPENGL(3, 3),
191 ES2_OPENGL(4, 0),
192 ES2_OPENGL(4, 1),
193 ES2_OPENGL(4, 2),
194 ES2_OPENGL(4, 3),
195 ES2_OPENGL(4, 4),
196 ES2_OPENGL(4, 5),
197
198 // ES2 on top of desktop OpenGL versions 3.2 to 4.5
199 ES3_OPENGL(),
200 ES3_OPENGL(3, 2),
201 ES3_OPENGL(3, 3),
202 ES3_OPENGL(4, 0),
203 ES3_OPENGL(4, 1),
204 ES3_OPENGL(4, 2),
205 ES3_OPENGL(4, 3),
206 ES3_OPENGL(4, 4),
207 ES3_OPENGL(4, 5),
208
209 // ES2 on top of OpenGL ES 2.0 to 3.2
210 ES2_OPENGLES(),
211 ES2_OPENGLES(2, 0),
212 ES2_OPENGLES(3, 0),
213 ES2_OPENGLES(3, 1),
214 ES2_OPENGLES(3, 2),
215
216 // ES2 on top of OpenGL ES 3.0 to 3.2
217 ES3_OPENGLES(),
218 ES3_OPENGLES(3, 0),
219 ES3_OPENGLES(3, 1),
Geoff Lang76cdbd52016-09-23 16:51:04 -0400220 ES3_OPENGLES(3, 2),
221
222 // All ES version on top of the NULL backend
223 ES2_NULL(),
224 ES3_NULL(),
225 ES31_NULL());
Jamie Madillfa05f602015-05-07 13:47:11 -0400226}