Skip to content

Commit

Permalink
Record XrSim tests for the composition layer and passthrough sample p…
Browse files Browse the repository at this point in the history
…rojects
  • Loading branch information
dsnopek committed Jun 20, 2024
1 parent 8ed3aeb commit 9c03449
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 14 deletions.
67 changes: 53 additions & 14 deletions .github/workflows/build-addon-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ jobs:
runs-on: [Windows, self-hosted, gpu]
needs: build

env:
GODOT_VERSION: "4.3-beta2"
XRSIM_VERSION: "65.0.0"

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -201,8 +205,7 @@ jobs:
- name: Download Godot
run: |
# @todo Download an actual Godot build!
Invoke-WebRequest -Uri "https://github.com/godotengine/godot-builds/releases/download/4.3-beta2/Godot_v4.3-beta2_win64.exe.zip" -OutFile "godot.zip"
Invoke-WebRequest -Uri "https://github.com/godotengine/godot-builds/releases/download/${{ env.GODOT_VERSION }}/Godot_v${{ env.GODOT_VERSION }}_win64.exe.zip" -OutFile "godot.zip"
- name: Extract Godot
run: |
Expand All @@ -214,7 +217,7 @@ jobs:

- name: Download Meta XR Simulator
run: |
Invoke-WebRequest -Uri "https://npm.developer.oculus.com/com.meta.xr.simulator/-/com.meta.xr.simulator-65.0.0.tgz" -OutFile MetaXRSimulator.tgz
Invoke-WebRequest -Uri "https://npm.developer.oculus.com/com.meta.xr.simulator/-/com.meta.xr.simulator-${{ env.XRSIM_VERSION }}.tgz" -OutFile MetaXRSimulator.tgz
- name: Extract Meta XR Simulator
run: |
Expand Down Expand Up @@ -242,16 +245,35 @@ jobs:
name: build-files-windows
path: build-files-windows

