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 | 0dfa807 | 2016-01-22 15:27:21 -0500 | [diff] [blame] | 15 | namespace angle |
| 16 | { |
| 17 | |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame^] | 18 | namespace |
| 19 | { |
| 20 | float ColorNorm(GLubyte channelValue) |
| 21 | { |
| 22 | return static_cast<float>(channelValue) / 255.0f; |
| 23 | } |
| 24 | } // anonymous namespace |
| 25 | |
Jamie Madill | 0dfa807 | 2016-01-22 15:27:21 -0500 | [diff] [blame] | 26 | GLColor::GLColor() : R(0), G(0), B(0), A(0) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | GLColor::GLColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a) : R(r), G(g), B(b), A(a) |
| 31 | { |
| 32 | } |
| 33 | |
Jamie Madill | e2509a3 | 2016-02-01 14:09:05 -0500 | [diff] [blame] | 34 | GLColor::GLColor(GLuint colorValue) : R(0), G(0), B(0), A(0) |
| 35 | { |
| 36 | memcpy(&R, &colorValue, sizeof(GLuint)); |
| 37 | } |
| 38 | |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame^] | 39 | Vector4 GLColor::toNormalizedVector() const |
| 40 | { |
| 41 | return Vector4(ColorNorm(R), ColorNorm(G), ColorNorm(B), ColorNorm(A)); |
| 42 | } |
| 43 | |
Jamie Madill | 0dfa807 | 2016-01-22 15:27:21 -0500 | [diff] [blame] | 44 | GLColor ReadColor(GLint x, GLint y) |
| 45 | { |
| 46 | GLColor actual; |
| 47 | glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &actual.R); |
| 48 | EXPECT_GL_NO_ERROR(); |
| 49 | return actual; |
| 50 | } |
| 51 | |
| 52 | bool operator==(const GLColor &a, const GLColor &b) |
| 53 | { |
| 54 | return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A; |
| 55 | } |
| 56 | |
| 57 | std::ostream &operator<<(std::ostream &ostream, const GLColor &color) |
| 58 | { |
| 59 | ostream << "(" << static_cast<unsigned int>(color.R) << ", " |
| 60 | << static_cast<unsigned int>(color.G) << ", " << static_cast<unsigned int>(color.B) |
| 61 | << ", " << static_cast<unsigned int>(color.A) << ")"; |
| 62 | return ostream; |
| 63 | } |
| 64 | |
| 65 | } // namespace angle |
| 66 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 67 | ANGLETest::ANGLETest() |
Austin Kinross | d544cc9 | 2016-01-11 15:26:42 -0800 | [diff] [blame] | 68 | : mEGLWindow(nullptr), mWidth(16), mHeight(16), mIgnoreD3D11SDKLayersWarnings(false) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 69 | { |
Geoff Lang | 5ade845 | 2015-09-02 11:00:30 -0400 | [diff] [blame] | 70 | mEGLWindow = |
| 71 | new EGLWindow(GetParam().majorVersion, GetParam().minorVersion, GetParam().eglParameters); |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | ANGLETest::~ANGLETest() |
| 75 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 76 | SafeDelete(mEGLWindow); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 77 | } |
| 78 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 79 | void ANGLETest::SetUp() |
| 80 | { |
Corentin Wallez | b44440d | 2015-07-22 17:54:20 -0400 | [diff] [blame] | 81 | // Resize the window before creating the context so that the first make current |
| 82 | // sets the viewport and scissor box to the right size. |
| 83 | bool needSwap = false; |
| 84 | if (mOSWindow->getWidth() != mWidth || mOSWindow->getHeight() != mHeight) |
Geoff Lang | 7f8dc49 | 2015-07-23 21:29:33 +0000 | [diff] [blame] | 85 | { |
Corentin Wallez | b44440d | 2015-07-22 17:54:20 -0400 | [diff] [blame] | 86 | if (!mOSWindow->resize(mWidth, mHeight)) |
| 87 | { |
| 88 | FAIL() << "Failed to resize ANGLE test window."; |
| 89 | } |
| 90 | needSwap = true; |
Geoff Lang | 7f8dc49 | 2015-07-23 21:29:33 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 93 | if (!createEGLContext()) |
| 94 | { |
| 95 | FAIL() << "egl context creation failed."; |
| 96 | } |
Corentin Wallez | b828b32 | 2015-07-16 17:51:30 -0400 | [diff] [blame] | 97 | |
Corentin Wallez | b44440d | 2015-07-22 17:54:20 -0400 | [diff] [blame] | 98 | if (needSwap) |
| 99 | { |
| 100 | // Swap the buffers so that the default framebuffer picks up the resize |
| 101 | // which will allow follow-up test code to assume the framebuffer covers |
| 102 | // the whole window. |
| 103 | swapBuffers(); |
| 104 | } |
Corentin Wallez | 096725b | 2015-07-20 16:58:57 -0400 | [diff] [blame] | 105 | |
Geoff Lang | 7f8dc49 | 2015-07-23 21:29:33 +0000 | [diff] [blame] | 106 | // This Viewport command is not strictly necessary but we add it so that programs |
| 107 | // taking OpenGL traces can guess the size of the default framebuffer and show it |
| 108 | // in their UIs |
| 109 | glViewport(0, 0, mWidth, mHeight); |
Jamie Madill | 508a5b7 | 2015-12-08 11:26:14 -0500 | [diff] [blame] | 110 | |
| 111 | const auto &info = testing::UnitTest::GetInstance()->current_test_info(); |
| 112 | angle::WriteDebugMessage("Entering %s.%s\n", info->test_case_name(), info->name()); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | void ANGLETest::TearDown() |
| 116 | { |
Austin Kinross | d544cc9 | 2016-01-11 15:26:42 -0800 | [diff] [blame] | 117 | checkD3D11SDKLayersMessages(); |
| 118 | |
Jamie Madill | 508a5b7 | 2015-12-08 11:26:14 -0500 | [diff] [blame] | 119 | const auto &info = testing::UnitTest::GetInstance()->current_test_info(); |
| 120 | angle::WriteDebugMessage("Exiting %s.%s\n", info->test_case_name(), info->name()); |
| 121 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 122 | swapBuffers(); |
Jamie Madill | 9e16d40 | 2014-09-08 17:36:33 -0400 | [diff] [blame] | 123 | mOSWindow->messageLoop(); |
| 124 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 125 | if (!destroyEGLContext()) |
| 126 | { |
| 127 | FAIL() << "egl context destruction failed."; |
| 128 | } |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 129 | |
| 130 | // Check for quit message |
| 131 | Event myEvent; |
| 132 | while (mOSWindow->popEvent(&myEvent)) |
| 133 | { |
| 134 | if (myEvent.Type == Event::EVENT_CLOSED) |
| 135 | { |
| 136 | exit(0); |
| 137 | } |
| 138 | } |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | void ANGLETest::swapBuffers() |
| 142 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 143 | if (mEGLWindow->isGLInitialized()) |
| 144 | { |
| 145 | mEGLWindow->swap(); |
| 146 | } |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 147 | } |
| 148 | |
Olli Etuaho | 4a8329f | 2016-01-11 17:12:57 +0200 | [diff] [blame] | 149 | void ANGLETest::drawQuad(GLuint program, |
| 150 | const std::string &positionAttribName, |
| 151 | GLfloat positionAttribZ) |
| 152 | { |
| 153 | drawQuad(program, positionAttribName, positionAttribZ, 1.0f); |
| 154 | } |
| 155 | |
| 156 | void ANGLETest::drawQuad(GLuint program, |
| 157 | const std::string &positionAttribName, |
| 158 | GLfloat positionAttribZ, |
| 159 | GLfloat positionAttribXYScale) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 160 | { |
| 161 | GLint positionLocation = glGetAttribLocation(program, positionAttribName.c_str()); |
| 162 | |
| 163 | glUseProgram(program); |
| 164 | |
Olli Etuaho | 4a8329f | 2016-01-11 17:12:57 +0200 | [diff] [blame] | 165 | const GLfloat vertices[] = { |
| 166 | -1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ, |
| 167 | -1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ, |
| 168 | 1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ, |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 169 | |
Olli Etuaho | 4a8329f | 2016-01-11 17:12:57 +0200 | [diff] [blame] | 170 | -1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ, |
| 171 | 1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ, |
| 172 | 1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ, |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 173 | }; |
| 174 | |
| 175 | glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, vertices); |
| 176 | glEnableVertexAttribArray(positionLocation); |
| 177 | |
| 178 | glDrawArrays(GL_TRIANGLES, 0, 6); |
| 179 | |
| 180 | glDisableVertexAttribArray(positionLocation); |
| 181 | glVertexAttribPointer(positionLocation, 4, GL_FLOAT, GL_FALSE, 0, NULL); |
| 182 | |
| 183 | glUseProgram(0); |
| 184 | } |
| 185 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 186 | GLuint ANGLETest::compileShader(GLenum type, const std::string &source) |
| 187 | { |
| 188 | GLuint shader = glCreateShader(type); |
| 189 | |
| 190 | const char *sourceArray[1] = { source.c_str() }; |
| 191 | glShaderSource(shader, 1, sourceArray, NULL); |
| 192 | glCompileShader(shader); |
| 193 | |
| 194 | GLint compileResult; |
| 195 | glGetShaderiv(shader, GL_COMPILE_STATUS, &compileResult); |
| 196 | |
| 197 | if (compileResult == 0) |
| 198 | { |
| 199 | GLint infoLogLength; |
| 200 | glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); |
| 201 | |
Jamie Madill | d2c52e3 | 2015-10-14 17:07:05 -0400 | [diff] [blame] | 202 | if (infoLogLength == 0) |
| 203 | { |
| 204 | std::cerr << "shader compilation failed with empty log." << std::endl; |
| 205 | } |
| 206 | else |
| 207 | { |
| 208 | std::vector<GLchar> infoLog(infoLogLength); |
| 209 | glGetShaderInfoLog(shader, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]); |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 210 | |
Jamie Madill | d2c52e3 | 2015-10-14 17:07:05 -0400 | [diff] [blame] | 211 | std::cerr << "shader compilation failed: " << &infoLog[0]; |
| 212 | } |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 213 | |
| 214 | glDeleteShader(shader); |
| 215 | shader = 0; |
| 216 | } |
| 217 | |
| 218 | return shader; |
| 219 | } |
| 220 | |
Austin Kinross | d544cc9 | 2016-01-11 15:26:42 -0800 | [diff] [blame] | 221 | void ANGLETest::checkD3D11SDKLayersMessages() |
| 222 | { |
| 223 | #if defined(ANGLE_PLATFORM_WINDOWS) && !defined(NDEBUG) |
| 224 | // In debug D3D11 mode, check ID3D11InfoQueue to see if any D3D11 SDK Layers messages |
| 225 | // were outputted by the test |
| 226 | if (mIgnoreD3D11SDKLayersWarnings || |
| 227 | mEGLWindow->getPlatform().renderer != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE || |
| 228 | mEGLWindow->getDisplay() == EGL_NO_DISPLAY) |
| 229 | { |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | const char *extensionString = |
| 234 | static_cast<const char *>(eglQueryString(mEGLWindow->getDisplay(), EGL_EXTENSIONS)); |
| 235 | if (!strstr(extensionString, "EGL_EXT_device_query")) |
| 236 | { |
| 237 | return; |
| 238 | } |
| 239 | |
| 240 | EGLAttrib device = 0; |
| 241 | EGLAttrib angleDevice = 0; |
| 242 | |
| 243 | PFNEGLQUERYDISPLAYATTRIBEXTPROC queryDisplayAttribEXT; |
| 244 | PFNEGLQUERYDEVICEATTRIBEXTPROC queryDeviceAttribEXT; |
| 245 | |
| 246 | queryDisplayAttribEXT = reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBEXTPROC>( |
| 247 | eglGetProcAddress("eglQueryDisplayAttribEXT")); |
| 248 | queryDeviceAttribEXT = reinterpret_cast<PFNEGLQUERYDEVICEATTRIBEXTPROC>( |
| 249 | eglGetProcAddress("eglQueryDeviceAttribEXT")); |
| 250 | ASSERT_NE(nullptr, queryDisplayAttribEXT); |
| 251 | ASSERT_NE(nullptr, queryDeviceAttribEXT); |
| 252 | |
| 253 | ASSERT_EGL_TRUE(queryDisplayAttribEXT(mEGLWindow->getDisplay(), EGL_DEVICE_EXT, &angleDevice)); |
| 254 | ASSERT_EGL_TRUE(queryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice), |
| 255 | EGL_D3D11_DEVICE_ANGLE, &device)); |
| 256 | ID3D11Device *d3d11Device = reinterpret_cast<ID3D11Device *>(device); |
| 257 | |
| 258 | ID3D11InfoQueue *infoQueue = nullptr; |
| 259 | HRESULT hr = |
| 260 | d3d11Device->QueryInterface(__uuidof(infoQueue), reinterpret_cast<void **>(&infoQueue)); |
| 261 | if (SUCCEEDED(hr)) |
| 262 | { |
| 263 | UINT64 numStoredD3DDebugMessages = |
| 264 | infoQueue->GetNumStoredMessagesAllowedByRetrievalFilter(); |
| 265 | |
| 266 | if (numStoredD3DDebugMessages > 0) |
| 267 | { |
| 268 | for (UINT64 i = 0; i < numStoredD3DDebugMessages; i++) |
| 269 | { |
| 270 | SIZE_T messageLength = 0; |
| 271 | hr = infoQueue->GetMessage(i, nullptr, &messageLength); |
| 272 | |
| 273 | if (SUCCEEDED(hr)) |
| 274 | { |
| 275 | D3D11_MESSAGE *pMessage = |
| 276 | reinterpret_cast<D3D11_MESSAGE *>(malloc(messageLength)); |
| 277 | infoQueue->GetMessage(i, pMessage, &messageLength); |
| 278 | |
| 279 | std::cout << "Message " << i << ":" |
| 280 | << " " << pMessage->pDescription << "\n"; |
| 281 | free(pMessage); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | FAIL() << numStoredD3DDebugMessages |
| 286 | << " D3D11 SDK Layers message(s) detected! Test Failed.\n"; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | SafeRelease(infoQueue); |
| 291 | #endif |
| 292 | } |
| 293 | |
Geoff Lang | 63046e2 | 2015-07-21 12:43:50 -0400 | [diff] [blame] | 294 | static bool checkExtensionExists(const char *allExtensions, const std::string &extName) |
| 295 | { |
| 296 | return strstr(allExtensions, extName.c_str()) != nullptr; |
| 297 | } |
| 298 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 299 | bool ANGLETest::extensionEnabled(const std::string &extName) |
| 300 | { |
Geoff Lang | 63046e2 | 2015-07-21 12:43:50 -0400 | [diff] [blame] | 301 | return checkExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)), |
| 302 | extName); |
| 303 | } |
| 304 | |
| 305 | bool ANGLETest::eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName) |
| 306 | { |
| 307 | return checkExtensionExists(eglQueryString(display, EGL_EXTENSIONS), extName); |
| 308 | } |
| 309 | |
| 310 | bool ANGLETest::eglClientExtensionEnabled(const std::string &extName) |
| 311 | { |
| 312 | return checkExtensionExists(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS), extName); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 313 | } |
| 314 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 315 | void ANGLETest::setWindowWidth(int width) |
| 316 | { |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 317 | mWidth = width; |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | void ANGLETest::setWindowHeight(int height) |
| 321 | { |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 322 | mHeight = height; |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 323 | } |
| 324 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 325 | void ANGLETest::setConfigRedBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 326 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 327 | mEGLWindow->setConfigRedBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 328 | } |
| 329 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 330 | void ANGLETest::setConfigGreenBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 331 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 332 | mEGLWindow->setConfigGreenBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 333 | } |
| 334 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 335 | void ANGLETest::setConfigBlueBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 336 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 337 | mEGLWindow->setConfigBlueBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 338 | } |
| 339 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 340 | void ANGLETest::setConfigAlphaBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 341 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 342 | mEGLWindow->setConfigAlphaBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 343 | } |
| 344 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 345 | void ANGLETest::setConfigDepthBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 346 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 347 | mEGLWindow->setConfigDepthBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 348 | } |
| 349 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 350 | void ANGLETest::setConfigStencilBits(int bits) |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 351 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 352 | mEGLWindow->setConfigStencilBits(bits); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | void ANGLETest::setMultisampleEnabled(bool enabled) |
| 356 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 357 | mEGLWindow->setMultisample(enabled); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 358 | } |
| 359 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 360 | void ANGLETest::setDebugEnabled(bool enabled) |
| 361 | { |
| 362 | mEGLWindow->setDebugEnabled(enabled); |
| 363 | } |
| 364 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 365 | void ANGLETest::setNoErrorEnabled(bool enabled) |
| 366 | { |
| 367 | mEGLWindow->setNoErrorEnabled(enabled); |
| 368 | } |
| 369 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 370 | int ANGLETest::getClientVersion() const |
| 371 | { |
Geoff Lang | 5ade845 | 2015-09-02 11:00:30 -0400 | [diff] [blame] | 372 | return mEGLWindow->getClientMajorVersion(); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 373 | } |
| 374 | |
Geoff Lang | b926627 | 2015-01-29 13:25:14 +0000 | [diff] [blame] | 375 | EGLWindow *ANGLETest::getEGLWindow() const |
| 376 | { |
| 377 | return mEGLWindow; |
| 378 | } |
| 379 | |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 380 | int ANGLETest::getWindowWidth() const |
| 381 | { |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 382 | return mWidth; |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | int ANGLETest::getWindowHeight() const |
| 386 | { |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 387 | return mHeight; |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 388 | } |
| 389 | |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 390 | bool ANGLETest::isMultisampleEnabled() const |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 391 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 392 | return mEGLWindow->isMultisample(); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | bool ANGLETest::createEGLContext() |
| 396 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 397 | return mEGLWindow->initializeGL(mOSWindow); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | bool ANGLETest::destroyEGLContext() |
| 401 | { |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 402 | mEGLWindow->destroyGL(); |
Geoff Lang | 8a079e5 | 2013-10-18 16:13:33 -0400 | [diff] [blame] | 403 | return true; |
| 404 | } |
Geoff Lang | bb13467 | 2013-10-23 13:06:46 -0400 | [diff] [blame] | 405 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 406 | bool ANGLETest::InitTestWindow() |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 407 | { |
| 408 | mOSWindow = CreateOSWindow(); |
| 409 | if (!mOSWindow->initialize("ANGLE_TEST", 128, 128)) |
| 410 | { |
| 411 | return false; |
| 412 | } |
| 413 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 414 | mOSWindow->setVisible(true); |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 415 | |
| 416 | return true; |
| 417 | } |
| 418 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 419 | bool ANGLETest::DestroyTestWindow() |
Jamie Madill | 8add0eb | 2014-08-26 13:16:35 -0400 | [diff] [blame] | 420 | { |
| 421 | if (mOSWindow) |
| 422 | { |
| 423 | mOSWindow->destroy(); |
| 424 | delete mOSWindow; |
| 425 | mOSWindow = NULL; |
| 426 | } |
| 427 | |
| 428 | return true; |
| 429 | } |
| 430 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 431 | void ANGLETest::SetWindowVisible(bool isVisible) |
Geoff Lang | bb13467 | 2013-10-23 13:06:46 -0400 | [diff] [blame] | 432 | { |
Jamie Madill | 4119ed3 | 2014-10-01 10:41:40 -0400 | [diff] [blame] | 433 | mOSWindow->setVisible(isVisible); |
Geoff Lang | bb13467 | 2013-10-23 13:06:46 -0400 | [diff] [blame] | 434 | } |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 435 | |
Jamie Madill | c3b9b26 | 2015-01-30 14:00:51 -0500 | [diff] [blame] | 436 | bool ANGLETest::isIntel() const |
| 437 | { |
| 438 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 439 | return (rendererString.find("Intel") != std::string::npos); |
| 440 | } |
| 441 | |
| 442 | bool ANGLETest::isAMD() const |
| 443 | { |
| 444 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 445 | return (rendererString.find("AMD") != std::string::npos) || |
| 446 | (rendererString.find("ATI") != std::string::npos); |
| 447 | } |
| 448 | |
| 449 | bool ANGLETest::isNVidia() const |
| 450 | { |
| 451 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 452 | return (rendererString.find("NVIDIA") != std::string::npos); |
| 453 | } |
| 454 | |
Jamie Madill | d55d283 | 2015-10-27 13:59:19 -0400 | [diff] [blame] | 455 | bool ANGLETest::isD3D11() const |
| 456 | { |
| 457 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 458 | return (rendererString.find("Direct3D11 vs_5_0") != std::string::npos); |
| 459 | } |
| 460 | |
Jamie Madill | 9fc3682 | 2015-11-18 13:08:07 -0500 | [diff] [blame] | 461 | bool ANGLETest::isD3D11_FL93() const |
| 462 | { |
| 463 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 464 | return (rendererString.find("Direct3D11 vs_4_0_") != std::string::npos); |
| 465 | } |
| 466 | |
| 467 | bool ANGLETest::isD3D9() const |
| 468 | { |
| 469 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 470 | return (rendererString.find("Direct3D9") != std::string::npos); |
| 471 | } |
| 472 | |
| 473 | bool ANGLETest::isD3DSM3() const |
| 474 | { |
| 475 | std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); |
| 476 | return isD3D9() || isD3D11_FL93(); |
| 477 | } |
| 478 | |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 479 | bool ANGLETest::isOSX() const |
| 480 | { |
| 481 | #ifdef __APPLE__ |
| 482 | return true; |
| 483 | #else |
| 484 | return false; |
| 485 | #endif |
| 486 | } |
| 487 | |
Jamie Madill | c3b9b26 | 2015-01-30 14:00:51 -0500 | [diff] [blame] | 488 | EGLint ANGLETest::getPlatformRenderer() const |
| 489 | { |
Jamie Madill | f685991 | 2015-01-30 17:05:35 -0500 | [diff] [blame] | 490 | assert(mEGLWindow); |
| 491 | return mEGLWindow->getPlatform().renderer; |
Jamie Madill | c3b9b26 | 2015-01-30 14:00:51 -0500 | [diff] [blame] | 492 | } |
| 493 | |
Austin Kinross | d544cc9 | 2016-01-11 15:26:42 -0800 | [diff] [blame] | 494 | void ANGLETest::ignoreD3D11SDKLayersWarnings() |
| 495 | { |
| 496 | // Some tests may need to disable the D3D11 SDK Layers Warnings checks |
| 497 | mIgnoreD3D11SDKLayersWarnings = true; |
| 498 | } |
| 499 | |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 500 | OSWindow *ANGLETest::mOSWindow = NULL; |
| 501 | |
| 502 | void ANGLETestEnvironment::SetUp() |
| 503 | { |
| 504 | if (!ANGLETest::InitTestWindow()) |
| 505 | { |
| 506 | FAIL() << "Failed to create ANGLE test window."; |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | void ANGLETestEnvironment::TearDown() |
| 511 | { |
| 512 | ANGLETest::DestroyTestWindow(); |
| 513 | } |