blob: 51f5b33d5498efe03f6a1431f8940f3a3acdec8a [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 Lang7825f612014-11-26 16:19:41 -05008
9ANGLE_TYPED_TEST_CASE(RendererTest, ES2_D3D9, ES2_D3D11, ES2_D3D11_WARP, ES2_D3D11_REFERENCE, ES3_D3D11, ES3_D3D11_WARP, ES3_D3D11_REFERENCE,
10 ES2_D3D9_REFERENCE, ES2_D3D11_FL11_0, ES2_D3D11_FL11_0_WARP, ES2_D3D11_FL11_0_REFERENCE, ES3_D3D11_FL11_0, ES3_D3D11_FL11_0_WARP, ES3_D3D11_FL11_0_REFERENCE,
11 ES2_D3D11_FL10_1, ES2_D3D11_FL10_1_WARP, ES2_D3D11_FL10_1_REFERENCE, ES3_D3D11_FL10_1, ES3_D3D11_FL10_1_WARP, ES3_D3D11_FL10_1_REFERENCE,
12 ES2_D3D11_FL10_0, ES2_D3D11_FL10_0_WARP, ES2_D3D11_FL10_0_REFERENCE, ES3_D3D11_FL10_0, ES3_D3D11_FL10_0_WARP, ES3_D3D11_FL10_0_REFERENCE,
13 ES2_D3D11_FL9_3, ES2_D3D11_FL9_3_WARP, ES2_D3D11_FL9_3_REFERENCE);
Austin Kinross18b931d2014-09-29 12:58:31 -070014
15template<typename T>
16class RendererTest : public ANGLETest
17{
18 protected:
Geoff Lang0d3683c2014-10-23 11:08:16 -040019 RendererTest() : ANGLETest(T::GetGlesMajorVersion(), T::GetPlatform())
Austin Kinross18b931d2014-09-29 12:58:31 -070020 {
21 setWindowWidth(128);
22 setWindowHeight(128);
23 }
24
25 T fixtureType;
26};
27
28TYPED_TEST(RendererTest, RequestedRendererCreated)
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 Lang0d3683c2014-10-23 11:08:16 -040036 EGLPlatformParameters platform = fixtureType.GetPlatform();
37
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
104 EGLint glesMajorVersion = fixtureType.GetGlesMajorVersion();
105
Austin Kinross18b931d2014-09-29 12:58:31 -0700106 // 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 -0400107 if (glesMajorVersion == 3)
Austin Kinross18b931d2014-09-29 12:58:31 -0700108 {
109 ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos);
110 }
111
112 // Ensure that the version string contains GL ES 2.0, if we requested GL ES 2.0
Geoff Lang0d3683c2014-10-23 11:08:16 -0400113 if (glesMajorVersion == 2)
Austin Kinross18b931d2014-09-29 12:58:31 -0700114 {
115 ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos);
116 }
117}
Geoff Lang7825f612014-11-26 16:19:41 -0500118
119// Perform a simple operation (clear and read pixels) to verify the device is working
120TYPED_TEST(RendererTest, SimpleOperation)
121{
122 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
123 glClear(GL_COLOR_BUFFER_BIT);
124 EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
125}