Skip to content

drm/format-helper: Add helpers for line conversion

Thomas Zimmermann dri-devel 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 0 repliesNew
  2. v18 patches 10 repliesSuperseded

Changes in v2 from the cover letter

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

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8drm/format-helper: Move helpers for pixel conversion to header filedrivers/gpu/drm/drm_draw.c drivers/gpu/drm/drm_format_internal.h+130 -890 replies
2/8drm/format-helper: Add generic conversion to 32-bit formatsdrivers/gpu/drm/drm_format_helper.c+19 -650 replies
3/8drm/format-helper: Add generic conversion to 24-bit formatsdrivers/gpu/drm/drm_format_helper.c drivers/gpu/drm/drm_format_internal.h+31 -240 replies
4/8drm/format-helper: Add generic conversion to 16-bit formatsdrivers/gpu/drm/drm_format_helper.c drivers/gpu/drm/drm_format_internal.h+34 -960 replies
5/8drm/format-helper: Add generic conversion to 8-bit formatsdrivers/gpu/drm/drm_format_helper.c drivers/gpu/drm/drm_format_internal.h+31 -240 replies
6/8drm/format-helper: Optimize 32-to-24-bpp conversiondrivers/gpu/drm/drm_format_helper.c+36 -10 replies
7/8drm/format-helper: Optimize 32-to-16-bpp conversiondrivers/gpu/drm/drm_format_helper.c+36 -10 replies
8/8drm/format-helper: Optimize 32-to-8-bpp conversiondrivers/gpu/drm/drm_format_helper.c+20 -10 replies

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchJocelyn Falempe
1/8R-b
2/8R-b
3/8R-b
4/8R-b
5/8R-b
6/8R-b
7/8R-b
8/8R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/8] drm/format-helper: Add helpers for line conversion

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
Signature · 1 line
2.48.1