Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DMA_BUF_IOCTL_EXPORT_SYNC_FILE ioctl for llvmpipe #3891

Open
cebtenzzre opened this issue Dec 18, 2024 · 1 comment
Open

Support DMA_BUF_IOCTL_EXPORT_SYNC_FILE ioctl for llvmpipe #3891

cebtenzzre opened this issue Dec 18, 2024 · 1 comment

Comments

@cebtenzzre
Copy link

llvmpipe seems to require this ioctl under normal operation, which makes it hard to use rr to debug an application that uses OpenGL to render its UI (e.g. something written in Qt Quick).

Tested with rr 5.8.0 built from commit 946378b.

Backtrace of where the ioctl is called:

#0  __GI___ioctl (fd=fd@entry=32, request=request@entry=3221774850) at ../sysdeps/unix/sysv/linux/ioctl.c:36
#1  0x00007ffff0fa8521 in drmIoctl (fd=32, request=3221774850, arg=0x7fffffffb930) at ../libdrm-2.4.124/xf86drm.c:692
#2  0x00007fffeeddb2c3 in llvmpipe_init_screen_fence_funcs () at ../mesa-24.3.1/src/gallium/drivers/llvmpipe/lp_fence.c:332
#3  0x00007fffeedd6d24 in llvmpipe_create_screen () at ../mesa-24.3.1/src/gallium/drivers/llvmpipe/lp_screen.c:1192
#4  0x00007fffee6342a1 in sw_screen_create_named () at ../mesa-24.3.1/src/gallium/auxiliary/target-helpers/sw_helper.h:43
#5  sw_screen_create_vk () at ../mesa-24.3.1/src/gallium/auxiliary/target-helpers/sw_helper.h:90
#6  0x00007fffeedb247d in pipe_loader_sw_create_screen () at ../mesa-24.3.1/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c:427
#7  0x00007fffeedb23b0 in pipe_loader_create_screen_vk () at ../mesa-24.3.1/src/gallium/auxiliary/pipe-loader/pipe_loader.c:181
#8  0x00007fffee638336 in driCreateNewScreen3 () at ../mesa-24.3.1/src/gallium/frontends/dri/dri_util.c:144
#9  0x00007ffff100ac51 in dri_screen_init () at ../mesa-24.3.1/src/glx/dri_common.c:995
#10 0x00007ffff100bd2c in driswCreateScreen () at ../mesa-24.3.1/src/glx/drisw_glx.c:654
#11 0x00007ffff10105b2 in AllocAndFetchScreenConfigs () at ../mesa-24.3.1/src/glx/glxext.c:904
#12 0x00007ffff10116fa in __glXInitialize () at ../mesa-24.3.1/src/glx/glxext.c:1079
#13 0x00007ffff100c8c0 in glXGetFBConfigs () at ../mesa-24.3.1/src/glx/glxcmds.c:1467
#14 0x00007ffff100d44a in glXChooseFBConfig () at ../mesa-24.3.1/src/glx/glxcmds.c:1407
#15 0x00007ffff707c265 in glXChooseFBConfig (dpy=0x555555c73020, screen=0, attrib_list=0x55555648f460, nelements=0x7fffffffc7d0) at ../libglvnd-v1.7.0/src/GLX/libglx.c:1486
#16 0x00007ffff5bf1a26 in qglx_findConfig
    (display=0x555555c73020, screen=0, format=..., highestPixelFormat=highestPixelFormat@entry=false, drawableBit=drawableBit@entry=1, flags=flags@entry=0)
    at /usr/src/debug/qt6-base/qtbase/src/corelib/tools/qarraydatapointer.h:120
#17 0x00007fffd0030b2f in QGLXPbuffer::QGLXPbuffer (this=0x5555563c9e00, offscreenSurface=0x5555563c5480)
    at /usr/src/debug/qt6-base/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp:727
#18 QXcbGlxIntegration::createPlatformOffscreenSurface (this=<optimized out>, surface=0x5555563c5480)
    at /usr/src/debug/qt6-base/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp:192
#19 0x00007ffff57ac46d in QOffscreenSurface::create (this=this@entry=0x5555563c5480) at /usr/src/debug/qt6-base/qtbase/src/gui/kernel/qoffscreensurface.cpp:121
#20 0x00007fffd0033ec1 in QGLXContext::queryDummyContext () at /usr/src/debug/qt6-base/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp:631
#21 0x00007fffd003484d in QGLXContext::supportsThreading () at /usr/src/debug/qt6-base/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp:716
#22 QXcbGlxIntegration::supportsThreadedOpenGL (this=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp:200
#23 0x00007ffff74f7dd8 in QSGRenderLoop::instance () at /usr/src/debug/qt6-declarative/qtdeclarative/src/quick/scenegraph/qsgrenderloop.cpp:190
#24 0x00007ffff7464778 in QQuickWindowPrivate::init (this=0x55555633c460, c=0x555555ddc4b0, control=0x0) at /usr/src/debug/qt6-declarative/qtdeclarative/src/quick/items/qquickwindow.cpp:790
#25 0x00007ffff7473a89 in QQuickWindow::QQuickWindow (this=0x555555ddc4b0, dd=<optimized out>, parent=<optimized out>)
    at /usr/src/debug/qt6-declarative/qtdeclarative/src/quick/items/qquickwindow.cpp:1150
#26 QQuickWindowQmlImpl::QQuickWindowQmlImpl (this=0x555555ddc4b0, dd=<optimized out>, parent=<optimized out>, this=<optimized out>, dd=<optimized out>, parent=<optimized out>)
    at /usr/src/debug/qt6-declarative/qtdeclarative/src/quick/items/qquickwindowmodule.cpp:35

I can avoid the use of OpenGL with export QMLSCENE_DEVICE=softwarecontext but my application does not render correctly at all with this flag, so it must not be very well supported.

@cebtenzzre
Copy link
Author

I was able to work around this by recompiling mesa with this patch:

diff --color -Naurp a/src/gallium/drivers/llvmpipe/lp_fence.c b/src/gallium/drivers/llvmpipe/lp_fence.c
--- a/src/gallium/drivers/llvmpipe/lp_fence.c   2024-12-04 17:13:54.000000000 -0500
+++ b/src/gallium/drivers/llvmpipe/lp_fence.c   2024-12-17 22:24:30.933888242 -0500
@@ -329,7 +329,7 @@ llvmpipe_init_screen_fence_funcs(struct
          .fd = -1,
       };

-      if (drmIoctl(screen->dummy_dmabuf->dmabuf_fd,
+      if (1 || drmIoctl(screen->dummy_dmabuf->dmabuf_fd,
                    DMA_BUF_IOCTL_EXPORT_SYNC_FILE,
                    &export))
          goto fail;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant