Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Replace GLX by EGL platform for headless view - #5843

Closed
tiagovignatti wants to merge 2 commits into
mapbox:masterfrom
tiagovignatti:egl-headless-view
Closed

tiagovignatti wants to merge 2 commits into
mapbox:masterfrom
tiagovignatti:egl-headless-view

Conversation

@tiagovignatti

Copy link
Copy Markdown
Contributor

Calling X11 window system is superfluous for headless rendering. This patch implements EGL platform using GBM, which is slightly more simple than the GLX path when using X11.

In principle there are no big advantages in terms of performance etc. My motivation behind this was to get in touch with the code and the project. For testing I'm using:

$ unset DISPLAY && make

Also, it removes headless GLX code and use EGL platform for Qt and Node.

Calling X11 window system is superfluous for headless rendering. This patch
implements EGL platform using GBM, which is slightly more simple than the GLX
path when using X11.

In principle there are no big advantages in terms of performance etc. My
motivation behind this was to get in touch with the code and the project. For
testing I'm using:

  $ unset DISPLAY && make

As a follow-up patch, one would now remove the GLX code all over (look for
MBGL_USE_GLX macro).
This patch removes headless GLX code entirely in favour of the new EGL one. Qt
and Node test suites needed to be accommodated to use that as well. I've tested
locally and had the following output:

$ node platform/node/test/render.test.js:
  317 passed (81.5%)
  37 passed but were ignored (9.5%)
  35 ignored (9.0%)

$ make test-qt
  [==========] 334 tests from 51 test cases ran. (24821 ms total)
  [  PASSED  ] 333 tests.
  [  FAILED  ] 1 test, listed below:
  [  FAILED  ] TextConversions.to_upper

The latter suite accuses one error which doesn't seem to be related with the
changes performed here.
@mention-bot

Copy link
Copy Markdown

@tiagovignatti, thanks for your PR! By analyzing this pull request, we identified @mikemorris, @jfirebaugh and @tmpsantos to be potential reviewers.

@brunoabinader

Copy link
Copy Markdown
Contributor

cc @kkaefer

@mikemorris mikemorris added Node.js node-mapbox-gl-native Qt Mapbox Maps SDK for Qt, aka Qt Location Mapbox GL labels Aug 2, 2016
@mikemorris

mikemorris commented Aug 2, 2016 •

Copy link
Copy Markdown
Contributor

Hmmm, neat! I've got a few questions:

  1. Am I correct in thinking that EGL is just the higher-level interface, and wouldn't directly affect anything lower level, like software rendering with the llvmpipe driver for Mesa on Linux?
  2. Any idea on how this approach would compare to rendering with OSMesa? I'm guessing we would still stick with cgl for macOS rendering.
  3. Would this allow us to drop the xvfb dependency for software rendering?

@tiagovignatti

Copy link
Copy Markdown
Contributor Author

EGL is more like the glue between the rendering API and what is providing the buffers to be rendered. So changing the headless now to use EGL doesn't mean much besides clean up -- with GLX there was this indirection to the X (X11) server, which is a window system but, well, headless doesn't care about windows.

So there shouldn't be any impact whether your system is rasterizing with software or not. I think you should be able to remove xvfb dependency now from your build bot (but again: it doesn't mean that its rendering method will be changed).

I hope I've answered the three questions, @mikemorris ?

@mikemorris

mikemorris commented Aug 2, 2016 •

Copy link
Copy Markdown
Contributor

@tiagovignatti Was specifically referring to #4638 re OSMesa, as an alternative means of eliminating the window server. I'm 👍 in general on this though, as EGL seems to be in better shape than the OSMesa API.

I'll test this out a bit today to see if anything unexpected pops up.

@mikemorris

Copy link
Copy Markdown
Contributor

This is currently failing CI tests because we're running against a version of Mesa compiled without EGL. I can work on publishing a release of Mesa 12.0.1 with EGL enabled.

@tiagovignatti

Copy link
Copy Markdown
Contributor Author

@mikemorris I think these are orthogonal problems: replace GLX by EGL would simply remove the window system underneath which is useless for the headless configuration, while your suggestion of using libOSMesa means that headless would also be using a software rasterizer instead.

Let me know how the new Mesa integration with the CI is going. Thanks!

@tiagovignatti

Copy link
Copy Markdown
Contributor Author

One more thing @mikemorris. In case your CI bot doesn't have a GPU hw available, then you will need to set Mesa to be compiled using --with-gallium-drivers=swrast

throw std::runtime_error("Failed to XInitThreads.");
#if MBGL_USE_EGL
// TODO(vignatti): it should search for a valid render* handle instead.
const char device_name[] = "/dev/dri/renderD128";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would we update this to search for a valid handle?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@mikemorris

mikemorris commented Aug 6, 2016 •

Copy link
Copy Markdown
Contributor

replace GLX by EGL would simply remove the window system underneath which is useless for the headless configuration

👍

your suggestion of using libOSMesa means that headless would also be using a software rasterizer instead. In case your CI bot doesn't have a GPU hw available, then you will need to set Mesa to be compiled using --with-gallium-drivers=swrast

Yep, this is exactly the case - we need to support hardware rendering as well as software rendering because Travis CI boxes don't have GPUs. I got a Mesa 12.0.1 build configured and packaged up at https://github.com/mapbox/mason/compare/mesa-12.0.1, and have mapbox-gl-native building against it successfully on Travis now by applying 04fc3cb to your branch @tiagovignatti.

CI tests are currently failing on a runtime error, which I'm guessing is expected at this point judging by your todo notes, would be great to figure out how to get this wrapped up 😄

terminate called after throwing an instance of 'std::runtime_error'
  what():  Couldn't open drm device.
Aborted (core dumped)

@tiagovignatti

Copy link
Copy Markdown
Contributor Author

hey back @mikemorris.

I've just rebased now the two commits and fixed the TODOs that you commented about. They're living here (egl-headless-view_v2 branch).

I thought about rebasing 04fc3cb as well but I can't test it cause I don't have access to the Travis machine. I'm sure you can roll this commit quite easy on top of my new branch though :) Let me know if the CI tests are alright then.

@tmpsantos tmpsantos removed the Qt Mapbox Maps SDK for Qt, aka Qt Location Mapbox GL label Sep 22, 2016
@tmpsantos

Copy link
Copy Markdown
Contributor

use EGL platform for Qt

Qt has now a "Qt headless view" using only Qt stuff, which could be potentially used on Windows.

@brunoabinader

Copy link
Copy Markdown
Contributor

Follow-up: #7007.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature Linux Node.js node-mapbox-gl-native

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants