Skip to content

tu/kgsl: timeline-based queue and sync primitives#75

Draft
lfdevs wants to merge 4 commits into
dev/adreno-mainfrom
test/turnip-sync
Draft

tu/kgsl: timeline-based queue and sync primitives#75
lfdevs wants to merge 4 commits into
dev/adreno-mainfrom
test/turnip-sync

Conversation

@lfdevs

@lfdevs lfdevs commented Jun 12, 2026

Copy link
Copy Markdown
Owner

The code is from an unmerged & draft MR of upstream: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39751
It may improve Turnip's performance.


Build artifacts: https://github.com/lfdevs/mesa-for-android-container/actions/runs/27422113017?pr=75#artifacts

It is worth mentioning that the directly downloaded file is a .zip archive, which needs to be unzipped once to get the .tar.gz installation package.

Pull profiling and perfetto integration out of the KGSL queue submit
implementation and into helper struct and functions, making it reusabl
in other KGSL submit variants.

Signed-off-by: Zan Dobersek <zdobersek@igalia.com>
Use timeline-based queue submit and sync primitives if the KGSL kernel
supports them.

When supported, a timeline-based vk_sync_type implementation will be used
by default, with a binary sync type emulated on top of it.

For submits, a queue-specific timeline object is used to track submit
completion. This enables a fast path that can be used when no command
buffers or binds are submitted, with any waits and signals handled through
simple ioctls.

When that's not possible, waits are done on the first submitted command,
and signals are handled through auxilliary commands.

Signed-off-by: Zan Dobersek <zdobersek@igalia.com>
@fishiatee

Copy link
Copy Markdown

On Adreno 725/730 at least this does improve vulkan performance greatly.

C++ designated initializers require fields to appear in the same order
as they are declared in the struct. In vk_sync_type, 'signal' is
declared before 'reset', so reorder the initializer accordingly.

Fixes: compilation error with -Werror=reorder-init-list
@natsumerinchan

Copy link
Copy Markdown

Strangely, this change currently causes a significant performance regression on Adreno 740.

mesa-26.2.0-devel-20260610

╰─ vkmark                                                                                                            ─╯
=======================================================
    vkmark 2025.01
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x43050A01
    Device Name:    Turnip Adreno (TM) 740
    Driver Version: 109056099
    Device UUID:    f632f63189368060153aaae425cbf91c
=======================================================
[vertex] device-local=true: FPS: 1838 FrameTime: 0.544 ms
[vertex] device-local=false: FPS: 2058 FrameTime: 0.486 ms
[texture] anisotropy=0: FPS: 1676 FrameTime: 0.597 ms
[texture] anisotropy=16: FPS: 1840 FrameTime: 0.543 ms
[shading] shading=gouraud: FPS: 1411 FrameTime: 0.709 ms
[shading] shading=blinn-phong-inf: FPS: 1414 FrameTime: 0.707 ms
[shading] shading=phong: FPS: 1534 FrameTime: 0.652 ms
[shading] shading=cel: FPS: 1419 FrameTime: 0.705 ms
[effect2d] kernel=edge: FPS: 1670 FrameTime: 0.599 ms
[effect2d] kernel=blur: FPS: 1281 FrameTime: 0.781 ms
[desktop] <default>: FPS: 1637 FrameTime: 0.611 ms
[cube] <default>: FPS: 1568 FrameTime: 0.638 ms
[clear] <default>: FPS: 1665 FrameTime: 0.601 ms
=======================================================
                                   vkmark Score: 1616
=======================================================

tu/kgsl: timeline-based queue and sync primitives

╰─ vkmark                                                                                                            ─╯
=======================================================
    vkmark 2025.01
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x43050A01
    Device Name:    Turnip Adreno (TM) 740
    Driver Version: 109056099
    Device UUID:    3be6a9e830c960e81512820760740024
=======================================================
[vertex] device-local=true: FPS: 615 FrameTime: 1.626 ms
[vertex] device-local=false: FPS: 603 FrameTime: 1.658 ms
[texture] anisotropy=0: FPS: 582 FrameTime: 1.718 ms
[texture] anisotropy=16: FPS: 684 FrameTime: 1.462 ms
[shading] shading=gouraud: FPS: 846 FrameTime: 1.182 ms
[shading] shading=blinn-phong-inf: FPS: 650 FrameTime: 1.538 ms
[shading] shading=phong: FPS: 587 FrameTime: 1.704 ms
[shading] shading=cel: FPS: 642 FrameTime: 1.558 ms
[effect2d] kernel=edge: FPS: 719 FrameTime: 1.391 ms
[effect2d] kernel=blur: FPS: 531 FrameTime: 1.883 ms
[desktop] <default>: FPS: 784 FrameTime: 1.276 ms
[cube] <default>: FPS: 847 FrameTime: 1.181 ms
[clear] <default>: FPS: 888 FrameTime: 1.126 ms
=======================================================
                                   vkmark Score: 690
