diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-08-04 13:31:20 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-09-05 10:30:50 +0000 |
commit | cf24d203850cd87e31bc123407e7ae126be9961c (patch) | |
tree | 52bbf250df26c320b706f2cfff6fc028cfef2ea3 /src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp | |
parent | f2289bbcbbbddfd248c5e0858e148d7cc7336f8a (diff) |
eglfs_kms: Add headless mode for DRM render nodes
Attempting to switch /dev/dri/cardX to /dev/dri/renderDY is futile
on its own now since many output-related drm operations fail and we
eventually crash.
Add a new headless mode that skips the real screen stuff and registers
a fairly dummy, headless screen, does not bother with the mouse cursor,
and disallows rendering to the screen via a QWindow (while keeping the
actual rendering still fully functional).
Such applications will not need any special privileges and will run even
if there is a DRM master (X11, Wayland compositor) active.
For example the configuration can look like this:
{
"device": "/dev/dri/renderD128",
"headless": "1024x768"
}
After this applications have two choices to perform offscreen
rendering:
1. Use an ordinary window (and its default framebuffer, meaning the
gbm_surface), e.g. a QOpenGLWindow subclass
MyOpenGLWindow w;
w.show(); // will not actually show on screen
w.grabFramebuffer().save("output.png");
Note that there is no vsync-based throttling. Also note that windows are
still sized to match the screen size, hence the need for specifying a size
in the headless property.
2. Or the typical offscreen approach with an extra FBO
QOffscreenSurface s;
s.setFormat(ctx.format());
s.create();
ctx.makeCurrent(&s0;
QOpenGLFramebufferObject fbo(1024, 768);
fbo.bind();
ctx.functions()->glClearColor(1, 0, 0, 1);
ctx.functions()->glClear(GL_COLOR_BUFFER_BIT);
fbo.toImage().save("output.png");
ctx.doneCurrent();
Task-number: QTBUG-62262
Change-Id: Ic1dbfa2b27b223bd5ef8ba36b665f0f61abf4f06
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp')
-rw-r--r-- | src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index d3573a4512..ac6f8944ed 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -109,8 +109,8 @@ QEglFSKmsGbmScreen::FrameBuffer *QEglFSKmsGbmScreen::framebufferForBufferObject( return fb.take(); } -QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output) - : QEglFSKmsScreen(device, output) +QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output, bool headless) + : QEglFSKmsScreen(device, output, headless) , m_gbm_surface(Q_NULLPTR) , m_gbm_bo_current(Q_NULLPTR) , m_gbm_bo_next(Q_NULLPTR) @@ -131,6 +131,8 @@ QEglFSKmsGbmScreen::~QEglFSKmsGbmScreen() QPlatformCursor *QEglFSKmsGbmScreen::cursor() const { QKmsScreenConfig *config = device()->screenConfig(); + if (config->headless()) + return nullptr; if (config->hwCursor()) { if (!config->separateScreens()) return static_cast<QEglFSKmsGbmDevice *>(device())->globalCursor(); @@ -240,10 +242,8 @@ void QEglFSKmsGbmScreen::ensureModeSet(uint32_t fb) void QEglFSKmsGbmScreen::waitForFlip() { - if (m_cloneSource) { - qWarning("Screen %s clones another screen. swapBuffers() not allowed.", qPrintable(name())); + if (m_headless || m_cloneSource) return; - } // Don't lock the mutex unless we actually need to if (!m_gbm_bo_next) @@ -256,6 +256,11 @@ void QEglFSKmsGbmScreen::waitForFlip() void QEglFSKmsGbmScreen::flip() { + // For headless screen just return silently. It is not necessarily an error + // to end up here, so show no warnings. + if (m_headless) + return; + if (m_cloneSource) { qWarning("Screen %s clones another screen. swapBuffers() not allowed.", qPrintable(name())); return; |