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 | ef97c61 | 2017-09-09 23:34:18 -0400 | [diff] [blame^] | 13 | #include "common/string_utils.h" |
| 14 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 15 | using namespace angle; |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 16 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 17 | namespace |
| 18 | { |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 19 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 20 | class RendererTest : public ANGLETest |
| 21 | { |
| 22 | protected: |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 23 | RendererTest() |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 24 | { |
| 25 | setWindowWidth(128); |
| 26 | setWindowHeight(128); |
| 27 | } |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 28 | }; |
| 29 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 30 | TEST_P(RendererTest, RequestedRendererCreated) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 31 | { |
| 32 | std::string rendererString = std::string(reinterpret_cast<const char*>(glGetString(GL_RENDERER))); |
Jamie Madill | ef97c61 | 2017-09-09 23:34:18 -0400 | [diff] [blame^] | 33 | angle::ToLower(&rendererString); |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 34 | |
| 35 | std::string versionString = std::string(reinterpret_cast<const char*>(glGetString(GL_VERSION))); |
Jamie Madill | ef97c61 | 2017-09-09 23:34:18 -0400 | [diff] [blame^] | 36 | angle::ToLower(&versionString); |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 37 | |
Geoff Lang | dd323e9 | 2015-06-09 15:16:31 -0400 | [diff] [blame] | 38 | const EGLPlatformParameters &platform = GetParam().eglParameters; |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 39 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 40 | // 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] | 41 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 42 | { |
| 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 Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 47 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 48 | { |
| 49 | ASSERT_NE(rendererString.find(std::string("direct3d9")), std::string::npos); |
| 50 | } |
| 51 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 52 | // Ensure that the major and minor versions trigger expected behavior in D3D11 |
| 53 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) |
| 54 | { |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 55 | // 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 Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 63 | 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 Kinross | 0dbda05 | 2014-12-04 18:13:04 -0800 | [diff] [blame] | 89 | if (platform.majorVersion == 9 && platform.minorVersion == 3) |
| 90 | { |
| 91 | acceptableShaderModels.push_back("ps_4_0_level_9_3"); |
| 92 | } |
| 93 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 94 | 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 Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 106 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE) |
| 107 | { |
| 108 | ASSERT_TRUE(IsNULL()); |
| 109 | } |
| 110 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 111 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE) |
| 112 | { |
| 113 | ASSERT_TRUE(IsVulkan()); |
| 114 | } |
| 115 | |
Geoff Lang | dd323e9 | 2015-06-09 15:16:31 -0400 | [diff] [blame] | 116 | EGLint glesMajorVersion = GetParam().majorVersion; |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 117 | EGLint glesMinorVersion = GetParam().minorVersion; |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 118 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 119 | // 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 Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 125 | { |
| 126 | ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos); |
| 127 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 128 | else if (glesMajorVersion == 2 && glesMinorVersion == 0) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 129 | { |
| 130 | ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos); |
| 131 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 132 | else |
| 133 | { |
| 134 | FAIL() << "Unhandled GL ES client version."; |
| 135 | } |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 136 | |
| 137 | ASSERT_GL_NO_ERROR(); |
| 138 | ASSERT_EGL_SUCCESS(); |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 139 | } |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 140 | |
| 141 | // 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] | 142 | TEST_P(RendererTest, SimpleOperation) |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 143 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 144 | if (IsNULL()) |
| 145 | { |
| 146 | std::cout << "ANGLE NULL backend clears are not functional" << std::endl; |
| 147 | return; |
| 148 | } |
| 149 | |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 150 | 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 Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 153 | |
| 154 | ASSERT_GL_NO_ERROR(); |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 155 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 156 | |
| 157 | // Select configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
| 158 | |
| 159 | ANGLE_INSTANTIATE_TEST(RendererTest, |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 160 | // ES2 on top of D3D9 |
| 161 | ES2_D3D9(), |
| 162 | ES2_D3D9_REFERENCE(), |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 163 | |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 164 | // 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 Madill | 1754ba0 | 2017-01-02 16:28:43 -0500 | [diff] [blame] | 185 | // ES3 on top of D3D11. |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 186 | ES3_D3D11(), |
| 187 | ES3_D3D11_FL11_0(), |
| 188 | ES3_D3D11_FL10_1(), |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 189 | |
Jamie Madill | 1754ba0 | 2017-01-02 16:28:43 -0500 | [diff] [blame] | 190 | // ES3 on top of D3D11 WARP. |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 191 | ES3_D3D11_WARP(), |
| 192 | ES3_D3D11_FL11_0_WARP(), |
| 193 | ES3_D3D11_FL10_1_WARP(), |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 194 | |
Jamie Madill | 1754ba0 | 2017-01-02 16:28:43 -0500 | [diff] [blame] | 195 | // ES3 on top of the D3D11 reference rasterizer. |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 196 | ES3_D3D11_REFERENCE(), |
| 197 | ES3_D3D11_FL11_0_REFERENCE(), |
| 198 | ES3_D3D11_FL10_1_REFERENCE(), |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 199 | |
| 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 Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 236 | ES3_OPENGLES(3, 2), |
| 237 | |
| 238 | // All ES version on top of the NULL backend |
| 239 | ES2_NULL(), |
| 240 | ES3_NULL(), |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 241 | ES31_NULL(), |
| 242 | |
| 243 | // ES on top of Vulkan |
Jamie Madill | 1754ba0 | 2017-01-02 16:28:43 -0500 | [diff] [blame] | 244 | ES2_VULKAN()); |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 245 | } // anonymous namespace |