Skip to content

drm/vkms: speed up composition with a precomputed gamma LUT

Oarora Etimis dri-devel lkml 2 versions – New

Get series with b4
b4 am [email protected] change-id 20261108-lut-4fde3dee44ce

Versions newest first

  1. v1 Latest posting 2/24 patches 0 repliesNew
  2. v1 posting 1/24 patches 0 repliesSuperseded

Patches in v1 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4drm/vkms: use the gamma LUT of the state being composeddrivers/gpu/drm/vkms/vkms_composer.c+7 -30 replies
2/4drm/vkms: precompute the gamma LUT for every channel valuedrivers/gpu/drm/vkms/vkms_composer.c drivers/gpu/drm/vkms/vkms_composer.h drivers/gpu/drm/vkms/vkms_crtc.c +1 more+64 -60 replies
3/4drm/vkms: add a KUnit test for the precomputed LUT tabledrivers/gpu/drm/vkms/tests/vkms_color_test.c+54 -00 replies
4/4drm/ci: drop the kms_plane pixel-format xfails for vkmsdrivers/gpu/drm/ci/xfails/vkms-none-fails.txt+0 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RESEND 0/4] drm/vkms: speed up composition with a precomputed gamma LUT

Four patches: a fix so that a frame takes the gamma LUT from the state it is built from, a table that turns applying it into a lookup, a test, and the CI entries that can go once the timeouts are gone.

apply_lut() samples the gamma LUT: every channel of every pixel gets a fixed-point index and an interpolation between two neighbouring entries. On a 1024x768 mode that is 2.36 million interpolations per frame, and kms_plane@pixel-format takes 160.1-167.8 s while pixel-format-source-clamping takes 78.9-83.8 s, over ten runs each. CI lists both as Timeout in drivers/gpu/drm/ci/xfails/vkms-none-fails.txt.

A channel value is a u16, so a channel has only 65536 possible outputs. Patch 2 computes them once per LUT change into three tables (384 KiB) and applies the LUT by indexing them, which leaves the composed output bit-identical to the interpolated path. The two subtests take 4.87-4.90 s and 9.70-9.84 s.

Patch 1 is the fix I posted on 22 October (<[email protected]>), and patch 2 builds on it. Patch 4 removes the two xfail entries and has to be merged with patch 2: on its own the subtests still time out.

The other approach I considered. drm_fixp_msbset() computes fls64() with a 62-step loop; replacing it with fls64() is three lines, needs no memory, no cache and no lifetime, and returns the same values. In a userspace copy of the same functions the LUT phase goes from 153.9 ms to 10.5 ms per frame, ~15x, where the tables give 0.9 ms, ~170x. I have not measured the subtests with it, so I have no wall clock for it. It is not part of this series.

---
Oarora Etimis (4):
drm/vkms: use the gamma LUT of the state being composed drm/vkms: precompute the gamma LUT for every channel value drm/vkms: add a KUnit test for the precomputed LUT table drm/ci: drop the kms_plane pixel-format xfails for vkms

 drivers/gpu/drm/ci/xfails/vkms-none-fails.txt |  2 -
 drivers/gpu/drm/vkms/tests/vkms_color_test.c  | 54 +++++++++++++++++++++++++++
 drivers/gpu/drm/vkms/vkms_composer.c          | 47 ++++++++++++++++++-----
 drivers/gpu/drm/vkms/vkms_composer.h          |  3 ++
 drivers/gpu/drm/vkms/vkms_crtc.c              | 24 ++++++++++++
 drivers/gpu/drm/vkms/vkms_drv.h               |  6 +++
 6 files changed, 125 insertions(+), 11 deletions(-)

---
base-commit: 33ed26235db93162935d1719bc6f538c384a2fd8
change-id: 20261108-lut-4fde3dee44ce

Best regards,
--
Oarora Etimis <[email protected]>

Signature · 1 line
Oarora Etimis <[email protected]>