Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/deqp_support/tcuANGLEPlatform.cpp
1693 views
1
/*-------------------------------------------------------------------------
2
* drawElements Quality Program Tester Core
3
* ----------------------------------------
4
*
5
* Copyright 2014 The Android Open Source Project
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
10
*
11
* http://www.apache.org/licenses/LICENSE-2.0
12
*
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
18
*
19
*/
20
21
#include "tcuANGLEPlatform.h"
22
23
#include <EGL/egl.h>
24
#include <EGL/eglext.h>
25
26
#include "egluGLContextFactory.hpp"
27
#include "tcuANGLENativeDisplayFactory.h"
28
#include "tcuNullContextFactory.hpp"
29
#include "util/test_utils.h"
30
31
static_assert(EGL_DONT_CARE == -1, "Unexpected value for EGL_DONT_CARE");
32
33
namespace tcu
34
{
35
ANGLEPlatform::ANGLEPlatform(angle::LogErrorFunc logErrorFunc,
36
uint32_t preRotation,
37
bool enableDirectSPIRVGen)
38
{
39
angle::SetLowPriorityProcess();
40
41
mPlatformMethods.logError = logErrorFunc;
42
43
// Enable non-conformant ES versions and extensions for testing. Our test expectations would
44
// suppress failing tests, but allowing continuous testing of the pieces that are implemented.
45
mEnableFeatureOverrides.push_back("exposeNonConformantExtensionsAndVersions");
46
47
// Create pre-rotation attributes.
48
switch (preRotation)
49
{
50
case 90:
51
mEnableFeatureOverrides.push_back("emulatedPrerotation90");
52
break;
53
case 180:
54
mEnableFeatureOverrides.push_back("emulatedPrerotation180");
55
break;
56
case 270:
57
mEnableFeatureOverrides.push_back("emulatedPrerotation270");
58
break;
59
default:
60
break;
61
}
62
63
if (enableDirectSPIRVGen)
64
{
65
mEnableFeatureOverrides.push_back("directSPIRVGeneration");
66
}
67
68
mEnableFeatureOverrides.push_back(nullptr);
69
70
#if (DE_OS == DE_OS_WIN32)
71
{
72
std::vector<eglw::EGLAttrib> d3d11Attribs = initAttribs(
73
EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE);
74
75
auto *d3d11Factory = new ANGLENativeDisplayFactory("angle-d3d11", "ANGLE D3D11 Display",
76
d3d11Attribs, &mEvents);
77
m_nativeDisplayFactoryRegistry.registerFactory(d3d11Factory);
78
}
79
80
{
81
std::vector<eglw::EGLAttrib> d3d11Attribs =
82
initAttribs(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
83
EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE);
84
85
auto *d3d11Factory = new ANGLENativeDisplayFactory(
86
"angle-d3d11-ref", "ANGLE D3D11 Reference Display", d3d11Attribs, &mEvents);
87
m_nativeDisplayFactoryRegistry.registerFactory(d3d11Factory);
88
}
89
90
{
91
std::vector<eglw::EGLAttrib> d3d9Attribs = initAttribs(
92
EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE);
93
94
auto *d3d9Factory = new ANGLENativeDisplayFactory("angle-d3d9", "ANGLE D3D9 Display",
95
d3d9Attribs, &mEvents);
96
m_nativeDisplayFactoryRegistry.registerFactory(d3d9Factory);
97
}
98
99
{
100
std::vector<eglw::EGLAttrib> d3d1193Attribs =
101
initAttribs(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
102
EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE, 9, 3);
103
104
auto *d3d1193Factory = new ANGLENativeDisplayFactory(
105
"angle-d3d11-fl93", "ANGLE D3D11 FL9_3 Display", d3d1193Attribs, &mEvents);
106
m_nativeDisplayFactoryRegistry.registerFactory(d3d1193Factory);
107
}
108
#endif // (DE_OS == DE_OS_WIN32)
109
110
#if defined(ANGLE_USE_GBM) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_WIN32)
111
{
112
std::vector<eglw::EGLAttrib> glesAttribs =
113
initAttribs(EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE);
114
115
auto *glesFactory = new ANGLENativeDisplayFactory("angle-gles", "ANGLE OpenGL ES Display",
116
glesAttribs, &mEvents);
117
m_nativeDisplayFactoryRegistry.registerFactory(glesFactory);
118
}
119
#endif
120
121
{
122
std::vector<eglw::EGLAttrib> glAttribs = initAttribs(EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE);
123
124
auto *glFactory =
125
new ANGLENativeDisplayFactory("angle-gl", "ANGLE OpenGL Display", glAttribs, &mEvents);
126
m_nativeDisplayFactoryRegistry.registerFactory(glFactory);
127
}
128
129
#if (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_WIN32) || (DE_OS == DE_OS_UNIX)
130
{
131
std::vector<eglw::EGLAttrib> vkAttribs = initAttribs(EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE);
132
133
auto *vkFactory = new ANGLENativeDisplayFactory("angle-vulkan", "ANGLE Vulkan Display",
134
vkAttribs, &mEvents);
135
m_nativeDisplayFactoryRegistry.registerFactory(vkFactory);
136
}
137
#endif
138
139
#if (DE_OS == DE_OS_WIN32) || (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX)
140
{
141
std::vector<eglw::EGLAttrib> swsAttribs = initAttribs(
142
EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE);
143
m_nativeDisplayFactoryRegistry.registerFactory(new ANGLENativeDisplayFactory(
144
"angle-swiftshader", "ANGLE SwiftShader Display", swsAttribs, &mEvents));
145
}
146
#endif
147
148
#if (DE_OS == DE_OS_OSX)
149
{
150
std::vector<eglw::EGLAttrib> mtlAttribs = initAttribs(EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE);
151
152
auto *mtlFactory = new ANGLENativeDisplayFactory("angle-metal", "ANGLE Metal Display",
153
mtlAttribs, &mEvents);
154
m_nativeDisplayFactoryRegistry.registerFactory(mtlFactory);
155
}
156
#endif
157
158
{
159
std::vector<eglw::EGLAttrib> nullAttribs = initAttribs(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE);
160
161
auto *nullFactory = new ANGLENativeDisplayFactory("angle-null", "ANGLE NULL Display",
162
nullAttribs, &mEvents);
163
m_nativeDisplayFactoryRegistry.registerFactory(nullFactory);
164
}
165
166
m_contextFactoryRegistry.registerFactory(
167
new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry));
168
169
// Add Null context type for use in generating case lists
170
m_contextFactoryRegistry.registerFactory(new null::NullGLContextFactory());
171
}
172
173
ANGLEPlatform::~ANGLEPlatform() {}
174
175
bool ANGLEPlatform::processEvents()
176
{
177
return !mEvents.quitSignaled();
178
}
179
180
std::vector<eglw::EGLAttrib> ANGLEPlatform::initAttribs(eglw::EGLAttrib type,
181
eglw::EGLAttrib deviceType,
182
eglw::EGLAttrib majorVersion,
183
eglw::EGLAttrib minorVersion)
184
{
185
std::vector<eglw::EGLAttrib> attribs;
186
187
attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
188
attribs.push_back(type);
189
190
if (deviceType != EGL_DONT_CARE)
191
{
192
attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
193
attribs.push_back(deviceType);
194
}
195
196
if (majorVersion != EGL_DONT_CARE)
197
{
198
attribs.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE);
199
attribs.push_back(majorVersion);
200
}
201
202
if (minorVersion != EGL_DONT_CARE)
203
{
204
attribs.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE);
205
attribs.push_back(minorVersion);
206
}
207
208
if (mPlatformMethods.logError)
209
{
210
static_assert(sizeof(eglw::EGLAttrib) == sizeof(angle::PlatformMethods *),
211
"Unexpected pointer size");
212
attribs.push_back(EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX);
213
attribs.push_back(reinterpret_cast<eglw::EGLAttrib>(&mPlatformMethods));
214
}
215
216
if (!mEnableFeatureOverrides.empty())
217
{
218
attribs.push_back(EGL_FEATURE_OVERRIDES_ENABLED_ANGLE);
219
attribs.push_back(reinterpret_cast<EGLAttrib>(mEnableFeatureOverrides.data()));
220
}
221
222
attribs.push_back(EGL_NONE);
223
return attribs;
224
}
225
} // namespace tcu
226
227
// Create platform
228
tcu::Platform *CreateANGLEPlatform(angle::LogErrorFunc logErrorFunc,
229
uint32_t preRotation,
230
bool enableDirectSPIRVGen)
231
{
232
return new tcu::ANGLEPlatform(logErrorFunc, preRotation, enableDirectSPIRVGen);
233
}
234
235
tcu::Platform *createPlatform()
236
{
237
return CreateANGLEPlatform(nullptr, 0, false);
238
}
239
240