Revert "Provide default implementation of rx::DisplayEGL"

This reverts commit e82ab75a4c.

Reason for revert: crbug.com/1052772

Original change's description:
> Provide default implementation of rx::DisplayEGL
> 
> Will allow to use EGL instead of GLX on X11.
> 
> Meant to be used on modern EGL so it requires the extensions
> EGL_KHR_no_config_context and EGL_KHR_surfaceless_context.
> This keeps the default implementation simple (no pBuffer
> fallback)
> 
> Also provide simple WorkerContextEGL.
> 
> Bug: angleproject:4328
> Change-Id: I825c6998e4a3727a13e533ede3d9fb1820edc804
> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2031699
> Commit-Queue: Jamie Madill <jmadill@chromium.org>
> Reviewed-by: Jamie Madill <jmadill@chromium.org>

TBR=geofflang@chromium.org,syoussefi@chromium.org,jonahr@google.com,jmadill@chromium.org,julien.isorce@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: angleproject:4328
Change-Id: I62436cad1e6aae0c5e072acb1dab0bd10b2cf722
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2058952
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-02-17 09:52:05 +00:00 коммит произвёл Commit Bot
Родитель 6b43fba9fe
Коммит 59126651bc
7 изменённых файлов: 35 добавлений и 345 удалений

Просмотреть файл

@ -6,60 +6,18 @@
#include "libANGLE/renderer/gl/egl/ContextEGL.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/gl/egl/DisplayEGL.h"
namespace rx
{
ContextEGL::ContextEGL(const gl::State &state,
gl::ErrorSet *errorSet,
DisplayEGL *display,
const gl::Context *shareContext,
const std::shared_ptr<RendererEGL> &renderer)
: ContextGL(state, errorSet, renderer),
mDisplay(display),
mShareContext(shareContext),
mRendererEGL(renderer)
: ContextGL(state, errorSet, renderer), mRendererEGL(renderer)
{}
ContextEGL::~ContextEGL() {}
angle::Result ContextEGL::initialize()
{
ANGLE_TRY(ContextGL::initialize());
if (!mRendererEGL)
{
EGLContext nativeShareContext = EGL_NO_CONTEXT;
if (mShareContext)
{
ContextEGL *shareContextEGL = GetImplAs<ContextEGL>(mShareContext);
nativeShareContext = shareContextEGL->getContext();
}
egl::Error error = mDisplay->createRenderer(nativeShareContext, &mRendererEGL);
if (error.isError())
{
ERR() << "Failed to create a shared renderer: " << error.getMessage();
return angle::Result::Stop;
}
mRenderer = mRendererEGL;
}
return angle::Result::Continue;
}
EGLContext ContextEGL::getContext() const
{
ASSERT(mRendererEGL);
return mRendererEGL->getContext();
}
std::shared_ptr<RendererEGL> ContextEGL::getRenderer() const
{
return mRendererEGL;
}
} // namespace rx

Просмотреть файл

@ -19,20 +19,12 @@ class ContextEGL : public ContextGL
public:
ContextEGL(const gl::State &state,
gl::ErrorSet *errorSet,
DisplayEGL *display,
const gl::Context *shareContext,
const std::shared_ptr<RendererEGL> &renderer);
~ContextEGL() override;
angle::Result initialize() override;
EGLContext getContext() const;
std::shared_ptr<RendererEGL> getRenderer() const;
private:
DisplayEGL *mDisplay;
const gl::Context *mShareContext;
std::shared_ptr<RendererEGL> mRendererEGL;
};
} // namespace rx

Просмотреть файл

