Hash :
8d23f34e
Author :
Date :
2023-01-18T16:20:05
Reland: DisplayEGL should support targeting specific EGL platforms This is a reland of 01c641d58c7b4e4809163e48f570145af89c4acc Updated changes: The value is used only if non-zero and marked as one of the supported platforms. For the moment the only platform listed as supported is EGL_PLATFORM_SURFACELESS_MESA since it's the only relevant platform value that the EGL_ANGLE_platform_angle extension is listing as acceptable value for the EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE attribute. When validated, and with relevant EGL extensions listed in the client EGL extensions list, a display object for the desired EGL platform is retrieved through the eglGetPlatformDisplayEXT entrypoint. Original change's description: > DisplayEGL should support targeting specific EGL platforms > > DisplayEGL should use the EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE > value, if provided, to target specific platforms when constructing the > native EGL display. > > The value is retrieved from the display attributes map and propagated > to FunctionsEGL::initialize(). If non-zero, and if the > eglGetPlatformDisplayEXT entrypoint is successfully loaded, then a > display object for the desired EGL platform is retrieved. > > Bug: angleproject:7942 > Change-Id: I3d8dd70c4c5c80259ae647dce039cfe741b0cf7d > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4152531 > Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Bug: angleproject:7942 Change-Id: I75212b48e0e0edceef92e38bf68791017fb30a56 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4178310 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
//
// Copyright 2016 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.
//
// FunctionsEGLDL.cpp: Implements the FunctionsEGLDL class.
#include "libANGLE/renderer/gl/egl/FunctionsEGLDL.h"
#include <dlfcn.h>
namespace rx
{
namespace
{
// In ideal world, we would want this to be a member of FunctionsEGLDL,
// and call dlclose() on it in ~FunctionsEGLDL().
// However, some GL implementations are broken and don't allow multiple
// load/unload cycles, but only static linking with them.
// That's why we dlopen() this handle once and never dlclose() it.
// This is consistent with Chromium's CleanupNativeLibraries() code,
// referencing crbug.com/250813 and http://www.xfree86.org/4.3.0/DRI11.html
void *nativeEGLHandle;
} // anonymous namespace
FunctionsEGLDL::FunctionsEGLDL() : mGetProcAddressPtr(nullptr) {}
FunctionsEGLDL::~FunctionsEGLDL() {}
egl::Error FunctionsEGLDL::initialize(EGLAttrib platformType,
EGLNativeDisplayType nativeDisplay,
const char *libName,
void *eglHandle)
{
if (eglHandle)
{
// If the handle is provided, use it.
// Caller has already dlopened the vendor library.
nativeEGLHandle = eglHandle;
}
if (!nativeEGLHandle)
{
nativeEGLHandle = dlopen(libName, RTLD_NOW);
if (!nativeEGLHandle)
{
return egl::EglNotInitialized() << "Could not dlopen native EGL: " << dlerror();
}
}
mGetProcAddressPtr =
reinterpret_cast<PFNEGLGETPROCADDRESSPROC>(dlsym(nativeEGLHandle, "eglGetProcAddress"));
if (!mGetProcAddressPtr)
{
return egl::EglNotInitialized() << "Could not find eglGetProcAddress";
}
return FunctionsEGL::initialize(platformType, nativeDisplay);
}
void *FunctionsEGLDL::getProcAddress(const char *name) const
{
void *f = reinterpret_cast<void *>(mGetProcAddressPtr(name));
if (f)
{
return f;
}
return dlsym(nativeEGLHandle, name);
}
} // namespace rx