forked from KhronosGroup/Vulkan-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
343 lines (305 loc) · 14 KB
/
Copy pathadvanced_gltf_example_ci.yml
File metadata and controls
343 lines (305 loc) · 14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
name: Advanced glTF Example CI
on:
push:
paths:
- 'attachments/advanced_gltf/**'
- 'attachments/simple_engine/**'
- '.github/workflows/advanced_gltf_example_ci.yml'
pull_request:
paths:
- 'attachments/advanced_gltf/**'
- 'attachments/simple_engine/**'
- '.github/workflows/advanced_gltf_example_ci.yml'
workflow_dispatch:
jobs:
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
defaults:
run:
working-directory: attachments/advanced_gltf
steps:
- name: Checkout
uses: actions/checkout@v4
# -----------------------------------------------------------------------
# Linux toolchain
# -----------------------------------------------------------------------
- name: Install Clang + Ninja + ccache (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y clang ninja-build ccache spirv-tools
- name: Select Clang toolchain (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
# -----------------------------------------------------------------------
# Windows toolchain
# -----------------------------------------------------------------------
- name: Set up MSVC dev environment (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Set up Ninja + sccache (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install -y ninja sccache
$chocoBin = "C:\ProgramData\chocolatey\bin"
if (Test-Path $chocoBin) {
$chocoBin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
}
"SCCACHE_DIR=$env:LOCALAPPDATA\Mozilla\sccache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# -----------------------------------------------------------------------
# Compiler cache
# -----------------------------------------------------------------------
- name: ccache (Linux)
if: runner.os == 'Linux'
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ${{ runner.os }}-advanced-gltf-ccache-${{ github.sha }}
restore-keys: ${{ runner.os }}-advanced-gltf-ccache-
- name: sccache (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: ${{ env.SCCACHE_DIR }}
key: ${{ runner.os }}-advanced-gltf-sccache-${{ github.sha }}
restore-keys: ${{ runner.os }}-advanced-gltf-sccache-
# -----------------------------------------------------------------------
# Vulkan SDK — provides slangc + headers; reuses same cache keys as
# simple_engine_ci so the two workflows share cached SDK tarballs.
# -----------------------------------------------------------------------
- name: Cache Vulkan SDK (Windows)
if: runner.os == 'Windows'
id: cache-vulkan-windows
uses: actions/cache@v4
with:
path: C:\VulkanSDK
key: ${{ runner.os }}-vulkan-sdk
- name: Install Vulkan SDK (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
if ("${{ steps.cache-vulkan-windows.outputs.cache-hit }}" -ne "true") {
choco install -y aria2
$installer = Join-Path $env:TEMP "vulkan-sdk.exe"
aria2c --split=8 --max-connection-per-server=8 --min-split-size=1M `
--dir="$env:TEMP" --out="vulkan-sdk.exe" `
"https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe"
Start-Process -FilePath $installer `
-ArgumentList "--accept-licenses --default-answer --confirm-command install" `
-Wait -NoNewWindow
}
$vulkanPath = Get-ChildItem "C:\VulkanSDK" |
Sort-Object Name -Descending | Select-Object -First 1 -ExpandProperty FullName
"VULKAN_SDK=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"$vulkanPath\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"CMAKE_PREFIX_PATH=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"Vulkan_INCLUDE_DIR=$vulkanPath\Include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Cache Vulkan SDK (Linux)
if: runner.os == 'Linux'
id: cache-vulkan-linux
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/VulkanSDK
key: ${{ runner.os }}-vulkan-sdk
- name: Install Vulkan SDK (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
SDK_DIR="${RUNNER_TEMP}/VulkanSDK"
if [ "${{ steps.cache-vulkan-linux.outputs.cache-hit }}" != "true" ]; then
SDK_TGZ="${RUNNER_TEMP}/vulkan-sdk.tar.xz"
download_ok=0
for url in \
"https://sdk.lunarg.com/sdk/download/latest/linux/vulkan-sdk.tar.xz" \
"https://sdk.lunarg.com/sdk/download/latest/linux/vulkansdk-linux-x86_64.tar.xz"
do
if curl -L --fail -o "$SDK_TGZ" "$url"; then
download_ok=1; break
fi
done
[ "$download_ok" -eq 1 ] || { echo "Vulkan SDK download failed" >&2; exit 1; }
rm -rf "$SDK_DIR"; mkdir -p "$SDK_DIR"
tar -xJf "$SDK_TGZ" -C "$SDK_DIR"
fi
VULKAN_SDK_PATH="$(find "$SDK_DIR" -maxdepth 1 -type d -name '1.*' | sort -r | head -n 1)"
SDK_SYSROOT="$VULKAN_SDK_PATH"
[ -d "$VULKAN_SDK_PATH/x86_64" ] && SDK_SYSROOT="$VULKAN_SDK_PATH/x86_64"
echo "VULKAN_SDK=$VULKAN_SDK_PATH" >> "$GITHUB_ENV"
echo "VULKAN_SDK_SYSROOT=$SDK_SYSROOT" >> "$GITHUB_ENV"
echo "CMAKE_PREFIX_PATH=$SDK_SYSROOT" >> "$GITHUB_ENV"
echo "Vulkan_INCLUDE_DIR=$SDK_SYSROOT/include" >> "$GITHUB_ENV"
for libname in libvulkan.so libvulkan.so.1; do
if [ -f "$SDK_SYSROOT/lib/$libname" ]; then
echo "Vulkan_LIBRARY=$SDK_SYSROOT/lib/$libname" >> "$GITHUB_ENV"; break
fi
done
[ -d "$VULKAN_SDK_PATH/bin" ] && echo "$VULKAN_SDK_PATH/bin" >> "$GITHUB_PATH"
[ -d "$SDK_SYSROOT/bin" ] && echo "$SDK_SYSROOT/bin" >> "$GITHUB_PATH"
if command -v slangc >/dev/null 2>&1; then
echo "SLANGC_EXECUTABLE=$(command -v slangc)" >> "$GITHUB_ENV"
fi
compat_dir="${RUNNER_TEMP}/slang-compat"
mkdir -p "$compat_dir"
pthread_path="$(ldconfig -p | awk '/libpthread\.so\.0/{print $NF; exit 0}' || true)"
if [ -n "${pthread_path:-}" ] && [ -f "$pthread_path" ]; then
ln -sf "$pthread_path" "$compat_dir/libpthread.so"
fi
echo "LD_LIBRARY_PATH=$compat_dir:${SDK_SYSROOT}/lib:${VULKAN_SDK_PATH}/lib:${LD_LIBRARY_PATH:-}" >> "$GITHUB_ENV"
# -----------------------------------------------------------------------
# simple_engine system dependencies
# The advanced_gltf project links against SimpleEngineLib which is built
# from simple_engine's sources, so we need the same library dependencies.
# -----------------------------------------------------------------------
- name: Install simple_engine dependencies (Linux)
if: runner.os == 'Linux'
shell: bash
run: bash ../simple_engine/install_dependencies_linux.sh
- name: Set up vcpkg (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$vcpkgRoot = "C:\vcpkg"
if (-not (Test-Path $vcpkgRoot)) {
git clone https://github.com/microsoft/vcpkg.git $vcpkgRoot
& "$vcpkgRoot\bootstrap-vcpkg.bat" -disableMetrics
}
"$vcpkgRoot" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"VCPKG_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install simple_engine dependencies (Windows)
if: runner.os == 'Windows'
shell: cmd
run: call ..\simple_engine\install_dependencies_windows.bat
# -----------------------------------------------------------------------
# FetchContent dependency cache (Jolt only; simple_engine deps are system-installed)
# -----------------------------------------------------------------------
- name: Cache FetchContent (Linux)
if: runner.os == 'Linux'
uses: actions/cache@v4
with:
path: attachments/advanced_gltf/build/_deps
key: ${{ runner.os }}-advanced-gltf-deps-v1
restore-keys: ${{ runner.os }}-advanced-gltf-deps-
- name: Cache FetchContent (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: attachments/advanced_gltf/build/_deps
key: ${{ runner.os }}-advanced-gltf-deps-v1
restore-keys: ${{ runner.os }}-advanced-gltf-deps-
# -----------------------------------------------------------------------
# Configure
# -----------------------------------------------------------------------
- name: Configure (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
extra_args=()
[ -n "${Vulkan_INCLUDE_DIR:-}" ] && extra_args+=("-DVulkan_INCLUDE_DIR=${Vulkan_INCLUDE_DIR}")
[ -n "${Vulkan_LIBRARY:-}" ] && extra_args+=("-DVulkan_LIBRARY=${Vulkan_LIBRARY}")
[ -n "${SLANGC_EXECUTABLE:-}" ] && extra_args+=("-DSLANGC_EXECUTABLE=${SLANGC_EXECUTABLE}")
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_PREFIX_PATH="${VULKAN_SDK_SYSROOT:-}" \
"${extra_args[@]}"
- name: Configure (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$extra = @()
if ($env:Vulkan_INCLUDE_DIR) { $extra += "-DVulkan_INCLUDE_DIR=$env:Vulkan_INCLUDE_DIR" }
if ($env:Vulkan_LIBRARY) { $extra += "-DVulkan_LIBRARY=$env:Vulkan_LIBRARY" }
if ($env:VCPKG_ROOT) { $extra += "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" }
cmake -S . -B build -G Ninja `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache `
-DCMAKE_C_COMPILER_LAUNCHER=sccache `
$extra
# -----------------------------------------------------------------------
# Build — the tutorial executable + all shader compilation targets
# -----------------------------------------------------------------------
- name: Build
run: cmake --build build --target AdvancedGLTF --parallel 4
- name: Verify shaders compiled
shell: bash
run: |
set -euo pipefail
missing=0
for spv in \
build/shaders/skinning.spv \
build/shaders/morph_accumulate.spv \
build/shaders/pbr_heatmap_vertex.spv \
"build/shaders/pbr_heatmap_fragment_dominant_bone.spv" \
"build/shaders/pbr_heatmap_fragment_weight_distribution.spv"
do
if [ -f "$spv" ]; then
echo " OK $spv"
else
echo " MISSING $spv" >&2
missing=$((missing + 1))
fi
done
[ "$missing" -eq 0 ] || { echo "$missing shader(s) missing" >&2; exit 1; }
- name: Cache stats
if: always()
shell: bash
run: |
command -v ccache >/dev/null 2>&1 && ccache -s || true
command -v sccache >/dev/null 2>&1 && sccache -s || true
# ---------------------------------------------------------------------------
# Validate Python asset tool (no deps beyond stdlib)
# ---------------------------------------------------------------------------
validate-python-tool:
name: Validate add_physics_extras.py
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Syntax check
run: python3 -m py_compile attachments/advanced_gltf/assets/add_physics_extras.py
- name: Download SimpleSkin and annotate
shell: bash
run: |
set -euo pipefail
# Fetch a minimal CC0 glTF that has a skin (SimpleSkin from Khronos samples)
curl -fsSL \
"https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/SimpleSkin/glTF/SimpleSkin.gltf" \
-o /tmp/SimpleSkin.gltf
python3 attachments/advanced_gltf/assets/add_physics_extras.py \
/tmp/SimpleSkin.gltf \
/tmp/SimpleSkin_physics.gltf
# Verify extras were written
python3 -c "
import json, sys
with open('/tmp/SimpleSkin_physics.gltf') as f:
g = json.load(f)
joints = set()
for skin in g.get('skins', []):
joints.update(skin.get('joints', []))
for idx in joints:
node = g['nodes'][idx]
extras = node.get('extras', {})
if 'collider' not in extras:
sys.exit(f'Node {idx} ({node.get(\"name\",\"?\")}) missing collider extras')
if 'constraint' not in extras:
sys.exit(f'Node {idx} ({node.get(\"name\",\"?\")}) missing constraint extras')
print(f'All {len(joints)} joint(s) annotated correctly.')
"