Olli Etuaho | f26b27e | 2018-08-17 11:01:19 +0300 | [diff] [blame^] | 1 | // |
| 2 | // Copyright 2018 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 | // MultiviewTest: |
| 7 | // Implementation of helpers for multiview testing. |
| 8 | // |
| 9 | |
| 10 | #ifndef ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_ |
| 11 | #define ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_ |
| 12 | |
| 13 | #include "test_utils/ANGLETest.h" |
| 14 | |
| 15 | namespace angle |
| 16 | { |
| 17 | |
| 18 | // Creates a simple program that passes through two-dimensional vertices and renders green |
| 19 | // fragments. |
| 20 | GLuint CreateSimplePassthroughProgram(int numViews); |
| 21 | |
| 22 | struct MultiviewImplementationParams : public PlatformParameters |
| 23 | { |
| 24 | MultiviewImplementationParams(GLint majorVersion, |
| 25 | GLint minorVersion, |
| 26 | bool forceUseGeometryShaderOnD3D, |
| 27 | const EGLPlatformParameters &eglPlatformParameters) |
| 28 | : PlatformParameters(majorVersion, minorVersion, eglPlatformParameters), |
| 29 | mForceUseGeometryShaderOnD3D(forceUseGeometryShaderOnD3D) |
| 30 | { |
| 31 | } |
| 32 | bool mForceUseGeometryShaderOnD3D; |
| 33 | }; |
| 34 | std::ostream &operator<<(std::ostream &os, const MultiviewImplementationParams ¶ms); |
| 35 | |
| 36 | MultiviewImplementationParams VertexShaderOpenGL(GLint majorVersion, GLint minorVersion); |
| 37 | MultiviewImplementationParams VertexShaderD3D11(GLint majorVersion, GLint minorVersion); |
| 38 | MultiviewImplementationParams GeomShaderD3D11(GLint majorVersion, GLint minorVersion); |
| 39 | |
| 40 | class MultiviewTestBase : public ANGLETestBase |
| 41 | { |
| 42 | protected: |
| 43 | MultiviewTestBase(const PlatformParameters ¶ms) : ANGLETestBase(params) |
| 44 | { |
| 45 | setWindowWidth(128); |
| 46 | setWindowHeight(128); |
| 47 | setWebGLCompatibilityEnabled(true); |
| 48 | } |
| 49 | virtual ~MultiviewTestBase() {} |
| 50 | |
| 51 | void MultiviewTestBaseSetUp() |
| 52 | { |
| 53 | ANGLETestBase::ANGLETestSetUp(); |
| 54 | |
| 55 | glRequestExtensionANGLE = reinterpret_cast<PFNGLREQUESTEXTENSIONANGLEPROC>( |
| 56 | eglGetProcAddress("glRequestExtensionANGLE")); |
| 57 | } |
| 58 | |
| 59 | void MultiviewTestBaseTearDown() { ANGLETestBase::ANGLETestTearDown(); } |
| 60 | |
| 61 | // Requests the ANGLE_multiview extension and returns true if the operation succeeds. |
| 62 | bool requestMultiviewExtension() |
| 63 | { |
| 64 | if (extensionRequestable("GL_ANGLE_multiview")) |
| 65 | { |
| 66 | glRequestExtensionANGLE("GL_ANGLE_multiview"); |
| 67 | } |
| 68 | |
| 69 | if (!extensionEnabled("GL_ANGLE_multiview")) |
| 70 | { |
| 71 | std::cout << "Test skipped due to missing GL_ANGLE_multiview." << std::endl; |
| 72 | return false; |
| 73 | } |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | PFNGLREQUESTEXTENSIONANGLEPROC glRequestExtensionANGLE = nullptr; |
| 78 | }; |
| 79 | |
| 80 | // Base class for multiview tests that don't need specific helper functions. |
| 81 | class MultiviewTest : public MultiviewTestBase, |
| 82 | public ::testing::TestWithParam<MultiviewImplementationParams> |
| 83 | { |
| 84 | protected: |
| 85 | MultiviewTest() : MultiviewTestBase(GetParam()) {} |
| 86 | void SetUp() override { MultiviewTestBase::MultiviewTestBaseSetUp(); } |
| 87 | void TearDown() override { MultiviewTestBase::MultiviewTestBaseTearDown(); } |
| 88 | |
| 89 | void overrideWorkaroundsD3D(WorkaroundsD3D *workarounds) final; |
| 90 | }; |
| 91 | |
| 92 | } // namespace angle |
| 93 | |
| 94 | #endif // ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_ |