mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Implement EGL_ANGLE_create_context_backwards_compatible
This extension allows the user to specify if ANGLE should create a context of the exact requested version or a higher version context that is backwards compatible. BUG=angleproject:3425 Change-Id: I7d0b75cdd7e34a2fc888aa238e1eeb67af82ae0d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1601560 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
3
BUILD.gn
3
BUILD.gn
@@ -96,9 +96,6 @@ config("internal_config") {
|
||||
if (angle_enable_vulkan_gpu_trace_events) {
|
||||
defines += [ "ANGLE_ENABLE_VULKAN_GPU_TRACE_EVENTS=1" ]
|
||||
}
|
||||
if (angle_vulkan_conformant_configs_only) {
|
||||
defines += [ "ANGLE_VULKAN_CONFORMANT_CONFIGS_ONLY=1" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (angle_enable_trace) {
|
||||
|
||||
93
extensions/EGL_ANGLE_create_context_backwards_compatible.txt
Normal file
93
extensions/EGL_ANGLE_create_context_backwards_compatible.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
Name
|
||||
|
||||
ANGLE_create_context_backwards_compatible
|
||||
|
||||
Name Strings
|
||||
|
||||
EGL_ANGLE_create_context_backwards_compatible
|
||||
|
||||
Contributors
|
||||
|
||||
Geoff Lang
|
||||
|
||||
Contacts
|
||||
|
||||
Geoff Lang (geofflang 'at' google.com)
|
||||
|
||||
Status
|
||||
|
||||
Draft
|
||||
|
||||
Version
|
||||
|
||||
Version 1, May 8, 2019
|
||||
|
||||
Number
|
||||
|
||||
EGL Extension #??
|
||||
|
||||
Dependencies
|
||||
|
||||
Requires EGL 1.4.
|
||||
|
||||
Written against the EGL 1.5 specification.
|
||||
|
||||
Overview
|
||||
|
||||
This extension allows the user to create a context with exact major and
|
||||
minor versions. By default, a context may be created of any version that
|
||||
is backwards-compatible with the requested verion but it is often useful to
|
||||
users to request and target a specific version.
|
||||
|
||||
New Types
|
||||
|
||||
None
|
||||
|
||||
New Procedures and Functions
|
||||
|
||||
None
|
||||
|
||||
New Tokens
|
||||
|
||||
Accepted as an attribute name in the <*attrib_list> argument to
|
||||
eglCreateContext:
|
||||
|
||||
EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE 0x3483
|
||||
|
||||
Additions to the EGL 1.5 Specification
|
||||
|
||||
Modify section 3.7.1.1 "OpenGL and OpenGL ES Context Versions":
|
||||
|
||||
- The context returned must be the specified version, or a later version
|
||||
- which is backwards compatible with that version.
|
||||
|
||||
+ The context returned must be the specified version, or a later version
|
||||
+ which is backwards compatible with that version if
|
||||
+ EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE is EGL_TRUE.
|
||||
|
||||
Append to section 3.7.1.1 "OpenGL and OpenGL ES Context Versions":
|
||||
|
||||
The default value of EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE is
|
||||
EGL_TRUE.
|
||||
|
||||
Errors
|
||||
|
||||
None
|
||||
|
||||
New State
|
||||
|
||||
None
|
||||
|
||||
Conformance Tests
|
||||
|
||||
TBD
|
||||
|
||||
Issues
|
||||
|
||||
None
|
||||
|
||||
Revision History
|
||||
|
||||
Rev. Date Author Changes
|
||||
---- ------------- --------- ----------------------------------------
|
||||
1 May 8, 2019 geofflang Initial version
|
||||
@@ -85,9 +85,6 @@ declare_args() {
|
||||
# Enable Vulkan GPU trace event capability
|
||||
angle_enable_vulkan_gpu_trace_events = false
|
||||
|
||||
# Disallow non-conformant configurations in official builds.
|
||||
angle_vulkan_conformant_configs_only = is_official_build
|
||||
|
||||
# Enable custom (cpu-side) secondary command buffers
|
||||
angle_enable_custom_vulkan_cmd_buffers = true
|
||||
}
|
||||
|
||||
@@ -231,6 +231,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribANGLE(EGLDisplay dpy, EGLint
|
||||
#define EGL_D3D11_TEXTURE_ANGLE 0x3484
|
||||
#endif /* EGL_ANGLE_image_d3d11_texture */
|
||||
|
||||
#ifndef EGL_ANGLE_create_context_backwards_compatible
|
||||
#define EGL_ANGLE_create_context_backwards_compatible 1
|
||||
#define EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE 0x3483
|
||||
#endif /* EGL_ANGLE_create_context_backwards_compatible */
|
||||
|
||||
// clang-format on
|
||||
|
||||
#endif // INCLUDE_EGL_EGLEXT_ANGLE_
|
||||
|
||||
@@ -1188,6 +1188,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const
|
||||
InsertExtensionString("EGL_ANGLE_image_d3d11_texture", imageD3D11Texture, &extensionStrings);
|
||||
InsertExtensionString("EGL_ANDROID_get_native_client_buffer", getNativeClientBufferANDROID, &extensionStrings);
|
||||
InsertExtensionString("EGL_ANDROID_native_fence_sync", nativeFenceSyncANDROID, &extensionStrings);
|
||||
InsertExtensionString("EGL_ANGLE_create_context_backwards_compatible", createContextBackwardsCompatible, &extensionStrings);
|
||||
// TODO(jmadill): Enable this when complete.
|
||||
//InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings);
|
||||
// clang-format on
|
||||
|
||||
@@ -913,6 +913,9 @@ struct DisplayExtensions
|
||||
|
||||
// EGL_ANDROID_native_fence_sync
|
||||
bool nativeFenceSyncANDROID = false;
|
||||
|
||||
// EGL_ANGLE_create_context_backwards_compatible
|
||||
bool createContextBackwardsCompatible = false;
|
||||
};
|
||||
|
||||
struct DeviceExtensions
|
||||
|
||||
@@ -42,8 +42,7 @@
|
||||
#include "libANGLE/formatutils.h"
|
||||
#include "libANGLE/queryconversions.h"
|
||||
#include "libANGLE/queryutils.h"
|
||||
#include "libANGLE/renderer/BufferImpl.h"
|
||||
#include "libANGLE/renderer/EGLImplFactory.h"
|
||||
#include "libANGLE/renderer/DisplayImpl.h"
|
||||
#include "libANGLE/renderer/Format.h"
|
||||
#include "libANGLE/validationES.h"
|
||||
|
||||
@@ -143,9 +142,34 @@ EGLint GetClientMinorVersion(const egl::AttributeMap &attribs)
|
||||
return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0));
|
||||
}
|
||||
|
||||
Version GetClientVersion(const egl::AttributeMap &attribs)
|
||||
bool GetBackwardCompatibleContext(const egl::AttributeMap &attribs)
|
||||
{
|
||||
return Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs));
|
||||
return attribs.get(EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE, EGL_TRUE) == EGL_TRUE;
|
||||
}
|
||||
|
||||
Version GetClientVersion(egl::Display *display, const egl::AttributeMap &attribs)
|
||||
{
|
||||
Version requestedVersion =
|
||||
Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs));
|
||||
if (GetBackwardCompatibleContext(attribs))
|
||||
{
|
||||
if (requestedVersion.major == 1)
|
||||
{
|
||||
// If the user requests an ES1 context, we cannot return an ES 2+ context.
|
||||
return Version(1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Always up the version to at least the max conformant version this display supports.
|
||||
// Only return a higher client version if requested.
|
||||
return std::max(display->getImplementation()->getMaxConformantESVersion(),
|
||||
requestedVersion);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return requestedVersion;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum GetResetStrategy(const egl::AttributeMap &attribs)
|
||||
@@ -272,7 +296,7 @@ enum SubjectIndexes : angle::SubjectIndex
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
Context::Context(rx::EGLImplFactory *implFactory,
|
||||
Context::Context(egl::Display *display,
|
||||
const egl::Config *config,
|
||||
const Context *shareContext,
|
||||
TextureManager *shareTextures,
|
||||
@@ -285,7 +309,7 @@ Context::Context(rx::EGLImplFactory *implFactory,
|
||||
shareContext ? &shareContext->mState : nullptr,
|
||||
shareTextures,
|
||||
clientType,
|
||||
GetClientVersion(attribs),
|
||||
GetClientVersion(display, attribs),
|
||||
GetDebug(attribs),
|
||||
GetBindGeneratesResource(attribs),
|
||||
GetClientArraysEnabled(attribs),
|
||||
@@ -294,7 +318,8 @@ Context::Context(rx::EGLImplFactory *implFactory,
|
||||
mSkipValidation(GetNoError(attribs)),
|
||||
mDisplayTextureShareGroup(shareTextures != nullptr),
|
||||
mErrors(this),
|
||||
mImplementation(implFactory->createContext(mState, &mErrors, config, shareContext, attribs)),
|
||||
mImplementation(display->getImplementation()
|
||||
->createContext(mState, &mErrors, config, shareContext, attribs)),
|
||||
mLabel(nullptr),
|
||||
mCompiler(),
|
||||
mConfig(config),
|
||||
|
||||
@@ -307,7 +307,7 @@ class StateCache final : angle::NonCopyable
|
||||
class Context final : public egl::LabeledObject, angle::NonCopyable, public angle::ObserverInterface
|
||||
{
|
||||
public:
|
||||
Context(rx::EGLImplFactory *implFactory,
|
||||
Context(egl::Display *display,
|
||||
const egl::Config *config,
|
||||
const Context *shareContext,
|
||||
TextureManager *shareTextures,
|
||||
|
||||
@@ -940,8 +940,8 @@ Error Display::createContext(const Config *configuration,
|
||||
}
|
||||
|
||||
gl::Context *context =
|
||||
new gl::Context(mImplementation, configuration, shareContext, shareTextures, cachePointer,
|
||||
clientType, attribs, mDisplayExtensions, GetClientExtensions());
|
||||
new gl::Context(this, configuration, shareContext, shareTextures, cachePointer, clientType,
|
||||
attribs, mDisplayExtensions, GetClientExtensions());
|
||||
|
||||
ASSERT(context != nullptr);
|
||||
mContextSet.insert(context);
|
||||
@@ -1312,6 +1312,9 @@ void Display::initDisplayExtensions()
|
||||
// that ANativeWindow is not recordable.
|
||||
mDisplayExtensions.recordable = true;
|
||||
|
||||
// All backends support specific context versions
|
||||
mDisplayExtensions.createContextBackwardsCompatible = true;
|
||||
|
||||
mDisplayExtensionString = GenerateExtensionsString(mDisplayExtensions);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ class DisplayImpl : public EGLImplFactory
|
||||
virtual egl::Error waitClient(const gl::Context *context) = 0;
|
||||
virtual egl::Error waitNative(const gl::Context *context, EGLint engine) = 0;
|
||||
virtual gl::Version getMaxSupportedESVersion() const = 0;
|
||||
virtual gl::Version getMaxConformantESVersion() const = 0;
|
||||
const egl::Caps &getCaps() const;
|
||||
|
||||
virtual void setBlobCacheFuncs(EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get) {}
|
||||
|
||||
@@ -386,6 +386,11 @@ gl::Version DisplayD3D::getMaxSupportedESVersion() const
|
||||
return mRenderer->getMaxSupportedESVersion();
|
||||
}
|
||||
|
||||
gl::Version DisplayD3D::getMaxConformantESVersion() const
|
||||
{
|
||||
return mRenderer->getMaxConformantESVersion();
|
||||
}
|
||||
|
||||
void DisplayD3D::handleResult(HRESULT hr,
|
||||
const char *message,
|
||||
const char *file,
|
||||
|
||||
@@ -83,6 +83,7 @@ class DisplayD3D : public DisplayImpl, public d3d::Context
|
||||
egl::Error waitClient(const gl::Context *context) override;
|
||||
egl::Error waitNative(const gl::Context *context, EGLint engine) override;
|
||||
gl::Version getMaxSupportedESVersion() const override;
|
||||
gl::Version getMaxConformantESVersion() const override;
|
||||
|
||||
void handleResult(HRESULT hr,
|
||||
const char *message,
|
||||
|
||||
@@ -387,6 +387,7 @@ class RendererD3D : public BufferFactoryD3D
|
||||
virtual FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) = 0;
|
||||
|
||||
virtual gl::Version getMaxSupportedESVersion() const = 0;
|
||||
virtual gl::Version getMaxConformantESVersion() const = 0;
|
||||
|
||||
angle::Result initRenderTarget(const gl::Context *context, RenderTargetD3D *renderTarget);
|
||||
|
||||
|
||||
@@ -3702,6 +3702,12 @@ gl::Version Renderer11::getMaxSupportedESVersion() const
|
||||
return d3d11_gl::GetMaximumClientVersion(mRenderer11DeviceCaps.featureLevel);
|
||||
}
|
||||
|
||||
gl::Version Renderer11::getMaxConformantESVersion() const
|
||||
{
|
||||
// Always force a 2.0 context unless the user explicitly requests higher
|
||||
return std::min(getMaxSupportedESVersion(), gl::Version(2, 0));
|
||||
}
|
||||
|
||||
gl::DebugAnnotator *Renderer11::getAnnotator()
|
||||
{
|
||||
return &mAnnotator;
|
||||
|
||||
@@ -427,6 +427,7 @@ class Renderer11 : public RendererD3D
|
||||
angle::MemoryBuffer **bufferOut);
|
||||
|
||||
gl::Version getMaxSupportedESVersion() const override;
|
||||
gl::Version getMaxConformantESVersion() const override;
|
||||
|
||||
angle::Result dispatchCompute(const gl::Context *context,
|
||||
GLuint numGroupsX,
|
||||
|
||||
@@ -3084,6 +3084,11 @@ gl::Version Renderer9::getMaxSupportedESVersion() const
|
||||
return gl::Version(2, 0);
|
||||
}
|
||||
|
||||
gl::Version Renderer9::getMaxConformantESVersion() const
|
||||
{
|
||||
return gl::Version(2, 0);
|
||||
}
|
||||
|
||||
angle::Result Renderer9::clearRenderTarget(const gl::Context *context,
|
||||
RenderTargetD3D *renderTarget,
|
||||
const gl::ColorF &clearColorValue,
|
||||
|
||||
@@ -405,6 +405,7 @@ class Renderer9 : public RendererD3D
|
||||
DebugAnnotator9 *getAnnotator() { return &mAnnotator; }
|
||||
|
||||
gl::Version getMaxSupportedESVersion() const override;
|
||||
gl::Version getMaxConformantESVersion() const override;
|
||||
|
||||
angle::Result clearRenderTarget(const gl::Context *context,
|
||||
RenderTargetD3D *renderTarget,
|
||||
|
||||
@@ -71,6 +71,12 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface,
|
||||
return egl::NoError();
|
||||
}
|
||||
|
||||
gl::Version DisplayGL::getMaxConformantESVersion() const
|
||||
{
|
||||
// Always force a 2.0 context unless the user explicitly requests higher
|
||||
return std::min(getMaxSupportedESVersion(), gl::Version(2, 0));
|
||||
}
|
||||
|
||||
void DisplayGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
|
||||
{
|
||||
// Advertise robust resource initialization on all OpenGL backends for testing even though it is
|
||||
|
||||
@@ -43,6 +43,8 @@ class DisplayGL : public DisplayImpl
|
||||
egl::Surface *readSurface,
|
||||
gl::Context *context) override;
|
||||
|
||||
gl::Version getMaxConformantESVersion() const override;
|
||||
|
||||
protected:
|
||||
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
|
||||
|
||||
|
||||
@@ -126,6 +126,11 @@ gl::Version DisplayNULL::getMaxSupportedESVersion() const
|
||||
return gl::Version(3, 2);
|
||||
}
|
||||
|
||||
gl::Version DisplayNULL::getMaxConformantESVersion() const
|
||||
{
|
||||
return getMaxSupportedESVersion();
|
||||
}
|
||||
|
||||
SurfaceImpl *DisplayNULL::createWindowSurface(const egl::SurfaceState &state,
|
||||
EGLNativeWindowType window,
|
||||
const egl::AttributeMap &attribs)
|
||||
|
||||
@@ -44,6 +44,7 @@ class DisplayNULL : public DisplayImpl
|
||||
egl::Error waitClient(const gl::Context *context) override;
|
||||
egl::Error waitNative(const gl::Context *context, EGLint engine) override;
|
||||
gl::Version getMaxSupportedESVersion() const override;
|
||||
gl::Version getMaxConformantESVersion() const override;
|
||||
|
||||
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
|
||||
EGLNativeWindowType window,
|
||||
|
||||
@@ -167,6 +167,11 @@ gl::Version DisplayVk::getMaxSupportedESVersion() const
|
||||
return mRenderer->getMaxSupportedESVersion();
|
||||
}
|
||||
|
||||
gl::Version DisplayVk::getMaxConformantESVersion() const
|
||||
{
|
||||
return mRenderer->getMaxConformantESVersion();
|
||||
}
|
||||
|
||||
void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
|
||||
{
|
||||
outExtensions->createContextRobustness = true;
|
||||
|
||||
@@ -71,6 +71,7 @@ class DisplayVk : public DisplayImpl, public vk::Context
|
||||
EGLSyncImpl *createSync(const egl::AttributeMap &attribs) override;
|
||||
|
||||
gl::Version getMaxSupportedESVersion() const override;
|
||||
gl::Version getMaxConformantESVersion() const override;
|
||||
|
||||
virtual const char *getWSIExtension() const = 0;
|
||||
virtual const char *getWSILayer() const;
|
||||
|
||||
@@ -1112,11 +1112,6 @@ gl::Version RendererVk::getMaxSupportedESVersion() const
|
||||
// Current highest supported version
|
||||
gl::Version maxVersion = gl::Version(3, 1);
|
||||
|
||||
#if ANGLE_VULKAN_CONFORMANT_CONFIGS_ONLY
|
||||
// TODO: Disallow ES 3.0+ until supported. http://crbug.com/angleproject/2950
|
||||
maxVersion = gl::Version(2, 0);
|
||||
#endif
|
||||
|
||||
// If the command buffer doesn't support queries, we can't support ES3.
|
||||
if (!vk::CommandBuffer::SupportsQueries(mPhysicalDeviceFeatures))
|
||||
{
|
||||
@@ -1142,6 +1137,12 @@ gl::Version RendererVk::getMaxSupportedESVersion() const
|
||||
return maxVersion;
|
||||
}
|
||||
|
||||
gl::Version RendererVk::getMaxConformantESVersion() const
|
||||
{
|
||||
// Always force a 2.0 context unless the user explicitly requests higher
|
||||
return std::min(getMaxSupportedESVersion(), gl::Version(2, 0));
|
||||
}
|
||||
|
||||
void RendererVk::initFeatures(const ExtensionNameList &deviceExtensionNames)
|
||||
{
|
||||
// Use OpenGL line rasterization rules by default.
|
||||
|
||||
@@ -64,6 +64,7 @@ class RendererVk : angle::NonCopyable
|
||||
std::string getRendererDescription() const;
|
||||
|
||||
gl::Version getMaxSupportedESVersion() const;
|
||||
gl::Version getMaxConformantESVersion() const;
|
||||
|
||||
VkInstance getInstance() const { return mInstance; }
|
||||
VkPhysicalDevice getPhysicalDevice() const { return mPhysicalDevice; }
|
||||
|
||||
@@ -1164,6 +1164,21 @@ Error ValidateCreateContext(Display *display,
|
||||
}
|
||||
break;
|
||||
|
||||
case EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE:
|
||||
if (!display->getExtensions().createContextBackwardsCompatible)
|
||||
{
|
||||
return EglBadAttribute()
|
||||
<< "Attribute EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE "
|
||||
"requires EGL_ANGLE_create_context_backwards_compatible.";
|
||||
}
|
||||
if (value != EGL_TRUE && value != EGL_FALSE)
|
||||
{
|
||||
return EglBadAttribute()
|
||||
<< "EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE must be "
|
||||
"either EGL_TRUE or EGL_FALSE.";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return EglBadAttribute() << "Unknown attribute.";
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ angle_end2end_tests_sources = [
|
||||
"gl_tests/WebGLCompatibilityTest.cpp",
|
||||
"gl_tests/WebGLFramebufferTest.cpp",
|
||||
"gl_tests/WebGLReadOutsideFramebufferTest.cpp",
|
||||
"egl_tests/EGLBackwardsCompatibleContextTest.cpp",
|
||||
"egl_tests/EGLBlobCacheTest.cpp",
|
||||
"egl_tests/EGLChooseConfigTest.cpp",
|
||||
"egl_tests/EGLContextCompatibilityTest.cpp",
|
||||
|
||||
166
src/tests/egl_tests/EGLBackwardsCompatibleContextTest.cpp
Normal file
166
src/tests/egl_tests/EGLBackwardsCompatibleContextTest.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
//
|
||||
// Copyright (c) 2015 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.
|
||||
//
|
||||
|
||||
// EGLBackwardsCompatibleContextTest.cpp.cpp:
|
||||
// Coverage of the EGL_ANGLE_create_context_backwards_compatible extension
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "test_utils/ANGLETest.h"
|
||||
#include "test_utils/angle_test_configs.h"
|
||||
#include "test_utils/angle_test_instantiate.h"
|
||||
|
||||
namespace angle
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
std::pair<EGLint, EGLint> GetCurrentContextVersion()
|
||||
{
|
||||
const char *versionString = reinterpret_cast<const char *>(glGetString(GL_VERSION));
|
||||
EXPECT_TRUE(strstr(versionString, "OpenGL ES") != nullptr);
|
||||
return {versionString[10] - '0', versionString[12] - '0'};
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
class EGLBackwardsCompatibleContextTest : public ANGLETest
|
||||
{
|
||||
public:
|
||||
EGLBackwardsCompatibleContextTest() : mDisplay(0) {}
|
||||
|
||||
void testSetUp() override
|
||||
{
|
||||
EGLint dispattrs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, GetParam().getRenderer(), EGL_NONE};
|
||||
mDisplay = eglGetPlatformDisplayEXT(
|
||||
EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast<void *>(EGL_DEFAULT_DISPLAY), dispattrs);
|
||||
ASSERT_TRUE(mDisplay != EGL_NO_DISPLAY);
|
||||
|
||||
ASSERT_EGL_TRUE(eglInitialize(mDisplay, nullptr, nullptr));
|
||||
|
||||
int configsCount = 0;
|
||||
ASSERT_EGL_TRUE(eglGetConfigs(mDisplay, nullptr, 0, &configsCount));
|
||||
ASSERT_TRUE(configsCount != 0);
|
||||
|
||||
std::vector<EGLConfig> configs(configsCount);
|
||||
ASSERT_EGL_TRUE(eglGetConfigs(mDisplay, configs.data(), configsCount, &configsCount));
|
||||
|
||||
for (auto config : configs)
|
||||
{
|
||||
EGLint surfaceType;
|
||||
eglGetConfigAttrib(mDisplay, config, EGL_SURFACE_TYPE, &surfaceType);
|
||||
if (surfaceType & EGL_PBUFFER_BIT)
|
||||
{
|
||||
mConfig = config;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT_NE(nullptr, mConfig);
|
||||
|
||||
const EGLint pbufferAttribs[] = {
|
||||
EGL_WIDTH, 500, EGL_HEIGHT, 500, EGL_NONE,
|
||||
};
|
||||
mPbuffer = eglCreatePbufferSurface(mDisplay, mConfig, pbufferAttribs);
|
||||
EXPECT_TRUE(mPbuffer != EGL_NO_SURFACE);
|
||||
}
|
||||
|
||||
void testTearDown() override
|
||||
{
|
||||
eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
if (mPbuffer != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface(mDisplay, mPbuffer);
|
||||
}
|
||||
|
||||
eglTerminate(mDisplay);
|
||||
}
|
||||
|
||||
EGLDisplay mDisplay = EGL_NO_DISPLAY;
|
||||
EGLSurface mPbuffer = EGL_NO_SURFACE;
|
||||
EGLConfig mConfig = 0;
|
||||
};
|
||||
|
||||
// Test extension presence. All backends should expose this extension
|
||||
TEST_P(EGLBackwardsCompatibleContextTest, PbufferDifferentConfig)
|
||||
{
|
||||
EXPECT_TRUE(
|
||||
IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANGLE_create_context_backwards_compatible"));
|
||||
}
|
||||
|
||||
// Test that disabling backwards compatibility will always return the expected context version
|
||||
TEST_P(EGLBackwardsCompatibleContextTest, BackwardsCompatibleDisbled)
|
||||
{
|
||||
ANGLE_SKIP_TEST_IF(
|
||||
!IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANGLE_create_context_backwards_compatible"));
|
||||
|
||||
std::pair<EGLint, EGLint> testVersions[] = {
|
||||
{1, 0}, {1, 1}, {2, 0}, {3, 0}, {3, 1}, {3, 2},
|
||||
};
|
||||
|
||||
for (const auto &version : testVersions)
|
||||
{
|
||||
EGLint attribs[] = {EGL_CONTEXT_MAJOR_VERSION,
|
||||
version.first,
|
||||
EGL_CONTEXT_MINOR_VERSION,
|
||||
version.second,
|
||||
EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE,
|
||||
EGL_FALSE,
|
||||
EGL_NONE,
|
||||
EGL_NONE};
|
||||
|
||||
EGLContext context = eglCreateContext(mDisplay, mConfig, nullptr, attribs);
|
||||
if (context == EGL_NO_CONTEXT)
|
||||
{
|
||||
// Context version not supported
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSERT_EGL_TRUE(eglMakeCurrent(mDisplay, mPbuffer, mPbuffer, context));
|
||||
|
||||
auto contextVersion = GetCurrentContextVersion();
|
||||
EXPECT_EQ(version, contextVersion);
|
||||
|
||||
eglDestroyContext(mDisplay, context);
|
||||
}
|
||||
}
|
||||
|
||||
// Test that if ES1.1 is supported and a 1.0 context is requested, an ES 1.1 context is returned
|
||||
TEST_P(EGLBackwardsCompatibleContextTest, BackwardsCompatibleEnabledES1)
|
||||
{
|
||||
ANGLE_SKIP_TEST_IF(
|
||||
!IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANGLE_create_context_backwards_compatible"));
|
||||
|
||||
EGLint es11ContextAttribs[] = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, 1, EGL_CONTEXT_MINOR_VERSION, 1, EGL_NONE, EGL_NONE};
|
||||
|
||||
EGLContext es11Context = eglCreateContext(mDisplay, mConfig, nullptr, es11ContextAttribs);
|
||||
ANGLE_SKIP_TEST_IF(es11Context == EGL_NO_CONTEXT);
|
||||
|
||||
ASSERT_EGL_TRUE(eglMakeCurrent(mDisplay, mPbuffer, mPbuffer, es11Context));
|
||||
auto es11ContextVersion = GetCurrentContextVersion();
|
||||
ASSERT_EQ(std::make_pair(1, 1), es11ContextVersion);
|
||||
eglDestroyContext(mDisplay, es11Context);
|
||||
|
||||
EGLint es10ContextAttribs[] = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, 1, EGL_CONTEXT_MINOR_VERSION, 0, EGL_NONE, EGL_NONE};
|
||||
|
||||
EGLContext es10Context = eglCreateContext(mDisplay, mConfig, nullptr, es10ContextAttribs);
|
||||
EXPECT_NE(es10Context, EGL_NO_CONTEXT);
|
||||
|
||||
ASSERT_EGL_TRUE(eglMakeCurrent(mDisplay, mPbuffer, mPbuffer, es10Context));
|
||||
auto es10ContextVersion = GetCurrentContextVersion();
|
||||
ASSERT_EQ(std::make_pair(1, 1), es10ContextVersion);
|
||||
eglDestroyContext(mDisplay, es10Context);
|
||||
}
|
||||
|
||||
ANGLE_INSTANTIATE_TEST(EGLBackwardsCompatibleContextTest,
|
||||
WithNoFixture(ES2_D3D9()),
|
||||
WithNoFixture(ES2_D3D11()),
|
||||
WithNoFixture(ES2_OPENGL()),
|
||||
WithNoFixture(ES2_OPENGLES()),
|
||||
WithNoFixture(ES2_VULKAN()));
|
||||
|
||||
} // namespace angle
|
||||
@@ -86,7 +86,7 @@ TEST_P(EGLQueryContextTest, GetClientVersion)
|
||||
EGLint clientVersion;
|
||||
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_CLIENT_VERSION, &clientVersion) !=
|
||||
EGL_FALSE);
|
||||
EXPECT_TRUE(clientVersion == GetParam().majorVersion);
|
||||
EXPECT_GE(clientVersion, GetParam().majorVersion);
|
||||
}
|
||||
|
||||
TEST_P(EGLQueryContextTest, GetRenderBufferNoSurface)
|
||||
|
||||
@@ -242,14 +242,6 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ANGLE_VULKAN_CONFORMANT_CONFIGS_ONLY
|
||||
// Vulkan ES 3.0 is not yet supported.
|
||||
if (param.majorVersion > 2 && param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (IsWindows())
|
||||
{
|
||||
switch (param.driver)
|
||||
|
||||
@@ -345,6 +345,14 @@ EGLContext EGLWindow::createContext(EGLContext share) const
|
||||
return EGL_NO_CONTEXT;
|
||||
}
|
||||
|
||||
bool hasBackwardsCompatibleContextExtension =
|
||||
strstr(displayExtensions, "EGL_ANGLE_create_context_backwards_compatible") != nullptr;
|
||||
if (!hasProgramCacheControlExtension)
|
||||
{
|
||||
std::cerr << "EGL_ANGLE_create_context_backwards_compatible missing.\n";
|
||||
return EGL_NO_CONTEXT;
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
if (eglGetError() != EGL_SUCCESS)
|
||||
{
|
||||
@@ -413,6 +421,13 @@ EGLContext EGLWindow::createContext(EGLContext share) const
|
||||
mConfigParams.contextProgramCacheEnabled.value() ? EGL_TRUE : EGL_FALSE);
|
||||
}
|
||||
|
||||
if (hasBackwardsCompatibleContextExtension)
|
||||
{
|
||||
// Always request the exact context version that the config wants
|
||||
contextAttributes.push_back(EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE);
|
||||
contextAttributes.push_back(EGL_FALSE);
|
||||
}
|
||||
|
||||
bool hasRobustResourceInit =
|
||||
strstr(displayExtensions, "EGL_ANGLE_robust_resource_initialization") != nullptr;
|
||||
if (hasRobustResourceInit && mConfigParams.robustResourceInit.valid())
|
||||
|
||||
Reference in New Issue
Block a user