@usemosio/cli-linux-x64 1.0.0-next.4 → 1.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/mosio +0 -0
- package/package.json +1 -1
- package/scripts/gpu-webgl-check.sh +47 -0
package/bin/mosio
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# WebGL on the GPU profile, on a machine with a GPU (CI Macs; by hand on a Windows/Linux GPU machine):
|
|
3
|
+
# 1. `mosio caps --gpu-profiles`: the webgl-gpu profile has a WebGL 2 context and it is no software rasteriser
|
|
4
|
+
# (SwiftShader, llvmpipe, WARP)
|
|
5
|
+
# 2. fixtures/gl-readback with "renderer": {"webgl": "gpu"}: a plain WebGL canvas drawn from onSeek is captured on
|
|
6
|
+
# the GPU (readback present): the canvas area is not the page background and the frames change
|
|
7
|
+
#
|
|
8
|
+
# scripts/gpu-webgl-check.sh <mosio> <out-dir>
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
MOSIO=$1
|
|
11
|
+
OUT=$2
|
|
12
|
+
REPO=$(cd "$(dirname "$0")/.." && pwd)
|
|
13
|
+
PY=$(command -v python3 || command -v python)
|
|
14
|
+
mkdir -p "$OUT"
|
|
15
|
+
OUT=$(cd "$OUT" && pwd)
|
|
16
|
+
"$MOSIO" caps --gpu-profiles --no-webgpu > "$OUT/caps.json"
|
|
17
|
+
"$PY" - "$OUT/caps.json" <<'PY'
|
|
18
|
+
import json, sys
|
|
19
|
+
v = json.load(open(sys.argv[1]))
|
|
20
|
+
g = v["chromium"].get("webgl-gpu", {})
|
|
21
|
+
w = g.get("webgl2", {})
|
|
22
|
+
print("[gpu-webgl] host gpu_present:", v["host"].get("gpu_present"), "| webgl-gpu flags:", g.get("flags"))
|
|
23
|
+
print("[gpu-webgl] webgl-gpu renderer:", w.get("renderer"), "| software:", (g.get("software") or {}).get("webgl"), "| error:", g.get("error"))
|
|
24
|
+
sys.exit(0 if w.get("available") and (g.get("software") or {}).get("webgl") is False else 1)
|
|
25
|
+
PY
|
|
26
|
+
P="$OUT/gl-readback-gpu"
|
|
27
|
+
rm -rf "$P" && cp -R "$REPO/fixtures/gl-readback" "$P"
|
|
28
|
+
"$PY" - "$P/mosio.json" <<'PY'
|
|
29
|
+
import json, sys
|
|
30
|
+
p = json.load(open(sys.argv[1])); p["renderer"] = {"webgl": "gpu"}
|
|
31
|
+
json.dump(p, open(sys.argv[1], "w"), indent=1)
|
|
32
|
+
PY
|
|
33
|
+
"$MOSIO" frames "$P" --scene readback --frames 0,7,15,29 --png-dir "$OUT/png" -o "$OUT/frames.json" > "$OUT/frames.log" 2>&1 || { cat "$OUT/frames.log" >&2; exit 1; }
|
|
34
|
+
# the canvas content box starts at (64, 44) in the 640x360 page; (200, 120) is inside it
|
|
35
|
+
for f in "$OUT"/png/*.png; do
|
|
36
|
+
ffmpeg -v error -i "$f" -vf "crop=1:1:200:120" -f rawvideo -pix_fmt rgb24 - | od -An -tu1 | tr -s ' ' | sed 's/^ //' > "$f.px"
|
|
37
|
+
done
|
|
38
|
+
"$PY" - "$OUT" <<'PY'
|
|
39
|
+
import json, glob, os, sys
|
|
40
|
+
out = sys.argv[1]
|
|
41
|
+
frames = json.load(open(os.path.join(out, "frames.json")))["frames"]
|
|
42
|
+
px = [open(f).read().split() for f in sorted(glob.glob(os.path.join(out, "png", "*.px")))]
|
|
43
|
+
bg = ["32", "32", "32"]
|
|
44
|
+
print("[gpu-webgl] canvas pixel per frame:", px, "| distinct frames:", len(set(frames)), "of", len(frames))
|
|
45
|
+
ok = len(frames) == 4 and len(set(frames)) == 4 and len(px) == 4 and all(p and p != bg for p in px)
|
|
46
|
+
sys.exit(0 if ok else 1)
|
|
47
|
+
PY
|