Mali bridge (#517, by ASEbrahim) on the non-Adreno test branch

Squash of Droid-Deck/DroidDeck#517 (ASEbrahim/DroidDeck mali-bridge @ 6b823341): the Vulkan
bridge (tools/vkbridge) that runs the guest's Vulkan on the phone's own driver, with BC1-BC7,
clip/cull distance, vertex-divisor and depth-clip emulation and dma-heap memory sharing for Mali.
All of the bridge is ASEbrahim's work; squashed only to carry it on this test branch.

Combined with #570 on this branch, a device draws through exactly one path:
- Adreno: Turnip, unchanged (checked first; the bridge setting is ignored there).
- PowerVR / Xclipse with the system HAL and a render node: the system-Vulkan path (#570).
- Anything else with the Setup toggle on (Mali): the bridge.
This commit is contained in:
The412Banner committed 2026-10-12 18:34:49 -04:00
1 parent cf06f89c11
commit ee0fb08268
125 files changed
+119982 -12

No files matched your search

+1
View File
@@ -0,0 +1 @@
out/
+39
View File
@@ -0,0 +1,39 @@
# Host (x86_64 Linux) build of both bridge halves, for testing against the desktop's own Vulkan
# driver: the server loads libvulkan.so.1 (pick a driver with VK_DRIVER_FILES in ITS environment),
# the client ICD is what test programs load (VK_DRIVER_FILES=$(OUT)/vkbridge_icd.json).
# make -C tools/vkbridge/host build
# make -C tools/vkbridge/host test vulkaninfo + vkcube-headless smoke tests
ROOT := $(abspath ../../..)
VKB := $(ROOT)/tools/vkbridge
SRV := $(ROOT)/app/src/main/cpp/vkbridge
OUT ?= $(VKB)/host/out
CC ?= gcc
CFLAGS ?= -O1 -g
WARN := -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare
INC := -I$(VKB)/third_party/Vulkan-Headers-1.4.341/include -I$(VKB)/common -I$(VKB)/common/gen
COMMON_SRC := $(VKB)/common/vkb_wire.c $(VKB)/common/gen/vkb_gen_structs.c
SERVER_SRC := $(wildcard $(SRV)/*.c) $(VKB)/common/gen/vkb_gen_server.c $(COMMON_SRC)
CLIENT_SRC := $(wildcard $(VKB)/client/*.c) $(VKB)/common/gen/vkb_gen_client.c $(COMMON_SRC)
all: $(OUT)/vkbridge-server $(OUT)/libvulkan_droidbridge.so $(OUT)/vkbridge_icd.json
$(OUT)/vkbridge-server: $(SERVER_SRC) $(wildcard $(SRV)/*.h $(VKB)/common/*.h $(VKB)/common/gen/*.h)
@mkdir -p $(OUT)
$(CC) $(CFLAGS) $(WARN) $(INC) -I$(SRV) -o $@ $(SERVER_SRC) -ldl -lpthread -lm -rdynamic
$(OUT)/libvulkan_droidbridge.so: $(CLIENT_SRC) $(wildcard $(VKB)/client/*.h $(VKB)/common/*.h $(VKB)/common/gen/*.h)
@mkdir -p $(OUT)
$(CC) $(CFLAGS) $(WARN) -fPIC -shared -fvisibility=hidden -DVKB_CLIENT $(INC) -I$(VKB)/client -I$(VKB)/client/compat \
-o $@ $(CLIENT_SRC) -ldl -lpthread -Wl,--no-undefined
$(OUT)/vkbridge_icd.json:
@mkdir -p $(OUT)
printf '{"file_format_version":"1.0.0","ICD":{"library_path":"%s","api_version":"1.4.341"}}\n' "$(OUT)/libvulkan_droidbridge.so" > $@
test: all
$(VKB)/host/run_tests.sh $(OUT)
clean:
rm -rf $(OUT)
.PHONY: all test clean
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
# Source this: starts a host vkbridge server on a desktop driver (VKB_HOST_ICD, default RADV) and
# points this shell's Vulkan programs at the bridge ICD.
# [VKB_HOST_ICD=...] . tools/vkbridge/host/bridge_env.sh
_vkb_host=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
_vkb_icd=${VKB_HOST_ICD:-/usr/share/vulkan/icd.d/radeon_icd.json}
export VKBRIDGE_SOCKET=${VKBRIDGE_SOCKET:-${XDG_RUNTIME_DIR:-/tmp}/vkbridge-host.sock}
pgrep -x vkbridge-server >/dev/null && kill $(pgrep -x vkbridge-server) 2>/dev/null; sleep 0.3
rm -f "$VKBRIDGE_SOCKET"
VK_DRIVER_FILES=$_vkb_icd VK_ICD_FILENAMES= nohup "$_vkb_host/out/vkbridge-server" --socket "$VKBRIDGE_SOCKET" \
--log "$_vkb_host/out/server.log" >/dev/null 2>&1 &
for _i in $(seq 50); do [ -S "$VKBRIDGE_SOCKET" ] && break; sleep 0.1; done
export VK_DRIVER_FILES=$_vkb_host/out/vkbridge_icd.json
echo "vkbridge server up ($_vkb_icd) at $VKBRIDGE_SOCKET"
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
# Runs tests/d3d11_check.exe under Proton Experimental's wine + DXVK. Needs a prefix dir with the
# exe, DXVK's d3d11/dxgi and vkd3d's DLLs (see README). VK_DRIVER_FILES picks native or bridge.
P="$HOME/.steam/steam/steamapps/common/Proton - Experimental/files"
W=${VKB_WINE_DIR:?set VKB_WINE_DIR}
cd "$W/app" && WINEPREFIX=$W/pfx WINEDEBUG=-all WINEDLLOVERRIDES="d3d11,dxgi=n,b" DXVK_LOG_PATH=$W timeout 180 "$P/bin/wine" d3d11_check.exe 2>&1 \
| grep -v "^info:\|^warn:\|fixme\|err:hid\|wineserver"
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# Phase 3 host test: Arch's gamescope (the runtime's distribution) in a container WITHOUT any GPU
# device, drawing only through the bridge, nested on the desktop's Wayland. Run after
# bridge_env.sh. Usage: gamescope_test.sh [command inside gamescope...]
host=$(cd "$(dirname "$0")" && pwd)
R=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}
cmd=${*:-vkcube --c 600}
exec docker run --rm ${VKB_DOCKER_EXTRA:-} --tmpfs /run/xdg:mode=0700 \
-e XDG_RUNTIME_DIR=/run/xdg -e WAYLAND_DISPLAY=host-wayland -e HOME=/root \
-v "$R/${WAYLAND_DISPLAY:-wayland-0}:/run/host-wayland" -v "$VKBRIDGE_SOCKET:/run/vkbridge.sock" \
-v "$host/out:$host/out" -v "$host/out/shots:/shots" -e VK_DRIVER_FILES=$host/out/vkbridge_icd.json -e VKBRIDGE_SOCKET=/run/vkbridge.sock \
-e VKBRIDGE_DRM_RENDER=${VKBRIDGE_DRM_RENDER:-} -e VKBRIDGE_HIDE_EXTS=${VKBRIDGE_HIDE_EXTS:-} -e VKBRIDGE_MAX_API=${VKBRIDGE_MAX_API:-} -e VKBRIDGE_LOG_LEVEL=${VKBRIDGE_LOG_LEVEL:-2} -e VKBRIDGE_WSI_DUMP=${VKBRIDGE_WSI_DUMP:-} \
vkb-arch-gamescope bash -c "ln -s /run/host-wayland /run/xdg/host-wayland; gamescope --backend wayland --expose-wayland -W 960 -H 540 -w 960 -h 540 -- $cmd"
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
# Source this: a host bridge server that behaves like the Mali-G720 driver as far as Phase 0
# found (no BCn, clip/cull distance, vertex attribute divisor, maintenance5, push descriptors, robustness2; Vulkan 1.3).
_vkb_host=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
export VKBRIDGE_SOCKET=${XDG_RUNTIME_DIR:-/tmp}/vkbridge-host.sock
pgrep -x vkbridge-server >/dev/null && kill $(pgrep -x vkbridge-server) 2>/dev/null; sleep 0.3
rm -f "$VKBRIDGE_SOCKET"
VKBRIDGE_FAKE_MISSING=${VKB_MISSING:-bc,clip,cull,divisor,maint5,depthclip,push,robustness2} VK_DRIVER_FILES=${VKB_HOST_ICD:-/usr/share/vulkan/icd.d/radeon_icd.json} \
nohup "$_vkb_host/out/vkbridge-server" --socket "$VKBRIDGE_SOCKET" --log "$_vkb_host/out/server.log" >/dev/null 2>&1 &
for _i in $(seq 50); do [ -S "$VKBRIDGE_SOCKET" ] && break; sleep 0.1; done
chmod 666 "$VKBRIDGE_SOCKET"
export VK_DRIVER_FILES=$_vkb_host/out/vkbridge_icd.json
export VKBRIDGE_HIDE_EXTS=VK_KHR_maintenance5,VK_KHR_push_descriptor,VK_EXT_robustness2,VK_KHR_robustness2,VK_EXT_vertex_attribute_divisor,VK_KHR_vertex_attribute_divisor,VK_EXT_depth_clip_enable
export VKBRIDGE_MAX_API=1.3
echo "vkbridge server up, imitating Mali's gaps"
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# Host regression suite for the bridge: every automated check, in two server modes -
# plain the desktop driver as it is (RADV)
# mali the desktop driver with Mali-G720's known gaps imitated (mali_env.sh)
# Needs: make (out/), Proton Experimental for the DXVK check (VKB_WINE_DIR prepared, see README),
# docker image vkb-arch-gamescope for the gamescope/Zink check (skipped if absent).
cd "$(dirname "$0")"
pass=0; fail=0
result() { if [ "$1" = 0 ]; then pass=$((pass+1)); echo " ok $2"; else fail=$((fail+1)); echo " FAIL $2"; fi; }
run_mode() {
local mode=$1
echo "== $mode"
if [ "$mode" = mali ]; then . ./mali_env.sh >/dev/null; else unset VKBRIDGE_HIDE_EXTS VKBRIDGE_MAX_API; . ./bridge_env.sh >/dev/null; fi
timeout 120 ./out/vkbridge-smoke >out/t-smoke.log 2>&1; result $? "smoke ($(tail -1 out/t-smoke.log))"
timeout 180 ./out/bcn_check >out/t-bcn.log 2>&1; result $? "bcn_check ($(tail -1 out/t-bcn.log))"
if [ -n "${VKB_WINE_DIR:-}" ] && [ -d "$VKB_WINE_DIR/app" ]; then
./d3d11_test.sh >out/t-d3d11.log 2>&1; grep -q "^OK:" out/t-d3d11.log; result $? "d3d11_check via DXVK ($(grep -E '^(OK|FAILED)' out/t-d3d11.log))"
fi
timeout 60 vkcube-wayland --c 120 >out/t-vkcube.log 2>&1; result $? "vkcube-wayland (dma-buf)"
VKBRIDGE_WSI_SHM=1 timeout 60 vkcube-wayland --c 120 >>out/t-vkcube.log 2>&1; result $? "vkcube-wayland (wl_shm)"
timeout 60 vkcube --c 120 >>out/t-vkcube.log 2>&1; result $? "vkcube (X11)"
if docker image inspect vkb-arch-gamescope >/dev/null 2>&1; then
VKB_DOCKER_EXTRA="--device /dev/dri/renderD128" VKBRIDGE_DRM_RENDER=226:128 timeout 120 ./gamescope_test.sh \
"bash -c 'export MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true; timeout 20 glxgears 2>&1 | grep -m1 frames'" \
>out/t-gamescope-$mode.log 2>&1
grep -q "frames in" out/t-gamescope-$mode.log; result $? "gamescope + Zink glxgears ($(grep -m1 -o '[0-9.]* FPS' out/t-gamescope-$mode.log))"
fi
}
run_mode plain
run_mode mali
echo "== $pass passed, $fail failed"
[ "$fail" = 0 ]