blob: 27c0a8f9e0f554a8db34f52b22120ee1638eed1b [file] [log] [blame]
Austin Kinross18b931d2014-09-29 12:58:31 -07001#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 Lang0d3683c2014-10-23 11:08:16 -04008ANGLE_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,
11 ES2_D3D11_FL10_0, ES2_D3D11_FL10_0_WARP, ES3_D3D11_FL10_0, ES3_D3D11_FL10_0_WARP);
Austin Kinross18b931d2014-09-29 12:58:31 -070012
13template<typename T>
14class RendererTest : public ANGLETest
15{
16 protected:
Geoff Lang0d3683c2014-10-23 11:08:16 -040017 RendererTest() : ANGLETest(T::GetGlesMajorVersion(), T::GetPlatform())
Austin Kinross18b931d2014-09-29 12:58:31 -070018 {
19 setWindowWidth(128);
20 setWindowHeight(128);
21 }
22
23 T fixtureType;
24};
25
26TYPED_TEST(RendererTest, RequestedRendererCreated)
27{
28 std::string rendererString = std::string(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
29 std::transform(rendererString.begin(), rendererString.end(), rendererString.begin(), ::tolower);
30
31 std::string versionString = std::string(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
32 std::transform(versionString.begin(), versionString.end(), versionString.begin(), ::tolower);
33
Geoff Lang0d3683c2014-10-23 11:08:16 -040034 EGLPlatformParameters platform = fixtureType.GetPlatform();
35
Austin Kinross18b931d2014-09-29 12:58:31 -070036 // Ensure that the renderer string contains D3D11, if we requested a D3D11 renderer.
Geoff Lang0d3683c2014-10-23 11:08:16 -040037 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
Austin Kinross18b931d2014-09-29 12:58:31 -070038 {
39 ASSERT_NE(rendererString.find(std::string("direct3d11")), std::string::npos);
40 }
41
42 // Ensure that the renderer string contains D3D9, if we requested a D3D9 renderer.
Geoff Lang0d3683c2014-10-23 11:08:16 -040043 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
Austin Kinross18b931d2014-09-29 12:58:31 -070044 {
45 ASSERT_NE(rendererString.find(std::string("direct3d9")), std::string::npos);
46 }
47
48 // Ensure that the renderer uses WARP, if we requested it.
Geoff Lang0d3683c2014-10-23 11:08:16 -040049 if (platform.useWarp == EGL_TRUE)
Austin Kinross18b931d2014-09-29 12:58:31 -070050 {
Jamie Madill00e54522014-10-02 10:44:17 -040051 auto basicRenderPos = rendererString.find(std::string("microsoft basic render"));
52 auto softwareAdapterPos = rendererString.find(std::string("software adapter"));
53 ASSERT_TRUE(basicRenderPos != std::string::npos || softwareAdapterPos != std::string::npos);
Austin Kinross18b931d2014-09-29 12:58:31 -070054 }
55
Geoff Lang0d3683c2014-10-23 11:08:16 -040056 // Ensure that the major and minor versions trigger expected behavior in D3D11
57 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
58 {
59 std::vector<std::string> acceptableShaderModels;
60
61 // When no specific major/minor version is requested, then ANGLE should return the highest possible feature level by default.
62 // The current hardware driver might not support Feature Level 11_0, but WARP always does.
63 // Therefore if WARP is specified but no major/minor version is specified, then we test to check that ANGLE returns FL11_0.
64 if (platform.majorVersion >= 11 || platform.majorVersion == EGL_DONT_CARE)
65 {
66 // Feature Level 10_0 corresponds to shader model 5_0
67 acceptableShaderModels.push_back("ps_5_0");
68 }
69
70 if (platform.majorVersion >= 10 || platform.majorVersion == EGL_DONT_CARE)
71 {
72 if (platform.minorVersion >= 1 || platform.minorVersion == EGL_DONT_CARE)
73 {
74 // Feature Level 10_1 corresponds to shader model 4_1
75 acceptableShaderModels.push_back("ps_4_1");
76 }
77
78 if (platform.minorVersion >= 0 || platform.minorVersion == EGL_DONT_CARE)
79 {
80 // Feature Level 10_0 corresponds to shader model 4_0
81 acceptableShaderModels.push_back("ps_4_0");
82 }
83 }
84
85 bool found = false;
86 for (size_t i = 0; i < acceptableShaderModels.size(); i++)
87 {
88 if (rendererString.find(acceptableShaderModels[i]) != std::string::npos)
89 {
90 found = true;
91 }
92 }
93
94 ASSERT_TRUE(found);
95 }
96
97 EGLint glesMajorVersion = fixtureType.GetGlesMajorVersion();
98
Austin Kinross18b931d2014-09-29 12:58:31 -070099 // 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 -0400100 if (glesMajorVersion == 3)
Austin Kinross18b931d2014-09-29 12:58:31 -0700101 {
102 ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos);
103 }
104
105 // Ensure that the version string contains GL ES 2.0, if we requested GL ES 2.0
Geoff Lang0d3683c2014-10-23 11:08:16 -0400106 if (glesMajorVersion == 2)
Austin Kinross18b931d2014-09-29 12:58:31 -0700107 {
108 ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos);
109 }
110}