Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1 | // |
| 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 Wallez | d3970de | 2015-05-14 11:07:48 -0400 | [diff] [blame] | 11 | #include "test_utils/ANGLETest.h" |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 12 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 13 | using namespace angle; |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 14 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 15 | namespace |
| 16 | { |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 17 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 18 | class RendererTest : public ANGLETest |
| 19 | { |
| 20 | protected: |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 21 | RendererTest() |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 22 | { |
| 23 | setWindowWidth(128); |
| 24 | setWindowHeight(128); |
| 25 | } |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 26 | }; |
| 27 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 28 | TEST_P(RendererTest, RequestedRendererCreated) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 29 | { |
| 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 Lang | dd323e9 | 2015-06-09 15:16:31 -0400 | [diff] [blame] | 36 | const EGLPlatformParameters &platform = GetParam().eglParameters; |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 37 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 38 | // Ensure that the renderer string contains D3D11, if we requested a D3D11 renderer. |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 39 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 40 | { |
| 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 Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 45 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 46 | { |
| 47 | ASSERT_NE(rendererString.find(std::string("direct3d9")), std::string::npos); |
| 48 | } |
| 49 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 50 | // Ensure that the major and minor versions trigger expected behavior in D3D11 |
| 51 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) |
| 52 | { |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 53 | // 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 Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 61 | 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 Kinross | 0dbda05 | 2014-12-04 18:13:04 -0800 | [diff] [blame] | 87 | if (platform.majorVersion == 9 && platform.minorVersion == 3) |
| 88 | { |
| 89 | acceptableShaderModels.push_back("ps_4_0_level_9_3"); |
| 90 | } |
| 91 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 92 | 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 Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 104 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE) |
| 105 | { |
| 106 | ASSERT_TRUE(IsNULL()); |
| 107 | } |
| 108 | |
Geoff Lang | dd323e9 | 2015-06-09 15:16:31 -0400 | [diff] [blame] | 109 | EGLint glesMajorVersion = GetParam().majorVersion; |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame^] | 110 | EGLint glesMinorVersion = GetParam().minorVersion; |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 111 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame^] | 112 | // Ensure that the renderer string contains the requested version number |
| 113 | if (glesMajorVersion == 3 && glesMinorVersion == 1) |
| 114 | { |
| 115 | ASSERT_NE(versionString.find(std::string("es 3.1")), std::string::npos); |
| 116 | } |
| 117 | else if (glesMajorVersion == 3 && glesMinorVersion == 0) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 118 | { |
| 119 | ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos); |
| 120 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame^] | 121 | else if (glesMajorVersion == 2 && glesMinorVersion == 0) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 122 | { |
| 123 | ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos); |
| 124 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame^] | 125 | else |
| 126 | { |
| 127 | FAIL() << "Unhandled GL ES client version."; |
| 128 | } |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 129 | } |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 130 | |
| 131 | // Perform a simple operation (clear and read pixels) to verify the device is working |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 132 | TEST_P(RendererTest, SimpleOperation) |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 133 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 134 | if (IsNULL()) |
| 135 | { |
| 136 | std::cout << "ANGLE NULL backend clears are not functional" << std::endl; |
| 137 | return; |
| 138 | } |
| 139 | |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 140 | glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| 141 | glClear(GL_COLOR_BUFFER_BIT); |
| 142 | EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255); |
| 143 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 144 | |
| 145 | // Select configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
| 146 | |
| 147 | ANGLE_INSTANTIATE_TEST(RendererTest, |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 148 | // ES2 on top of D3D9 |
| 149 | ES2_D3D9(), |
| 150 | ES2_D3D9_REFERENCE(), |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 151 | |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 152 | // ES2 on top of D3D11 feature level 9.3 to 11.0 |
| 153 | ES2_D3D11(), |
| 154 | ES2_D3D11_FL11_0(), |
| 155 | ES2_D3D11_FL10_1(), |
| 156 | ES2_D3D11_FL10_0(), |
| 157 | ES2_D3D11_FL9_3(), |
| 158 | |
| 159 | // ES2 on top of D3D11 WARP feature level 9.3 to 11.0 |
| 160 | ES2_D3D11_WARP(), |
| 161 | ES2_D3D11_FL11_0_WARP(), |
| 162 | ES2_D3D11_FL10_1_WARP(), |
| 163 | ES2_D3D11_FL10_0_WARP(), |
| 164 | ES2_D3D11_FL9_3_WARP(), |
| 165 | |
| 166 | // ES2 on top of D3D11 reference feature level 9.3 to 11.0 |
| 167 | ES2_D3D11_REFERENCE(), |
| 168 | ES2_D3D11_FL11_0_REFERENCE(), |
| 169 | ES2_D3D11_FL10_1_REFERENCE(), |
| 170 | ES2_D3D11_FL10_0_REFERENCE(), |
| 171 | ES2_D3D11_FL9_3_REFERENCE(), |
| 172 | |
| 173 | // ES3 on top of D3D11 feature level 9.3 to 11.0 |
| 174 | ES3_D3D11(), |
| 175 | ES3_D3D11_FL11_0(), |
| 176 | ES3_D3D11_FL10_1(), |
| 177 | ES3_D3D11_FL10_0(), |
| 178 | |
| 179 | // ES3 on top of D3D11 WARP feature level 9.3 to 11.0 |
| 180 | ES3_D3D11_WARP(), |
| 181 | ES3_D3D11_FL11_0_WARP(), |
| 182 | ES3_D3D11_FL10_1_WARP(), |
| 183 | ES3_D3D11_FL10_0_WARP(), |
| 184 | |
| 185 | // ES3 on top of D3D11 reference feature level 9.3 to 11.0 |
| 186 | ES3_D3D11_REFERENCE(), |
| 187 | ES3_D3D11_FL11_0_REFERENCE(), |
| 188 | ES3_D3D11_FL10_1_REFERENCE(), |
| 189 | ES3_D3D11_FL10_0_REFERENCE(), |
| 190 | |
| 191 | // ES2 on top of desktop OpenGL versions 2.1 to 4.5 |
| 192 | ES2_OPENGL(), |
| 193 | ES2_OPENGL(2, 1), |
| 194 | ES2_OPENGL(3, 0), |
| 195 | ES2_OPENGL(3, 1), |
| 196 | ES2_OPENGL(3, 2), |
| 197 | ES2_OPENGL(3, 3), |
| 198 | ES2_OPENGL(4, 0), |
| 199 | ES2_OPENGL(4, 1), |
| 200 | ES2_OPENGL(4, 2), |
| 201 | ES2_OPENGL(4, 3), |
| 202 | ES2_OPENGL(4, 4), |
| 203 | ES2_OPENGL(4, 5), |
| 204 | |
| 205 | // ES2 on top of desktop OpenGL versions 3.2 to 4.5 |
| 206 | ES3_OPENGL(), |
| 207 | ES3_OPENGL(3, 2), |
| 208 | ES3_OPENGL(3, 3), |
| 209 | ES3_OPENGL(4, 0), |
| 210 | ES3_OPENGL(4, 1), |
| 211 | ES3_OPENGL(4, 2), |
| 212 | ES3_OPENGL(4, 3), |
| 213 | ES3_OPENGL(4, 4), |
| 214 | ES3_OPENGL(4, 5), |
| 215 | |
| 216 | // ES2 on top of OpenGL ES 2.0 to 3.2 |
| 217 | ES2_OPENGLES(), |
| 218 | ES2_OPENGLES(2, 0), |
| 219 | ES2_OPENGLES(3, 0), |
| 220 | ES2_OPENGLES(3, 1), |
| 221 | ES2_OPENGLES(3, 2), |
| 222 | |
| 223 | // ES2 on top of OpenGL ES 3.0 to 3.2 |
| 224 | ES3_OPENGLES(), |
| 225 | ES3_OPENGLES(3, 0), |
| 226 | ES3_OPENGLES(3, 1), |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 227 | ES3_OPENGLES(3, 2), |
| 228 | |
| 229 | // All ES version on top of the NULL backend |
| 230 | ES2_NULL(), |
| 231 | ES3_NULL(), |
| 232 | ES31_NULL()); |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 233 | } |