[Draft] freedreno/kgsl: add opt-in renderonly and X11 presentation support for leased KMS displays - #101
Draft
KiralyCraft wants to merge 16 commits into
Draft
Conversation
Keep deferred submit objects alive until KGSL has consumed their command lists and populated the shared kernel timestamp. This prevents BO teardown from freeing GPU addresses that the merged submission still references.
The HDMI loader stopped honoring the ordinary KGSL device override and always requested a server DRI3 fd. Termux:X11 supports imported DRI3 pixmaps but has no open-device callback, so the otherwise clean PR96/HDMI merge could not create a GLX context. Preserve direct KGSL selection unless renderonly is explicitly enabled. Bridge clients also retain native KGSL rendering. Parse the bridge option consistently with the DRI loader, including true/false values. Do not add a fallback that could discard a required KMS fd. Add a hardware device-selection regression test covering eight ordinary, bridge, renderonly and other-driver configurations without GPU submission or display changes. The merged AArch64 GLX/EGL/Gallium/GBM stack passed Termux:X11 pixel, MSAA, resize, context-switch, imported-fence, burst and cadence checks, plus native BO-handle and real KMS framebuffer allocation tests. Full leased HDMI scanout remains a separate acceptance gate. (cherry picked from commit a522d4e1a1fd1ff610d8d13dfefeb6ec6171a44d)
Author
|
I should look into whether any further copies take place here, because we currently copy from the GPU into an xorg-owned pixmap (and who knows what Xorg is doing then); Otherwise things appear to be rendering fine, but the actual render is black when presented to the user. So far it works, but improvements may be done for the actual data path, to make it more efficient. Since Qualcomm's implementation can also crash my SoC, I'm taking a break for now. We'll see how long I can put this off 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have been working on getting a normal accelerated Xorg desktop onto the external display of an Android device, while Android keeps running on the phone's own screen. This is the Mesa side of that work, tested on a Sony Xperia 1 V / Adreno 740 with LineageOS and a Linux chroot. This patch would only work on chroot devices with REAL ROOT. Moreover, it requires patched OS composer binaries, but this can be done with Magisk for your particular device.
This is separate from #96's ordinary Termux:X11 fence/performance work, but currently depends on its native render-fence support. Please keep this as a draft until that dependency is resolved and the remaining correctness checks below pass. Installing this Mesa alone does not enable HDMI leasing.
What this adds
FD_KGSL_RENDERONLY=1path, keeping the KMS/control descriptor separate from/dev/kgsl-3d0, which is used for GPU submission. It uses Mesa's renderonly helpers for KMS-compatible scanout allocation and recognizes downstream Qualcomm'smsm_drmdevice name.MESA_LOADER_DRIVER_OVERRIDE=kgslclients still open KGSL directly unless renderonly is explicitly requested. Termux:X11 does not supply a DRI3 Open device fd, so unconditionally requesting one breaks ordinary GLX context creation. The HDMI compatibility fix covers this with an eight-case device-selection regression test.The working client path uses
MESA_KGSL_X11_SHM_BRIDGE=1together withMESA_KGSL_X11_GPU_BRIDGE=1. The SHM name is historical: GPU mode imports server-owned DRI3 pixmaps and does not normally perform the CPU readback. The Xorg server uses renderonly; bridge clients render directly on KGSL. These roles must not be given the same renderonly environment indiscriminately. Our bridge configuration keeps ordinary Freedreno tiling enabled;noubwcis used for the CPU-visible fallback, notnotile.What Android's composer must provide
Mesa does not create the lease or speak an Android composer protocol. It needs a working KMS-backed Xorg/DRI3 server. In our Android setup, making that server possible requires a cooperating, patched Qualcomm composer:
drmModeCreateLease()for the external connector, CRTC and fixed primary plane, and transfers the fd to the trusted broker usingSCM_RIGHTS. Our implementation has a root-only abstract Unix socket,hdmi-los-composer-v1, authenticated withSO_PEERCRED. That socket is project-specific plumbing, not a new Mesa requirement or standard HWC API.-masterfd, inheriting the established Android timing rather than forcing 1080p. Composer must keep its HWC/SurfaceFlinger power, fence and hotplug lifecycle coherent while the external display is leased; stopping SurfaceFlinger is not the design.The kernel/display stack also needs DRM leases, usable KMS buffer allocation, PRIME/dma-buf sharing between KMS and KGSL, and working page-flip/vblank events. This is device-specific: stock composer does not expose our lease endpoint, and the Qualcomm patches must preserve the vendor display-extension ABI and have suitable SELinux permissions. They are not portable drop-in binaries.
The companion implementation and exact patch series are in LineageOS-Linux-HDMI, particularly its architecture and composer patches. Those Android changes are outside this Mesa PR. The tested Xorg also uses the upstream modesetting TearFree work to avoid cursor-motion cadence collapse; the Mesa bridge alone is not a replacement for that server-side behavior.
What has actually been tested
The tested combined candidate is
a522d4e1(HDMI plus the current #96 fixes), on its existing26.2.0-develbase, not a newly rebased26.3upstream build. Its GLX/EGL/Gallium/GBM stack passed ordinary Termux:X11 pixel, MSAA, resize, context-switch and imported-native-fence checks. Short uncapped gears A/B testing showed no meaningful ordinary Termux:X11 regression from adding HDMI.On a real leased
1280x720@60output, LXDE and OpenGL applications were visible. A 30-second SDL test with a visible cursor moving at 120 Hz measured about59.997active captured updates/s, with no detected torn frames or skipped source IDs. This was a source-frame/capture check, not just client FPS. The capture timestamps are quantized, so these are not exact scanout timings.The combined client libraries also improved the same-server HDMI comparison from about
908to2027FPS in uncappedglxgears, and from688.5to2086inglmark2, at640x480. Those gains include the #96 performance fixes: they are NOT an isolated speedup claim for this HDMI-only series.Still unresolved
recv_sbcwhen work is queued rather than when its presentation completes, soglXWaitForSbcOMLcan return too early. This also reproduces with the older HDMI client libraries and must be fixed in the HDMI path.glsl_type_cache.users > 0.vkmarkran but its HDMI window was black with the unchanged Turnip library. Its score is not a valid displayed-performance result, and this Gallium/DRI bridge is not a Vulkan WSI fix.I do not call this merge-ready. It works, it's reliable, but it's currently brittle. The performance on the leased X display is amazing, however! It's like a real desktop. It works flawlessly; I could not tell I am on a phone.
This work was assisted by Codex GPT 5.6 Sol xHigh. I used up 3 resets on this!