Jamie Madill | 508a5b7 | 2015-12-08 11:26:14 -0500 | [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 | // ANGLETest: |
| 7 | // Implementation of common ANGLE testing fixture. |
| 8 | // |
| 9 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 10 | #include "ANGLETest.h" |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 11 | #include "EGLWindow.h" |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 12 | #include "OSWindow.h" |
Jamie Madill | 508a5b7 | 2015-12-08 11:26:14 -0500 | [diff] [blame] | 13 | #include "system_utils.h" |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 14 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 15 | ANGLETest::ANGLETest() |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 16 | : mEGLWindow(nullptr), |
Jamie Madill | 2511d06 | 2015-09-11 15:19:56 -0400 | [diff] [blame] | 17 | mWidth(16), |
| 18 | mHeight(16) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 19 | { |
Geoff Lang | 5ade845 | 2015-09-02 11:00:30 -0400 | [diff] [blame] | 20 | mEGLWindow = |
| 21 | new EGLWindow(GetParam().majorVersion, GetParam().minorVersion, GetParam().eglParameters); |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | ANGLETest::~ANGLETest() |
| 25 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 26 | SafeDelete(mEGLWindow); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 27 | } |
| 28 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 29 | void ANGLETest::SetUp() |
| 30 | { |
Corentin Wallez | b44440d | 2015-07-22 17:54:20 -0400 | [diff] [blame] | 31 | // Resize the window before creating the context so that the first make current |
| 32 | // sets the viewport and scissor box to the right size. |
| 33 | bool needSwap = false; |
| 34 | if (mOSWindow->getWidth() != mWidth || mOSWindow->getHeight() != mHeight) |
Geoff Lang | 7f8dc49 | 2015-07-23 21:29:33 +0000 | [diff] [blame] | 35 | { |
Corentin Wallez | b44440d | 2015-07-22 17:54:20 -0400 | [diff] [blame] | 36 | if (!mOSWindow->resize(mWidth, mHeight)) |
| 37 | { |
| 38 | FAIL() << "Failed to resize ANGLE test window."; |
| 39 | } |
| 40 | needSwap = true; |
Geoff Lang | 7f8dc49 | 2015-07-23 21:29:33 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 43 | if (!createEGLContext()) |
| 44 | { |
| 45 | FAIL() << "egl context creation failed."; |
| 46 | } |
Corentin Wallez | b828b32 | 2015-07-16 17:51:30 -0400 | [diff] [blame] | 47 | |
Corentin Wallez | b44440d | 2015-07-22 17:54:20 -0400 | [diff] [blame] | 48 | if (needSwap) |
| 49 | { |
| 50 | // Swap the buffers so that the default framebuffer picks up the resize |
| 51 | // which will allow follow-up test code to assume the framebuffer covers |
| 52 | // the whole window. |
| 53 | swapBuffers(); |
| 54 | } |
Corentin Wallez | 096725b | 2015-07-20 16:58:57 -0400 | [diff] [blame] | 55 | |
Geoff Lang | 7f8dc49 | 2015-07-23 21:29:33 +0000 | [diff] [blame] | 56 | // This Viewport command is not strictly necessary but we add it so that programs |
| 57 | // taking OpenGL traces can guess the size of the default framebuffer and show it |
| 58 | // in their UIs |
| 59 | glViewport(0, 0, mWidth, mHeight); |
Jamie Madill | 508a5b7 | 2015-12-08 11:26:14 -0500 | [diff] [blame] | 60 | |
| 61 | const auto &info = testing::UnitTest::GetInstance()->current_test_info(); |
| 62 | angle::WriteDebugMessage("Entering %s.%s\n", info->test_case_name(), info->name()); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | void ANGLETest::TearDown() |
| 66 | { |
Jamie Madill | 508a5b7 | 2015-12-08 11:26:14 -0500 | [diff] [blame] | 67 | const auto &info = testing::UnitTest::GetInstance()->current_test_info(); |
| 68 | angle::WriteDebugMessage("Exiting %s.%s\n", info->test_case_name(), info->name()); |
| 69 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 70 | swapBuffers(); |
Jamie Madill | 9e16d40 | 2014-09-08 17:36:33 -0400 | [diff] [blame] | 71 | mOSWindow->messageLoop(); |
| 72 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 73 | if (!destroyEGLContext()) |
| 74 | { |
| 75 | FAIL() << "egl context destruction failed."; |
| 76 | } |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 77 | |
| 78 | // Check for quit message |
| 79 | Event myEvent; |
| 80 | while (mOSWindow->popEvent(&myEvent)) |
| 81 | { |
| 82 | if (myEvent.Type == Event::EVENT_CLOSED) |
| 83 | { |
| 84 | exit(0); |
| 85 | } |
| 86 | } |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | void ANGLETest::swapBuffers() |
| 90 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 91 | if (mEGLWindow->isGLInitialized()) |
| 92 | { |
| 93 | mEGLWindow->swap(); |
| 94 | } |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 95 | } |
| 96 | |
Olli Etuaho | 4a8329f | 2016-01-11 17:12:57 +0200 | [diff] [blame^] | 97 | void ANGLETest::drawQuad(GLuint program, |
| 98 | const std::string &positionAttribName, |
| 99 | GLfloat positionAttribZ) |
| 100 | { |
| 101 | drawQuad(program, positionAttribName, positionAttribZ, 1.0f); |
| 102 | } |
| 103 | |
| 104 | void ANGLETest::drawQuad(GLuint program, |
| 105 | const std::string &positionAttribName, |
| 106 | GLfloat positionAttribZ, |
| 107 | GLfloat positionAttribXYScale) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 108 | { |
| 109 | GLint positionLocation = glGetAttribLocation(program, positionAttribName.c_str()); |
| 110 | |
| 111 | glUseProgram(program); |
| 112 | |
Olli Etuaho | 4a8329f | 2016-01-11 17:12:57 +0200 | [diff] [blame^] | 113 | const GLfloat vertices[] = { |
| 114 | -1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ, |
| 115 | -1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ, |
| 116 | 1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ, |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 117 | |
Olli Etuaho | 4a8329f | 2016-01-11 17:12:57 +0200 | [diff] [blame^] | 118 | -1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ, |
| 119 | 1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ, |
| 120 | 1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ, |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, vertices); |
| 124 | glEnableVertexAttribArray(positionLocation); |
| 125 | |
| 126 | glDrawArrays(GL_TRIANGLES, 0, 6); |
| 127 | |
| 128 | glDisableVertexAttribArray(positionLocation); |
| 129 | glVertexAttribPointer(positionLocation, 4, GL_FLOAT, GL_FALSE, 0, NULL); |
| 130 | |
| 131 | glUseProgram(0); |
| 132 | } |
| 133 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 134 | GLuint ANGLETest::compileShader(GLenum type, const std::string &source) |
| 135 | { |
| 136 | GLuint shader = glCreateShader(type); |
| 137 | |
| 138 | const char *sourceArray[1] = { source.c_str() }; |
| 139 | glShaderSource(shader, 1, sourceArray, NULL); |
| 140 | glCompileShader(shader); |
| 141 | |
| 142 | GLint compileResult; |
| 143 | glGetShaderiv(shader, GL_COMPILE_STATUS, &compileResult); |
| 144 | |
| 145 | if (compileResult == 0) |
| 146 | { |
| 147 | GLint infoLogLength; |
| 148 | glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); |
| 149 | |
Jamie Madill | d2c52e3 | 2015-10-14 17:07:05 -0400 | [diff] [blame] | 150 | if (infoLogLength == 0) |
| 151 | { |
| 152 | std::cerr << "shader compilation failed with empty log." << std::endl; |
| 153 | } |
| 154 | else |
| 155 | { |
| 156 | std::vector<GLchar> infoLog(infoLogLength); |
| 157 | glGetShaderInfoLog(shader, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]); |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 158 | |
Jamie Madill | d2c52e3 | 2015-10-14 17:07:05 -0400 | [diff] [blame] | 159 | std::cerr << "shader compilation failed: " << &infoLog[0]; |
| 160 | } |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 161 | |
| 162 | glDeleteShader(shader); |
| 163 | shader = 0; |
| 164 | } |
| 165 | |
| 166 | return shader; |
| 167 | } |
| 168 | |
Geoff Lang | 63046e2 | 2015-07-21 12:43:50 -0400 | [diff] [blame] | 169 | static bool checkExtensionExists(const char *allExtensions, const std::string &extName) |
| 170 | { |
| 171 | return strstr(allExtensions, extName.c_str()) != nullptr; |
| 172 | } |
| 173 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 174 | bool ANGLETest::extensionEnabled(const std::string &extName) |
| 175 | { |
Geoff Lang | 63046e2 | 2015-07-21 12:43:50 -0400 | [diff] [blame] | 176 | return checkExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)), |
| 177 | extName); |
| 178 | } |
| 179 | |
| 180 | bool ANGLETest::eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName) |
| 181 | { |
| 182 | return checkExtensionExists(eglQueryString(display, EGL_EXTENSIONS), extName); |
| 183 | } |
| 184 | |
| 185 | bool ANGLETest::eglClientExtensionEnabled(const std::string &extName) |
| 186 | { |
| 187 | return checkExtensionExists(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS), extName); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 188 | } |
| 189 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 190 | void ANGLETest::setWindowWidth(int width) |
| 191 | { |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 192 | mWidth = width; |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | void ANGLETest::setWindowHeight(int height) |
| 196 | { |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 197 | mHeight = height; |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 198 | } |
| 199 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 200 | void ANGLETest::setConfigRedBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 201 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 202 | mEGLWindow->setConfigRedBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 203 | } |
| 204 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 205 | void ANGLETest::setConfigGreenBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 206 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 207 | mEGLWindow->setConfigGreenBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 208 | } |
| 209 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 210 | void ANGLETest::setConfigBlueBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 211 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 212 | mEGLWindow->setConfigBlueBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 213 | } |
| 214 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 215 | void ANGLETest::setConfigAlphaBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 216 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 217 | mEGLWindow->setConfigAlphaBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 218 | } |
| 219 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 220 | void ANGLETest::setConfigDepthBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 221 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 222 | mEGLWindow->setConfigDepthBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 223 | } |
| 224 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 225 | void ANGLETest::setConfigStencilBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 226 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 227 | mEGLWindow->setConfigStencilBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | void ANGLETest::setMultisampleEnabled(bool enabled) |
| 231 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 232 | mEGLWindow->setMultisample(enabled); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 233 | } |
| 234 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 235 | void ANGLETest::setDebugEnabled(bool enabled) |
| 236 | { |
| 237 | mEGLWindow->setDebugEnabled(enabled); |
| 238 | } |
| 239 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 240 | int ANGLETest::getClientVersion() const |
| 241 | { |
Geoff Lang | 5ade845 | 2015-09-02 11:00:30 -0400 | [diff] [blame] | 242 | return mEGLWindow->getClientMajorVersion(); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 243 | } |
| 244 | |
Geoff Lang | b926627 | 2015-01-29 13:25:14 +0000 | [diff] [blame] | 245 | EGLWindow *ANGLETest::getEGLWindow() const |
| 246 | { |
| 247 | return mEGLWindow; |
| 248 | } |
| 249 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 250 | int ANGLETest::getWindowWidth() const |
| 251 | { |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 252 | return mWidth; |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | int ANGLETest::getWindowHeight() const |
| 256 | { |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 257 | return mHeight; |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 258 | } |
| 259 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 260 | bool ANGLETest::isMultisampleEnabled() const |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 261 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 262 | return mEGLWindow->isMultisample(); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | bool ANGLETest::createEGLContext() |
| 266 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 267 | return mEGLWindow->initializeGL(mOSWindow); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | bool ANGLETest::destroyEGLContext() |
| 271 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 272 | mEGLWindow->destroyGL(); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 273 | return true; |
| 274 | } |
Geoff Lang | bb13467 | 2013-10-23 13:06:46 -0400 | [diff] [blame] | 275 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 276 | bool ANGLETest::InitTestWindow() |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 277 | { |
| 278 | mOSWindow = CreateOSWindow(); |
| 279 | if (!mOSWindow->initialize("ANGLE_TEST", 128, 128)) |
| 280 | { |
| 281 | return false; |
| 282 | } |
| 283 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 284 | mOSWindow->setVisible(true); |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 285 | |
| 286 | return true; |
| 287 | } |
| 288 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 289 | bool ANGLETest::DestroyTestWindow() |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 290 | { |
| 291 | if (mOSWindow) |
| 292 | { |
| 293 | mOSWindow->destroy(); |
| 294 | delete mOSWindow; |
| 295 | mOSWindow = NULL; |
| 296 | } |
| 297 | |
| 298 | return true; |
| 299 | } |
| 300 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 301 | void ANGLETest::SetWindowVisible(bool isVisible) |
Geoff Lang | bb13467 | 2013-10-23 13:06:46 -0400 | [diff] [blame] | 302 | { |
Jamie Madill | 4119ed3 | 2014-10-01 10:41:40 -0400 | [diff] [blame] | 303 | mOSWindow->setVisible(isVisible); |
Geoff Lang | bb13467 | 2013-10-23 13:06:46 -0400 | [diff] [blame] | 304 | } |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 305 | |
Jamie Madill | c3b9b26 | 2015-01-30 14:00:51 -0500 | [diff] [blame] | 306 | bool ANGLETest::isIntel() const |
| 307 | { |
| 308 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 309 | return (rendererString.find("Intel") != std::string::npos); |
| 310 | } |
| 311 | |
| 312 | bool ANGLETest::isAMD() const |
| 313 | { |
| 314 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 315 | return (rendererString.find("AMD") != std::string::npos) || |
| 316 | (rendererString.find("ATI") != std::string::npos); |
| 317 | } |
| 318 | |
| 319 | bool ANGLETest::isNVidia() const |
| 320 | { |
| 321 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 322 | return (rendererString.find("NVIDIA") != std::string::npos); |
| 323 | } |
| 324 | |
Jamie Madill | d55d283 | 2015-10-27 13:59:19 -0400 | [diff] [blame] | 325 | bool ANGLETest::isD3D11() const |
| 326 | { |
| 327 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 328 | return (rendererString.find("Direct3D11 vs_5_0") != std::string::npos); |
| 329 | } |
| 330 | |
Jamie Madill | 9fc3682 | 2015-11-18 13:08:07 -0500 | [diff] [blame] | 331 | bool ANGLETest::isD3D11_FL93() const |
| 332 | { |
| 333 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 334 | return (rendererString.find("Direct3D11 vs_4_0_") != std::string::npos); |
| 335 | } |
| 336 | |
| 337 | bool ANGLETest::isD3D9() const |
| 338 | { |
| 339 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 340 | return (rendererString.find("Direct3D9") != std::string::npos); |
| 341 | } |
| 342 | |
| 343 | bool ANGLETest::isD3DSM3() const |
| 344 | { |
| 345 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 346 | return isD3D9() || isD3D11_FL93(); |
| 347 | } |
| 348 | |
Jamie Madill | c3b9b26 | 2015-01-30 14:00:51 -0500 | [diff] [blame] | 349 | EGLint ANGLETest::getPlatformRenderer() const |
| 350 | { |
Jamie Madill | f685991 | 2015-01-30 17:05:35 -0500 | [diff] [blame] | 351 | assert(mEGLWindow); |
| 352 | return mEGLWindow->getPlatform().renderer; |
Jamie Madill | c3b9b26 | 2015-01-30 14:00:51 -0500 | [diff] [blame] | 353 | } |
| 354 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 355 | OSWindow *ANGLETest::mOSWindow = NULL; |
| 356 | |
| 357 | void ANGLETestEnvironment::SetUp() |
| 358 | { |
| 359 | if (!ANGLETest::InitTestWindow()) |
| 360 | { |
| 361 | FAIL() << "Failed to create ANGLE test window."; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | void ANGLETestEnvironment::TearDown() |
| 366 | { |
| 367 | ANGLETest::DestroyTestWindow(); |
| 368 | } |