=======================================================

@lfdevs

lfdevs commented Jun 13, 2026

Copy link
Copy Markdown
Owner Author

Based on my testing, on Adreno 730, this PR currently only improves the performance of Turnip + Zink slightly, but in scenarios where only Turnip is used (such as vkmark and Minecraft Vulkan), the driver performance has decreased.

26.2.0-devel-20260610 26.2.0-devel-5c6ee1c (this PR)
vkmark (Turnip) 2669 925
glmark2 (Turnip + Zink) 379 531
Test details

26.2.0-devel-20260610

vkmark (Turnip)

lf@23046RP50C:~$ vkmark --winsys xcb
=======================================================
    vkmark 2025.01
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x7030002
    Device Name:    Turnip Adreno (TM) 725
    Driver Version: 109056099
    Device UUID:    1c64138e88333d4deff93f5698755ef1
=======================================================
[vertex] device-local=true: FPS: 2615 FrameTime: 0.382 ms
[vertex] device-local=false: FPS: 2806 FrameTime: 0.356 ms
[texture] anisotropy=0: FPS: 2702 FrameTime: 0.370 ms
[texture] anisotropy=16: FPS: 2706 FrameTime: 0.370 ms
[shading] shading=gouraud: FPS: 2660 FrameTime: 0.376 ms
[shading] shading=blinn-phong-inf: FPS: 2644 FrameTime: 0.378 ms
[shading] shading=phong: FPS: 2690 FrameTime: 0.372 ms
[shading] shading=cel: FPS: 2668 FrameTime: 0.375 ms
[effect2d] kernel=edge: FPS: 2825 FrameTime: 0.354 ms
[effect2d] kernel=blur: FPS: 2655 FrameTime: 0.377 ms
[desktop] <default>: FPS: 2498 FrameTime: 0.400 ms
[cube] <default>: FPS: 2646 FrameTime: 0.378 ms
[clear] <default>: FPS: 2593 FrameTime: 0.386 ms
=======================================================
                                   vkmark Score: 2669
=======================================================

glmark2 (Turnip + Zink)

lf@23046RP50C:~$ MESA_VK_WSI_PRESENT_MODE=immediate MESA_LOADER_DRIVER_OVERRIDE=zink 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-9c8bdb4f2e)
    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: 518 FrameTime: 1.932 ms
[build] use-vbo=true: FPS: 499 FrameTime: 2.005 ms
[texture] texture-filter=nearest: FPS: 471 FrameTime: 2.123 ms
[texture] texture-filter=linear: FPS: 460 FrameTime: 2.175 ms
[texture] texture-filter=mipmap: FPS: 467 FrameTime: 2.145 ms
[shading] shading=gouraud: FPS: 464 FrameTime: 2.158 ms
[shading] shading=blinn-phong-inf: FPS: 461 FrameTime: 2.171 ms
[shading] shading=phong: FPS: 452 FrameTime: 2.217 ms
[shading] shading=cel: FPS: 453 FrameTime: 2.210 ms
[bump] bump-render=high-poly: FPS: 430 FrameTime: 2.329 ms
[bump] bump-render=normals: FPS: 463 FrameTime: 2.164 ms
[bump] bump-render=height: FPS: 461 FrameTime: 2.173 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 440 FrameTime: 2.275 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 399 FrameTime: 2.507 ms
[pulsar] light=false:quads=5:texture=false: FPS: 438 FrameTime: 2.283 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 226 FrameTime: 4.433 ms
[desktop] effect=shadow:windows=4: FPS: 346 FrameTime: 2.897 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 180 FrameTime: 5.560 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 219 FrameTime: 4.567 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 193 FrameTime: 5.188 ms
[ideas] speed=duration: FPS: 196 FrameTime: 5.114 ms
[jellyfish] <default>: FPS: 381 FrameTime: 2.626 ms
[terrain] <default>: FPS: 98 FrameTime: 10.285 ms
[shadow] <default>: FPS: 424 FrameTime: 2.364 ms
[refract] <default>: FPS: 168 FrameTime: 5.986 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 413 FrameTime: 2.422 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 418 FrameTime: 2.396 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 415 FrameTime: 2.413 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 404 FrameTime: 2.479 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 408 FrameTime: 2.457 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 399 FrameTime: 2.506 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 401 FrameTime: 2.498 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 395 FrameTime: 2.535 ms
=======================================================
                                  glmark2 Score: 379
