Bug 1922506: EGL software rendering fixup. r=jgilbert

The main issue with EGL was DefaultEglDisplay function would return the already existing gl display and it could be an HW accelerated or SW rendered. For that reason, we now force a new software display creatation when asked for it.

Differential Revision: https://phabricator.services.mozilla.com/D226207
This commit is contained in:
Fatih 2024-11-07 21:48:50 +00:00
parent 15f03f9971
commit aaf4d401bd
3 changed files with 17 additions and 4 deletions

View File

@ -30,6 +30,15 @@ inline std::shared_ptr<EglDisplay> DefaultEglDisplay(
return lib->DefaultDisplay(out_failureId);
}
inline std::shared_ptr<EglDisplay> CreateSoftwareEglDisplay(
nsACString* const out_failureId) {
const auto lib = GLLibraryEGL::Get(out_failureId);
if (!lib) {
return nullptr;
}
return lib->CreateDisplay(false, true, out_failureId);
}
// -
class GLContextEGL final : public GLContext {

View File

@ -1242,7 +1242,11 @@ void GLContextEGL::DestroySurface(EglDisplay& aEgl, const EGLSurface aSurface) {
/*static*/
already_AddRefed<GLContext> GLContextProviderEGL::CreateHeadless(
const GLContextCreateDesc& desc, nsACString* const out_failureId) {
const auto display = DefaultEglDisplay(out_failureId);
bool useSoftwareDisplay =
static_cast<bool>(desc.flags & CreateContextFlags::FORBID_HARDWARE);
const auto display = useSoftwareDisplay
? CreateSoftwareEglDisplay(out_failureId)
: DefaultEglDisplay(out_failureId);
if (!display) {
return nullptr;
}

View File

@ -938,14 +938,14 @@ std::shared_ptr<EglDisplay> GLLibraryEGL::CreateDisplayLocked(
ret = GetAndInitSoftwareDisplay(*this, aProofOfLock);
}
// Initialize the display the normal way
if (!ret && !gdk_display_get_default()) {
if (!ret && !gdk_display_get_default() && !forceSoftware) {
ret = GetAndInitDeviceDisplay(*this, aProofOfLock);
if (!ret) {
ret = GetAndInitSurfacelessDisplay(*this, aProofOfLock);
}
}
# ifdef MOZ_WAYLAND
else if (!ret && widget::GdkIsWaylandDisplay()) {
else if (!ret && widget::GdkIsWaylandDisplay() && !forceSoftware) {
// Wayland does not support EGL_DEFAULT_DISPLAY
nativeDisplay = widget::WaylandDisplayGetWLDisplay();
if (!nativeDisplay) {
@ -955,7 +955,7 @@ std::shared_ptr<EglDisplay> GLLibraryEGL::CreateDisplayLocked(
}
# endif
#endif
if (!ret) {
if (!ret && !forceSoftware) {
ret = GetAndInitDisplay(*this, nativeDisplay, aProofOfLock);
}
}