Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 1 | #include "ANGLETest.h" |
| 2 | |
| 3 | // These tests are designed to ensure that the various configurations of the test fixtures work as expected. |
| 4 | // If one of these tests fails, then it is likely that some of the other tests are being configured incorrectly. |
| 5 | // For example, they might be using the D3D11 renderer when the test is meant to be using the D3D9 renderer. |
| 6 | |
| 7 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 8 | ANGLE_TYPED_TEST_CASE(RendererTest, ES2_D3D9, ES2_D3D11, ES2_D3D11_WARP, ES3_D3D11, ES3_D3D11_WARP, |
| 9 | ES2_D3D11_FL11_0, ES2_D3D11_FL11_0_WARP, ES3_D3D11_FL11_0, ES3_D3D11_FL11_0_WARP, |
| 10 | ES2_D3D11_FL10_1, ES2_D3D11_FL10_1_WARP, ES3_D3D11_FL10_1, ES3_D3D11_FL10_1_WARP, |
Austin Kinross | 0dbda05 | 2014-12-04 18:13:04 -0800 | [diff] [blame^] | 11 | ES2_D3D11_FL10_0, ES2_D3D11_FL10_0_WARP, ES3_D3D11_FL10_0, ES3_D3D11_FL10_0_WARP, |
| 12 | ES2_D3D11_FL9_3, ES2_D3D11_FL9_3_WARP); |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 13 | |
| 14 | template<typename T> |
| 15 | class RendererTest : public ANGLETest |
| 16 | { |
| 17 | protected: |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 18 | RendererTest() : ANGLETest(T::GetGlesMajorVersion(), T::GetPlatform()) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 19 | { |
| 20 | setWindowWidth(128); |
| 21 | setWindowHeight(128); |
| 22 | } |
| 23 | |
| 24 | T fixtureType; |
| 25 | }; |
| 26 | |
| 27 | TYPED_TEST(RendererTest, RequestedRendererCreated) |
| 28 | { |
| 29 | std::string rendererString = std::string(reinterpret_cast<const char*>(glGetString(GL_RENDERER))); |
| 30 | std::transform(rendererString.begin(), rendererString.end(), rendererString.begin(), ::tolower); |
| 31 | |
| 32 | std::string versionString = std::string(reinterpret_cast<const char*>(glGetString(GL_VERSION))); |
| 33 | std::transform(versionString.begin(), versionString.end(), versionString.begin(), ::tolower); |
| 34 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 35 | EGLPlatformParameters platform = fixtureType.GetPlatform(); |
| 36 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 37 | // 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] | 38 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 39 | { |
| 40 | ASSERT_NE(rendererString.find(std::string("direct3d11")), std::string::npos); |
| 41 | } |
| 42 | |
| 43 | // 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] | 44 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 45 | { |
| 46 | ASSERT_NE(rendererString.find(std::string("direct3d9")), std::string::npos); |
| 47 | } |
| 48 | |
| 49 | // Ensure that the renderer uses WARP, if we requested it. |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 50 | if (platform.useWarp == EGL_TRUE) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 51 | { |
Jamie Madill | 00e5452 | 2014-10-02 10:44:17 -0400 | [diff] [blame] | 52 | auto basicRenderPos = rendererString.find(std::string("microsoft basic render")); |
| 53 | auto softwareAdapterPos = rendererString.find(std::string("software adapter")); |
| 54 | ASSERT_TRUE(basicRenderPos != std::string::npos || softwareAdapterPos != std::string::npos); |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 57 | // Ensure that the major and minor versions trigger expected behavior in D3D11 |
| 58 | if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) |
| 59 | { |
| 60 | std::vector<std::string> acceptableShaderModels; |
| 61 | |
| 62 | // When no specific major/minor version is requested, then ANGLE should return the highest possible feature level by default. |
| 63 | // The current hardware driver might not support Feature Level 11_0, but WARP always does. |
| 64 | // Therefore if WARP is specified but no major/minor version is specified, then we test to check that ANGLE returns FL11_0. |
| 65 | if (platform.majorVersion >= 11 || platform.majorVersion == EGL_DONT_CARE) |
| 66 | { |
| 67 | // Feature Level 10_0 corresponds to shader model 5_0 |
| 68 | acceptableShaderModels.push_back("ps_5_0"); |
| 69 | } |
| 70 | |
| 71 | if (platform.majorVersion >= 10 || platform.majorVersion == EGL_DONT_CARE) |
| 72 | { |
| 73 | if (platform.minorVersion >= 1 || platform.minorVersion == EGL_DONT_CARE) |
| 74 | { |
| 75 | // Feature Level 10_1 corresponds to shader model 4_1 |
| 76 | acceptableShaderModels.push_back("ps_4_1"); |
| 77 | } |
| 78 | |
| 79 | if (platform.minorVersion >= 0 || platform.minorVersion == EGL_DONT_CARE) |
| 80 | { |
| 81 | // Feature Level 10_0 corresponds to shader model 4_0 |
| 82 | acceptableShaderModels.push_back("ps_4_0"); |
| 83 | } |
| 84 | } |
| 85 | |
Austin Kinross | 0dbda05 | 2014-12-04 18:13:04 -0800 | [diff] [blame^] | 86 | if (platform.majorVersion == 9 && platform.minorVersion == 3) |
| 87 | { |
| 88 | acceptableShaderModels.push_back("ps_4_0_level_9_3"); |
| 89 | } |
| 90 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 91 | bool found = false; |
| 92 | for (size_t i = 0; i < acceptableShaderModels.size(); i++) |
| 93 | { |
| 94 | if (rendererString.find(acceptableShaderModels[i]) != std::string::npos) |
| 95 | { |
| 96 | found = true; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | ASSERT_TRUE(found); |
| 101 | } |
| 102 | |
| 103 | EGLint glesMajorVersion = fixtureType.GetGlesMajorVersion(); |
| 104 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 105 | // Ensure that the renderer string contains GL ES 3.0, if we requested a GL ES 3.0 |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 106 | if (glesMajorVersion == 3) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 107 | { |
| 108 | ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos); |
| 109 | } |
| 110 | |
| 111 | // Ensure that the version string contains GL ES 2.0, if we requested GL ES 2.0 |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 112 | if (glesMajorVersion == 2) |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 113 | { |
| 114 | ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos); |
| 115 | } |
| 116 | } |