=======================================================

26.2.0-devel-5c6ee1c (this PR)

vkmark (Turnip)

lf@23046RP50C:~$ vkmark
=======================================================
    vkmark 2025.01
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x7030002
    Device Name:    Turnip Adreno (TM) 725
    Driver Version: 109056099
    Device UUID:    3a33cb0bc755853cf260487534e204b4
=======================================================
[vertex] device-local=true: FPS: 905 FrameTime: 1.105 ms
[vertex] device-local=false: FPS: 901 FrameTime: 1.110 ms
[texture] anisotropy=0: FPS: 860 FrameTime: 1.163 ms
[texture] anisotropy=16: FPS: 864 FrameTime: 1.157 ms
[shading] shading=gouraud: FPS: 860 FrameTime: 1.163 ms
[shading] shading=blinn-phong-inf: FPS: 861 FrameTime: 1.161 ms
[shading] shading=phong: FPS: 839 FrameTime: 1.192 ms
[shading] shading=cel: FPS: 832 FrameTime: 1.202 ms
[effect2d] kernel=edge: FPS: 1104 FrameTime: 0.906 ms
[effect2d] kernel=blur: FPS: 716 FrameTime: 1.397 ms
[desktop] <default>: FPS: 942 FrameTime: 1.062 ms
[cube] <default>: FPS: 1134 FrameTime: 0.882 ms
[clear] <default>: FPS: 1207 FrameTime: 0.829 ms
=======================================================
                                   vkmark Score: 925
=======================================================

glmark2 (Turnip + Zink)

lf@23046RP50C:~$ MESA_VK_WSI_PRESENT_MODE=immediate MESA_LOADER_DRIVER_OVERRIDE=zink 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-5c6ee1c64b)
    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: 923 FrameTime: 1.084 ms
[build] use-vbo=true: FPS: 634 FrameTime: 1.579 ms
[texture] texture-filter=nearest: FPS: 627 FrameTime: 1.595 ms
[texture] texture-filter=linear: FPS: 636 FrameTime: 1.573 ms
[texture] texture-filter=mipmap: FPS: 625 FrameTime: 1.602 ms
[shading] shading=gouraud: FPS: 632 FrameTime: 1.585 ms
[shading] shading=blinn-phong-inf: FPS: 601 FrameTime: 1.666 ms
[shading] shading=phong: FPS: 614 FrameTime: 1.630 ms
[shading] shading=cel: FPS: 616 FrameTime: 1.626 ms
[bump] bump-render=high-poly: FPS: 624 FrameTime: 1.603 ms
[bump] bump-render=normals: FPS: 597 FrameTime: 1.677 ms
[bump] bump-render=height: FPS: 605 FrameTime: 1.655 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 613 FrameTime: 1.632 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 511 FrameTime: 1.959 ms
[pulsar] light=false:quads=5:texture=false: FPS: 569 FrameTime: 1.758 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 438 FrameTime: 2.286 ms
[desktop] effect=shadow:windows=4: FPS: 501 FrameTime: 1.998 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 181 FrameTime: 5.529 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 328 FrameTime: 3.056 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 186 FrameTime: 5.399 ms
[ideas] speed=duration: FPS: 325 FrameTime: 3.086 ms
[jellyfish] <default>: FPS: 530 FrameTime: 1.890 ms
[terrain] <default>: FPS: 244 FrameTime: 4.100 ms
[shadow] <default>: FPS: 491 FrameTime: 2.040 ms
[refract] <default>: FPS: 290 FrameTime: 3.460 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 575 FrameTime: 1.741 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 588 FrameTime: 1.702 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 564 FrameTime: 1.776 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 588 FrameTime: 1.703 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 586 FrameTime: 1.707 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 567 FrameTime: 1.766 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 568 FrameTime: 1.761 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 580 FrameTime: 1.725 ms
=======================================================
                                  glmark2 Score: 531
=======================================================

On Adreno 830, running vkmark after installing the driver built by this PR (26.2.0-devel-5c6ee1c) will even freeze on the first frame. However, running other applications and games that use Vulkan is fine.

Therefore, we still have to wait for upstream to perfect this MR.

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.

4 participants