Path: blob/main_old/src/tests/deqp_support/tcuANGLEPlatform.cpp
1693 views
/*-------------------------------------------------------------------------1* drawElements Quality Program Tester Core2* ----------------------------------------3*4* Copyright 2014 The Android Open Source Project5*6* Licensed under the Apache License, Version 2.0 (the "License");7* you may not use this file except in compliance with the License.8* You may obtain a copy of the License at9*10* http://www.apache.org/licenses/LICENSE-2.011*12* Unless required by applicable law or agreed to in writing, software13* distributed under the License is distributed on an "AS IS" BASIS,14* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15* See the License for the specific language governing permissions and16* limitations under the License.17*18*/1920#include "tcuANGLEPlatform.h"2122#include <EGL/egl.h>23#include <EGL/eglext.h>2425#include "egluGLContextFactory.hpp"26#include "tcuANGLENativeDisplayFactory.h"27#include "tcuNullContextFactory.hpp"28#include "util/test_utils.h"2930static_assert(EGL_DONT_CARE == -1, "Unexpected value for EGL_DONT_CARE");3132namespace tcu33{34ANGLEPlatform::ANGLEPlatform(angle::LogErrorFunc logErrorFunc,35uint32_t preRotation,36bool enableDirectSPIRVGen)37{38angle::SetLowPriorityProcess();3940mPlatformMethods.logError = logErrorFunc;4142// Enable non-conformant ES versions and extensions for testing. Our test expectations would43// suppress failing tests, but allowing continuous testing of the pieces that are implemented.44mEnableFeatureOverrides.push_back("exposeNonConformantExtensionsAndVersions");4546// Create pre-rotation attributes.47switch (preRotation)48{49case 90:50mEnableFeatureOverrides.push_back("emulatedPrerotation90");51break;52case 180:53mEnableFeatureOverrides.push_back("emulatedPrerotation180");54break;55case 270:56mEnableFeatureOverrides.push_back("emulatedPrerotation270");57break;58default:59break;60}6162if (enableDirectSPIRVGen)63{64mEnableFeatureOverrides.push_back("directSPIRVGeneration");65}6667mEnableFeatureOverrides.push_back(nullptr);6869#if (DE_OS == DE_OS_WIN32)70{71std::vector<eglw::EGLAttrib> d3d11Attribs = initAttribs(72EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE);7374auto *d3d11Factory = new ANGLENativeDisplayFactory("angle-d3d11", "ANGLE D3D11 Display",75d3d11Attribs, &mEvents);76m_nativeDisplayFactoryRegistry.registerFactory(d3d11Factory);77}7879{80std::vector<eglw::EGLAttrib> d3d11Attribs =81initAttribs(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,82EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE);8384auto *d3d11Factory = new ANGLENativeDisplayFactory(85"angle-d3d11-ref", "ANGLE D3D11 Reference Display", d3d11Attribs, &mEvents);86m_nativeDisplayFactoryRegistry.registerFactory(d3d11Factory);87}8889{90std::vector<eglw::EGLAttrib> d3d9Attribs = initAttribs(91EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE);9293auto *d3d9Factory = new ANGLENativeDisplayFactory("angle-d3d9", "ANGLE D3D9 Display",94d3d9Attribs, &mEvents);95m_nativeDisplayFactoryRegistry.registerFactory(d3d9Factory);96}9798{99std::vector<eglw::EGLAttrib> d3d1193Attribs =100initAttribs(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,101EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE, 9, 3);102103auto *d3d1193Factory = new ANGLENativeDisplayFactory(104"angle-d3d11-fl93", "ANGLE D3D11 FL9_3 Display", d3d1193Attribs, &mEvents);105m_nativeDisplayFactoryRegistry.registerFactory(d3d1193Factory);106}107#endif // (DE_OS == DE_OS_WIN32)108109#if defined(ANGLE_USE_GBM) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_WIN32)110{111std::vector<eglw::EGLAttrib> glesAttribs =112initAttribs(EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE);113114auto *glesFactory = new ANGLENativeDisplayFactory("angle-gles", "ANGLE OpenGL ES Display",115glesAttribs, &mEvents);116m_nativeDisplayFactoryRegistry.registerFactory(glesFactory);117}118#endif119120{121std::vector<eglw::EGLAttrib> glAttribs = initAttribs(EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE);122123auto *glFactory =124new ANGLENativeDisplayFactory("angle-gl", "ANGLE OpenGL Display", glAttribs, &mEvents);125m_nativeDisplayFactoryRegistry.registerFactory(glFactory);126}127128#if (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_WIN32) || (DE_OS == DE_OS_UNIX)129{130std::vector<eglw::EGLAttrib> vkAttribs = initAttribs(EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE);131132auto *vkFactory = new ANGLENativeDisplayFactory("angle-vulkan", "ANGLE Vulkan Display",133vkAttribs, &mEvents);134m_nativeDisplayFactoryRegistry.registerFactory(vkFactory);135}136#endif137138#if (DE_OS == DE_OS_WIN32) || (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX)139{140std::vector<eglw::EGLAttrib> swsAttribs = initAttribs(141EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE);142m_nativeDisplayFactoryRegistry.registerFactory(new ANGLENativeDisplayFactory(143"angle-swiftshader", "ANGLE SwiftShader Display", swsAttribs, &mEvents));144}145#endif146147#if (DE_OS == DE_OS_OSX)148{149std::vector<eglw::EGLAttrib> mtlAttribs = initAttribs(EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE);150151auto *mtlFactory = new ANGLENativeDisplayFactory("angle-metal", "ANGLE Metal Display",152mtlAttribs, &mEvents);153m_nativeDisplayFactoryRegistry.registerFactory(mtlFactory);154}155#endif156157{158std::vector<eglw::EGLAttrib> nullAttribs = initAttribs(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE);159160auto *nullFactory = new ANGLENativeDisplayFactory("angle-null", "ANGLE NULL Display",161nullAttribs, &mEvents);162m_nativeDisplayFactoryRegistry.registerFactory(nullFactory);163}164165m_contextFactoryRegistry.registerFactory(166new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry));167168// Add Null context type for use in generating case lists169m_contextFactoryRegistry.registerFactory(new null::NullGLContextFactory());170}171172ANGLEPlatform::~ANGLEPlatform() {}173174bool ANGLEPlatform::processEvents()175{176return !mEvents.quitSignaled();177}178179std::vector<eglw::EGLAttrib> ANGLEPlatform::initAttribs(eglw::EGLAttrib type,180eglw::EGLAttrib deviceType,181eglw::EGLAttrib majorVersion,182eglw::EGLAttrib minorVersion)183{184std::vector<eglw::EGLAttrib> attribs;185186attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);187attribs.push_back(type);188189if (deviceType != EGL_DONT_CARE)190{191attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);192attribs.push_back(deviceType);193}194195if (majorVersion != EGL_DONT_CARE)196{197attribs.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE);198attribs.push_back(majorVersion);199}200201if (minorVersion != EGL_DONT_CARE)202{203attribs.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE);204attribs.push_back(minorVersion);205}206207if (mPlatformMethods.logError)208{209static_assert(sizeof(eglw::EGLAttrib) == sizeof(angle::PlatformMethods *),210"Unexpected pointer size");211attribs.push_back(EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX);212attribs.push_back(reinterpret_cast<eglw::EGLAttrib>(&mPlatformMethods));213}214215if (!mEnableFeatureOverrides.empty())216{217attribs.push_back(EGL_FEATURE_OVERRIDES_ENABLED_ANGLE);218attribs.push_back(reinterpret_cast<EGLAttrib>(mEnableFeatureOverrides.data()));219}220221attribs.push_back(EGL_NONE);222return attribs;223}224} // namespace tcu225226// Create platform227tcu::Platform *CreateANGLEPlatform(angle::LogErrorFunc logErrorFunc,228uint32_t preRotation,229bool enableDirectSPIRVGen)230{231return new tcu::ANGLEPlatform(logErrorFunc, preRotation, enableDirectSPIRVGen);232}233234tcu::Platform *createPlatform()235{236return CreateANGLEPlatform(nullptr, 0, false);237}238239240