- name: Copy Windows build of the addon into the demo project
- name: Copy Windows build of the addon into the demo and samples project
run: |
mkdir -p demo/addons/godotopenxrvendors/.bin/windows/
cp -r build-files-windows/* demo/addons/godotopenxrvendors/.bin/windows/
- name: Import the demo project
$sampleProjects = Get-ChildItem -Path "samples/" -Directory
foreach ($project in $sampleProjects) {
cp -r demo/addons "$($project.FullName)/"
}
- name: Import the demo and sample projects
run: |
$godot = "Godot_v4.3-beta2_win64.exe"
$godot = "Godot_v${{ env.GODOT_VERSION }}_win64.exe"
Write-Output ""
Write-Output " ** Importing demo project"
Write-Output ""
Start-Process -FilePath "$godot" -ArgumentList "--path demo --import --headless" -NoNewWindow -Wait
$sampleProjects = Get-ChildItem -Path "samples/" -Directory
foreach ($project in $sampleProjects) {
Write-Output ""
Write-Output " ** Importing project $($project.Name)"
Write-Output ""
Start-Process -FilePath "$godot" -ArgumentList "--path $($project.FullName) --import --headless" -NoNewWindow -Wait
}
- name: Launch a synthetic environment
run: |
# Ensure a synthetic environment isn't already running.
Expand All @@ -267,7 +289,12 @@ jobs:
run: |
$jsonPath = "$env:AppData\MetaXR\MetaXrSimulator\persistent_data.json"
$vrsFiles = Get-ChildItem -Path tests/vrs -Filter *.vrs
$demoVrsFiles = Get-ChildItem -Path "demo/tests/" -Recurse -Filter *.vrs
$sampleVrsFiles = Get-ChildItem -Path "samples/*/tests/" -Recurse -Filter *.vrs
$vrsFiles = @()
$vrsFiles += $demoVrsFiles
$vrsFiles += $sampleVrsFiles
foreach ($file in $vrsFiles) {
$replayPath = Join-Path -Path $file.DirectoryName -ChildPath ($file.BaseName + "-replay.vrs")
$jsonContent = @{
Expand All @@ -285,11 +312,17 @@ jobs:
Set-Content -Path $jsonPath -Value $jsonContent
echo "$jsonContent"
$godot = "Godot_v4.3-beta2_win64.exe"
$godot = "Godot_v${{ env.GODOT_VERSION }}_win64.exe"
$timeout = 300
$waitTime = 0
$process = Start-Process -FilePath "$godot" -ArgumentList "--path demo --rendering-method mobile --verbose -- --quit-with-openxr" -NoNewWindow -PassThru
$projectPath = (Get-Item $file.DirectoryName).Parent
Write-Output ""
Write-Output " ** Running VRS $($file.Name) on $($projectPath.Name) project"
Write-Output ""
$process = Start-Process -FilePath "$godot" -ArgumentList "--path $($projectPath.FullName) --rendering-method mobile --verbose -- --quit-with-openxr" -NoNewWindow -PassThru
while ($process.HasExited -eq $false -and $waitTime -lt $timeout) {
Start-Sleep -Seconds 1
Expand Down Expand Up @@ -317,14 +350,17 @@ jobs:
- name: Copy vrs_pixmatch.py from Meta XR Simulator
run: |
$scriptsPath = "C:\Meta\package\MetaXRSimulator\scripts"
cp "$scriptsPath\requirements.txt" tests\vrs\
cp "$scriptsPath\vrs_pixmatch.py" tests\vrs\
mkdir test-scripts
cp "$scriptsPath/requirements.txt" test-scripts/
cp "$scriptsPath/vrs_pixmatch.py" test-scripts/
- name: Upload VRS artifacts
uses: actions/upload-artifact@v3
with:
name: ReplayVRS
path: tests/vrs/**/*
path: |
test-scripts/
**/*/tests/*.vrs
compare_vrs_replay:
name: "Compare VRS replay"
Expand All @@ -348,18 +384,21 @@ jobs:

- name: Install dependencies
run: |
find tests/vrs
python -m pip install --upgrade pip
pip install -r tests/vrs/requirements.txt
pip install -r tests/vrs/test-scripts/requirements.txt
- name: Compare VRS replay with expected recordings
run: |
cd tests/vrs/
ls
mv test-scripts/* ./
# Fix bugs in vrs_pixmatch.py script.
patch -p0 < ../../thirdparty/meta_xr_simulator/vrs_pixmatch.patch
mkdir diffs
for replay in *-replay.vrs; do
for replay in $(find . -name \*-replay.vrs); do
expected=$(echo $replay | sed -e 's/-replay.vrs$/.vrs/')
python vrs_pixmatch.py "$replay" "$expected" --threshold 0.4 --best_match_pixels_diff_threshold 40000 --diffs_output_path diffs
done
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions samples/fb-composition-layers-sample/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var xr_interface : XRInterface = null
func _ready():
xr_interface = XRServer.find_interface("OpenXR")
if xr_interface and xr_interface.is_initialized():
xr_interface.session_stopping.connect(self._on_session_stopping)
var vp: Viewport = get_viewport()
vp.use_xr = true
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
Expand All @@ -46,6 +47,13 @@ func _ready():
add_child(node_3d)


func _on_session_stopping() -> void:
if "--quit-with-openxr" in OS.get_cmdline_user_args():
# When we're running tests via the XR Simulator, it will end the OpenXR
# session automatically, and in that case, we want to quit.
get_tree().quit()


func _process(_delta: float) -> void:
var ray_intersection_left: Vector2
var ray_intersection_right: Vector2
Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions samples/fb-hand-tracking-sample/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ var right_capsules_loaded := false
func _ready() -> void:
openxr_interface = XRServer.find_interface("OpenXR")
if openxr_interface and openxr_interface.initialize():
openxr_interface.session_stopping.connect(self._on_session_stopping)
get_viewport().use_xr = true
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
fb_capsule_ext = Engine.get_singleton("OpenXRFbHandTrackingCapsulesExtensionWrapper")


func _on_session_stopping() -> void:
if "--quit-with-openxr" in OS.get_cmdline_user_args():
# When we're running tests via the XR Simulator, it will end the OpenXR
# session automatically, and in that case, we want to quit.
get_tree().quit()


func _process(delta):
if countdown_to_group_hand_meshes > 0:
countdown_to_group_hand_meshes -= 1
Expand Down
8 changes: 8 additions & 0 deletions samples/fb-passthrough-sample/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var countdown_to_recenter_hmd: int = 3
func _ready() -> void:
openxr_interface = XRServer.find_interface("OpenXR")
if openxr_interface and openxr_interface.initialize():
openxr_interface.session_stopping.connect(self._on_session_stopping)
get_viewport().use_xr = true
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)

Expand All @@ -55,6 +56,13 @@ func _ready() -> void:
mono_map_mat.albedo_texture = curve_texture


func _on_session_stopping() -> void:
if "--quit-with-openxr" in OS.get_cmdline_user_args():
# When we're running tests via the XR Simulator, it will end the OpenXR
# session automatically, and in that case, we want to quit.
get_tree().quit()


func _process(_delta: float) -> void:
if countdown_to_recenter_hmd > 0:
countdown_to_recenter_hmd -= 1
Expand Down
Binary file added samples/fb-passthrough-sample/tests/test1.vrs
Binary file not shown.

0 comments on commit 9c03449

Please sign in to comment.