All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] drm/format-helper: Add helpers for line conversion
@ 2025-03-28 14:14 Thomas Zimmermann
  2025-03-28 14:14 ` [PATCH v2 1/8] drm/format-helper: Move helpers for pixel conversion to header file Thomas Zimmermann
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-03-28 14:14 UTC (permalink / raw)
  To: jfalempe, jani.nikula, simona, airlied, mripard,
	maarten.lankhorst
  Cc: dri-devel, Thomas Zimmermann

Add helpers for converting the pixel format of scanline. This used
to be implemented for each format individually, but only the per-pixel
code is really different among formats.

Patch 1 moves the per-pixel format helpers from drm_draw.c to an
internal header. These functions have equivalents in the format-helper
code. Just update the interface to make them exportable and add some
comments.

Patches 2 to 5 add generic line-conversion helpers. Each takes a 
scanline with pixels with a specific number of bits per pixel and
converts it to a scanline with a specific number of bits per pixel.
Conversion of each individual pixel is done by the provided per-pixel
helper that was extracted from drm_draw.c.

Patches 6 to 8 slightly optimize the line-conversion helpers by
storing multiple pixels at once. With the current code, there are
too many functions to make opimization feasible. But with the new
helpers, there are only a few places to optimize to benefit all use
cases.

Here's a little benchmark for the common use case of watching a
full-screen video under X. The tests measures the average time
to display a single frame. It uses an XRGB8888 framebuffer for each
frame, but displays it to an RGB565 scanout buffer, thus doing format
conversion with the _32to16 helper. The test system is an Intel Core
i5-3470 with an Intel HD2500 graphics card. The graphics driver is
simpledrm at 1024x768 pixels.

- 32-bit memcpy:	 510 µs/frame
- Current code:		1640 µs/frame
- New (unoptimized):	1600 µs/frame
- New (no 64-bit):	1580 µs/frame
- New (optimized):	1470 µs/frame

The first line shows the time to memcpy a single frame to video
memory without format conversion. With conversion, the old and new
code takes roughly 3 times as long. Both variants are comparable
in performance. With 64-bit stores added, the new code is even 10%
faster than the current one. (This is not to be considered a full
performance test. The main objective is to see whether the new code
is on par with the old code, which is the case.)

v2:
- simplify address calculation (Jani)
- fix typos (Jocelyn)

Thomas Zimmermann (8):
  drm/format-helper: Move helpers for pixel conversion to header file
  drm/format-helper: Add generic conversion to 32-bit formats
  drm/format-helper: Add generic conversion to 24-bit formats
  drm/format-helper: Add generic conversion to 16-bit formats
  drm/format-helper: Add generic conversion to 8-bit formats
  drm/format-helper: Optimize 32-to-24-bpp conversion
  drm/format-helper: Optimize 32-to-16-bpp conversion
  drm/format-helper: Optimize 32-to-8-bpp conversion

 drivers/gpu/drm/drm_draw.c            | 100 +------
 drivers/gpu/drm/drm_format_helper.c   | 374 +++++++++++---------------
 drivers/gpu/drm/drm_format_internal.h | 160 +++++++++++
 3 files changed, 335 insertions(+), 299 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_format_internal.h

-- 
2.48.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-03-28 14:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-28 14:14 [PATCH v2 0/8] drm/format-helper: Add helpers for line conversion Thomas Zimmermann
2025-03-28 14:14 ` [PATCH v2 1/8] drm/format-helper: Move helpers for pixel conversion to header file Thomas Zimmermann
2025-03-28 14:14 ` [PATCH v2 2/8] drm/format-helper: Add generic conversion to 32-bit formats Thomas Zimmermann
2025-03-28 14:14 ` [PATCH v2 3/8] drm/format-helper: Add generic conversion to 24-bit formats Thomas Zimmermann
2025-03-28 14:15 ` [PATCH v2 4/8] drm/format-helper: Add generic conversion to 16-bit formats Thomas Zimmermann
2025-03-28 14:15 ` [PATCH v2 5/8] drm/format-helper: Add generic conversion to 8-bit formats Thomas Zimmermann
2025-03-28 14:15 ` [PATCH v2 6/8] drm/format-helper: Optimize 32-to-24-bpp conversion Thomas Zimmermann
2025-03-28 14:15 ` [PATCH v2 7/8] drm/format-helper: Optimize 32-to-16-bpp conversion Thomas Zimmermann
2025-03-28 14:15 ` [PATCH v2 8/8] drm/format-helper: Optimize 32-to-8-bpp conversion Thomas Zimmermann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.