Hash :
f3e23295
Author :
Date :
2018-01-04T18:19:21
EGL: Expose NULL driver device selection. This makes the device type selection part of the ANGLE platform extension. We currently support NULL driver selection on all available back-ends (although on the NULL back-end, it already has no device type). Optionally we could expose certain features of this as separate extensions. This currently also supports the old hidden enum, until we can update Chrome and consolidate to the new exposed official enum. Bug: angleproject:2159 Change-Id: I85d0811098e644e8192c207673af9e18ed7c1da2 Reviewed-on: https://chromium-review.googlesource.com/846021 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RendererTest:
// These tests are designed to ensure that the various configurations of the test fixtures work as expected.
// If one of these tests fails, then it is likely that some of the other tests are being configured incorrectly.
// For example, they might be using the D3D11 renderer when the test is meant to be using the D3D9 renderer.
#include "test_utils/ANGLETest.h"
#include "common/string_utils.h"
using namespace angle;
namespace
{
class RendererTest : public ANGLETest
{
protected:
RendererTest()
{
setWindowWidth(128);
setWindowHeight(128);
}
};
TEST_P(RendererTest, RequestedRendererCreated)
{
std::string rendererString = std::string(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
angle::ToLower(&rendererString);
std::string versionString = std::string(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
angle::ToLower(&versionString);
const EGLPlatformParameters &platform = GetParam().eglParameters;
// Ensure that the renderer string contains D3D11, if we requested a D3D11 renderer.
if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
ASSERT_NE(rendererString.find(std::string("direct3d11")), std::string::npos);
}
// Ensure that the renderer string contains D3D9, if we requested a D3D9 renderer.
if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
{
ASSERT_NE(rendererString.find(std::string("direct3d9")), std::string::npos);
}
// Ensure that the major and minor versions trigger expected behavior in D3D11
if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
// Ensure that the renderer uses WARP, if we requested it.
if (platform.deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE)
{
auto basicRenderPos = rendererString.find(std::string("microsoft basic render"));
auto softwareAdapterPos = rendererString.find(std::string("software adapter"));
ASSERT_TRUE(basicRenderPos != std::string::npos || softwareAdapterPos != std::string::npos);
}
std::vector<std::string> acceptableShaderModels;
// When no specific major/minor version is requested, then ANGLE should return the highest possible feature level by default.
// The current hardware driver might not support Feature Level 11_0, but WARP always does.
// Therefore if WARP is specified but no major/minor version is specified, then we test to check that ANGLE returns FL11_0.
if (platform.majorVersion >= 11 || platform.majorVersion == EGL_DONT_CARE)
{
// Feature Level 10_0 corresponds to shader model 5_0
acceptableShaderModels.push_back("ps_5_0");
}
if (platform.majorVersion >= 10 || platform.majorVersion == EGL_DONT_CARE)
{
if (platform.minorVersion >= 1 || platform.minorVersion == EGL_DONT_CARE)
{
// Feature Level 10_1 corresponds to shader model 4_1
acceptableShaderModels.push_back("ps_4_1");
}
if (platform.minorVersion >= 0 || platform.minorVersion == EGL_DONT_CARE)
{
// Feature Level 10_0 corresponds to shader model 4_0
acceptableShaderModels.push_back("ps_4_0");
}
}
if (platform.majorVersion == 9 && platform.minorVersion == 3)
{
acceptableShaderModels.push_back("ps_4_0_level_9_3");
}
bool found = false;
for (size_t i = 0; i < acceptableShaderModels.size(); i++)
{
if (rendererString.find(acceptableShaderModels[i]) != std::string::npos)
{
found = true;
}
}
ASSERT_TRUE(found);
}
if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)
{
ASSERT_TRUE(IsNULL());
}
if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
{
ASSERT_TRUE(IsVulkan());
}
EGLint glesMajorVersion = GetParam().majorVersion;
EGLint glesMinorVersion = GetParam().minorVersion;
// Ensure that the renderer string contains the requested version number
if (glesMajorVersion == 3 && glesMinorVersion == 1)
{
ASSERT_NE(versionString.find(std::string("es 3.1")), std::string::npos);
}
else if (glesMajorVersion == 3 && glesMinorVersion == 0)
{
ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos);
}
else if (glesMajorVersion == 2 && glesMinorVersion == 0)
{
ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos);
}
else
{
FAIL() << "Unhandled GL ES client version.";
}
ASSERT_GL_NO_ERROR();
ASSERT_EGL_SUCCESS();
}
// Perform a simple operation (clear and read pixels) to verify the device is working
TEST_P(RendererTest, SimpleOperation)
{
if (IsNULL())
{
std::cout << "ANGLE NULL backend clears are not functional" << std::endl;
return;
}
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
ASSERT_GL_NO_ERROR();
}
// Select configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(RendererTest,
// ES2 on top of D3D9
ES2_D3D9(),
ES2_D3D9_REFERENCE(),
// ES2 on top of D3D11 feature level 9.3 to 11.0
ES2_D3D11(),
ES2_D3D11_FL11_0(),
ES2_D3D11_FL10_1(),
ES2_D3D11_FL10_0(),
ES2_D3D11_FL9_3(),
// ES2 on top of D3D11 WARP feature level 9.3 to 11.0
ES2_D3D11_WARP(),
ES2_D3D11_FL11_0_WARP(),
ES2_D3D11_FL10_1_WARP(),
ES2_D3D11_FL10_0_WARP(),
ES2_D3D11_FL9_3_WARP(),
// ES2 on top of D3D11 reference feature level 9.3 to 11.0
ES2_D3D11_REFERENCE(),
ES2_D3D11_FL11_0_REFERENCE(),
ES2_D3D11_FL10_1_REFERENCE(),
ES2_D3D11_FL10_0_REFERENCE(),
ES2_D3D11_FL9_3_REFERENCE(),
// ES3 on top of D3D11.
ES3_D3D11(),
ES3_D3D11_FL11_0(),
ES3_D3D11_FL10_1(),
// ES3 on top of D3D11 WARP.
ES3_D3D11_WARP(),
ES3_D3D11_FL11_0_WARP(),
ES3_D3D11_FL10_1_WARP(),
// ES3 on top of the D3D11 reference rasterizer.
ES3_D3D11_REFERENCE(),
ES3_D3D11_FL11_0_REFERENCE(),
ES3_D3D11_FL10_1_REFERENCE(),
// ES2 on top of desktop OpenGL versions 2.1 to 4.5
ES2_OPENGL(),
ES2_OPENGL(2, 1),
ES2_OPENGL(3, 0),
ES2_OPENGL(3, 1),
ES2_OPENGL(3, 2),
ES2_OPENGL(3, 3),
ES2_OPENGL(4, 0),
ES2_OPENGL(4, 1),
ES2_OPENGL(4, 2),
ES2_OPENGL(4, 3),
ES2_OPENGL(4, 4),
ES2_OPENGL(4, 5),
// ES2 on top of desktop OpenGL versions 3.2 to 4.5
ES3_OPENGL(),
ES3_OPENGL(3, 2),
ES3_OPENGL(3, 3),
ES3_OPENGL(4, 0),
ES3_OPENGL(4, 1),
ES3_OPENGL(4, 2),
ES3_OPENGL(4, 3),
ES3_OPENGL(4, 4),
ES3_OPENGL(4, 5),
// ES2 on top of OpenGL ES 2.0 to 3.2
ES2_OPENGLES(),
ES2_OPENGLES(2, 0),
ES2_OPENGLES(3, 0),
ES2_OPENGLES(3, 1),
ES2_OPENGLES(3, 2),
// ES2 on top of OpenGL ES 3.0 to 3.2
ES3_OPENGLES(),
ES3_OPENGLES(3, 0),
ES3_OPENGLES(3, 1),
ES3_OPENGLES(3, 2),
// All ES version on top of the NULL backend
ES2_NULL(),
ES3_NULL(),
ES31_NULL(),
// ES on top of Vulkan
ES2_VULKAN());
} // anonymous namespace