@ -8,95 +8,12 @@
#include "libANGLE/renderer/gl/egl/DisplayEGL.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/egl/ContextEGL.h"
#include "libANGLE/renderer/gl/egl/FunctionsEGLDL.h"
#include "libANGLE/renderer/gl/egl/ImageEGL.h"
#include "libANGLE/renderer/gl/egl/PbufferSurfaceEGL.h"
#include "libANGLE/renderer/gl/egl/RendererEGL.h"
#include "libANGLE/renderer/gl/egl/SyncEGL.h"
#include "libANGLE/renderer/gl/egl/WindowSurfaceEGL.h"
#include "libANGLE/renderer/gl/renderergl_utils.h"
namespace
{
EGLint ESBitFromPlatformAttrib(const rx::FunctionsEGL *egl, const EGLAttrib platformAttrib)
{
EGLint esBit = EGL_NONE;
switch (platformAttrib)
{
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
{
esBit = EGL_OPENGL_BIT;
break;
}
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
{
static_assert(EGL_OPENGL_ES3_BIT == EGL_OPENGL_ES3_BIT_KHR,
"Extension define must match core");
gl::Version eglVersion(egl->majorVersion, egl->minorVersion);
esBit = (eglVersion >= gl::Version(1, 5) || egl->hasExtension("EGL_KHR_create_context"))
? EGL_OPENGL_ES3_BIT
: EGL_OPENGL_ES2_BIT;
break;
}
default:
break;
}
return esBit;
}
class WorkerContextEGL final : public rx::WorkerContext
{
public:
WorkerContextEGL(EGLContext context, rx::FunctionsEGL *functions, EGLSurface pbuffer);
~WorkerContextEGL() override;
bool makeCurrent() override;
void unmakeCurrent() override;
private:
EGLContext mContext;
rx::FunctionsEGL *mFunctions;
EGLSurface mPbuffer;
};
WorkerContextEGL::WorkerContextEGL(EGLContext context,
rx::FunctionsEGL *functions,
EGLSurface pbuffer)
: mContext(context), mFunctions(functions), mPbuffer(pbuffer)
{}
WorkerContextEGL::~WorkerContextEGL()
{
mFunctions->destroyContext(mContext);
}
bool WorkerContextEGL::makeCurrent()
{
if (mFunctions->makeCurrent(mPbuffer, mContext) == EGL_FALSE)
{
ERR() << "Unable to make the EGL context current.";
return false;
}
return true;
}
void WorkerContextEGL::unmakeCurrent()
{
mFunctions->makeCurrent(EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
} // namespace
namespace rx
{
@ -196,96 +113,6 @@ egl::Error DisplayEGL::initializeContext(EGLContext shareContext,
return egl::Error(mEGL->getError(), "eglCreateContext failed");
}
egl::Error DisplayEGL::initialize(egl::Display *display)
{
mDisplayAttributes = display->getAttributeMap();
mEGL = new FunctionsEGLDL();
void *eglHandle =
reinterpret_cast<void *>(mDisplayAttributes.get(EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE, 0));
ANGLE_TRY(mEGL->initialize(display->getNativeDisplayId(), "libEGL.so.1", eglHandle));
gl::Version eglVersion(mEGL->majorVersion, mEGL->minorVersion);
if (eglVersion < gl::Version(1, 4))
{
return egl::EglNotInitialized() << "EGL >= 1.4 is required";
}
// Only support modern EGL implementation to keep default implementation
// simple.
const char *necessaryExtensions[] = {
"EGL_KHR_no_config_context",
"EGL_KHR_surfaceless_context",
};
for (const char *ext : necessaryExtensions)
{
if (!mEGL->hasExtension(ext))
{
return egl::EglNotInitialized() << "need " << ext;
}
}
const EGLAttrib platformAttrib = mDisplayAttributes.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, 0);
EGLint esBit = ESBitFromPlatformAttrib(mEGL, platformAttrib);
if (esBit == EGL_NONE)
{
return egl::EglNotInitialized() << "No matching ES Bit";
}
std::vector<EGLint> configAttribListBase = {
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER, EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
EGL_CONFIG_CAVEAT, EGL_NONE, EGL_CONFORMANT, esBit,
EGL_RENDERABLE_TYPE, esBit, EGL_NONE};
mConfigAttribList = configAttribListBase;
EGLContext context = EGL_NO_CONTEXT;
native_egl::AttributeVector attribs;
ANGLE_TRY(initializeContext(EGL_NO_CONTEXT, mDisplayAttributes, &context, &attribs));
if (!mEGL->makeCurrent(EGL_NO_SURFACE, context))
{
return egl::EglNotInitialized() << "Could not make context current.";
}
std::unique_ptr<FunctionsGL> functionsGL(mEGL->makeFunctionsGL());
functionsGL->initialize(mDisplayAttributes);
mRenderer.reset(
new RendererEGL(std::move(functionsGL), mDisplayAttributes, this, context, attribs));
const gl::Version &maxVersion = mRenderer->getMaxSupportedESVersion();
if (maxVersion < gl::Version(2, 0))
{
return egl::EglNotInitialized() << "OpenGL ES 2.0 is not supportable.";
}
ANGLE_TRY(DisplayGL::initialize(display));
return egl::NoError();
}
void DisplayEGL::terminate()
{
DisplayGL::terminate();
EGLBoolean success = mEGL->makeCurrent(EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (success == EGL_FALSE)
{
ERR() << "eglMakeCurrent error " << egl::Error(mEGL->getError());
}
mRenderer.reset();
egl::Error result = mEGL->terminate();
if (result.isError())
{
ERR() << "eglTerminate error " << result;
}
SafeDelete(mEGL);
}
SurfaceImpl *DisplayEGL::createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs)
@ -332,15 +159,6 @@ SurfaceImpl *DisplayEGL::createPixmapSurface(const egl::SurfaceState &state,
return nullptr;
}
ContextImpl *DisplayEGL::createContext(const gl::State &state,
gl::ErrorSet *errorSet,
const egl::Config *configuration,
const gl::Context *shareContext,
const egl::AttributeMap &attribs)
{
return new ContextEGL(state, errorSet, this, shareContext, nullptr);
}
template <typename T>
void DisplayEGL::getConfigAttrib(EGLConfig config, EGLint attribute, T *value) const
{
@ -531,37 +349,6 @@ egl::Error DisplayEGL::waitNative(const gl::Context *context, EGLint engine)
return egl::NoError();
}
egl::Error DisplayEGL::makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context)
{
EGLSurface newSurface = EGL_NO_SURFACE;
if (drawSurface)
{
SurfaceEGL *drawSurfaceEGL = GetImplAs<SurfaceEGL>(drawSurface);
newSurface = drawSurfaceEGL->getSurface();
}
EGLContext newContext = EGL_NO_CONTEXT;
if (context)
{
ContextEGL *contextEGL = GetImplAs<ContextEGL>(context);
if (!contextEGL->getRenderer() && contextEGL->initialize() != angle::Result::Continue)
{
return egl::Error(mEGL->getError(), "eglMakeCurrent failed");
}
newContext = contextEGL->getContext();
}
if (mEGL->makeCurrent(newSurface, newContext) == EGL_FALSE)
{
return egl::Error(mEGL->getError(), "eglMakeCurrent failed");
}
return DisplayGL::makeCurrent(drawSurface, readSurface, context);
}
gl::Version DisplayEGL::getMaxSupportedESVersion() const
{
return mRenderer->getMaxSupportedESVersion();
@ -629,8 +416,6 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->noConfigContext = mEGL->hasExtension("EGL_KHR_no_config_context");
outExtensions->surfacelessContext = mEGL->hasExtension("EGL_KHR_surfaceless_context");
outExtensions->framebufferTargetANDROID = mEGL->hasExtension("EGL_ANDROID_framebuffer_target");
DisplayGL::generateExtensions(outExtensions);
@ -656,41 +441,6 @@ egl::Error DisplayEGL::makeCurrentSurfaceless(gl::Context *context)
return egl::NoError();
}
egl::Error DisplayEGL::createRenderer(EGLContext shareContext,
std::shared_ptr<RendererEGL> *outRenderer)
{
EGLContext context = EGL_NO_CONTEXT;
native_egl::AttributeVector attribs;
ANGLE_TRY(initializeContext(shareContext, mDisplayAttributes, &context, &attribs));
if (mEGL->makeCurrent(EGL_NO_SURFACE, context) == EGL_FALSE)
{
return egl::EglNotInitialized()
<< "eglMakeCurrent failed with " << egl::Error(mEGL->getError());
}
std::unique_ptr<FunctionsGL> functionsGL(mEGL->makeFunctionsGL());
functionsGL->initialize(mDisplayAttributes);
outRenderer->reset(
new RendererEGL(std::move(functionsGL), mDisplayAttributes, this, context, attribs));
return egl::NoError();
}
WorkerContext *DisplayEGL::createWorkerContext(std::string *infoLog,
EGLContext sharedContext,
const native_egl::AttributeVector workerAttribs)
{
EGLContext context = mEGL->createContext(mConfig, sharedContext, workerAttribs.data());
if (context == EGL_NO_CONTEXT)
{
*infoLog += "Unable to create the EGL context.";
return nullptr;
}
return new WorkerContextEGL(context, mEGL, EGL_NO_SURFACE);
}
void DisplayEGL::initializeFrontendFeatures(angle::FrontendFeatures *features) const
{
mRenderer->initializeFrontendFeatures(features);

Просмотреть файл

@ -14,12 +14,12 @@
#include <vector>
#include "libANGLE/renderer/gl/DisplayGL.h"
#include "libANGLE/renderer/gl/egl/FunctionsEGL.h"
#include "libANGLE/renderer/gl/egl/egl_utils.h"
namespace rx
{
class FunctionsEGLDL;
class RendererEGL;
class WorkerContext;
@ -44,13 +44,7 @@ class DisplayEGL : public DisplayGL
virtual WorkerContext *createWorkerContext(std::string *infoLog,
EGLContext sharedContext,
const native_egl::AttributeVector workerAttribs);
virtual egl::Error createRenderer(EGLContext shareContext,
std::shared_ptr<RendererEGL> *outRenderer);
egl::Error initialize(egl::Display *display) override;
void terminate() override;
const native_egl::AttributeVector workerAttribs) = 0;
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
@ -65,12 +59,6 @@ class DisplayEGL : public DisplayGL
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs) override;
ContextImpl *createContext(const gl::State &state,
gl::ErrorSet *errorSet,
const egl::Config *configuration,
const gl::Context *shareContext,
const egl::AttributeMap &attribs) override;
egl::ConfigSet generateConfigs() override;
bool testDeviceLost() override;
@ -83,10 +71,6 @@ class DisplayEGL : public DisplayGL
egl::Error waitClient(const gl::Context *context) override;
egl::Error waitNative(const gl::Context *context, EGLint engine) override;
egl::Error makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context) override;
gl::Version getMaxSupportedESVersion() const override;
void initializeFrontendFeatures(angle::FrontendFeatures *features) const override;
@ -114,7 +98,7 @@ class DisplayEGL : public DisplayGL
const U &defaultValue) const;
std::shared_ptr<RendererEGL> mRenderer;
FunctionsEGLDL *mEGL;
FunctionsEGL *mEGL;
EGLConfig mConfig;
egl::AttributeMap mDisplayAttributes;
std::vector<EGLint> mConfigAttribList;

