Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/test_utils/MultiviewTest.h
1693 views
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
enum ExtensionName
18
{
19
multiview,
20
multiview2
21
};
22
23
// Creates a simple program that passes through two-dimensional vertices and renders green
24
// fragments.
25
GLuint CreateSimplePassthroughProgram(int numViews, ExtensionName multiviewExtension);
26
27
// Create a 2D texture array to use for multiview rendering. Texture ids should be
28
// created beforehand. If depthTexture or stencilTexture is 0, it will not be initialized.
29
// If samples is 0, then non-multisampled textures are created. Otherwise multisampled textures are
30
// created with the requested sample count.
31
void CreateMultiviewBackingTextures(int samples,
32
int viewWidth,
33
int height,
34
int numLayers,
35
std::vector<GLuint> colorTextures,
36
GLuint depthTexture,
37
GLuint depthStencilTexture);
38
void CreateMultiviewBackingTextures(int samples,
39
int viewWidth,
40
int height,
41
int numLayers,
42
GLuint colorTexture,
43
GLuint depthTexture,
44
GLuint depthStencilTexture);
45
46
// Attach multiview textures to the framebuffer denoted by target. If there are multiple color
47
// textures they get attached to different color attachments starting from 0.
48
void AttachMultiviewTextures(GLenum target,
49
int viewWidth,
50
int numViews,
51
int baseViewIndex,
52
std::vector<GLuint> colorTextures,
53
GLuint depthTexture,
54
GLuint depthStencilTexture);
55
void AttachMultiviewTextures(GLenum target,
56
int viewWidth,
57
int numViews,
58
int baseViewIndex,
59
GLuint colorTexture,
60
GLuint depthTexture,
61
GLuint depthStencilTexture);
62
63
struct MultiviewImplementationParams : public PlatformParameters
64
{
65
MultiviewImplementationParams(GLint majorVersion,
66
GLint minorVersion,
67
bool forceUseGeometryShaderOnD3D,
68
const EGLPlatformParameters &eglPlatformParameters,
69
ExtensionName multiviewExtension)
70
: PlatformParameters(majorVersion, minorVersion, eglPlatformParameters),
71
mForceUseGeometryShaderOnD3D(forceUseGeometryShaderOnD3D),
72
mMultiviewExtension(multiviewExtension)
73
{}
74
bool mForceUseGeometryShaderOnD3D;
75
ExtensionName mMultiviewExtension;
76
};
77
std::ostream &operator<<(std::ostream &os, const MultiviewImplementationParams &params);
78
79
MultiviewImplementationParams VertexShaderOpenGL(GLint majorVersion,
80
GLint minorVersion,
81
ExtensionName multiviewExtension);
82
MultiviewImplementationParams VertexShaderVulkan(GLint majorVersion,
83
GLint minorVersion,
84
ExtensionName multiviewExtension);
85
MultiviewImplementationParams VertexShaderD3D11(GLint majorVersion,
86
GLint minorVersion,
87
ExtensionName multiviewExtension);
88
MultiviewImplementationParams GeomShaderD3D11(GLint majorVersion,
89
GLint minorVersion,
90
ExtensionName multiviewExtension);
91
92
class MultiviewTestBase : public ANGLETestBase
93
{
94
protected:
95
MultiviewTestBase(const PlatformParameters &params) : ANGLETestBase(params)
96
{
97
setWindowWidth(128);
98
setWindowHeight(128);
99
setWebGLCompatibilityEnabled(true);
100
}
101
virtual ~MultiviewTestBase() {}
102
103
void MultiviewTestBaseSetUp() { ANGLETestBase::ANGLETestSetUp(); }
104
105
void MultiviewTestBaseTearDown() { ANGLETestBase::ANGLETestTearDown(); }
106
};
107
108
// Base class for multiview tests that don't need specific helper functions.
109
class MultiviewTest : public MultiviewTestBase,
110
public ::testing::TestWithParam<MultiviewImplementationParams>
111
{
112
protected:
113
MultiviewTest() : MultiviewTestBase(GetParam()) {}
114
115
void overrideWorkaroundsD3D(FeaturesD3D *features) final;
116
117
virtual void testSetUp() {}
118
virtual void testTearDown() {}
119
120
// Requests the OVR_multiview(2) extension and returns true if the operation succeeds.
121
bool requestMultiviewExtension(bool requireMultiviewMultisample)
122
{
123
if (!EnsureGLExtensionEnabled(extensionName()))
124
{
125
std::cout << "Test skipped due to missing " << extensionName() << "." << std::endl;
126
return false;
127
}
128
129
if (requireMultiviewMultisample)
130
{
131
if (!EnsureGLExtensionEnabled("GL_OES_texture_storage_multisample_2d_array"))
132
{
133
std::cout << "Test skipped due to missing GL_ANGLE_multiview_multisample."
134
<< std::endl;
135
return false;
136
}
137
138
if (!EnsureGLExtensionEnabled("GL_ANGLE_multiview_multisample"))
139
{
140
std::cout << "Test skipped due to missing GL_ANGLE_multiview_multisample."
141
<< std::endl;
142
return false;
143
}
144
}
145
return true;
146
}
147
148
bool requestMultiviewExtension() { return requestMultiviewExtension(false); }
149
150
std::string extensionName()
151
{
152
switch (GetParam().mMultiviewExtension)
153
{
154
case multiview:
155
return "GL_OVR_multiview";
156
case multiview2:
157
return "GL_OVR_multiview2";
158
default:
159
// Ignore unknown.
160
return "";
161
}
162
}
163
164
private:
165
void SetUp() override
166
{
167
MultiviewTestBase::MultiviewTestBaseSetUp();
168
testSetUp();
169
}
170
void TearDown() override
171
{
172
testTearDown();
173
MultiviewTestBase::MultiviewTestBaseTearDown();
174
}
175
};
176
177
} // namespace angle
178
179
#endif // ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_
180
181