зеркало из https://github.com/AvaloniaUI/angle.git
Revert "Provide default implementation of rx::DisplayEGL"
This reverts commit 123fd97000
.
Reason for revert: Causes GL creation failure on Linux FYI Ozone (Intel)
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: I92a1ded9e09e65de8bb83710274e0a73ecdff0a4
> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2061168
> Commit-Queue: Jamie Madill <jmadill@chromium.org>
> Reviewed-by: Jamie Madill <jmadill@chromium.org>
TBR=geofflang@chromium.org,jmadill@chromium.org,julien.isorce@chromium.org
Change-Id: Ia55180ed83386fe1a158ccefda6155b33d779e98
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: angleproject:4328
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2062604
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Родитель
fa9eff37c3
Коммит
90c9f66cc4
|
@ -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,30 +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)
|
||||
{
|
||||
std::shared_ptr<RendererEGL> renderer;
|
||||
EGLContext nativeShareContext = EGL_NO_CONTEXT;
|
||||
if (shareContext)
|
||||
{
|
||||
ContextEGL *shareContextEGL = GetImplAs<ContextEGL>(shareContext);
|
||||
nativeShareContext = shareContextEGL->getContext();
|
||||
}
|
||||
|
||||
egl::Error error = createRenderer(nativeShareContext, &renderer);
|
||||
if (error.isError())
|
||||
{
|
||||
ERR() << "Failed to create a shared renderer: " << error.getMessage();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new ContextEGL(state, errorSet, renderer);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DisplayEGL::getConfigAttrib(EGLConfig config, EGLint attribute, T *value) const
|
||||
{
|
||||
|
@ -546,32 +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);
|
||||
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();
|
||||
|
@ -639,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);
|
||||
|
@ -666,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,10 +44,7 @@ class DisplayEGL : public DisplayGL
|
|||
|
||||
virtual WorkerContext *createWorkerContext(std::string *infoLog,
|
||||
EGLContext sharedContext,
|
||||
const native_egl::AttributeVector workerAttribs);
|
||||
|
||||
egl::Error initialize(egl::Display *display) override;
|
||||
void terminate() override;
|
||||
const native_egl::AttributeVector workerAttribs) = 0;
|
||||
|
||||
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
|
||||
EGLNativeWindowType window,
|
||||
|
@ -62,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;
|
||||
|
@ -80,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;
|
||||
|
@ -98,8 +85,6 @@ class DisplayEGL : public DisplayGL
|
|||
|
||||
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
|
||||
|
||||
egl::Error createRenderer(EGLContext shareContext, std::shared_ptr<RendererEGL> *outRenderer);
|
||||
|
||||
egl::Error makeCurrentSurfaceless(gl::Context *context) override;
|
||||
|
||||
template <typename T>
|
||||
|
@ -113,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;
|
||||
|
|
|
@ -346,11 +346,11 @@ 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::createRenderer(EGLContext shareContext,
|
||||
|
|
|
@ -953,10 +953,10 @@ void DisplayOzone::setSwapInterval(EGLSurface drawable, SwapControlData *data)
|
|||
|
||||
void DisplayOzone::generateExtensions(egl::DisplayExtensions *outExtensions) const
|
||||
{
|
||||
DisplayEGL::generateExtensions(outExtensions);
|
||||
|
||||
// Surfaceless contexts are emulated even if there is no native support.
|
||||
outExtensions->surfacelessContext = true;
|
||||
|
||||
DisplayEGL::generateExtensions(outExtensions);
|
||||
}
|
||||
|
||||
class WorkerContextOzone final : public WorkerContext
|
||||
|
|
Загрузка…
Ссылка в новой задаче