Просмотреть файл

@ -152,7 +152,7 @@ egl::Error DisplayAndroid::initialize(egl::Display *display)
mConfig = configWithFormat;
}
ANGLE_TRY(createRendererHelper(EGL_NO_CONTEXT, true, &mRenderer));
ANGLE_TRY(createRenderer(EGL_NO_CONTEXT, true, &mRenderer));
const gl::Version &maxVersion = mRenderer->getMaxSupportedESVersion();
if (maxVersion < gl::Version(2, 0))
@ -210,8 +210,27 @@ ContextImpl *DisplayAndroid::createContext(const gl::State &state,
{
renderer = mRenderer;
}
else
{
EGLContext nativeShareContext = EGL_NO_CONTEXT;
if (shareContext)
{
ContextEGL *shareContextEGL = GetImplAs<ContextEGL>(shareContext);
nativeShareContext = shareContextEGL->getContext();
}
return new ContextEGL(state, errorSet, this, shareContext, renderer);
// Create a new renderer for this context. It only needs to share with the user's requested
// share context because there are no internal resources in DisplayAndroid that are shared
// at the GL level.
egl::Error error = createRenderer(nativeShareContext, false, &renderer);
if (error.isError())
{
ERR() << "Failed to create a shared renderer: " << error.getMessage();
return nullptr;
}
}
return new ContextEGL(state, errorSet, renderer);
}
bool DisplayAndroid::isValidNativeWindow(EGLNativeWindowType window) const
@ -267,11 +286,7 @@ egl::Error DisplayAndroid::makeCurrent(egl::Surface *drawSurface,
if (context)
{
ContextEGL *contextEGL = GetImplAs<ContextEGL>(context);
if (!contextEGL->getRenderer() && contextEGL->initialize() != angle::Result::Continue)
{
return egl::Error(mEGL->getError(), "eglMakeCurrent failed");
}
newContext = contextEGL->getContext();
newContext = contextEGL->getContext();
}
// The context should never change when context virtualization is being used, even when a null
@ -331,16 +346,16 @@ void DisplayAndroid::destroyNativeContext(EGLContext context)
void DisplayAndroid::generateExtensions(egl::DisplayExtensions *outExtensions) const
{
DisplayEGL::generateExtensions(outExtensions);
// Surfaceless can be support if the native driver supports it or we know that we are running on
// a single thread (mVirtualizedContexts == true)
outExtensions->surfacelessContext = mSupportsSurfaceless || mVirtualizedContexts;
DisplayEGL::generateExtensions(outExtensions);
}
egl::Error DisplayAndroid::createRendererHelper(EGLContext shareContext,
bool makeNewContextCurrent,
std::shared_ptr<RendererEGL> *outRenderer)
egl::Error DisplayAndroid::createRenderer(EGLContext shareContext,
bool makeNewContextCurrent,
std::shared_ptr<RendererEGL> *outRenderer)
{
EGLContext context = EGL_NO_CONTEXT;
native_egl::AttributeVector attribs;
@ -431,10 +446,4 @@ WorkerContext *DisplayAndroid::createWorkerContext(std::string *infoLog,
return new WorkerContextAndroid(context, mEGL, mDummyPbuffer);
}
egl::Error DisplayAndroid::createRenderer(EGLContext shareContext,
std::shared_ptr<RendererEGL> *outRenderer)
{
return createRendererHelper(shareContext, false, outRenderer);
}
} // namespace rx

Просмотреть файл

@ -57,15 +57,12 @@ class DisplayAndroid : public DisplayEGL
EGLContext sharedContext,
const native_egl::AttributeVector workerAttribs) override;
egl::Error createRenderer(EGLContext shareContext,
std::shared_ptr<RendererEGL> *outRenderer) override;
private:
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
egl::Error createRendererHelper(EGLContext shareContext,
bool makeNewContextCurrent,
std::shared_ptr<RendererEGL> *outRenderer);
egl::Error createRenderer(EGLContext shareContext,
bool makeNewContextCurrent,
std::shared_ptr<RendererEGL> *outRenderer);
bool mVirtualizedContexts;

Просмотреть файл

@ -917,7 +917,7 @@ ContextImpl *DisplayOzone::createContext(const gl::State &state,
const egl::AttributeMap &attribs)
{
// All contexts on Ozone are virtualized and share the same renderer.
return new ContextEGL(state, errorSet, this, shareContext, mRenderer);
return new ContextEGL(state, errorSet, mRenderer);
}
egl::ConfigSet DisplayOzone::generateConfigs()