mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-19 19:18:08 +02:00
Add examples/gbm-egl-benchmark.c, a headless benchmark that compares the display-path cost of uploading Cairo-rendered content to a GL texture via two methods: Image surface: glTexSubImage2D (CPU → GPU memcpy) GBM surface: EGL DMA-BUF import (zero-copy) The benchmark renders an animated Cairo scene at the requested resolution, then measures only the upload/import step per frame. It runs entirely on a DRM render node with no window system required. Typical results on AMD Radeon RX 580: 1080p (7.9 MB/frame): ~24x faster with GBM (1.42 ms → 0.06 ms) 4K (31.6 MB/frame): ~80x faster with GBM (5.18 ms → 0.07 ms) Built automatically when gbm, egl, and glesv2 are all available.
46 lines
1.6 KiB
Meson
46 lines
1.6 KiB
Meson
egl_dep = dependency('egl', required: false)
|
|
glesv2_dep = dependency('glesv2', required: false)
|
|
|
|
if not (feature_conf.get('CAIRO_HAS_GBM_SURFACE', 0) == 1 and egl_dep.found() and glesv2_dep.found())
|
|
subdir_done()
|
|
endif
|
|
|
|
benchmark_deps = [libcairo_dep, gbm_dep, libdrm_dep, egl_dep, glesv2_dep]
|
|
benchmark_sources = ['gbm-egl-benchmark.c']
|
|
benchmark_c_args = []
|
|
|
|
# Wayland support for --window mode
|
|
wl_client_dep = dependency('wayland-client', required: false)
|
|
wl_egl_dep = dependency('wayland-egl', required: false)
|
|
wl_protocols_dep = dependency('wayland-protocols', required: false)
|
|
wl_scanner = find_program('wayland-scanner', required: false)
|
|
|
|
if wl_client_dep.found() and wl_egl_dep.found() and wl_protocols_dep.found() and wl_scanner.found()
|
|
wl_protocols_dir = wl_protocols_dep.get_variable('pkgdatadir')
|
|
|
|
xdg_shell_xml = wl_protocols_dir / 'stable' / 'xdg-shell' / 'xdg-shell.xml'
|
|
|
|
xdg_shell_client_header = custom_target('xdg-shell-client-header',
|
|
input: xdg_shell_xml,
|
|
output: 'xdg-shell-client-protocol.h',
|
|
command: [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
|
|
)
|
|
|
|
xdg_shell_code = custom_target('xdg-shell-code',
|
|
input: xdg_shell_xml,
|
|
output: 'xdg-shell-protocol.c',
|
|
command: [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
|
|
)
|
|
|
|
benchmark_sources += [xdg_shell_client_header, xdg_shell_code]
|
|
benchmark_deps += [wl_client_dep, wl_egl_dep]
|
|
benchmark_c_args += ['-DHAS_WAYLAND']
|
|
endif
|
|
|
|
executable('gbm-egl-benchmark',
|
|
benchmark_sources,
|
|
dependencies: benchmark_deps,
|
|
c_args: benchmark_c_args,
|
|
link_args: ['-lm'],
|
|
install: false,
|
|
)
|