mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
The benchmark tree had nothing that exercised a driver: SanityBench times std::vector, and the Buffer/Program benches call into MobileGL_s directly, so neither can say what a backend costs against the native driver. This adds a headless EGL client that can, and shapes its cases from measured traces rather than guesses. DriverBench dlopens exactly one EGL provider - the system libEGL.so.1, or a libMobileGL.so with MOBILEGL_BACKEND_TYPE selecting Espryt or Magma - so the same binary measures all three stacks with no LD_LIBRARY_PATH shadowing, which matters because MobileGL's own loader has to keep finding the real driver underneath. It renders into its own renderbuffer FBO on a 64x64 pbuffer and paces frames with glFinish, so it needs no window and no compositor. The six mc_* cases replay the per-frame call mix of 30-second render-distance-32 captures of three Minecraft versions, at the rates those captures measured: vanilla 1.21.1 issues 5495 glDrawElements per frame, each preceded by its own glBindVertexArray and glUniform3fv; Fabric+Sodium collapses the same scene into 132 glMultiDrawElementsBaseVertex; the 26.2 snapshot issues 3401 glDrawElementsBaseVertex, each preceded by glBindBufferRange + glBindBuffer. The texture case wraps every 16x16 atlas upload in the four glPixelStorei and two glTexParameteri calls Blaze3D re-sets around it, because that wrapper is a large part of what an upload costs a translation layer. One bench frame therefore costs what one real frame of that version costs, and ns_per_op is directly comparable across renderers. run_driver_bench.sh pins __EGL_VENDOR_LIBRARY_FILENAMES and VK_ICD_FILENAMES. Without that, eglGetDisplay(EGL_DEFAULT_DISPLAY) on this glvnd system resolves to Mesa llvmpipe and the "native" numbers silently describe a software rasteriser - the first run of this bench reported 11 us per draw before the pin, versus 250 ns on the real GPU. Verified against the NVIDIA 610.43.03 driver, Espryt and Magma on a GTX 1660 SUPER; the CMake target builds and runs from a clean configure.
42 lines
1.6 KiB
Bash
42 lines
1.6 KiB
Bash
#!/bin/bash
|
|
# Run the headless EGL DriverBench on one renderer:
|
|
# ./run_driver_bench.sh native [bench args...]
|
|
# ./run_driver_bench.sh espryt <libMobileGL.so> [bench args...]
|
|
# ./run_driver_bench.sh magma <libMobileGL.so> [bench args...]
|
|
# The bench dlopens exactly one EGL provider (DRIVERBENCH_EGL_LIB): the system
|
|
# libEGL.so.1 for native, or the given libMobileGL.so for a MobileGL backend -
|
|
# no LD_LIBRARY_PATH shadowing, so MobileGL's own loader still finds the real
|
|
# driver underneath.
|
|
#
|
|
# Pin the vendor libraries explicitly. A bare libEGL.so.1 on a glvnd system
|
|
# picks whatever vendor eglGetDisplay(EGL_DEFAULT_DISPLAY) resolves first,
|
|
# which is Mesa/llvmpipe here - a software rasteriser silently replacing the
|
|
# GPU under a benchmark. Override MGL_EGL_VENDOR / MGL_VK_ICD to test another
|
|
# driver.
|
|
set -eu
|
|
HERE=$(cd "$(dirname "$0")" && pwd)
|
|
BENCH=${DRIVERBENCH_BIN:-$HERE/DriverBench}
|
|
EGL_VENDOR=${MGL_EGL_VENDOR:-/usr/share/glvnd/egl_vendor.d/10_nvidia.json}
|
|
VK_ICD=${MGL_VK_ICD:-/usr/share/vulkan/icd.d/nvidia_icd.x86_64.json}
|
|
MODE=$1; shift
|
|
|
|
export __EGL_VENDOR_LIBRARY_FILENAMES=$EGL_VENDOR
|
|
export EGL_PLATFORM=${EGL_PLATFORM:-x11}
|
|
|
|
case "$MODE" in
|
|
native)
|
|
export DRIVERBENCH_EGL_LIB=${DRIVERBENCH_EGL_LIB:-libEGL.so.1}
|
|
;;
|
|
espryt)
|
|
export DRIVERBENCH_EGL_LIB=$(readlink -f "$1"); shift
|
|
export MOBILEGL_BACKEND_TYPE=DirectGLES
|
|
;;
|
|
magma)
|
|
export DRIVERBENCH_EGL_LIB=$(readlink -f "$1"); shift
|
|
export MOBILEGL_BACKEND_TYPE=DirectVulkan
|
|
export VK_ICD_FILENAMES=$VK_ICD
|
|
;;
|
|
*) echo "unknown mode: $MODE (native|espryt|magma)"; exit 1 ;;
|
|
esac
|
|
exec "$BENCH" "$@"
|