Hash :
785353fd
Author :
Date :
2022-05-24T12:40:16
Support Desktop OpenGL context creation in end2end tests Validation of Desktop GL versions and profile masks is unimplemented. Bug: angleproject:7360 Change-Id: Ifae94215b6aada895c2b02318a1d05c9515e9b96 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3664916 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
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
//
// Copyright 2018 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.
//
// MultiviewTest:
// Implementation of helpers for multiview testing.
//
#ifndef ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_
#define ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_
#include "test_utils/ANGLETest.h"
namespace angle
{
enum ExtensionName
{
multiview,
multiview2
};
// Creates a simple program that passes through two-dimensional vertices and renders green
// fragments.
GLuint CreateSimplePassthroughProgram(int numViews, ExtensionName multiviewExtension);
// Create a 2D texture array to use for multiview rendering. Texture ids should be
// created beforehand. If depthTexture or stencilTexture is 0, it will not be initialized.
// If samples is 0, then non-multisampled textures are created. Otherwise multisampled textures are
// created with the requested sample count.
void CreateMultiviewBackingTextures(int samples,
int viewWidth,
int height,
int numLayers,
std::vector<GLuint> colorTextures,
GLuint depthTexture,
GLuint depthStencilTexture);
void CreateMultiviewBackingTextures(int samples,
int viewWidth,
int height,
int numLayers,
GLuint colorTexture,
GLuint depthTexture,
GLuint depthStencilTexture);
// Attach multiview textures to the framebuffer denoted by target. If there are multiple color
// textures they get attached to different color attachments starting from 0.
void AttachMultiviewTextures(GLenum target,
int viewWidth,
int numViews,
int baseViewIndex,
std::vector<GLuint> colorTextures,
GLuint depthTexture,
GLuint depthStencilTexture);
void AttachMultiviewTextures(GLenum target,
int viewWidth,
int numViews,
int baseViewIndex,
GLuint colorTexture,
GLuint depthTexture,
GLuint depthStencilTexture);
struct MultiviewImplementationParams : public PlatformParameters
{
MultiviewImplementationParams(EGLenum clientType,
GLint majorVersion,
GLint minorVersion,
EGLint profileMask,
const EGLPlatformParameters &eglPlatformParameters,
ExtensionName multiviewExtension)
: PlatformParameters(clientType,
majorVersion,
minorVersion,
profileMask,
eglPlatformParameters),
mMultiviewExtension(multiviewExtension)
{}
ExtensionName mMultiviewExtension;
};
std::ostream &operator<<(std::ostream &os, const MultiviewImplementationParams ¶ms);
MultiviewImplementationParams VertexShaderOpenGL(EGLenum clientType,
GLint majorVersion,
GLint minorVersion,
EGLint profileMask,
ExtensionName multiviewExtension);
MultiviewImplementationParams VertexShaderVulkan(EGLenum clientType,
GLint majorVersion,
GLint minorVersion,
EGLint profileMask,
ExtensionName multiviewExtension);
MultiviewImplementationParams VertexShaderD3D11(EGLenum clientType,
GLint majorVersion,
GLint minorVersion,
EGLint profileMask,
ExtensionName multiviewExtension);
MultiviewImplementationParams GeomShaderD3D11(EGLenum clientType,
GLint majorVersion,
GLint minorVersion,
EGLint profileMask,
ExtensionName multiviewExtension);
class MultiviewTestBase : public ANGLETestBase
{
protected:
MultiviewTestBase(const PlatformParameters ¶ms) : ANGLETestBase(params)
{
setWindowWidth(128);
setWindowHeight(128);
setWebGLCompatibilityEnabled(true);
}
virtual ~MultiviewTestBase() {}
void MultiviewTestBaseSetUp() { ANGLETestBase::ANGLETestSetUp(); }
void MultiviewTestBaseTearDown() { ANGLETestBase::ANGLETestTearDown(); }
};
// Base class for multiview tests that don't need specific helper functions.
class MultiviewTest : public MultiviewTestBase,
public ::testing::TestWithParam<MultiviewImplementationParams>
{
protected:
MultiviewTest() : MultiviewTestBase(GetParam()) {}
virtual void testSetUp() {}
virtual void testTearDown() {}
// Requests the OVR_multiview(2) extension and returns true if the operation succeeds.
bool requestMultiviewExtension(bool requireMultiviewMultisample)
{
if (!EnsureGLExtensionEnabled(extensionName()))
{
std::cout << "Test skipped due to missing " << extensionName() << "." << std::endl;
return false;
}
if (requireMultiviewMultisample)
{
if (!EnsureGLExtensionEnabled("GL_OES_texture_storage_multisample_2d_array"))
{
std::cout << "Test skipped due to missing GL_ANGLE_multiview_multisample."
<< std::endl;
return false;
}
if (!EnsureGLExtensionEnabled("GL_ANGLE_multiview_multisample"))
{
std::cout << "Test skipped due to missing GL_ANGLE_multiview_multisample."
<< std::endl;
return false;
}
}
return true;
}
bool requestMultiviewExtension() { return requestMultiviewExtension(false); }
std::string extensionName()
{
switch (GetParam().mMultiviewExtension)
{
case multiview:
return "GL_OVR_multiview";
case multiview2:
return "GL_OVR_multiview2";
default:
// Ignore unknown.
return "";
}
}
private:
void SetUp() override
{
MultiviewTestBase::MultiviewTestBaseSetUp();
testSetUp();
}
void TearDown() override
{
testTearDown();
MultiviewTestBase::MultiviewTestBaseTearDown();
}
};
} // namespace angle
#endif // ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_