mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
feat: Cardboard VR mode with ARM64 SteamVR (#704)
* feat: add Cardboard mode with side-by-side lens-distorted eyes and 3DoF head tracking * fix: derive the Cardboard field of view from the panel and recentre fully when far from upright * feat: share the Cardboard head pose with the guest and add a SteamVR driver for it * feat: run SteamVR's compositor on Turnip/KGSL with a display-extension layer and a driver-direct HMD * feat: show SteamVR frames in Cardboard mode through a driver-side presenter and a fake direct-mode display * feat: install and start SteamVR for Cardboard mode from the session drawer * docs: describe Cardboard mode and the SteamVR path * feat: drive SteamVR hands from the game pad and keep the Cardboard headset out of standby * docs: record where the SteamVR dashboard stops * fix: map Cardboard head tracking to the screen's axes and keep turns about the real vertical as yaw * fix: give Cardboard its previous picture back when SteamVR stops * fix: report sem_otime from emulated SysV semaphores so SteamVR's web helper can start * fix: bridge SteamVR's shared semaphores across processes and keep Steam alive while SteamVR runs * feat: present SteamVR straight to DroidDeck's compositor at panel resolution * docs: update Cardboard VR notes for the dashboard, semaphore bridge and direct presenter * fix: keep Wine and FEX signal handlers in the VR layer; add semaphore tracing * fix: clear a stale SteamVR active marker on status * fix: clear only an old SteamVR active marker * fix: unblock SteamVR clients on Turnip and keep Steam's web helper alive across SteamVR runs * fix: judge shared waits before a submit's own signals and on Vulkan 1.0 devices * docs: record VR games, SteamVR Home and OpenXR results on the Thor * docs: add Cardboard VR learnings from the Thor bring-up * docs: add Cardboard VR screenshots from the Thor * fix: keep the VR layer's display stand-in to SteamVR runs and clear a leftover marker at session start * fix: report SteamVR start and stop failures from the helper's exit code
This commit is contained in:
1 parent
92d038b428
commit
f4b0ab6867
57 files changed
+17799
-15
No files matched your search
@@ -0,0 +1,28 @@
|
||||
/* Host test for sysv.c: IPC_STAT's sem_otime turns non-zero with the first semop, which the usual
|
||||
* race-free init (and SteamVR's web helper) waits for. Linked with sysv.c, whose semget/semop/semctl
|
||||
* replace libc's. */
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
|
||||
int main(void) {
|
||||
int creator = semget(0x5eed0001, 1, IPC_CREAT | IPC_EXCL | 0600);
|
||||
if (creator < 0) { perror("semget"); return 1; }
|
||||
struct semid_ds ds;
|
||||
if (semctl(creator, 0, IPC_STAT, &ds) != 0 || ds.sem_otime != 0 || ds.sem_ctime == 0) {
|
||||
printf("FAIL: a new set has otime %ld ctime %ld\n", (long)ds.sem_otime, (long)ds.sem_ctime);
|
||||
return 1;
|
||||
}
|
||||
struct sembuf up = {0, 1, 0};
|
||||
if (semop(creator, &up, 1) != 0) { perror("semop"); return 1; }
|
||||
int other = semget(0x5eed0001, 1, 0600);
|
||||
if (other < 0 || semctl(other, 0, IPC_STAT, &ds) != 0 || ds.sem_otime == 0) {
|
||||
printf("FAIL: otime still 0 after semop\n");
|
||||
return 1;
|
||||
}
|
||||
if (semctl(other, 0, GETVAL) != 1) { printf("FAIL: value\n"); return 1; }
|
||||
semctl(creator, 0, IPC_RMID);
|
||||
printf("PASS: sysv otime\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SRC = ROOT / 'app' / 'src' / 'main' / 'cpp' / 'waylandcomp' / 'src'
|
||||
TOOLS = ROOT / 'tools' / 'cardboard'
|
||||
|
||||
|
||||
def spirv_words(header: str) -> list[str]:
|
||||
return re.findall(r'0x[0-9a-fA-F]{8}', header)
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which('cc'), 'needs a C compiler')
|
||||
class CardboardParamsTest(unittest.TestCase):
|
||||
def test_clamp_and_push_constant_layout(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
binary = str(Path(folder) / 'test-cardboard')
|
||||
subprocess.run(['cc', '-std=c11', '-Wall', '-Wextra', '-Werror', '-O2', '-DCARDBOARD_HOST_TEST',
|
||||
'-D_DEFAULT_SOURCE', f'-I{SRC}', f'-I{Path(folder)}', '-o', binary,
|
||||
str(TOOLS / 'test_cardboard_params.c'), str(SRC / 'cardboard.c'), '-lm'],
|
||||
check=True, cwd=folder, env=self._env(folder))
|
||||
result = subprocess.run([binary], capture_output=True, text=True, check=True, timeout=10)
|
||||
self.assertIn('PASS: cardboard params', result.stdout)
|
||||
|
||||
@staticmethod
|
||||
def _env(folder):
|
||||
# cardboard.h includes <vulkan/vulkan.h>; the host test only needs the types, so a stub
|
||||
# header stands in when the Vulkan SDK is not installed.
|
||||
import os
|
||||
stub = Path(folder) / 'vulkan'
|
||||
stub.mkdir(exist_ok=True)
|
||||
(stub / 'vulkan.h').write_text('typedef struct VkDevice_T *VkDevice; typedef struct VkImage_T *VkImage;\n'
|
||||
'typedef struct VkCommandBuffer_T *VkCommandBuffer;\n'
|
||||
'typedef struct { int unused; } VkPhysicalDeviceMemoryProperties;\n')
|
||||
return dict(os.environ)
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which('glslangValidator'), 'needs glslangValidator')
|
||||
class CardboardShaderTest(unittest.TestCase):
|
||||
def test_committed_spirv_matches_the_glsl(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
out = Path(folder) / 'cardboard_frag.h'
|
||||
subprocess.run(['glslangValidator', '-V', '--vn', 'cardboard_frag_code', '-o', str(out),
|
||||
str(SRC / 'cardboard.frag')], check=True, capture_output=True)
|
||||
self.assertEqual(spirv_words(out.read_text()), spirv_words((SRC / 'cardboard_frag.h').read_text()),
|
||||
'cardboard_frag.h is stale: regenerate it from cardboard.frag (see cardboard.c)')
|
||||
|
||||
def test_push_constants_fit_the_guaranteed_range(self):
|
||||
# 7 vec4 = 112 bytes in the shader; Vulkan guarantees 128.
|
||||
glsl = (SRC / 'cardboard.frag').read_text()
|
||||
block = glsl[glsl.index('uniform PC {'):glsl.index('} pc;')]
|
||||
self.assertLessEqual(16 * len(re.findall(r'\bvec4\b', block)), 128)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -91,6 +91,37 @@ class AgentTest(unittest.TestCase):
|
||||
self.assertFalse(path.exists(), "the request file is consumed")
|
||||
return json.loads((self.dir / "resp" / "req.json").read_text())
|
||||
|
||||
def vr_helper(self, body):
|
||||
helper = self.dir / "droiddeck-steamvr"
|
||||
helper.write_text("#!/bin/sh\n" + body)
|
||||
old = os.environ.get("DROIDDECK_VR_HELPER")
|
||||
os.environ["DROIDDECK_VR_HELPER"] = str(helper)
|
||||
self.addCleanup(lambda: os.environ.pop("DROIDDECK_VR_HELPER") if old is None
|
||||
else os.environ.__setitem__("DROIDDECK_VR_HELPER", old))
|
||||
return helper
|
||||
|
||||
def test_vr_status_is_parsed(self):
|
||||
self.vr_helper('echo "installed=1 running=0 installing=0 driver=1"\n')
|
||||
answer = self.ask({"kind": "vr", "action": "status"})
|
||||
self.assertTrue(answer["ok"])
|
||||
self.assertEqual((True, False, False, True),
|
||||
(answer["installed"], answer["running"], answer["installing"], answer["driver"]))
|
||||
|
||||
def test_vr_runs_only_its_own_actions(self):
|
||||
log = self.dir / "args"
|
||||
self.vr_helper('echo "$@" > %s\n' % log)
|
||||
self.assertTrue(self.ask({"kind": "vr", "action": "start"})["ok"])
|
||||
self.assertEqual("start", log.read_text().strip())
|
||||
answer = self.ask({"kind": "vr", "action": "rm -rf /"})
|
||||
self.assertFalse(answer["ok"])
|
||||
self.assertEqual("INVALID_REQUEST", answer["error"]["code"])
|
||||
|
||||
def test_vr_without_a_helper_is_unavailable(self):
|
||||
os.environ["DROIDDECK_VR_HELPER"] = str(self.dir / "missing")
|
||||
self.addCleanup(os.environ.pop, "DROIDDECK_VR_HELPER")
|
||||
answer = self.ask({"kind": "vr", "action": "status"})
|
||||
self.assertEqual("UNAVAILABLE", answer["error"]["code"])
|
||||
|
||||
def test_exec_output_and_status(self):
|
||||
answer = self.ask({"kind": "exec", "argv": ["sh", "-c", "echo out; echo err >&2; exit 3"], "env": {"X": "1"}})
|
||||
self.assertTrue(answer["ok"])
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
PRELOAD = Path(__file__).resolve().parents[1] / 'linuxfs' / 'preload'
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform == 'linux' and shutil.which('gcc'), 'needs Linux and gcc')
|
||||
class SysvPreloadTest(unittest.TestCase):
|
||||
def test_semop_sets_otime_for_waiters(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
binary = str(Path(folder) / 'test-sysv')
|
||||
subprocess.run(['gcc', '-Wall', '-Wextra', '-O2', '-pthread', '-o', binary,
|
||||
str(Path(__file__).resolve().parent / 'sysv_otime_harness.c'), str(PRELOAD / 'sysv.c')], check=True)
|
||||
env = dict(os.environ, BL_SYSV_DIR=folder)
|
||||
result = subprocess.run([binary], capture_output=True, text=True, timeout=10, env=env)
|
||||
self.assertIn('PASS: sysv otime', result.stdout, result.stdout + result.stderr)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user