Skip to content

Commit 7e2b49b

Browse files
ci(audience): build SwiftShader and register its Vulkan ICD for Linux PlayMode
1 parent 8bdb0b0 commit 7e2b49b

1 file changed

Lines changed: 40 additions & 6 deletions

File tree

.github/workflows/test-audience-sample-app.yml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,41 @@ jobs:
509509
exit 1
510510
fi
511511
512+
# Build SwiftShader (Google's CPU Vulkan ICD) from source.
513+
# Apt does not package SwiftShader on Ubuntu. Build is roughly
514+
# 5 to 10 minutes, single-threaded steps near the end. The ICD
515+
# JSON is registered via VK_ICD_FILENAMES.
516+
echo "::group::install build deps"
517+
apt-get update
518+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
519+
git cmake ninja-build build-essential vulkan-tools libvulkan1
520+
echo "::endgroup::"
521+
522+
echo "::group::clone + build SwiftShader"
523+
ss_dir=/tmp/swiftshader
524+
git clone --depth=1 https://swiftshader.googlesource.com/SwiftShader "$ss_dir"
525+
cmake -S "$ss_dir" -B "$ss_dir/build" -G Ninja \
526+
-DCMAKE_BUILD_TYPE=Release \
527+
-DSWIFTSHADER_BUILD_VULKAN=ON \
528+
-DSWIFTSHADER_BUILD_TESTS=OFF \
529+
-DSWIFTSHADER_BUILD_BENCHMARKS=OFF
530+
cmake --build "$ss_dir/build" --target vk_swiftshader
531+
echo "::endgroup::"
532+
533+
# The build produces vk_swiftshader_icd.json next to libvk_swiftshader.so.
534+
icd=$(find "$ss_dir/build" -name vk_swiftshader_icd.json | head -1)
535+
if [ -z "$icd" ]; then
536+
echo "::error::SwiftShader build did not produce vk_swiftshader_icd.json"
537+
find "$ss_dir/build" -name "*swiftshader*" 2>/dev/null | head -10
538+
exit 1
539+
fi
540+
echo "SwiftShader ICD at $icd"
541+
export VK_ICD_FILENAMES="$icd"
542+
543+
# Capture device list for post-run confirmation. If SwiftShader is
544+
# discovered, this prints "deviceName: SwiftShader Device".
545+
vulkaninfo --summary > /github/workspace/artifacts/vulkaninfo.txt 2>&1 || true
546+
512547
# xvfb-run gives Unity a virtual X display so PlayMode tests
513548
# that load scenes and exercise UI Toolkit can actually launch
514549
# the player. GLX + render are required for UIElements; the
@@ -547,15 +582,13 @@ jobs:
547582
# only on UI Toolkit log-row presence (queried via the
548583
# VisualElement tree, not via screen capture).
549584
#
550-
# Why -force-glcore: Unity 6 prefers Vulkan on Linux and
551-
# falls back to OpenGL when Vulkan init fails. Each frame
552-
# carries the negotiation overhead. -force-glcore tells the
553-
# player to skip Vulkan entirely and open a GLX context
554-
# directly, the same path Unity 2021.3 takes by default.
585+
# This PR tests SwiftShader Vulkan (registered via
586+
# VK_ICD_FILENAMES above) instead of forcing OpenGL. Unity 6
587+
# is allowed to pick its preferred backend; if Vulkan init
588+
# fails it falls back to OpenGL via mesa-llvmpipe.
555589
xvfb-run -a --server-args="-screen 0 320x240x24 -ac +extension GLX +render -noreset" -- \
556590
unity-editor \
557591
-batchmode \
558-
-force-glcore \
559592
-screen-fullscreen 0 \
560593
-screen-width 320 \
561594
-screen-height 240 \
@@ -730,6 +763,7 @@ jobs:
730763
artifacts/playmode-results.xml
731764
artifacts/playmode.log
732765
artifacts/activation.log
766+
artifacts/vulkaninfo.txt
733767
artifacts/Player-*.log
734768
examples/audience/Logs/**
735769

0 commit comments

Comments
 (0)