Skip to content

tu/kgsl,x11: fix Termux:X11 presentation on KGSL#69

Open
lfdevs wants to merge 3 commits into
dev/adreno-mainfrom
test/fix-patched-turnip-fd725
Open

tu/kgsl,x11: fix Termux:X11 presentation on KGSL#69
lfdevs wants to merge 3 commits into
dev/adreno-mainfrom
test/fix-patched-turnip-fd725

Conversation

@lfdevs
Copy link
Copy Markdown
Owner

@lfdevs lfdevs commented May 26, 2026

Currently, the Turnip driver from the standard release (whose release title doesn't have the turnip- prefix) fails to work on Adreno 730 or other GPUs. This PR aims to fix this issue.

Assisted by gpt-5.5 (xhigh) model.

Changelog

Fixed

  • Fixed Turnip presentation on KGSL under Termux:X11 by allowing KGSL devices to report X11 WSI presentation support without DRM fd matching. KGSL exposes /dev/kgsl-3d0, not a DRM render node, so the normal DRM device comparison is not valid for this path.
  • Added a generic X11 WSI fallback for servers that reject DRI3FenceFromFD on imported DRI3 pixmaps with BadValue. When this occurs, the current swapchain now skips shm fences and relies on Present IdleNotify for implicit-sync image reuse.
  • Improved KGSL shareable BO allocation by closing temporary dma-buf allocation fds after import and falling back from dma-heap allocation to ION when available.

Changed

  • Made the shm-fence workaround runtime-detected instead of tied to a specific GPU model.
  • Kept the working native DRI3 path for KGSL while avoiding assumptions that only apply to DRM render-node drivers.

lfdevs added 3 commits May 27, 2026 01:25
Allow KGSL devices to report WSI presentation support without DRM fd
matching, since /dev/kgsl-3d0 is not a DRM render node.

For FD725 on KGSL, avoid the DRI3 modifier import path and keep the
native DRI3 linear path, which preserves the working A830 behavior while
working around FD725 swapchain creation failures.

Add TU_WSI_DEBUG diagnostics around X11 swapchain creation, WSI image
allocation, dma-buf export/import, XCB pixmap import, and xshmfence setup.
Also make KGSL shareable BO allocation report clearer errors and fall back
from dma-heap to ION when possible.
FD725 on KGSL can create and export scanout dma-bufs, and Termux:X11 can
import them as DRI3 pixmaps, but DRI3FenceFromFD fails with BadValue
during swapchain image setup.

Add an internal X11 WSI workaround to skip shm fence import and rely on
Present IdleNotify for implicit-sync image reuse. Enable it only for KGSL
FD725, leaving A830 and other devices on the existing fence path.

Keep FD725 on the native DRI3 linear path by disabling modifier use for
the affected chip IDs.
Some X servers reject DRI3FenceFromFD for imported DRI3 pixmaps with
BadValue. In that case, fall back within the current X11 swapchain by
skipping shm fences and relying on Present IdleNotify for implicit-sync
image reuse.
Remove the temporary TU_WSI_DEBUG diagnostic logging added while
debugging the Termux:X11 KGSL path.
@lfdevs lfdevs changed the title tu/kgsl: Fix patched Turnip for Adreno 730 tu/kgsl,x11: fix Termux:X11 presentation on KGSL May 27, 2026
@lfdevs lfdevs force-pushed the test/fix-patched-turnip-fd725 branch from cf67788 to 4211a1b Compare May 27, 2026 05:19
@lfdevs lfdevs marked this pull request as ready for review May 27, 2026 13:50
@lfdevs
Copy link
Copy Markdown
Owner Author

lfdevs commented May 27, 2026

Benchmarks

Overview

Device GPU vkmark glmark2 (Turnip+Zink) glmark2-es2 (Turnip+Zink)
Xiaomi Pad 6 Pro Adreno 730 1750 382 393

Detailed test results

Adreno 730

vkmark
lfdevs@debian:~$ MESA_LOADER_DRIVER_OVERRIDE=kgsl vkmark --winsys xcb
=======================================================
    vkmark 2025.01
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x7030002
    Device Name:    Turnip Adreno (TM) 725
    Driver Version: 109056099
    Device UUID:    6b3c0b4ed298dc3f102ba94e21bb9b05
=======================================================
[vertex] device-local=true: FPS: 3860 FrameTime: 0.259 ms
[vertex] device-local=false: FPS: 2005 FrameTime: 0.499 ms
[texture] anisotropy=0: FPS: 1550 FrameTime: 0.645 ms
[texture] anisotropy=16: FPS: 1502 FrameTime: 0.666 ms
[shading] shading=gouraud: FPS: 1541 FrameTime: 0.649 ms
[shading] shading=blinn-phong-inf: FPS: 1466 FrameTime: 0.682 ms
[shading] shading=phong: FPS: 1427 FrameTime: 0.701 ms
[shading] shading=cel: FPS: 1430 FrameTime: 0.699 ms
[effect2d] kernel=edge: FPS: 1680 FrameTime: 0.595 ms
[effect2d] kernel=blur: FPS: 1435 FrameTime: 0.697 ms
[desktop] <default>: FPS: 1539 FrameTime: 0.650 ms
[cube] <default>: FPS: 1637 FrameTime: 0.611 ms
[clear] <default>: FPS: 1680 FrameTime: 0.595 ms
=======================================================
                                   vkmark Score: 1750
=======================================================
glmark2 (Turnip+Zink)
lfdevs@debian:~$ MESA_LOADER_DRIVER_OVERRIDE=zink MESA_VK_WSI_PRESENT_MODE=immediate glmark2
=======================================================
    glmark2 2023.01
=======================================================
    OpenGL Information
    GL_VENDOR:      Mesa
    GL_RENDERER:    zink Vulkan 1.4(Turnip Adreno (TM) 725 (MESA_TURNIP))
    GL_VERSION:     4.6 (Compatibility Profile) Mesa 26.2.0-devel (git-4211a1bfb3)
    Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0
    Surface Size:   800x600 windowed
=======================================================
[build] use-vbo=false: FPS: 521 FrameTime: 1.920 ms
[build] use-vbo=true: FPS: 681 FrameTime: 1.469 ms
[texture] texture-filter=nearest: FPS: 461 FrameTime: 2.170 ms
[texture] texture-filter=linear: FPS: 460 FrameTime: 2.176 ms
[texture] texture-filter=mipmap: FPS: 464 FrameTime: 2.160 ms
[shading] shading=gouraud: FPS: 464 FrameTime: 2.158 ms
[shading] shading=blinn-phong-inf: FPS: 465 FrameTime: 2.154 ms
[shading] shading=phong: FPS: 460 FrameTime: 2.175 ms
[shading] shading=cel: FPS: 456 FrameTime: 2.193 ms
[bump] bump-render=high-poly: FPS: 436 FrameTime: 2.295 ms
[bump] bump-render=normals: FPS: 464 FrameTime: 2.158 ms
[bump] bump-render=height: FPS: 458 FrameTime: 2.187 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 442 FrameTime: 2.263 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 402 FrameTime: 2.492 ms
[pulsar] light=false:quads=5:texture=false: FPS: 443 FrameTime: 2.261 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 221 FrameTime: 4.538 ms
[desktop] effect=shadow:windows=4: FPS: 343 FrameTime: 2.918 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 165 FrameTime: 6.072 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 199 FrameTime: 5.046 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 192 FrameTime: 5.219 ms
[ideas] speed=duration: FPS: 189 FrameTime: 5.305 ms
[jellyfish] <default>: FPS: 384 FrameTime: 2.609 ms
[terrain] <default>: FPS: 92 FrameTime: 10.906 ms
[shadow] <default>: FPS: 347 FrameTime: 2.886 ms
[refract] <default>: FPS: 165 FrameTime: 6.062 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 417 FrameTime: 2.402 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 425 FrameTime: 2.358 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 431 FrameTime: 2.324 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 413 FrameTime: 2.427 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 413 FrameTime: 2.427 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 396 FrameTime: 2.530 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 397 FrameTime: 2.524 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 392 FrameTime: 2.557 ms
=======================================================
                                  glmark2 Score: 382
=======================================================
glmark2-es2 (Turnip+Zink)
lfdevs@debian:~$ MESA_LOADER_DRIVER_OVERRIDE=zink MESA_VK_WSI_PRESENT_MODE=immediate glmark2-es2
MESA-EGL: warning: DRI3 error: Could not get DRI3 device
MESA-EGL: warning: Ensure your X server supports DRI3 to get accelerated rendering
=======================================================
    glmark2 2023.01
=======================================================
    OpenGL Information
    GL_VENDOR:      Mesa
    GL_RENDERER:    zink Vulkan 1.4(Turnip Adreno (TM) 725 (MESA_TURNIP))
    GL_VERSION:     OpenGL ES 3.2 Mesa 26.2.0-devel (git-4211a1bfb3)
    Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0
    Surface Size:   800x600 windowed
=======================================================
[build] use-vbo=false: FPS: 463 FrameTime: 2.162 ms
[build] use-vbo=true: FPS: 478 FrameTime: 2.095 ms
[texture] texture-filter=nearest: FPS: 475 FrameTime: 2.106 ms
[texture] texture-filter=linear: FPS: 466 FrameTime: 2.146 ms
[texture] texture-filter=mipmap: FPS: 468 FrameTime: 2.141 ms
[shading] shading=gouraud: FPS: 477 FrameTime: 2.099 ms
[shading] shading=blinn-phong-inf: FPS: 537 FrameTime: 1.865 ms
[shading] shading=phong: FPS: 462 FrameTime: 2.167 ms
[shading] shading=cel: FPS: 462 FrameTime: 2.169 ms
[bump] bump-render=high-poly: FPS: 433 FrameTime: 2.314 ms
[bump] bump-render=normals: FPS: 471 FrameTime: 2.125 ms
[bump] bump-render=height: FPS: 469 FrameTime: 2.133 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 448 FrameTime: 2.234 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 412 FrameTime: 2.428 ms
[pulsar] light=false:quads=5:texture=false: FPS: 455 FrameTime: 2.199 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 218 FrameTime: 4.598 ms
[desktop] effect=shadow:windows=4: FPS: 351 FrameTime: 2.854 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 163 FrameTime: 6.155 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 196 FrameTime: 5.117 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 182 FrameTime: 5.497 ms
[ideas] speed=duration: FPS: 190 FrameTime: 5.280 ms
[jellyfish] <default>: FPS: 398 FrameTime: 2.514 ms
[terrain] <default>: FPS: 89 FrameTime: 11.249 ms
[shadow] <default>: FPS: 356 FrameTime: 2.810 ms
[refract] <default>: FPS: 171 FrameTime: 5.861 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 461 FrameTime: 2.171 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 462 FrameTime: 2.169 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 459 FrameTime: 2.180 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 495 FrameTime: 2.024 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 463 FrameTime: 2.164 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 455 FrameTime: 2.202 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 451 FrameTime: 2.220 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 475 FrameTime: 2.108 ms
=======================================================
                                  glmark2 Score: 393
=======================================================

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

Successfully merging this pull request may close these issues.

1 participant