Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
410c505099 | ||
|
|
50924ddd5c | ||
|
|
20296a7913 | ||
|
|
1ea133c5e2 | ||
|
|
6b4aa7460e | ||
|
|
5e1998c28a | ||
|
|
88d2e03f49 | ||
|
|
b5d5a5928c | ||
|
|
7ad6a2451f | ||
|
|
0e20f5bfae | ||
|
|
c01de0a3d2 | ||
|
|
6b58b63a33 | ||
|
|
9d0bbdc357 | ||
|
|
0aaf736b48 | ||
|
|
3149ced724 | ||
|
|
b71a1eddf5 | ||
|
|
392ed5c4dd | ||
|
|
cd9b3fc031 | ||
|
|
706f76b18d | ||
|
|
14089200ab | ||
|
|
4f00287c6e | ||
|
|
eda77c9273 | ||
|
|
2dd6f0e6f9 | ||
|
|
53d2079801 | ||
|
|
78b449e84b | ||
|
|
6cabcfb047 | ||
|
|
fc56ced616 | ||
|
|
1edae28630 | ||
|
|
91953fbef7 | ||
|
|
5c60d70d24 | ||
|
|
796ec69728 | ||
|
|
23689abaa7 | ||
|
|
22a819b8c8 | ||
|
|
b2f95938e6 | ||
|
|
36a0377dc8 | ||
|
|
fb7703cb76 | ||
|
|
456d65ef8c | ||
|
|
902a665c36 | ||
|
|
a491561271 | ||
|
|
78d7fc40f2 | ||
|
|
7164a7dbeb | ||
|
|
45907329c7 | ||
|
|
515010aeab | ||
|
|
caa191ff06 | ||
|
|
78addc1f22 | ||
|
|
26f21348f3 | ||
|
|
7d9031e843 | ||
|
|
79df7370f3 | ||
|
|
2b7409b363 | ||
|
|
b3b2c49da4 | ||
|
|
13a94f3dec | ||
|
|
94ef8945cc | ||
|
|
02d06562a6 | ||
|
|
9690633030 | ||
|
|
bc115b9969 | ||
|
|
be75748d5c | ||
|
|
0ad6cf0507 | ||
|
|
8a4edf46af | ||
|
|
33fac50895 | ||
|
|
6859db7c34 | ||
|
|
f32d6f4710 | ||
|
|
dfa0fff46d | ||
|
|
65cc572fde | ||
|
|
ce3e54b2d0 | ||
|
|
822f28ab23 | ||
|
|
3ac94dc320 | ||
|
|
7f5d254d8e | ||
|
|
51855e195c | ||
|
|
34ce871f2d | ||
|
|
4a1c58a137 | ||
|
|
1903d5c910 | ||
|
|
b96833cc9b | ||
|
|
93ee0cc577 | ||
|
|
9a2f31e011 | ||
|
|
b5e93607df | ||
|
|
9a81bc8213 | ||
|
|
a823df96d3 | ||
|
|
c44940d004 | ||
|
|
7d11674b2a | ||
|
|
adf4b1fc84 | ||
|
|
5b6e172b41 | ||
|
|
a8504545e9 | ||
|
|
e81393fe87 | ||
|
|
bfe44c6b8d | ||
|
|
9df870a7fa | ||
|
|
8a7cc105cb | ||
|
|
1e6937d4a4 | ||
|
|
0f21191e9b | ||
|
|
6254386370 | ||
|
|
e32d3bbf36 | ||
|
|
63cb9ff179 | ||
|
|
a16a0df1c0 | ||
|
|
f476f9a1db | ||
|
|
ea84391ba3 | ||
|
|
71ee653312 | ||
|
|
19ac929be9 | ||
|
|
4ff91f1e13 | ||
|
|
e837396944 | ||
|
|
51ee0b46ac | ||
|
|
eddda44def | ||
|
|
f8a6db5834 | ||
|
|
42c64a6569 | ||
|
|
b4349767ce | ||
|
|
b8e9c79180 | ||
|
|
df6667fd0d | ||
|
|
7732dc87df | ||
|
|
1f42c0cfb8 | ||
|
|
01caa4e7c5 | ||
|
|
e97618e99e | ||
|
|
a651f1b252 | ||
|
|
31e98fceab | ||
|
|
07f50572ea | ||
|
|
a94edf52e2 | ||
|
|
6b9e1e108c | ||
|
|
749649d868 | ||
|
|
9353646b55 | ||
|
|
219146e763 | ||
|
|
6c202db59e | ||
|
|
df76543fb7 | ||
|
|
b09af79edc | ||
|
|
627e87c144 | ||
|
|
66a56dac82 | ||
|
|
1158afdad5 | ||
|
|
b5d4f67860 | ||
|
|
067d3a7679 | ||
|
|
fc5f0b9c6c | ||
|
|
17bae9459a | ||
|
|
b80814adb5 | ||
|
|
bb6280a9c3 | ||
|
|
a1dad6962c | ||
|
|
ed433905c0 | ||
|
|
2d45d53cc7 | ||
|
|
4cd6862c1a | ||
|
|
b34aa59876 | ||
|
|
2f54a74b05 | ||
|
|
0b7cf25a93 | ||
|
|
3bbaf8b8e2 | ||
|
|
fe46fc4545 | ||
|
|
5d1ba50e92 | ||
|
|
74946403f0 | ||
|
|
9af70baa58 | ||
|
|
c0a061b4be | ||
|
|
c19056498d | ||
|
|
6f6ccefbf3 | ||
|
|
06d771b89e | ||
|
|
50ae773fec | ||
|
|
6cf46a6b73 | ||
|
|
f0e3e8d4ad | ||
|
|
399477edf5 | ||
|
|
0ec0de4509 | ||
|
|
a8657f7f91 | ||
|
|
87b11d6817 | ||
|
|
6ccf6eaf26 | ||
|
|
375d06dee2 | ||
|
|
6b407a2d1c | ||
|
|
a712eec83a | ||
|
|
be96c4da4f | ||
|
|
8b4b021048 | ||
|
|
a610fef6ac | ||
|
|
d81734f7e2 | ||
|
|
7166e06ada | ||
|
|
e1392fef3a | ||
|
|
1a3a81201b | ||
|
|
5ac1e06291 | ||
|
|
915aed8df1 | ||
|
|
3acf9f26f2 | ||
|
|
1398b9ebfd | ||
|
|
5d87ce04fc | ||
|
|
a9b065df55 | ||
|
|
994f67d5fe | ||
|
|
e1c12b8720 | ||
|
|
9e8f231714 | ||
|
|
3fc3dfa575 | ||
|
|
ab7e497735 | ||
|
|
6d49f409ad | ||
|
|
2ec78da729 | ||
|
|
bb92a5e388 | ||
|
|
2fdb21ed68 | ||
|
|
e46e8f26b4 | ||
|
|
a8148378d9 | ||
|
|
48c480e303 | ||
|
|
edf00c5f35 | ||
|
|
fe64caf273 | ||
|
|
363b487d74 | ||
|
|
3285a485e8 | ||
|
|
dec566f3d2 | ||
|
|
628a19a3e1 | ||
|
|
e878896595 | ||
|
|
30fddf7518 | ||
|
|
67f4ced505 | ||
|
|
02b212483c | ||
|
|
25f7a3dddb | ||
|
|
6bb842cc2d | ||
|
|
5837fa3a12 | ||
|
|
bd7fd535fe | ||
|
|
829d7c0b7a | ||
|
|
3a1f47285a | ||
|
|
cda9595a27 | ||
|
|
ead0150932 | ||
|
|
c0b78c1ec4 | ||
|
|
c693993748 | ||
|
|
6961485430 | ||
|
|
0d5aa4d887 | ||
|
|
542b9822cf | ||
|
|
ef21074d29 | ||
|
|
d5e4e3cfce | ||
|
|
18b00fde24 | ||
|
|
5aa90f5d0a | ||
|
|
e3b4dfd29a | ||
|
|
7ae5dd2921 | ||
|
|
7e50e6a38f | ||
|
|
370b7e87a8 | ||
|
|
6afa5fc67f | ||
|
|
bd264e23b6 | ||
|
|
2919f7d820 | ||
|
|
f6d151c040 | ||
|
|
0efa540ce0 | ||
|
|
f3cfa0d747 | ||
|
|
2d8c5002ec | ||
|
|
3d24faa47a | ||
|
|
2d400d9314 | ||
|
|
30f472bdb4 | ||
|
|
f5597a81fd | ||
|
|
47d7322070 | ||
|
|
3f58345cf0 | ||
|
|
fc01002317 | ||
|
|
0a71756024 | ||
|
|
4e3eff6505 | ||
|
|
25c2449a5e | ||
|
|
97d6a19199 | ||
|
|
254f32b262 | ||
|
|
c846cb1ed2 | ||
|
|
20a81ed004 | ||
|
|
6fcc19d198 | ||
|
|
cd614c2361 | ||
|
|
4831e8847d | ||
|
|
2ee3306d6a | ||
|
|
2893ab857d | ||
|
|
94457a566a | ||
|
|
740b255461 | ||
|
|
cc773294e3 | ||
|
|
514c44b0a1 | ||
|
|
5e4108f1c1 | ||
|
|
62a626e35e | ||
|
|
e06d0d0943 | ||
|
|
b632502da5 | ||
|
|
25a532bc15 | ||
|
|
70adbafdc9 | ||
|
|
317cd6bb91 | ||
|
|
3702cc05b8 | ||
|
|
eeb624875e | ||
|
|
a49cc3dea8 | ||
|
|
cd8abacd7b | ||
|
|
6a49861b50 | ||
|
|
061039b645 | ||
|
|
f963d336ab | ||
|
|
bf0a1bc184 | ||
|
|
cdc4a8f3d6 | ||
|
|
5bb7310093 | ||
|
|
1de1b19201 | ||
|
|
ae740acbb5 | ||
|
|
f58f9c7e0b | ||
|
|
0b134102d2 | ||
|
|
7870cc6484 | ||
|
|
43bbb8b0f8 | ||
|
|
2c9928db63 | ||
|
|
81363b3602 | ||
|
|
a291226a46 | ||
|
|
2e1e5571d6 | ||
|
|
d6768d59a7 | ||
|
|
12cddd4d6f | ||
|
|
b284daca6a | ||
|
|
d4854d77b0 | ||
|
|
caba985ce1 | ||
|
|
26bdd6e85b | ||
|
|
867c78d826 | ||
|
|
1e488a8a9c | ||
|
|
6be85971ea | ||
|
|
fe8c320d67 | ||
|
|
eb99b474ae | ||
|
|
857e5fce2c | ||
|
|
f383eb8e8d | ||
|
|
a3c7a604e0 | ||
|
|
416297f232 | ||
|
|
205c84b273 | ||
|
|
727d4fab4d | ||
|
|
21c04be1f8 | ||
|
|
08ebe00a4d | ||
|
|
1c3b6dd2e3 | ||
|
|
9df93b2cad | ||
|
|
1ec4340c74 | ||
|
|
6356f37f4d | ||
|
|
c217577b81 | ||
|
|
ea7ab55198 | ||
|
|
01bc6e8804 | ||
|
|
0393f7cb07 | ||
|
|
e41410bcc9 | ||
|
|
dce89d655f | ||
|
|
832df65d17 | ||
|
|
d1d6c343a3 | ||
|
|
3df615cb8a | ||
|
|
2e1ed8d87e | ||
|
|
9d8f64e6f2 | ||
|
|
da9392c791 | ||
|
|
291ab85bd6 | ||
|
|
1e2823c019 | ||
|
|
1a35e1f7fc | ||
|
|
f4c4021e20 | ||
|
|
6fc48c7d4f | ||
|
|
52eef0e02e | ||
|
|
2095ab6f7e | ||
|
|
65a02bb04f | ||
|
|
fc6fcda0cd | ||
|
|
366792cf46 | ||
|
|
a1f186eb23 | ||
|
|
8940220fc2 | ||
|
|
4c2e24536d | ||
|
|
172ef89dea | ||
|
|
bb4d12ef33 | ||
|
|
06ad530e2f | ||
|
|
a32a4e4182 | ||
|
|
5329bfd28c | ||
|
|
e4df4191ce | ||
|
|
f89606f8a9 | ||
|
|
d43d864dee | ||
|
|
2b9e267fc8 | ||
|
|
24faf2cd3b | ||
|
|
8e7192c767 | ||
|
|
2585754497 | ||
|
|
c16478b940 | ||
|
|
c0532ce6e4 | ||
|
|
ba3d582c92 | ||
|
|
741298be97 | ||
|
|
e6e32ce39d | ||
|
|
0d865ffc14 | ||
|
|
e46c317f87 | ||
|
|
340c0d546b | ||
|
|
ad31a8dfcc | ||
|
|
e1d5f0e636 | ||
|
|
225a0db69e | ||
|
|
f340dc5940 | ||
|
|
2057aff195 | ||
|
|
7587b6ae84 | ||
|
|
5a669e71f5 | ||
|
|
6f32f049d7 | ||
|
|
9b4a26b5a8 | ||
|
|
db345c832d | ||
|
|
0b526cef9d | ||
|
|
e0cbd202a8 | ||
|
|
b2f3b925d9 | ||
|
|
5ab7731be3 | ||
|
|
5c50b9a1ad | ||
|
|
bf811ac65d | ||
|
|
099d68a83d | ||
|
|
db622b4252 | ||
|
|
6638cefb37 | ||
|
|
740dcfdcfb | ||
|
|
281dd6000e | ||
|
|
bd907d8496 | ||
|
|
854e4c7b57 | ||
|
|
e394cb0dcb | ||
|
|
4553379d74 | ||
|
|
ca45eed21e | ||
|
|
fad0a8feee | ||
|
|
bb07e5afd7 | ||
|
|
0a2c374b52 | ||
|
|
fadaf7600a | ||
|
|
afc9766840 | ||
|
|
2c7812069e | ||
|
|
007aed6310 | ||
|
|
aef6c1bced | ||
|
|
8874ea8753 | ||
|
|
d1308bfbb8 | ||
|
|
a37498eedf | ||
|
|
24380867d4 | ||
|
|
f2a202f29d | ||
|
|
831bdf7a29 | ||
|
|
53d94d6c04 | ||
|
|
b1aaeb78e8 | ||
|
|
51d8742029 | ||
|
|
ac0a926811 | ||
|
|
a4e5475ff7 | ||
|
|
804f85e7b8 | ||
|
|
eadd9a1813 | ||
|
|
f0ab1284f3 | ||
|
|
fc4a2bf49d | ||
|
|
e94901043b | ||
|
|
3cf46e03e3 | ||
|
|
f12ebe14bc | ||
|
|
85cde18718 | ||
|
|
23b643422b | ||
|
|
c183857113 | ||
|
|
c05104ba82 | ||
|
|
9eb3ecb4d5 | ||
|
|
ab2ee24e90 | ||
|
|
20cf6ea2e0 | ||
|
|
3621404e71 | ||
|
|
e51d653bd7 | ||
|
|
3afed5549e | ||
|
|
6317d77dba | ||
|
|
6f50ba3979 | ||
|
|
f99fb8fa18 | ||
|
|
ab82fb5866 | ||
|
|
91a41b306e | ||
|
|
8d531cbc53 | ||
|
|
b907eb63ad | ||
|
|
8e60a03aaf | ||
|
|
a8fa6c3961 | ||
|
|
3f37bd7570 | ||
|
|
6cd65de21d | ||
|
|
34a4ffcb59 | ||
|
|
5bdcf783cf | ||
|
|
1939ed027c | ||
|
|
6273a54776 | ||
|
|
658d4997f2 | ||
|
|
f28d70e7b3 | ||
|
|
bc1c0b9e93 | ||
|
|
7c2057ec9e | ||
|
|
01c4f0343a | ||
|
|
aff498bc2d | ||
|
|
9a55178b41 | ||
|
|
ead740a8d5 | ||
|
|
60563ef0de | ||
|
|
c31d3537d8 | ||
|
|
518d4b24d0 | ||
|
|
59cab00c52 | ||
|
|
65894401c1 | ||
|
|
231e4c1cc0 | ||
|
|
91c72de89c | ||
|
|
2264b68553 | ||
|
|
0b368aed08 | ||
|
|
3ba9fae20d | ||
|
|
7bcad7804b | ||
|
|
b5e59dabfa | ||
|
|
98bb0c56c5 | ||
|
|
9edb8fd2ae | ||
|
|
1393ff0f11 | ||
|
|
bca2e29dd8 | ||
|
|
1e1c6c4075 | ||
|
|
ec88bbf8b0 | ||
|
|
f8ca5a9161 | ||
|
|
6a6a8ad473 | ||
|
|
5caebf6067 | ||
|
|
e9b8fddac1 | ||
|
|
c0cfcbecc7 | ||
|
|
feecb97214 | ||
|
|
fd514bda6a | ||
|
|
f5f917dfe0 | ||
|
|
2dd07da12d | ||
|
|
33e8016048 | ||
|
|
11abd8d9fe | ||
|
|
2e9c380f78 | ||
|
|
ee8d6229b3 | ||
|
|
fb3f7a1599 | ||
|
|
57ba039f51 | ||
|
|
186362f4f5 | ||
|
|
f880a987b2 | ||
|
|
1af4ae760c | ||
|
|
673d55e8a7 | ||
|
|
8c131c7ef4 | ||
|
|
e1ecca7e0a | ||
|
|
a08d35d404 | ||
|
|
114f15c4f3 | ||
|
|
6a40aa46f4 | ||
|
|
59281c970b | ||
|
|
c12d16ef86 | ||
|
|
1f3e7d7b86 | ||
|
|
4edac2143f | ||
|
|
3e8a78002e | ||
|
|
a9907e0810 | ||
|
|
c3b4ebd446 | ||
|
|
f26bf12c38 | ||
|
|
85fb560ad1 | ||
|
|
eb3b89dc21 | ||
|
|
015b242e27 | ||
|
|
68f6bf5e48 | ||
|
|
2063cae3ae | ||
|
|
efde4bf247 | ||
|
|
ffd5cf882a | ||
|
|
d79ee4c43b | ||
|
|
286278dde0 | ||
|
|
c1be3d08af | ||
|
|
c83956748d | ||
|
|
09031b9aa5 | ||
|
|
1d481f7b77 | ||
|
|
87d024e78b | ||
|
|
b1a325c102 | ||
|
|
5337af4c56 | ||
|
|
793b0c8d81 | ||
|
|
99b883d747 | ||
|
|
39d50479b1 | ||
|
|
0ffd998896 | ||
|
|
391f69ba17 | ||
|
|
59e3d41305 | ||
|
|
dee36472ef | ||
|
|
24847eb88f | ||
|
|
234ce61e23 | ||
|
|
dcf44dbf9b | ||
|
|
23d7067985 | ||
|
|
46b6f39a41 | ||
|
|
f5393d4fae | ||
|
|
6656547e6b | ||
|
|
7b23715310 | ||
|
|
78ee60620a | ||
|
|
12ecede0e7 | ||
|
|
a971949c9b | ||
|
|
4e296d780a | ||
|
|
6e4f69b327 | ||
|
|
775f386db6 | ||
|
|
09e787493c | ||
|
|
c9f8e6a542 | ||
|
|
2696fa3b24 | ||
|
|
5d0b87afce | ||
|
|
b383aa4c20 | ||
|
|
a67673327b | ||
|
|
c4265d80a5 | ||
|
|
dd874eea4b | ||
|
|
b9c1320823 | ||
|
|
833e405060 | ||
|
|
e6c8488283 | ||
|
|
505de3d625 | ||
|
|
631025a513 | ||
|
|
c0dc193247 | ||
|
|
aa3a1808f8 | ||
|
|
07bc8c9bac | ||
|
|
e23b571d7e | ||
|
|
7e014a7a33 | ||
|
|
6553036a73 | ||
|
|
a4201481aa | ||
|
|
209acc793d | ||
|
|
16076a05c8 | ||
|
|
3c91e4eca8 | ||
|
|
1635bdabce | ||
|
|
4908f50a00 | ||
|
|
442e09dcfc | ||
|
|
855539fab0 | ||
|
|
ba39b4da0b | ||
|
|
13ff9231f0 | ||
|
|
1696512385 | ||
|
|
4604b061d7 | ||
|
|
2204fdd396 | ||
|
|
7bf9bac094 | ||
|
|
38e345025e | ||
|
|
e7c0c008a3 | ||
|
|
c2c70e0469 | ||
|
|
b687f83950 | ||
|
|
9b6531908c | ||
|
|
9b9a7b6f3f | ||
|
|
c7b94b6524 | ||
|
|
93bf067139 | ||
|
|
b6b3a4da80 | ||
|
|
41abd36e33 | ||
|
|
725aa9d9a8 | ||
|
|
24d718f916 | ||
|
|
bdec1f85cd | ||
|
|
7e5b9a7e4f | ||
|
|
de32f6e24f | ||
|
|
4adfe21987 | ||
|
|
149de4eeab | ||
|
|
cb1d0d7c2c | ||
|
|
33a5bf7494 | ||
|
|
f1b80a1ebd | ||
|
|
038622fd46 | ||
|
|
a9ad5195b7 | ||
|
|
7d76367d2c | ||
|
|
1e03b6e672 | ||
|
|
a9f774c67c | ||
|
|
7963efc034 | ||
|
|
17ac7ab7d9 | ||
|
|
b8c08f1feb | ||
|
|
045036f3a2 | ||
|
|
9fe7c5829b | ||
|
|
52be025d51 | ||
|
|
e584d9607f | ||
|
|
aad1bb6a1b | ||
|
|
1f6ea0d4ca | ||
|
|
e526d572c2 | ||
|
|
e0ff42800f | ||
|
|
7243092682 | ||
|
|
be6028982e | ||
|
|
8854b1b548 | ||
|
|
fb509361b6 | ||
|
|
60226e5346 | ||
|
|
a90ee6a018 | ||
|
|
44a5a889e1 | ||
|
|
61c5c871c1 | ||
|
|
50e1ecab37 | ||
|
|
b1ee9bad47 | ||
|
|
0e5b339b68 | ||
|
|
219d251d1b | ||
|
|
ab2671633a | ||
|
|
51c25624b7 | ||
|
|
275a8195eb | ||
|
|
4061119aef | ||
|
|
3e0f6bf6fa | ||
|
|
1dd0ed4fe3 | ||
|
|
56f32f4ae6 | ||
|
|
e3f35aad54 | ||
|
|
c1111fe036 | ||
|
|
14333ce208 | ||
|
|
2d5b619429 | ||
|
|
38efb9ff28 | ||
|
|
12e3df5b9c | ||
|
|
56a94bfc10 | ||
|
|
19d46db554 | ||
|
|
c6e05754c8 | ||
|
|
26f087c906 | ||
|
|
903a02d881 | ||
|
|
1365f4f527 | ||
|
|
cb7e6dabfc | ||
|
|
e4acf2401e | ||
|
|
5f373460a1 | ||
|
|
25a81b6f5f | ||
|
|
70ec7acbec | ||
|
|
421d935dde | ||
|
|
7ea256a4c2 | ||
|
|
db91edf4c1 | ||
|
|
aca45420dd | ||
|
|
98fc4ad4bb | ||
|
|
8e4e4c9596 | ||
|
|
34494f18e6 | ||
|
|
f4d66eb4e7 | ||
|
|
39b7c6c45a | ||
|
|
b81d010841 | ||
|
|
db70d3975c | ||
|
|
64355ff916 | ||
|
|
ed51bcc3b6 | ||
|
|
4baa98c8f1 | ||
|
|
4516beb2a5 | ||
|
|
092dbc893d | ||
|
|
2c1996eca1 | ||
|
|
fb3786fc2d | ||
|
|
190f4ae8bb | ||
|
|
79a34bcdd5 | ||
|
|
0ec2cd5a3e | ||
|
|
db66b0dbb7 | ||
|
|
ba18eac4a7 | ||
|
|
b0573c4265 | ||
|
|
46a36fcd55 | ||
|
|
a5bb9c2678 | ||
|
|
5b6e20bdbe | ||
|
|
1667065084 | ||
|
|
67918b7fe7 | ||
|
|
f03c460aa6 | ||
|
|
e7c69e9464 | ||
|
|
6e64dd03b3 | ||
|
|
7fb8f4c1a8 | ||
|
|
fcbdda9908 | ||
|
|
4e5eca204f | ||
|
|
6932f9461d | ||
|
|
7861d508c7 | ||
|
|
1290a15b7f | ||
|
|
5873de80b8 | ||
|
|
66ca73981d | ||
|
|
a193b4084c | ||
|
|
f159e58c12 | ||
|
|
8bc6a3f388 | ||
|
|
e3356acc16 | ||
|
|
6e9afab96b | ||
|
|
13c7f8fbc2 | ||
|
|
668a94bae0 | ||
|
|
d8707e0b4c | ||
|
|
6f696a92fb | ||
|
|
3e6c407406 | ||
|
|
98347fc832 | ||
|
|
6ddde98714 | ||
|
|
1477120888 | ||
|
|
5edc7f2f56 | ||
|
|
b411afb946 | ||
|
|
f33dc57ec9 | ||
|
|
509311604c | ||
|
|
88ae120c52 | ||
|
|
ea54031627 | ||
|
|
8b9beb272d | ||
|
|
0e5a09cc45 | ||
|
|
b0144b96fc | ||
|
|
3269fecef2 | ||
|
|
7e2b0cb973 | ||
|
|
608cf0c7b2 | ||
|
|
bd820a4f4a | ||
|
|
891a087ccc | ||
|
|
adc07e8f50 | ||
|
|
200586a0af | ||
|
|
80933a3392 | ||
|
|
3c08a3de2f | ||
|
|
ccf430d26a | ||
|
|
5405176890 | ||
|
|
b1c7160bba | ||
|
|
9a5af1a0ca | ||
|
|
6b99cf4cc3 | ||
|
|
cc5990a513 | ||
|
|
c80ba550eb | ||
|
|
9186bafd28 | ||
|
|
633f7feeb1 | ||
|
|
435c2be127 | ||
|
|
692d4dec04 | ||
|
|
5ff85ef7a7 | ||
|
|
74ff55d5cb | ||
|
|
f97c241f9f | ||
|
|
9f2aa0157c | ||
|
|
2f91217e02 | ||
|
|
d4665eb713 | ||
|
|
8f8e583eb6 | ||
|
|
05c8de4733 | ||
|
|
90fa63a8fb | ||
|
|
33f343e454 | ||
|
|
cdd6064f2f | ||
|
|
d8d623fd7b | ||
|
|
dd7bd8469e | ||
|
|
348a5a8313 | ||
|
|
66b7b1fabb | ||
|
|
aade274777 | ||
|
|
b5c94c24a4 | ||
|
|
211922ea02 | ||
|
|
959661c830 | ||
|
|
4a2c83a70d | ||
|
|
b5e5586ef6 | ||
|
|
bebd2cd97e | ||
|
|
fadec7a7a0 | ||
|
|
87b68aaa7b | ||
|
|
1e6d8b5a95 | ||
|
|
8dd3c75139 | ||
|
|
ec4a95efb2 | ||
|
|
1390ade131 | ||
|
|
d18d33a615 | ||
|
|
1574f82b8e | ||
|
|
a82ee8c038 | ||
|
|
5c397e125c | ||
|
|
48c9bf0726 | ||
|
|
cb5a7ad9cd | ||
|
|
ae75d95d7c | ||
|
|
68edc66fb7 | ||
|
|
d2ea30e70f | ||
|
|
9f80c1da7c | ||
|
|
4b8295b7c7 | ||
|
|
1e37261cfa | ||
|
|
0acfe7cd24 | ||
|
|
5f6641c38f | ||
|
|
c2f23223a2 | ||
|
|
94aceb3f0f | ||
|
|
bce3e498e8 | ||
|
|
b9052c6ebb | ||
|
|
c15de9bf27 | ||
|
|
dc04f7edcc | ||
|
|
b1d6d50a4a | ||
|
|
5784cbd4fa | ||
|
|
757e0fd97b | ||
|
|
31c347475e | ||
|
|
6d0cc60626 | ||
|
|
50c44c8422 | ||
|
|
a5b3178f36 | ||
|
|
49ab1af542 | ||
|
|
c7fc144a66 | ||
|
|
c8b8d798d1 | ||
|
|
5e4edc9857 | ||
|
|
461de7c540 | ||
|
|
a2e470799e | ||
|
|
d2191a354e |
@@ -106,6 +106,6 @@ SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
Standard: Latest
|
||||
TabWidth: 8
|
||||
UseTab: ForIndentation
|
||||
|
||||
@@ -36,17 +36,33 @@ body:
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: Installation method
|
||||
description: Describe how WiVRn and OpenComposite/xrizer were installed
|
||||
placeholder: flatpak --user, flatpak, AUR, Gentoo/Guru, built from sources...
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Server Config
|
||||
description: Provide the content of `config.json` for the server.
|
||||
placeholder: Add the content of config.json here...
|
||||
description: |
|
||||
Provide the content of `config.json` for the server.
|
||||
Located in `${XDG_CONFIG_HOME-${HOME}/.config}/wivrn/config.json`
|
||||
or `~/.var/app/io.github.wivrn.wivrn/config/wivrn/config.json` for the flatpak version
|
||||
placeholder: |
|
||||
{
|
||||
"encoders": [
|
||||
{"codec": "h264"}
|
||||
]
|
||||
}
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Server Logs
|
||||
description: Provide the `wivrn-server` output.
|
||||
placeholder: Add the output of the wivrn-server here...
|
||||
placeholder: |
|
||||
Add the output of the wivrn-server here.
|
||||
If more than a few lines, prefer file attachment.
|
||||
|
||||
- type: dropdown
|
||||
id: gpu
|
||||
@@ -64,7 +80,8 @@ body:
|
||||
attributes:
|
||||
label: Vulkan Info
|
||||
description: Provide the output of `vulkaninfo --summary` command.
|
||||
placeholder: Add the output of vulkaninfo command here...
|
||||
render: text
|
||||
placeholder: Attach the output as a file here.
|
||||
|
||||
- type: dropdown
|
||||
id: hmd
|
||||
@@ -90,4 +107,5 @@ body:
|
||||
attributes:
|
||||
label: ADB Logs
|
||||
description: Provide the output of `adb logcat` command.
|
||||
placeholder: Add the output of adb logcat command here...
|
||||
render: plain
|
||||
placeholder: Attach the output of adb logcat as a file.
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
# Disable hand tracking
|
||||
set left hand_tracking_active false
|
||||
set right hand_tracking_active false
|
||||
|
||||
# Reset positions
|
||||
set head position 0.0 1.5 0.2
|
||||
set head rotation 0.0 0.0 0.0 1.0
|
||||
set left position -0.2 1.3 -0.3
|
||||
set left rotation 0.4 0 0 0.9
|
||||
set right position 0.2 1.3 -0.3
|
||||
set right rotation 0.4 0 0 0.9
|
||||
|
||||
# Server list
|
||||
set right direction -1.8 1.55 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 1
|
||||
exec grim -g "0,0 2560x1440" ${LANG}/screenshot-01-list.png
|
||||
|
||||
|
||||
# Connect to the first server
|
||||
set right direction 0.2 1.42 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 5
|
||||
exec grim -g "0,0 2560x1440" ${LANG}/screenshot-02-connect.png
|
||||
|
||||
# Cancel
|
||||
set right direction -0.3 1.25 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 1
|
||||
|
||||
|
||||
# Add server
|
||||
set right direction -1.45 1.55 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 1
|
||||
set right rotation 0.4 0 0 0.9
|
||||
|
||||
set head position 0.0 1.5 0.5
|
||||
set left position -0.2 1.4 0.2
|
||||
set left direction -0.1 -0.3 -1
|
||||
set right position 0.2 1.4 0.2
|
||||
set right direction -0.1 -0.3 -1
|
||||
|
||||
sleep 1
|
||||
exec grim -g "0,0 2560x1440" ${LANG}/screenshot-03-add-server.png
|
||||
set head position 0.0 1.5 0.2
|
||||
set left position -0.2 1.3 -0.3
|
||||
set left rotation 0.4 0 0 0.9
|
||||
set right position 0.2 1.3 -0.3
|
||||
set right rotation 0.4 0 0 0.9
|
||||
|
||||
|
||||
# Cancel
|
||||
set right direction -2.2 1.05 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 1
|
||||
|
||||
|
||||
# Settings
|
||||
set right direction -1.9 1.5 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 1
|
||||
set right rotation 0.4 0 0 0.9
|
||||
sleep 1
|
||||
exec grim -g "0,0 2560x1440" ${LANG}/screenshot-04-settings.png
|
||||
|
||||
# Post-processing
|
||||
set right direction -1.95 1.45 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 1
|
||||
set right rotation 0.4 0 0 0.9
|
||||
sleep 1
|
||||
exec grim -g "0,0 2560x1440" ${LANG}/screenshot-07-post-processing.png
|
||||
|
||||
# About
|
||||
set right direction -2.4 0.45 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 1
|
||||
set right rotation 0.4 0 0 0.9
|
||||
sleep 1
|
||||
exec grim -g "0,0 2560x1440" ${LANG}/screenshot-05-about.png
|
||||
|
||||
# Licences
|
||||
set right direction -2.4 0.32 -1
|
||||
sleep 1
|
||||
set right trigger_value 1
|
||||
sleep 1
|
||||
set right trigger_value 0
|
||||
sleep 1
|
||||
exec grim -g "0,0 2560x1440" ${LANG}/screenshot-06-licence.png
|
||||
@@ -2,42 +2,111 @@ name: Release APK Only
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
branches: [ "apk-build" ]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
|
||||
jobs:
|
||||
build-steam-frame:
|
||||
name: Steam Frame
|
||||
runs-on: ubuntu-24.04-arm
|
||||
if: ${{ vars.APK_ONLY != '' }}
|
||||
container:
|
||||
image: registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk/arm64:4.0.20260805.254769
|
||||
volumes:
|
||||
- ${{github.workspace}}/install:/tmp/install
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
repository: 'gitea/WiVRn'
|
||||
ref: ${{ github.sha }}
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Apt dependencies
|
||||
uses: awalsh128/cache-apt-pkgs-action@v1.6.1
|
||||
with:
|
||||
packages: librsvg2-bin npm
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
||||
with:
|
||||
key: steam-frame
|
||||
job-summary: ""
|
||||
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
key: cmake-frame
|
||||
path: |
|
||||
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
|
||||
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
|
||||
${{github.workspace}}/cmake-fetch/*.tar.*
|
||||
${{github.workspace}}/cmake-fetch/*.tgz
|
||||
${{github.workspace}}/cmake-fetch/*-src/.git
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-arm64.deb
|
||||
sudo dpkg --install KTX-Software-4.4.2-Linux-arm64.deb
|
||||
npm install --global @gltf-transform/cli@4.1.1
|
||||
|
||||
- name: Configure CMake
|
||||
run: >
|
||||
cmake -B "$GITHUB_WORKSPACE/build"
|
||||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
-DWIVRN_CSS=${{env.CSS}}
|
||||
-DFETCHCONTENT_BASE_DIR="$GITHUB_WORKSPACE/cmake-fetch"
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
-DCMAKE_INSTALL_PREFIX=/usr
|
||||
--preset frame
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
cd "$GITHUB_WORKSPACE/build"
|
||||
DESTDIR="$GITHUB_WORKSPACE/install" ninja install
|
||||
|
||||
- name: Archive
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: wivrn-frame-client.zip
|
||||
path: install/usr
|
||||
if-no-files-found: error
|
||||
retention-days: 30
|
||||
|
||||
build-android-only:
|
||||
name: Android
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
if: ${{ vars.APK_ONLY != '' }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hmd: ['Standard']
|
||||
buildtype: ['Release', 'Debug', 'DebugWithValidationLayer']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
# Checkout from upstream instead of WiVRn-APK to ensure the GIT_DESC variable is set correctly
|
||||
repository: 'WiVRn/WiVRn'
|
||||
repository: 'gitea/WiVRn'
|
||||
ref: ${{ github.sha }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/setup-vulkan-sdk@286ed76c72de45dbf50c515779cf4ca2f6aa3944
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
vulkan-query-version: 1.3.296.0
|
||||
vulkan-components: Glslang, SPIRV-Tools
|
||||
vulkan-use-cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install glslang-tools librsvg2-bin gettext
|
||||
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.3.2/KTX-Software-4.3.2-Linux-x86_64.deb
|
||||
sudo dpkg --install KTX-Software-4.3.2-Linux-x86_64.deb
|
||||
sudo apt-get update && sudo apt-get install glslang-tools librsvg2-bin gettext npm
|
||||
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.0/KTX-Software-4.4.0-Linux-x86_64.deb
|
||||
sudo dpkg --install KTX-Software-4.4.0-Linux-x86_64.deb
|
||||
npm install --global @gltf-transform/cli@4.1.1
|
||||
|
||||
- name: Check for Secret availability
|
||||
id: secret-check
|
||||
@@ -60,10 +129,8 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
sudo rm /usr/local/bin/cmake
|
||||
"${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" --install "cmake;3.30.3"
|
||||
chmod +x gradlew
|
||||
./gradlew -Psuffix=".github.nightly" -Pwivrn_css=images/wivrn-nightly.css -Pwivrn_app_name="WiVRn Nightly" assemble${{ matrix.hmd }}${{ matrix.buildtype }}
|
||||
./gradlew -Psuffix=".github.nightly" -Pwivrn_css=images/wivrn-nightly.css -Pwivrn_app_name="WiVRn Nightly" -Pwivrn_compress_glb=ON assemble${{ matrix.buildtype }}
|
||||
|
||||
- name: Prepare before archiving artifacts
|
||||
run: |
|
||||
@@ -76,7 +143,7 @@ jobs:
|
||||
- name: Archive APK
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: apk-${{ matrix.hmd }}-${{ (github.event_name == 'pull_request' && matrix.buildtype == 'Release') && 'Release-unsigned' || matrix.buildtype }}
|
||||
name: apk-${{ (github.event_name == 'pull_request' && matrix.buildtype == 'Release') && 'Release-unsigned' || matrix.buildtype }}
|
||||
path: apk/*.apk
|
||||
retention-days: 7
|
||||
|
||||
@@ -84,14 +151,14 @@ jobs:
|
||||
if: ${{ matrix.buildtype != 'Release' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: symbols-${{ matrix.hmd }}-${{ matrix.buildtype }}
|
||||
name: symbols-${{ matrix.buildtype }}
|
||||
path: debug/**/*.so
|
||||
retention-days: 7
|
||||
|
||||
release:
|
||||
name: Create APK release
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build-android-only
|
||||
needs: [build-android-only, build-steam-frame]
|
||||
if: ${{ vars.APK_ONLY != '' }}
|
||||
|
||||
steps:
|
||||
@@ -102,13 +169,12 @@ jobs:
|
||||
pattern: 'apk-*'
|
||||
merge-multiple: true
|
||||
|
||||
- name: Rename APK artifacts
|
||||
run: |
|
||||
cd apk
|
||||
for f in *.apk; do
|
||||
BASENAME=`echo ${f}|awk -F '-APK-' '{print $2}'`
|
||||
mv "${f}" "org.meumeu.wivrn-${BASENAME}"
|
||||
done
|
||||
- name: Download Steam Frame artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: install/usr
|
||||
pattern: 'wivrn-frame-client.zip'
|
||||
merge-multiple: true
|
||||
|
||||
- name: Download APK debug artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -132,5 +198,6 @@ jobs:
|
||||
prerelease: false
|
||||
fail_on_unmatched_files: true
|
||||
files: |
|
||||
install/usr/wivrn-frame-client.zip
|
||||
apk/*.apk
|
||||
debug-symbols.zip
|
||||
|
||||
@@ -5,41 +5,81 @@ on:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
SERVER_DEPS: libx264-dev libavcodec-dev libavutil-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev nlohmann-json3-dev librsvg2-dev libdrm-dev libglib2.0-dev-bin libpipewire-0.3-dev libcli11-dev libnotify-dev libarchive-dev libudev-dev
|
||||
CSS: images/wivrn-${{(github.ref_type == 'tag' && 'release') || 'nightly'}}.css
|
||||
|
||||
jobs:
|
||||
build-server:
|
||||
name: Linux server
|
||||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
|
||||
# You can convert this to a matrix build if you need cross-platform coverage.
|
||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||
runs-on: ubuntu-24.04
|
||||
build-linux:
|
||||
name: Linux
|
||||
runs-on: ubuntu-26.04
|
||||
if: ${{ vars.APK_ONLY == '' }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
cmake_preset: ['server', 'server-no-systemd', 'server-no-system-boost']
|
||||
config:
|
||||
- preset: 'client-no-system-boost'
|
||||
packages: libharfbuzz-dev libfreetype-dev libavcodec-dev libavutil-dev libswscale-dev librsvg2-bin gettext libcurl4-openssl-dev libfontconfig-dev libpipewire-0.3-dev
|
||||
- preset: 'dashboard'
|
||||
packages: extra-cmake-modules libarchive-dev libboost-all-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev libkirigami-dev librsvg2-dev nlohmann-json3-dev qcoro-qt6-dev qml6-module-org-kde-kirigamiaddons-formcard
|
||||
- preset: 'dissector-no-system-boost'
|
||||
packages: libboost-all-dev wireshark-dev
|
||||
- preset: 'server'
|
||||
packages: libboost-all-dev libsystemd-dev
|
||||
# tracing is opt-in and rarely built; build it here so the instrumentation and the
|
||||
# Perfetto SDK glue don't bitrot (WIVRN_TRACE_MONADO needs percetto, not packaged in CI)
|
||||
- preset: 'server-tracing'
|
||||
packages: libboost-all-dev libsystemd-dev
|
||||
- preset: 'server-no-systemd'
|
||||
packages: libboost-all-dev
|
||||
- preset: 'server-no-system-boost'
|
||||
packages: libsystemd-dev
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Apt dependencies
|
||||
uses: awalsh128/cache-apt-pkgs-action@v1.6.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
packages: ccache libvulkan-dev glslang-tools spirv-tools libwayland-dev libxrandr-dev ${{matrix.config.packages}} ${{ startsWith(matrix.config.preset, 'server') && env.SERVER_DEPS || ''}}
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
||||
with:
|
||||
create-symlink: true
|
||||
key: linux-${{matrix.config.preset}}
|
||||
job-summary: ""
|
||||
restore-keys: linux-
|
||||
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
key: cmake-linux-${{matrix.config.preset}}
|
||||
path: |
|
||||
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
|
||||
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
|
||||
${{github.workspace}}/cmake-fetch/*.tar.*
|
||||
${{github.workspace}}/cmake-fetch/*.tgz
|
||||
${{github.workspace}}/cmake-fetch/*-src/.git
|
||||
restore-keys: cmake-linux-
|
||||
|
||||
- name: Install dependencies
|
||||
run: >
|
||||
sudo apt-get update && sudo apt-get install libvulkan-dev libcjson-dev libx264-dev libavcodec-dev libavutil-dev libswscale-dev libavfilter-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev glslang-tools libudev-dev libwayland-dev libx11-xcb-dev libxrandr-dev libxcb-randr0-dev libgl-dev libglx-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libsystemd-dev libva-dev nlohmann-json3-dev libpulse-dev xz-utils libpipewire-0.3-dev libcli11-dev libboost-all-dev librsvg2-bin libssl-dev libnotify-dev librsvg2-dev libarchive-dev
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/setup-vulkan-sdk@286ed76c72de45dbf50c515779cf4ca2f6aa3944
|
||||
with:
|
||||
vulkan-query-version: 1.3.283.0
|
||||
vulkan-components: Vulkan-Headers
|
||||
vulkan-use-cache: true
|
||||
if: ${{ startswith(matrix.config.preset, 'client') }}
|
||||
run: |
|
||||
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-x86_64.deb
|
||||
sudo dpkg --install KTX-Software-4.4.2-Linux-x86_64.deb
|
||||
npm install --global @gltf-transform/cli@4.1.1
|
||||
|
||||
- name: Fetch Perfetto SDK
|
||||
if: ${{ matrix.config.preset == 'server-tracing' }}
|
||||
# The amalgamated SDK is two files; install them where server/CMakeLists.txt looks.
|
||||
env:
|
||||
PERFETTO_TAG: v51.0
|
||||
run: |
|
||||
sudo mkdir -p /usr/share/perfetto/sdk
|
||||
for f in perfetto.h perfetto.cc; do
|
||||
sudo curl -fsSL -o /usr/share/perfetto/sdk/$f \
|
||||
https://raw.githubusercontent.com/google/perfetto/${PERFETTO_TAG}/sdk/$f
|
||||
done
|
||||
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
@@ -47,76 +87,115 @@ jobs:
|
||||
run: >
|
||||
cmake -B ${{github.workspace}}/build
|
||||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
-DCMAKE_INSTALL_PREFIX=/usr
|
||||
--preset ${{ matrix.cmake_preset }}
|
||||
-DFETCHCONTENT_BASE_DIR=${{github.workspace}}/cmake-fetch
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
--preset ${{ matrix.config.preset }}
|
||||
-DWIVRN_USE_SYSTEM_OPENXR=OFF
|
||||
|
||||
- name: Package build dependencies
|
||||
if: ${{ matrix.cmake_preset == 'server' }}
|
||||
if: ${{ matrix.config.preset == 'server' }}
|
||||
# For easier packaging, build dependencies are made available as a separate archive
|
||||
run: (cd ${{github.workspace}}/build/_deps/ ; tar --create --xz *-src) > ${{github.workspace}}/server-build-deps.tar.xz
|
||||
run: cd ${{github.workspace}}/cmake-fetch ; tar --create --xz --exclude .git --file ${{github.workspace}}/server-build-deps.tar.xz *-src
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Publish build dependencies
|
||||
if: ${{ matrix.cmake_preset == 'server' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ matrix.config.preset == 'server' }}
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: server-build-deps
|
||||
path: server-build-deps.tar.xz
|
||||
|
||||
- name: Release build dependencies
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/') && matrix.cmake_preset == 'server'
|
||||
if: startsWith(github.ref, 'refs/tags/') && matrix.config.preset == 'server'
|
||||
with:
|
||||
tag_name: ${{ inputs.ref }}
|
||||
generate_release_notes: true
|
||||
draft: true
|
||||
files: server-build-deps.tar.xz
|
||||
|
||||
build-dashboard:
|
||||
name: Linux dashboard
|
||||
runs-on: ubuntu-24.04
|
||||
container: ubuntu:oracular
|
||||
build-steam-frame:
|
||||
name: Steam Frame
|
||||
runs-on: ubuntu-24.04-arm
|
||||
if: ${{ vars.APK_ONLY == '' }}
|
||||
container:
|
||||
image: registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk/arm64:4.0.20260805.254769
|
||||
volumes:
|
||||
- ${{github.workspace}}/install:/tmp/install
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Apt dependencies
|
||||
uses: awalsh128/cache-apt-pkgs-action@v1.6.1
|
||||
with:
|
||||
packages: librsvg2-bin npm
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
||||
with:
|
||||
key: steam-frame
|
||||
job-summary: ""
|
||||
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
key: cmake-frame
|
||||
path: |
|
||||
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
|
||||
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
|
||||
${{github.workspace}}/cmake-fetch/*.tar.*
|
||||
${{github.workspace}}/cmake-fetch/*.tgz
|
||||
${{github.workspace}}/cmake-fetch/*-src/.git
|
||||
|
||||
- name: Install dependencies
|
||||
run: >
|
||||
apt-get update && apt-get install --yes libvulkan-dev libcjson-dev libx264-dev libavcodec-dev libavutil-dev libswscale-dev libavfilter-dev libbsd-dev libwayland-dev libx11-xcb-dev libxrandr-dev libxcb-randr0-dev libgl-dev libglx-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libsystemd-dev libva-dev nlohmann-json3-dev qt6-base-dev qt6-tools-dev libcap-dev pkexec libboost-all-dev librsvg2-bin libssl-dev libnotify-dev qt6-declarative-dev extra-cmake-modules libkirigami-dev libkf6i18n-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev jq sudo cmake gcc g++ git qcoro-qt6-dev librsvg2-dev libarchive-dev
|
||||
# runtime: qml6-module-qtqml-workerscript qml6-module-qtquick-dialogs
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/setup-vulkan-sdk@286ed76c72de45dbf50c515779cf4ca2f6aa3944
|
||||
with:
|
||||
vulkan-query-version: 1.3.283.0
|
||||
vulkan-components: Vulkan-Headers
|
||||
vulkan-use-cache: true
|
||||
run: |
|
||||
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-arm64.deb
|
||||
sudo dpkg --install KTX-Software-4.4.2-Linux-arm64.deb
|
||||
npm install --global @gltf-transform/cli@4.1.1
|
||||
|
||||
- name: Configure CMake
|
||||
run: >
|
||||
cmake -B ${{github.workspace}}/build
|
||||
cmake -B "$GITHUB_WORKSPACE/build"
|
||||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
-DWIVRN_CSS=${{env.CSS}}
|
||||
-DFETCHCONTENT_BASE_DIR="$GITHUB_WORKSPACE/cmake-fetch"
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
-DCMAKE_INSTALL_PREFIX=/usr
|
||||
--preset dashboard
|
||||
--preset frame
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
run: |
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
cd "$GITHUB_WORKSPACE/build"
|
||||
DESTDIR="$GITHUB_WORKSPACE/install" ninja install
|
||||
|
||||
- name: Archive
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: wivrn-frame-client.zip
|
||||
path: install/usr
|
||||
if-no-files-found: error
|
||||
retention-days: 30
|
||||
|
||||
build-server-flatpak:
|
||||
name: Linux server (flatpak)
|
||||
runs-on: ubuntu-24.04
|
||||
if: ${{ vars.APK_ONLY == '' }}
|
||||
container:
|
||||
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.8
|
||||
# Tag matches runtime-version in the manifest.
|
||||
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.10
|
||||
options: --privileged
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -127,22 +206,18 @@ jobs:
|
||||
tools/gen_flatpak_manifest.py --gitlocal --out flatpak
|
||||
cat flatpak/io.github.wivrn.wivrn.yml
|
||||
|
||||
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.4
|
||||
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.7
|
||||
with:
|
||||
manifest-path: flatpak/io.github.wivrn.wivrn.yml
|
||||
bundle: wivrn-server.flatpak
|
||||
upload-artifact: false
|
||||
|
||||
# Upload manually instead of using flatpak/flatpak-github-actions/flatpak-builder because
|
||||
# it uses upload-artifact@v3
|
||||
- name: Publish artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: wivrn-flatpak-x86_64
|
||||
path: wivrn-server.flatpak
|
||||
# The manifest is regenerated on every commit with the git hash embedded,
|
||||
# so its default (manifest-hash) cache key never hits. Key on the files
|
||||
# that actually define the dependency set instead, so the toolchain
|
||||
# downloads and build cache persist across commits.
|
||||
cache-key: flatpak-builder-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev', 'CMakeLists.txt') }}
|
||||
|
||||
- name: Debug bundle
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
if: failure()
|
||||
with:
|
||||
name: flatpak-debug
|
||||
@@ -156,188 +231,54 @@ jobs:
|
||||
if: ${{ vars.APK_ONLY == '' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: cachix/install-nix-action@v31
|
||||
- run: nix flake check
|
||||
- run: nix build
|
||||
|
||||
build-test-client:
|
||||
name: Linux client
|
||||
runs-on: ubuntu-24.04
|
||||
if: ${{ vars.APK_ONLY == '' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
create-symlink: true
|
||||
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/setup-vulkan-sdk@286ed76c72de45dbf50c515779cf4ca2f6aa3944
|
||||
with:
|
||||
vulkan-query-version: 1.3.283.0
|
||||
vulkan-components: Vulkan-Headers
|
||||
vulkan-use-cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: >
|
||||
sudo apt-get update && sudo apt-get install libvulkan-dev libcjson-dev libx264-dev libavcodec-dev libavutil-dev libswscale-dev libavfilter-dev libbsd-dev libavahi-client-dev libeigen3-dev glslang-tools libudev-dev libwayland-dev libx11-xcb-dev libxrandr-dev libxcb-randr0-dev libgl-dev libglx-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libsystemd-dev libva-dev libxcb-glx0-dev gettext libfontconfig-dev libboost-all-dev librsvg2-bin libssl-dev sway grim mesa-vulkan-drivers wayland-protocols fonts-noto-cjk fonts-roboto
|
||||
|
||||
- name: install server dependencies
|
||||
run: >
|
||||
sudo apt-get update && sudo apt-get install libavahi-glib-dev nlohmann-json3-dev libpulse-dev xz-utils libpipewire-0.3-dev libcli11-dev qt6-base-dev qt6-tools-dev libcap-dev pkexec libnotify-dev librsvg2-dev libarchive-dev
|
||||
|
||||
- name: Configure CMake
|
||||
run: >
|
||||
cmake -B ${{github.workspace}}/build
|
||||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
-DCMAKE_INSTALL_PREFIX=/usr
|
||||
--preset everything
|
||||
-DWIVRN_BUILD_DASHBOARD=OFF
|
||||
-DWIVRN_BUILD_DISSECTOR=OFF
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build Monado
|
||||
# Disable XRT_FEATURE_OPENXR_VISIBILITY_MASK because of https://gitlab.freedesktop.org/monado/monado/-/issues/480
|
||||
run: |
|
||||
mkdir monado
|
||||
curl https://gitlab.freedesktop.org/Meumeu/monado/-/archive/5bdb51697685320e3f5d494210f25fb2967c9fc3/monado-main.tar.gz | tar -xz -C monado --strip-components=1
|
||||
patch --directory=${{github.workspace}}/monado --strip=1 < ${{github.workspace}}/patches/monado-ci/0001-remote-resolution.patch
|
||||
|
||||
DRIVERS=$(grep -oE "XRT_BUILD_DRIVER_[A-Z0-9_]*" monado/CMakeLists.txt | sort -u | grep -v XRT_BUILD_DRIVER_REMOTE | sed 's/\(.*\)/-D\1=OFF/')
|
||||
cmake monado -B ${{github.workspace}}/build-monado -DCMAKE_BUILD_TYPE=Release -DXRT_FEATURE_SERVICE_SYSTEMD=OFF -DXRT_FEATURE_SERVICE=OFF -DXRT_BUILD_DRIVER_REMOTE=ON -DXRT_MODULE_COMPOSITOR_MAIN=ON -DXRT_HAVE_WAYLAND=ON $DRIVERS -DXRT_MODULE_MONADO_REMOTECTL=ON -DBUILD_TESTING=OFF -DXRT_FEATURE_OPENXR_VISIBILITY_MASK=OFF
|
||||
|
||||
cmake --build ${{github.workspace}}/build-monado
|
||||
|
||||
- name: Take screenshots
|
||||
continue-on-error: true
|
||||
env:
|
||||
WLR_BACKENDS: headless
|
||||
WLR_RENDERER: pixman
|
||||
WLR_LIBINPUT_NO_DEVICES: 1
|
||||
XR_RUNTIME_JSON: ${{github.workspace}}/build-monado/openxr_monado-dev.json
|
||||
P_OVERRIDE_ACTIVE_CONFIG: remote
|
||||
WIVRN_CONTROLLER: meta-quest-touch-plus
|
||||
WIVRN_GRIP_LEFT_OFFSET: '0 0 0 0 45 0'
|
||||
WIVRN_GRIP_RIGHT_OFFSET: '0 0 0 0 45 0'
|
||||
XRT_COMPOSITOR_SCALE_PERCENTAGE: '100'
|
||||
run: |
|
||||
echo "xwayland disable" > sway-config
|
||||
echo -e "output HEADLESS-1 {\n mode 2560x1440@60Hz\n}" >> sway-config
|
||||
sway -c sway-config &
|
||||
sleep 10
|
||||
export WAYLAND_DISPLAY=$(cd "${XDG_RUNTIME_DIR}" && ls -tr wayland* | tail -1)
|
||||
|
||||
mkdir -p ~/.config/fontconfig
|
||||
cp ${{github.workspace}}/.github/fonts.conf ~/.config/fontconfig/fonts.conf
|
||||
|
||||
${{github.workspace}}/build/server/wivrn-server --no-encrypt --no-publish-service &
|
||||
WIVRN_SERVER_PID=$!
|
||||
|
||||
mkdir -p ~/.config/wivrn
|
||||
echo '{"servers": [{"autoconnect": false, "manual": true, "pretty_name": "Deep Thought", "hostname": "localhost", "port": 9757, "tcp_only": false, "cookie": ""}], "first_run": false}' > ~/.config/wivrn/client.json.in
|
||||
|
||||
for LANG in en $(basename -a ${{github.workspace}}/locale/*)
|
||||
do
|
||||
mkdir ${LANG}
|
||||
|
||||
if [ ${LANG} = fr ]
|
||||
then
|
||||
cat ~/.config/wivrn/client.json.in | jq .virtual_keyboard_layout=\"AZERTY\" > ~/.config/wivrn/client.json
|
||||
else
|
||||
cat ~/.config/wivrn/client.json.in | jq .virtual_keyboard_layout=\"QWERTY\" > ~/.config/wivrn/client.json
|
||||
fi
|
||||
|
||||
${{github.workspace}}/build/bin/wivrn &
|
||||
WIVRN_PID=$!
|
||||
sleep 10
|
||||
${{github.workspace}}/build-monado/src/xrt/targets/remotectl/monado-remotectl 127.0.0.1 4242 < ${{github.workspace}}/.github/screenshot-script.txt
|
||||
killall wivrn
|
||||
wait $WIVRN_PID || true
|
||||
done
|
||||
|
||||
killall wivrn-server
|
||||
wait $WIVRN_SERVER_PID || true
|
||||
|
||||
- name: Upload screenshots
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Screenshots
|
||||
path: "*/screenshot-*.png"
|
||||
|
||||
build-dissector:
|
||||
name: Wireshark dissector
|
||||
runs-on: ubuntu-24.04
|
||||
if: ${{ vars.APK_ONLY == '' }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
# Ubuntu 24.04 has boost 1.83, the dissector requires 1.84
|
||||
# cmake_preset: ['dissector', 'dissector-no-system-boost']
|
||||
cmake_preset: ['dissector-no-system-boost']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Prepare Vulkan SDK
|
||||
uses: humbletim/setup-vulkan-sdk@286ed76c72de45dbf50c515779cf4ca2f6aa3944
|
||||
with:
|
||||
vulkan-query-version: 1.3.268.0
|
||||
vulkan-components: Vulkan-Headers
|
||||
vulkan-use-cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: >
|
||||
sudo apt-get update && sudo apt-get install libvulkan-dev libopenxr-dev wireshark wireshark-dev libssl-dev
|
||||
|
||||
- name: Configure CMake
|
||||
run: >
|
||||
cmake -B ${{github.workspace}}/build
|
||||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
-DCMAKE_INSTALL_PREFIX=/usr
|
||||
--preset ${{ matrix.cmake_preset }}
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
- run: nix build --print-build-logs
|
||||
|
||||
build-android:
|
||||
name: Android
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
if: ${{ vars.APK_ONLY == '' }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
hmd: ['Standard']
|
||||
buildtype: ['Release', 'Debug', 'DebugWithValidationLayer', 'Oculus']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
key: cmake-android-${{matrix.buildtype}}
|
||||
path: |
|
||||
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
|
||||
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
|
||||
${{github.workspace}}/cmake-fetch/*.tar.*
|
||||
${{github.workspace}}/cmake-fetch/*.zip
|
||||
${{github.workspace}}/cmake-fetch/*.tgz
|
||||
restore-keys: cmake-android-
|
||||
|
||||
# Gradle distribution and the Android plugin's dependencies.
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
key: gradle-android-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'build.gradle') }}
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
restore-keys: gradle-android-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install glslang-tools librsvg2-bin gettext
|
||||
sudo apt-get update && sudo apt-get install glslang-tools spirv-tools librsvg2-bin gettext
|
||||
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.3.2/KTX-Software-4.3.2-Linux-x86_64.deb
|
||||
sudo dpkg --install KTX-Software-4.3.2-Linux-x86_64.deb
|
||||
npm install --global @gltf-transform/cli
|
||||
|
||||
- name: Check for Secret availability
|
||||
id: secret-check
|
||||
@@ -365,7 +306,7 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
VERSION=$(git describe --tags --always)
|
||||
VERSION=$(git describe --tags --always | sed "s/^v\([0-9]\)/\1/")
|
||||
if [ ${{ matrix.buildtype }} = 'Oculus' ]
|
||||
then
|
||||
SUFFIX=""
|
||||
@@ -375,7 +316,6 @@ jobs:
|
||||
VERSION_CODE=$(( $VERSION_CODE + 1 ))
|
||||
fi
|
||||
|
||||
CSS=images/wivrn-release.css
|
||||
APPNAME=WiVRn
|
||||
else
|
||||
VERSION_CODE=1
|
||||
@@ -383,26 +323,29 @@ jobs:
|
||||
if [ ${{ github.ref_type }} = 'tag' ]
|
||||
then
|
||||
SUFFIX=".github"
|
||||
CSS=images/wivrn-release.css
|
||||
APPNAME="WiVRn"
|
||||
else
|
||||
SUFFIX=".github.testing"
|
||||
CSS=images/wivrn-nightly.css
|
||||
APPNAME="WiVRn Testing"
|
||||
fi
|
||||
fi
|
||||
|
||||
sudo rm /usr/local/bin/cmake
|
||||
"${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" --install "cmake;3.30.3"
|
||||
|
||||
echo Setting version $VERSION and version code $VERSION_CODE in manifest
|
||||
echo Using stylesheet $CSS and name $APPNAME
|
||||
echo Using stylesheet ${{env.CSS}} and name $APPNAME
|
||||
|
||||
chmod +x gradlew
|
||||
./gradlew -Pwivrn_version=$VERSION -Pwivrn_versionCode=$VERSION_CODE -Psuffix=$SUFFIX -Pwivrn_css=$CSS -Pwivrn_app_name="$APPNAME" assemble${{ matrix.hmd }}${{ matrix.buildtype }}
|
||||
./gradlew \
|
||||
-Pwivrn_version=$VERSION \
|
||||
-Pwivrn_versionCode=$VERSION_CODE \
|
||||
-Psuffix=$SUFFIX \
|
||||
-Pwivrn_css=${{env.CSS}} \
|
||||
-Pwivrn_app_name="$APPNAME" \
|
||||
-Pwivrn_compress_glb=ON \
|
||||
-Pfetchcontent_base_dir=${{github.workspace}}/cmake-fetch \
|
||||
assemble${{ matrix.buildtype }}
|
||||
|
||||
- name: Upload build dir
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
if: failure()
|
||||
with:
|
||||
name: android-cxx-debug-${{ matrix.buildtype }}
|
||||
@@ -419,20 +362,18 @@ jobs:
|
||||
find debug -name libopenxr_loader.so -delete
|
||||
|
||||
- name: Archive APK
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
if: ${{ matrix.buildtype != 'Oculus' }}
|
||||
with:
|
||||
name: apk-${{ matrix.hmd }}-${{ (steps.secret-check.outputs.available == 'false' && matrix.buildtype == 'Release') && 'Release-unsigned' || matrix.buildtype }}
|
||||
name: apk-${{ (steps.secret-check.outputs.available == 'false' && matrix.buildtype == 'Release') && 'Release-unsigned' || matrix.buildtype }}
|
||||
path: apk/*.apk
|
||||
retention-days: 30
|
||||
|
||||
- name: Archive debug symbols
|
||||
if: ${{ matrix.buildtype != 'Release' && matrix.buildtype != 'Oculus' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: symbols-${{ matrix.hmd }}-${{ matrix.buildtype }}
|
||||
name: symbols-${{ matrix.buildtype }}
|
||||
path: debug/**/*.so
|
||||
retention-days: 30
|
||||
|
||||
- name: Push to Oculus store
|
||||
if: ${{ matrix.buildtype == 'Oculus' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') && steps.secret-check.outputs.oculus-token == 'true' }}
|
||||
@@ -451,7 +392,7 @@ jobs:
|
||||
IS_DRAFT=
|
||||
fi
|
||||
|
||||
./ovr-platform-util upload-quest-build --app-id 7959676140827574 --token $OCULUS_TOKEN --apk apk/WiVRn-standard-oculus.apk --channel $CHANNEL --age-group TEENS_AND_ADULTS $IS_DRAFT --debug_symbols_dir debug/ --debug-symbols-pattern '*.so'
|
||||
./ovr-platform-util upload-quest-build --app-id 7959676140827574 --token $OCULUS_TOKEN --apk apk/WiVRn-oculus.apk --channel $CHANNEL --age-group TEENS_AND_ADULTS $IS_DRAFT --debug_symbols_dir debug/ --debug-symbols-pattern '*.so'
|
||||
|
||||
build-ubuntu:
|
||||
name: Build Ubuntu package
|
||||
@@ -459,7 +400,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
distro: ['oracular', 'plucky']
|
||||
distro: ['plucky']
|
||||
runs-on: ubuntu-24.04
|
||||
container: ubuntu:${{ matrix.distro }}
|
||||
steps:
|
||||
@@ -467,9 +408,13 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update
|
||||
apt install --yes libcjson-dev libx264-dev libavcodec-dev libavutil-dev libswscale-dev libavfilter-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev glslang-tools libudev-dev libwayland-dev libx11-xcb-dev libxrandr-dev libxcb-randr0-dev libgl-dev libglx-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libsystemd-dev libva-dev nlohmann-json3-dev libpulse-dev xz-utils libpipewire-0.3-dev libcli11-dev qt6-base-dev qt6-tools-dev libcap-dev pkexec libboost-all-dev librsvg2-bin dpkg-dev pkg-config debhelper-compat build-essential lintian cmake libnotify-dev qt6-declarative-dev extra-cmake-modules libkirigami-dev libkf6i18n-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev jq sudo cmake gcc g++ git wget libssl-dev qcoro-qt6-dev librsvg2-dev libarchive-dev
|
||||
apt install --yes libcjson-dev libx264-dev libavcodec-dev libavutil-dev libswscale-dev libavfilter-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev glslang-tools libudev-dev libwayland-dev libx11-xcb-dev libxrandr-dev libxcb-randr0-dev libgl-dev libglx-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libsystemd-dev libva-dev nlohmann-json3-dev xz-utils libpipewire-0.3-dev libcli11-dev qt6-base-dev qt6-tools-dev pkexec libboost-all-dev librsvg2-bin dpkg-dev pkg-config debhelper-compat build-essential lintian cmake libnotify-dev qt6-declarative-dev extra-cmake-modules libkirigami-dev libkf6i18n-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev jq sudo cmake gcc g++ git wget libssl-dev qcoro-qt6-dev librsvg2-dev libarchive-dev npm qml6-module-org-kde-kirigamiaddons-formcard
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.3.2/KTX-Software-4.3.2-Linux-x86_64.deb
|
||||
sudo dpkg --install KTX-Software-4.3.2-Linux-x86_64.deb
|
||||
npm install --global @gltf-transform/cli
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
path: wivrn
|
||||
@@ -511,7 +456,7 @@ jobs:
|
||||
run: dpkg-buildpackage --build=binary --no-sign
|
||||
|
||||
- name: Publish package
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: wivrn-${{ matrix.distro }}
|
||||
path: |
|
||||
@@ -525,11 +470,11 @@ jobs:
|
||||
release:
|
||||
name: Create release
|
||||
runs-on: ubuntu-22.04
|
||||
needs: [build-server, build-android, build-test-client, build-dissector, build-server-flatpak, build-ubuntu, build-dashboard]
|
||||
needs: [build-linux, build-android, build-server-flatpak, build-ubuntu]
|
||||
if: success() && startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
path: wivrn
|
||||
@@ -544,7 +489,7 @@ jobs:
|
||||
echo "available=false" >> $GITHUB_OUTPUT;
|
||||
fi
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
if: ${{ steps.flathub-token-check.outputs.available == 'true' }}
|
||||
with:
|
||||
fetch-depth: 0
|
||||
@@ -553,20 +498,19 @@ jobs:
|
||||
token: ${{ secrets.FLATHUB_TOKEN }}
|
||||
|
||||
- name: Download artifacts (APK)
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: apk-Release
|
||||
path: apk
|
||||
pattern: '*-Release'
|
||||
merge-multiple: true
|
||||
|
||||
- name: Download artifacts (flatpak)
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: wivrn-flatpak-x86_64
|
||||
name: wivrn-server-x86_64.flatpak
|
||||
path: flatpak
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
tag_name: ${{ inputs.ref }}
|
||||
generate_release_notes: true
|
||||
@@ -601,18 +545,11 @@ jobs:
|
||||
|
||||
git show
|
||||
|
||||
- name: Update release branch
|
||||
run: |
|
||||
cd wivrn
|
||||
if git fetch origin release; then
|
||||
git push origin HEAD:release
|
||||
fi
|
||||
|
||||
sync_fork_downstream:
|
||||
name: Sync fork downstream
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [build-server, build-android]
|
||||
if: ${{ vars.APK_ONLY == '' }} && github.branch == 'master'
|
||||
needs: [build-linux, build-android]
|
||||
if: ${{ vars.APK_ONLY == '' && github.ref == 'refs/heads/master' }}
|
||||
steps:
|
||||
- name: Check for DOWNSTREAM_GITHUB_TOKEN
|
||||
id: downstream-secret-check
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run clang-format style check for C/C++/Protobuf programs.
|
||||
uses: jidicula/clang-format-action@v4.13.0
|
||||
uses: jidicula/clang-format-action@v4.16.0
|
||||
with:
|
||||
clang-format-version: '18'
|
||||
clang-format-version: '21'
|
||||
check-path: ${{ matrix.path }}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
name: Sync Fork with Upstream
|
||||
|
||||
env:
|
||||
UPSTREAM_URL: "https://github.com/wivrn/wivrn.git"
|
||||
WORKFLOW_TOKEN: ${{ secrets.DOWNSTREAM_GITHUB_TOKEN }}
|
||||
UPSTREAM_BRANCH: "master"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '18 2 * * *'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
upstream_repo: vindicus999/wivrn
|
||||
fetch-depth: 0
|
||||
token: ${{ env.WORKFLOW_TOKEN }}
|
||||
|
||||
- name: Add upstream
|
||||
run: |
|
||||
git remote add upstream ${{ env.UPSTREAM_URL }}
|
||||
|
||||
- name: Fetch all
|
||||
run: |
|
||||
git fetch origin
|
||||
git fetch upstream
|
||||
|
||||
- name: Update sync branch
|
||||
run: |
|
||||
git config --global user.email "sneed@feedandse.edu"
|
||||
git config --global user.name "Sneed Chuckinson"
|
||||
git checkout -B sync upstream/master
|
||||
git push origin sync --force
|
||||
|
||||
- name: Copy master -> apk-build
|
||||
run: |
|
||||
git checkout -B apk-build sync
|
||||
git push origin apk-build --force
|
||||
|
||||
- name: Apply sneed changes
|
||||
run: |
|
||||
git merge origin/sneed --no-edit
|
||||
|
||||
- name: Push apk build
|
||||
run: |
|
||||
git push origin apk-build --force
|
||||
@@ -47,6 +47,9 @@
|
||||
<uses-permission android:name="com.oculus.permission.FACE_TRACKING" />
|
||||
<uses-permission android:name="com.picovr.permission.FACE_TRACKING" />
|
||||
<uses-permission android:name="com.oculus.permission.BODY_TRACKING" />
|
||||
<uses-permission android:name="android.permission.EYE_TRACKING_FINE" />
|
||||
<uses-permission android:name="android.permission.FACE_TRACKING" />
|
||||
<uses-permission android:name="android.permission.HAND_TRACKING" />
|
||||
|
||||
<!-- Required for XR_FB_render_model -->
|
||||
<uses-feature android:name="com.oculus.feature.RENDER_MODEL" android:required="false" />
|
||||
@@ -62,6 +65,12 @@
|
||||
<uses-feature android:name="wave.feature.lipexpression" android:required="false" />
|
||||
<uses-feature android:name="wave.feature.tracker" android:required="false" />
|
||||
|
||||
<!-- See https://developer.android.com/develop/xr/get-started -->
|
||||
<uses-feature android:name="android.software.xr.api.openxr" android:version="0x00010000" android:required="true" />
|
||||
<uses-feature android:name="android.hardware.xr.input.controller" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.xr.input.hand_tracking" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.xr.input.eye_tracking" android:required="false" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:hasCode="true"
|
||||
@@ -71,6 +80,9 @@
|
||||
|
||||
<profileable android:shell="true" />
|
||||
|
||||
<!-- https://developer.android.com/develop/xr/get-started#uses-native-library_openxr -->
|
||||
<uses-native-library android:name="libopenxr.google.so" android:required="false" />
|
||||
|
||||
<meta-data android:name="pvr.app.type" android:value="vr" />
|
||||
<meta-data android:name="pvr.sdk.version" android:value="OpenXR" />
|
||||
<meta-data android:name="picovr.software.eye_tracking" android:value="true" />
|
||||
@@ -91,6 +103,14 @@
|
||||
<!-- https://developers.meta.com/horizon/documentation/native/android/mobile-passthrough-loading-screens -->
|
||||
<meta-data android:name="com.oculus.ossplash.background" android:value="passthrough-contextual"/>
|
||||
|
||||
<!-- https://developer.android.com/develop/xr/get-started#xr_activity_start_mode_full_space_unmanaged -->
|
||||
<property
|
||||
android:name="android.window.PROPERTY_XR_ACTIVITY_START_MODE"
|
||||
android:value="XR_ACTIVITY_START_MODE_FULL_SPACE_UNMANAGED" />
|
||||
<property
|
||||
android:name="android.window.PROPERTY_XR_BOUNDARY_TYPE_RECOMMENDED"
|
||||
android:value="XR_BOUNDARY_TYPE_LARGE" />
|
||||
|
||||
<!-- The activity is the built-in NativeActivity framework class. -->
|
||||
<!-- launchMode is set to singleTask because there should never be multiple copies of the app running. -->
|
||||
<!-- Theme.Black.NoTitleBar.Fullscreen gives solid black instead of a (bad stereoscopic) gradient on app transition. -->
|
||||
|
||||
@@ -6,9 +6,14 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
if(ANDROID)
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/android)
|
||||
endif()
|
||||
|
||||
# Default to PIC code
|
||||
include(CheckPIESupported)
|
||||
check_pie_supported()
|
||||
@@ -17,14 +22,15 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
include(FetchContent)
|
||||
include(ExternalProject)
|
||||
include(GNUInstallDirs)
|
||||
include("cmake/AutoOption.cmake")
|
||||
|
||||
option(WIVRN_USE_SYSTEM_FREETYPE "Use system FreeType" ON)
|
||||
auto_option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" AUTO)
|
||||
auto_option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" AUTO)
|
||||
auto_option(WIVRN_USE_SYSTEMD "Use libsystemd" AUTO)
|
||||
auto_option(WIVRN_USE_LIBKTX "Use libktx" AUTO)
|
||||
option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" ON)
|
||||
option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" ON)
|
||||
option(WIVRN_USE_SYSTEM_LIBKTX "Use system KTX-Software library" ON)
|
||||
option(WIVRN_USE_SYSTEMD "Use libsystemd" ON)
|
||||
option(WIVRN_COMPRESS_GLB "Compress textures in GLB files with gltf-transform" OFF)
|
||||
option(WIVRN_USE_ANDROID_VALIDATION_LAYER "Download the android version of the Vulkan validation layer" OFF)
|
||||
option(WIVRN_USE_ANDROID_BIN_LIBKTX "Download the prebuilt libktx for android" OFF)
|
||||
option(WIVRN_BUILD_CLIENT "Build WiVRn client" OFF)
|
||||
option(WIVRN_BUILD_SERVER "Build WiVRn server" ON)
|
||||
option(WIVRN_BUILD_SERVER_LIBRARY "Build OpenXR library for WiVRn server" ${WIVRN_BUILD_SERVER})
|
||||
@@ -33,24 +39,29 @@ option(WIVRN_BUILD_WIVRNCTL "Build wivrnctl" ON)
|
||||
option(WIVRN_BUILD_DISSECTOR "Build Wireshark dissector" OFF)
|
||||
option(WIVRN_BUILD_TEST "Build test binaries" OFF)
|
||||
option(WIVRN_WERROR "Treat warnings as errors" OFF)
|
||||
option(WIVRN_OPTIMIZE_SHADERS "Run spirv-opt on compiled shaders" ON)
|
||||
option(WIVRN_DEBUG_SHADERS "Compile shaders with debug information" OFF)
|
||||
|
||||
if(WIVRN_OPTIMIZE_SHADERS AND WIVRN_DEBUG_SHADERS)
|
||||
message(FATAL_ERROR "WIVRN_OPTIMIZE_SHADERS and WIVRN_DEBUG_SHADERS are incompatible")
|
||||
endif()
|
||||
|
||||
option(WIVRN_USE_NVENC "Enable nvenc (Nvidia) hardware encoder" ON)
|
||||
auto_option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" AUTO)
|
||||
auto_option(WIVRN_USE_VULKAN_ENCODE "Enable vulkan video encoder" AUTO)
|
||||
auto_option(WIVRN_USE_X264 "Enable x264 software encoder" AUTO)
|
||||
option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" ON)
|
||||
option(WIVRN_USE_VULKAN_ENCODE "Enable vulkan video encoder" ON)
|
||||
option(WIVRN_USE_X264 "Enable x264 software encoder" ON)
|
||||
|
||||
auto_option(WIVRN_USE_PIPEWIRE "Enable pipewire backend" AUTO)
|
||||
auto_option(WIVRN_USE_PULSEAUDIO "Enable pulseaudio backend" AUTO)
|
||||
option(WIVRN_USE_PIPEWIRE "Enable pipewire backend" ON)
|
||||
option(WIVRN_USE_PULSEAUDIO "Enable pulseaudio backend" OFF)
|
||||
|
||||
set(OVR_COMPAT_SEARCH_PATH "/opt/xrizer:/usr/local/lib/OpenComposite:/usr/lib/OpenComposite:/opt/OpenComposite:/opt/opencomposite"
|
||||
CACHE STRING "List of places to search for the OpenVR compatibility layer, separated by :")
|
||||
|
||||
option(WIVRN_FEATURE_DEBUG_GUI "Enable Monado debug GUI" OFF)
|
||||
option(WIVRN_FEATURE_RENDERDOC "Support renderdoc" OFF)
|
||||
set(WIVRN_FEATURE_SOLARXR OFF) # Will be added back when merged in upstream Monado
|
||||
option(WIVRN_FEATURE_STEAMVR_LIGHTHOUSE "Enable SteamVR Lighthouse driver" OFF)
|
||||
option(WIVRN_FEATURE_SOLARXR "Enable SolarXR driver" ON)
|
||||
option(WIVRN_FEATURE_STEAMVR_LIGHTHOUSE "Enable SteamVR Lighthouse driver" ON)
|
||||
|
||||
option(WIVRN_CHECK_CAPSYSNICE "Check if CAP_SYS_NICE is available at startup" ON)
|
||||
set(WIVRN_CSS "${CMAKE_SOURCE_DIR}/images/wivrn-local.css" CACHE STRING "Stylesheet to use to render SVGs" )
|
||||
|
||||
option(WIVRN_SHOW_IMGUI_DEMO_WINDOW "Show the Dear ImGui demo window in the client" OFF)
|
||||
@@ -61,9 +72,18 @@ set(WIVRN_OPENXR_MANIFEST_TYPE "relative" CACHE STRING "How to reference librari
|
||||
if (NOT WIVRN_OPENXR_MANIFEST_TYPE IN_LIST WIVRN_OPENXR_MANIFEST_TYPE_VALUES)
|
||||
message(FATAL_ERROR "WIVRN_OPENXR_MANIFEST_TYPE must be one of ${WIVRN_OPENXR_MANIFEST_TYPE_VALUES}")
|
||||
endif()
|
||||
option(WIVRN_OPENXR_MANIFEST_ABI "Generate an ABI specific OpenXR manifest")
|
||||
|
||||
option(ENABLE_COLOURED_OUTPUT "Always produce ANSI-coloured output (GNU/Clang only)." ON)
|
||||
|
||||
set(WIVRN_ENVIRONMENTS_URL "https://github.com/WiVRn/WiVRn-environments/releases/latest/download/index.json" CACHE STRING "URL hosting the custom environments json file")
|
||||
|
||||
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_SERVER OR WIVRN_BUILD_DASHBOARD OR WIVRN_BUILD_DISSECTOR)
|
||||
set(NEED_COMMON TRUE)
|
||||
else()
|
||||
set(NEED_COMMON FALSE)
|
||||
endif()
|
||||
|
||||
if(ENABLE_COLOURED_OUTPUT)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
add_compile_options(-fdiagnostics-color=always)
|
||||
@@ -75,22 +95,16 @@ endif()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
find_package(Git)
|
||||
if (NOT ANDROID)
|
||||
if (NEED_COMMON)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
endif()
|
||||
include(VulkanVersion)
|
||||
|
||||
if (WIVRN_USE_SYSTEM_BOOST STREQUAL "AUTO")
|
||||
if(WIVRN_BUILD_DISSECTOR)
|
||||
find_package(Boost 1.84.0 COMPONENTS locale url)
|
||||
if (WIVRN_USE_SYSTEM_BOOST AND NEED_COMMON)
|
||||
if (WIVRN_BUILD_DISSECTOR)
|
||||
find_package(Boost 1.84.0 REQUIRED COMPONENTS locale url iostreams)
|
||||
else()
|
||||
find_package(Boost 1.75.0 COMPONENTS locale url)
|
||||
endif()
|
||||
elseif(WIVRN_USE_SYSTEM_BOOST STREQUAL "ON")
|
||||
if(WIVRN_BUILD_DISSECTOR)
|
||||
find_package(Boost 1.84.0 REQUIRED COMPONENTS locale url)
|
||||
else()
|
||||
find_package(Boost 1.75.0 REQUIRED COMPONENTS locale url)
|
||||
find_package(Boost 1.75.0 REQUIRED COMPONENTS locale url iostreams)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -104,72 +118,30 @@ if (WIVRN_BUILD_SERVER)
|
||||
message(FATAL_ERROR "No encoder selected, use at least one of WIVRN_USE_NVENC, WIVRN_USE_VAAPI, WIVRN_USE_VULKAN_ENCODE or WIVRN_USE_X264")
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_VAAPI STREQUAL "AUTO")
|
||||
pkg_check_modules(LIBAV IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
|
||||
pkg_check_modules(LIBDRM IMPORTED_TARGET libdrm)
|
||||
if (LIBAV_FOUND AND LIBDRM_FOUND)
|
||||
set(WIVRN_USE_VAAPI ON)
|
||||
else()
|
||||
set(WIVRN_USE_VAAPI OFF)
|
||||
endif()
|
||||
elseif (WIVRN_USE_VAAPI)
|
||||
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
|
||||
if (WIVRN_USE_VAAPI)
|
||||
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil)
|
||||
pkg_check_modules(LIBDRM REQUIRED IMPORTED_TARGET libdrm)
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_VULKAN_ENCODE STREQUAL "AUTO")
|
||||
if (Vulkan_VERSION VERSION_GREATER_EQUAL 1.3.283)
|
||||
set(WIVRN_USE_VULKAN_ENCODE ON)
|
||||
else()
|
||||
set(WIVRN_USE_VULKAN_ENCODE OFF)
|
||||
endif()
|
||||
elseif(WIVRN_USE_VULKAN_ENCODE)
|
||||
if (WIVRN_USE_VULKAN_ENCODE)
|
||||
if (Vulkan_VERSION VERSION_LESS 1.3.283)
|
||||
message(FATAL_ERROR "Vulkan video encode requires 1.3.283, found ${Vulkan_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_X264 STREQUAL "AUTO")
|
||||
pkg_check_modules(X264 IMPORTED_TARGET x264)
|
||||
if (X264_FOUND)
|
||||
set(WIVRN_USE_X264 ON)
|
||||
else()
|
||||
set(WIVRN_USE_X264 OFF)
|
||||
endif()
|
||||
elseif (WIVRN_USE_X264)
|
||||
if (WIVRN_USE_X264)
|
||||
pkg_check_modules(X264 REQUIRED IMPORTED_TARGET x264)
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_SYSTEMD STREQUAL "AUTO")
|
||||
pkg_check_modules(SYSTEMD IMPORTED_TARGET libsystemd)
|
||||
if (SYSTEMD_FOUND)
|
||||
set(WIVRN_USE_SYSTEMD ON)
|
||||
else()
|
||||
set(WIVRN_USE_SYSTEMD OFF)
|
||||
endif()
|
||||
elseif (WIVRN_USE_SYSTEMD)
|
||||
if (WIVRN_USE_SYSTEMD)
|
||||
pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd)
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_PIPEWIRE STREQUAL "AUTO")
|
||||
pkg_check_modules(libpipewire IMPORTED_TARGET libpipewire-0.3)
|
||||
if (libpipewire_FOUND)
|
||||
set(WIVRN_USE_PIPEWIRE ON)
|
||||
else()
|
||||
set(WIVRN_USE_PIPEWIRE OFF)
|
||||
endif()
|
||||
elseif (WIVRN_USE_PIPEWIRE)
|
||||
if (WIVRN_USE_PIPEWIRE)
|
||||
pkg_check_modules(libpipewire REQUIRED IMPORTED_TARGET libpipewire-0.3)
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_PULSEAUDIO STREQUAL "AUTO")
|
||||
pkg_check_modules(libpulse IMPORTED_TARGET libpulse)
|
||||
if (libpulse_FOUND)
|
||||
set(WIVRN_USE_PULSEAUDIO ON)
|
||||
else()
|
||||
set(WIVRN_USE_PULSEAUDIO OFF)
|
||||
endif()
|
||||
elseif (WIVRN_USE_PULSEAUDIO)
|
||||
if (WIVRN_USE_PULSEAUDIO)
|
||||
pkg_check_modules(libpulse REQUIRED IMPORTED_TARGET libpulse)
|
||||
endif()
|
||||
|
||||
@@ -192,6 +164,11 @@ endif()
|
||||
if (WIVRN_BUILD_DASHBOARD)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Quick Test Gui QuickControls2 Widgets Network)
|
||||
|
||||
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.10.0)
|
||||
# QtCoro needs this for Qt 6.10 and (currently) doesn't do this by itself
|
||||
find_package(Qt6 REQUIRED COMPONENTS QmlPrivate)
|
||||
endif()
|
||||
|
||||
find_package(ECM 5.115 REQUIRED NO_MODULE)
|
||||
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
|
||||
|
||||
@@ -200,41 +177,36 @@ if (WIVRN_BUILD_DASHBOARD)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
find_package(QCoro6 REQUIRED COMPONENTS Core Network Qml)
|
||||
qcoro_enable_coroutines()
|
||||
|
||||
if (WIVRN_CHECK_CAPSYSNICE)
|
||||
pkg_check_modules(libcap REQUIRED IMPORTED_TARGET libcap)
|
||||
endif()
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
endif()
|
||||
|
||||
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_DASHBOARD)
|
||||
find_program(RSVG_CONVERT rsvg-convert REQUIRED)
|
||||
find_package(Gettext REQUIRED)
|
||||
endif()
|
||||
|
||||
if (WIVRN_BUILD_CLIENT)
|
||||
if (WIVRN_USE_LIBKTX STREQUAL "AUTO")
|
||||
if (ANDROID)
|
||||
set(WIVRN_USE_LIBKTX ON)
|
||||
else()
|
||||
set(WIVRN_USE_LIBKTX OFF)
|
||||
endif()
|
||||
find_program(RSVG_CONVERT rsvg-convert REQUIRED)
|
||||
find_program(TOKTX toktx REQUIRED)
|
||||
|
||||
if (WIVRN_COMPRESS_GLB)
|
||||
find_program(GLTF_TRANSFORM gltf-transform REQUIRED)
|
||||
endif()
|
||||
|
||||
if(NOT ANDROID)
|
||||
find_package(CURL REQUIRED COMPONENTS HTTP HTTPS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
|
||||
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
|
||||
pkg_check_modules(LIBAV_CLIENT REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale)
|
||||
find_package(Fontconfig REQUIRED)
|
||||
|
||||
if (WIVRN_USE_SYSTEM_OPENXR STREQUAL "AUTO")
|
||||
find_package(OpenXR 1.1.48)
|
||||
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
|
||||
find_package(OpenXR 1.1.48 REQUIRED)
|
||||
if (WIVRN_USE_SYSTEM_OPENXR)
|
||||
find_package(OpenXR 1.1.53 REQUIRED)
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_SYSTEM_LIBKTX)
|
||||
find_package(Ktx REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
@@ -245,10 +217,8 @@ if(ANDROID)
|
||||
endif()
|
||||
|
||||
if (WIVRN_BUILD_DISSECTOR)
|
||||
if (WIVRN_USE_SYSTEM_OPENXR STREQUAL "AUTO")
|
||||
find_package(OpenXR 1.1.48)
|
||||
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
|
||||
find_package(OpenXR 1.1.48 REQUIRED)
|
||||
if (WIVRN_USE_SYSTEM_OPENXR)
|
||||
find_package(OpenXR 1.1.53 REQUIRED)
|
||||
endif()
|
||||
find_package(Wireshark REQUIRED)
|
||||
endif()
|
||||
@@ -259,38 +229,42 @@ if (WIVRN_BUILD_WIVRNCTL)
|
||||
endif()
|
||||
|
||||
# Common dependencies
|
||||
FetchContent_Declare(boostpfr EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/pfr/archive/refs/tags/2.2.0.tar.gz
|
||||
URL_HASH SHA256=6f490ec1383de5855dcf801c23f0a967f888eb6e1440b6ca0bf36c12d4ae7ac7)
|
||||
FetchContent_Declare(boost EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
|
||||
URL_HASH SHA256=2e64e5d79a738d0fa6fb546c6e5c2bd28f88d268a2a080546f74e5ff98f29d0e)
|
||||
FetchContent_Declare(boost EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/boost/releases/download/boost-1.89.0/boost-1.89.0-cmake.tar.xz
|
||||
URL_HASH SHA256=67acec02d0d118b5de9eb441f5fb707b3a1cdd884be00ca24b9a73c995511f74)
|
||||
|
||||
# Client dependencies
|
||||
FetchContent_Declare(simdjson EXCLUDE_FROM_ALL SYSTEM URL https://github.com/simdjson/simdjson/archive/refs/tags/v3.10.1.tar.gz
|
||||
URL_HASH SHA256=1e8f881cb2c0f626c56cd3665832f1e97b9d4ffc648ad9e1067c134862bba060)
|
||||
FetchContent_Declare(fastgltf EXCLUDE_FROM_ALL SYSTEM URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.7.1.tar.gz
|
||||
URL_HASH SHA256=44bcb025dd5cd480236a3bc7a3f8c9a708a801ed773b7859677440d22e0e1e7c)
|
||||
FetchContent_Declare(glm EXCLUDE_FROM_ALL SYSTEM URL https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
|
||||
URL_HASH SHA256=9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c)
|
||||
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.48.tar.gz
|
||||
URL_HASH SHA256=c9372992dcdfac643e28796e41d4dbd36c4cdf0388d01fa89245628edae9d411)
|
||||
FetchContent_Declare(spdlog EXCLUDE_FROM_ALL SYSTEM URL https://github.com/gabime/spdlog/archive/refs/tags/v1.14.1.tar.gz
|
||||
URL_HASH SHA256=1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b)
|
||||
FetchContent_Declare(simdjson EXCLUDE_FROM_ALL SYSTEM URL https://github.com/simdjson/simdjson/archive/refs/tags/v4.2.2.tar.gz
|
||||
URL_HASH SHA256=3efae22cb41f83299fe0b2e8a187af543d3dda93abbb910586f897df670f9eaa)
|
||||
FetchContent_Declare(fastgltf EXCLUDE_FROM_ALL SYSTEM URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.9.0.tar.gz
|
||||
URL_HASH SHA256=0bb564e127b14c22f062db50f89381dd2e0a20dbaf4987ca138a4ae8728712f9)
|
||||
FetchContent_Declare(glm EXCLUDE_FROM_ALL SYSTEM URL https://github.com/g-truc/glm/releases/download/1.0.2/glm-1.0.2.zip
|
||||
URL_HASH SHA256=77fff075c5ab0caf076fade41558c5458d9a242aba2b2076bb72008bdb51a35e)
|
||||
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.54.tar.gz
|
||||
URL_HASH SHA256=2055688081066e37238be996534f349420ac52ed34f8514836704232121ee7f3)
|
||||
FetchContent_Declare(spdlog EXCLUDE_FROM_ALL SYSTEM URL https://github.com/gabime/spdlog/archive/refs/tags/v1.16.0.tar.gz
|
||||
URL_HASH SHA256=8741753e488a78dd0d0024c980e1fb5b5c85888447e309d9cb9d949bdb52aa3e)
|
||||
FetchContent_Declare(stb EXCLUDE_FROM_ALL SYSTEM URL https://github.com/nothings/stb/archive/013ac3beddff3dbffafd5177e7972067cd2b5083.zip
|
||||
URL_HASH SHA256=b7f476902bbef1b30f8ecc2d9d95c459c32302c8b559d09b589b5955463b7af8)
|
||||
FetchContent_Declare(libktx EXCLUDE_FROM_ALL SYSTEM
|
||||
GIT_REPOSITORY https://github.com/KhronosGroup/KTX-Software
|
||||
GIT_TAG 91ace88675ac59a97e55d0378a6602a9ae6b98bd)
|
||||
set(KTX_VERSION "4.4.2")
|
||||
set(KTX_VERSION_FULL "v${KTX_VERSION}")
|
||||
FetchContent_Declare(libktx EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/KTX-Software/archive/refs/tags/${KTX_VERSION_FULL}.tar.gz
|
||||
URL_HASH SHA256=9412cb45045a503005acd47d98f9e8b47154634a50b4df21e17a1dfa8971d323
|
||||
)
|
||||
FetchContent_Declare(implot EXCLUDE_FROM_ALL SYSTEM URL https://github.com/epezent/implot/archive/3da8bd34299965d3b0ab124df743fe3e076fa222.zip
|
||||
URL_HASH SHA256=e9b439a94aa6f09fcf12ed9c2cd784efe5e99e96242122aa683e690b29f7a59f)
|
||||
file(GLOB IMGUI_PATCHES CONFIGURE_DEPENDS patches/imgui/*)
|
||||
FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.1.tar.gz
|
||||
URL_HASH SHA256=32c237c2abf67a2ffccaac17192f711d4a787554b4133187a153d49057d6109c
|
||||
FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.5.tar.gz
|
||||
URL_HASH SHA256=0eb50fe9aeba1a51f96b5843c7f630a32ed2e9362d693c61b87e4fa870cf826d
|
||||
PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${IMGUI_PATCHES}
|
||||
)
|
||||
FetchContent_Declare(uni-algo EXCLUDE_FROM_ALL SYSTEM URL https://github.com/uni-algo/uni-algo/archive/v1.2.0.tar.gz
|
||||
URL_HASH SHA256=f2a1539cd8635bc6088d05144a73ecfe7b4d74ee0361fabed6f87f9f19e74ca9)
|
||||
FetchContent_Declare(entt EXCLUDE_FROM_ALL SYSTEM URL https://github.com/skypjack/entt/archive/refs/tags/v3.15.0.tar.gz
|
||||
URL_HASH SHA256=01466fcbf77618a79b62891510c0bbf25ac2804af5751c84982b413852234d66)
|
||||
FetchContent_Declare(entt EXCLUDE_FROM_ALL SYSTEM URL https://github.com/skypjack/entt/archive/refs/tags/v3.16.0.tar.gz
|
||||
URL_HASH SHA256=7d7b4037b737992342049ffab14f22fa10243e01664f8c3a0657aa247ac52f71)
|
||||
FetchContent_Declare(curl EXCLUDE_FROM_ALL SYSTEM URL https://github.com/curl/curl/releases/download/curl-8_17_0/curl-8.17.0.tar.xz
|
||||
URL_HASH SHA256=955f6e729ad6b3566260e8fef68620e76ba3c31acf0a18524416a185acf77992)
|
||||
FetchContent_Declare(spirv-reflect EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/SPIRV-Reflect/archive/refs/tags/vulkan-sdk-1.4.328.1.tar.gz
|
||||
URL_HASH SHA256=77f4b5b5630d960d7c17e39ddd5bf2e7dd62e6d8da24259ed14ca5b59783ea35)
|
||||
|
||||
file(GLOB MONADO_PATCHES CONFIGURE_DEPENDS patches/monado/*)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS monado-rev)
|
||||
@@ -304,8 +278,22 @@ FetchContent_Declare(monado
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
add_custom_target(wivrn-version ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/common/version.cpp.in
|
||||
-D OUTPUT_FILE=${CMAKE_BINARY_DIR}/version.cpp
|
||||
-D INPUT_FILE_1=${CMAKE_CURRENT_SOURCE_DIR}/server/u_git_tag.cpp.in
|
||||
-D OUTPUT_FILE_1=${CMAKE_BINARY_DIR}/u_git_tag.cpp
|
||||
-D GIT_DESC="${GIT_DESC}"
|
||||
-D GIT_COMMIT="${GIT_COMMIT}"
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/version.cpp ${CMAKE_BINARY_DIR}/u_git_tag.cpp
|
||||
SOURCES common/version.cpp.in server/u_git_tag.cpp.in
|
||||
)
|
||||
|
||||
add_subdirectory(external)
|
||||
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_SERVER OR WIVRN_BUILD_DASHBOARD OR WIVRN_BUILD_DISSECTOR)
|
||||
if (NEED_COMMON)
|
||||
add_subdirectory(common)
|
||||
endif()
|
||||
|
||||
@@ -317,18 +305,18 @@ if (WIVRN_BUILD_SERVER OR WIVRN_BUILD_SERVER_LIBRARY)
|
||||
add_subdirectory(server)
|
||||
|
||||
if (WIVRN_BUILD_SERVER)
|
||||
message("Selected encoders:")
|
||||
message("\tNVENC : ${WIVRN_USE_NVENC}")
|
||||
message("\tVAAPI : ${WIVRN_USE_VAAPI}")
|
||||
message("\tVulkan: ${WIVRN_USE_VULKAN_ENCODE}")
|
||||
message("\tx264 : ${WIVRN_USE_X264}")
|
||||
message("")
|
||||
message("Audio backends:")
|
||||
message("\tPipewire : ${WIVRN_USE_PIPEWIRE}")
|
||||
message("\tPulseaudio: ${WIVRN_USE_PULSEAUDIO}")
|
||||
message("")
|
||||
message("Optional features:")
|
||||
message("\tsystemd: ${WIVRN_USE_SYSTEMD}")
|
||||
message(STATUS "Selected encoders:")
|
||||
message(STATUS "\tNVENC : ${WIVRN_USE_NVENC}")
|
||||
message(STATUS "\tVAAPI : ${WIVRN_USE_VAAPI}")
|
||||
message(STATUS "\tVulkan: ${WIVRN_USE_VULKAN_ENCODE}")
|
||||
message(STATUS "\tx264 : ${WIVRN_USE_X264}")
|
||||
message(STATUS "")
|
||||
message(STATUS "Audio backends:")
|
||||
message(STATUS "\tPipewire : ${WIVRN_USE_PIPEWIRE}")
|
||||
message(STATUS "\tPulseaudio: ${WIVRN_USE_PULSEAUDIO}")
|
||||
message(STATUS "")
|
||||
message(STATUS "Optional features:")
|
||||
message(STATUS "\tsystemd: ${WIVRN_USE_SYSTEMD}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -343,6 +331,7 @@ foreach(TARGET_NAME wivrn wivrn-server wivrn-dashboard wivrn-common wivrn-dissec
|
||||
if(TARGET ${TARGET_NAME})
|
||||
target_compile_options(${TARGET_NAME} PRIVATE
|
||||
-fdiagnostics-color -Wall -Wextra -pedantic
|
||||
-ffast-math
|
||||
-Wundef
|
||||
-Wno-missing-field-initializers
|
||||
-Wno-unused-parameter
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
"inherits": "everything",
|
||||
"binaryDir": "${sourceDir}/build-no-systemd",
|
||||
"cacheVariables": {
|
||||
"WIVRN_BUILD_WIVRNCTL": "OFF",
|
||||
"WIVRN_USE_SYSTEMD": "OFF"
|
||||
}
|
||||
},
|
||||
@@ -108,6 +109,7 @@
|
||||
"inherits": "server",
|
||||
"binaryDir": "${sourceDir}/build-server-no-systemd",
|
||||
"cacheVariables": {
|
||||
"WIVRN_BUILD_WIVRNCTL": "OFF",
|
||||
"WIVRN_USE_SYSTEMD": "OFF"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,33 +1,68 @@
|
||||
# WiVRn
|
||||
<h1 align="center"> WiVRn </h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://www.gnu.org/licenses/gpl-3.0)  
|
||||
|
||||
|
||||
</div>
|
||||
<p align="center"><img src="images/wivrn.svg" width="180"></p>
|
||||
<h3 align="center">Fully FOSS PCVR streamer</h3>
|
||||
|
||||
WiVRn wirelessly connects a standalone VR headset to a Linux computer. You can then play PCVR games on the headset while processing is done on the computer.
|
||||
# About
|
||||
|
||||
It supports a wide range of headsets such as Quest 1 / 2 / Pro / 3 / 3S, Pico Neo 4, HTC Vive Focus 3, HTC Vive XR elite and most other Android based headsets.
|
||||
WiVRn is an application that wirelessly streams a virtual reality game to a standalone VR headset from a <b>Linux</b> computer.
|
||||
|
||||
WiVRn support a wide range of VR devices:
|
||||
|
||||
| Headset | Supported | Notes |
|
||||
|:--------:|:--------:|:--------:|
|
||||
| Quest 1 | ✓ | |
|
||||
| Quest 2 | ✓ | |
|
||||
| Quest 3 | ✓ | |
|
||||
| Quest 3s | ✓ | |
|
||||
| Quest Pro | ✓ | |
|
||||
| Pico Neo 3 | ✓ | |
|
||||
| Pico 4 | ✓ | |
|
||||
| HTC Vive Focus 3 | ✓ | Laggy |
|
||||
| HTC Vive XR Elite | ✓ | Laggy |
|
||||
| Samsung Galaxy XR | ✓ | |
|
||||
| Other Android VR | ? | Cannot know |
|
||||
| Play for Dream | ✖ | https://github.com/WiVRn/WiVRn/issues/465 |
|
||||
| Non-Android VR | ✖ | Not Android |
|
||||
| Non-VR Android | ✖ | VR required |
|
||||
|
||||
<sup>A Linux client does exist, only for debugging. It has no audio or hardware decoding.</sup>
|
||||
|
||||
# Getting started
|
||||
|
||||
|
||||
## Server and dashboard
|
||||
## PC Server/Dashboard
|
||||
|
||||
We recommend using the flatpak package from Flathub:
|
||||
We recommend using native packages if available for your distribution:
|
||||
- [Arch User Repository](https://aur.archlinux.org/packages/wivrn-dashboard)
|
||||
- [Fedora](https://packages.fedoraproject.org/pkgs/wivrn/wivrn/)
|
||||
- [Gentoo Guru](https://gitweb.gentoo.org/repo/proj/guru.git/tree/media-libs/wivrn)
|
||||
- [NixOS](https://search.nixos.org/packages?channel=25.11&show=wivrn)
|
||||
|
||||
For OpenVR and Steam compatibility, you also need a [compatibility library](#openvr-and-steam-games) such as xrizer or OpenComposite.
|
||||
|
||||
A flatpak is available on Flathub for all distributions:
|
||||
|
||||
[](https://flathub.org/apps/io.github.wivrn.wivrn)
|
||||
|
||||
Alternatively, packages are available:
|
||||
- [AUR for Arch](https://aur.archlinux.org/packages/wivrn-dashboard)
|
||||
- [Fedora](https://packages.fedoraproject.org/pkgs/wivrn/wivrn/)
|
||||
- [Guru for Gentoo](https://gitweb.gentoo.org/repo/proj/guru.git/tree/media-libs/wivrn).
|
||||
Note that due to flatpak sandboxing some features may not be available such as Lighthouse tracked devices.
|
||||
|
||||
## Headset Client/App
|
||||
|
||||
## Headset app
|
||||
Follow the wizard in the PC dashboard to install the client on your VR headset.
|
||||
|
||||
Follow the wizard in the dashboard to install the client app on the headset: it will either lead you to the [Meta Store](https://www.meta.com/experiences/7959676140827574/) or download the correct APK.
|
||||
It should either lead you to the [Meta Store](https://www.meta.com/experiences/7959676140827574/) (for Meta Quest headsets) or to download the correct APK (for other headsets).
|
||||
|
||||
⚠️ You will need to have a compatible version: if the headset fails to connect to your computer, see [troubleshooting](#troubleshooting).
|
||||
> [!WARNING]
|
||||
> The VR client and PC server need to be on the same version of WiVRn
|
||||
|
||||
> [!TIP]
|
||||
> If the headset fails to connect to the computer, see [troubleshooting](#troubleshooting).
|
||||
|
||||
|
||||
|
||||
@@ -41,51 +76,52 @@ Avahi must be running:
|
||||
systemctl enable --now avahi-daemon
|
||||
```
|
||||
|
||||
If a firewall is installed, open port 5353/UDP for avahi.
|
||||
Open ports 9757/UDP+TCP for WiVRn itself.
|
||||
- If a firewall is installed, open port 5353/UDP for Avahi and ports 9757/UDP+TCP for WiVRn.
|
||||
- For example, if using UFW run `ufw allow 5353/udp` and `ufw allow 9757`.
|
||||
|
||||
### Running
|
||||
- On your computer, run "WiVRn server" application, or `wivrn-dashboard` from the command line, it will show the connection wizard the first time you launch it.
|
||||
- On your headset, run WiVRn from the App Library. If you are using a Quest and you have installed it from an APK instead of the Meta Store, it will be in the "unknown sources" section.
|
||||
- You should now see your computer in the list: click connect, the screen will show "Connection ready. Start a VR application on **your computer's name**".
|
||||
- On your computer, run "WiVRn server" application, or `wivrn-dashboard` from the command line. It will show the setup wizard the first time you launch it.
|
||||
- On your headset, run WiVRn from the App Library. If you are using a Meta Quest and you have installed it from an APK instead of the Meta Store, it should be in the "unknown sources" section.
|
||||
- You should now see your computer in the list: click connect, the screen will show "Connection ready. Start a VR application on <i>\[your computer's name\]</i>".
|
||||
|
||||
You can now start an OpenXR application on your computer. For Steam games, you will also need to set the launch options to be able to use WiVRn:
|
||||
You can now stream an OpenXR application from your computer to your headset. For Steam games, you may also need to set the launch options to be able to use WiVRn. The server/dashboard will tell you how to do this if required.
|
||||
- Right-click on the game you want to play in VR in Steam and click "Properties".
|
||||
- In the "General" tab, set the launch options to the value given in the dashboard.
|
||||
- In the "General" tab, enter the launch options that the WiVRn server/dashboard gave you inside the "Launch Options" setting.
|
||||
|
||||
You can set an application to be started automatically when you connect your headset in the dashboard settings or [manually](docs/configuration.md#application)
|
||||
You can set an application to be started automatically when your headset is connected, in the dashboard settings or [manually](docs/configuration.md#application).
|
||||
|
||||
### Application list
|
||||
When the headset is connected and no XR application is running, it will show an application launcher. Applications in that list are sourced from:
|
||||
- Steam games that are flagged as VR. Steam may need to be restarted for the list to be updated when new games are installed.
|
||||
- .desktop files that contain `X-WiVRn-VR` in the `Categories` section. Files are searched in [standard locations](https://specifications.freedesktop.org/desktop-entry/latest/file-naming.html#desktop-file-id) which usually include `~/.local/share/applications` and `/usr/share/applications/`.
|
||||
|
||||
### OpenVR and Steam games
|
||||
|
||||
The flatpak also includes [OpenComposite](https://gitlab.com/znixian/OpenOVR/), used to translate the OpenVR API used by SteamVR to OpenXR used by WiVRn, see [SteamVR](docs/steamvr.md) for details.
|
||||
The flatpak includes [OpenComposite](https://gitlab.com/znixian/OpenOVR/) and [xrizer](https://github.com/Supreeeme/xrizer/), used to translate the OpenVR API to OpenXR. see [SteamVR](docs/steamvr.md) for details.
|
||||
|
||||
If using Wine/Proton, it will probe for OpenVR at startup, so even for OpenXR applications, OpenComposite is required.
|
||||
If using Wine/Proton, it will probe for OpenVR at startup, This means even for OpenXR applications, OpenComposite or xrizer is required.
|
||||
|
||||
When you start the server through flatpak, it will automatically configure the current OpenVR to use OpenComposite.
|
||||
When a headset connects, wivrn-server sets the OpenVR runtime to xrizer unless manually configured differently.
|
||||
|
||||
### Steam Flatpak
|
||||
|
||||
If you're using the Steam Flatpak, you'll need to grant read only access to the following paths:
|
||||
|
||||
```bash
|
||||
flatpak override --user \
|
||||
flatpak override \
|
||||
--filesystem=xdg-run/wivrn:ro \
|
||||
--filesystem=xdg-data/flatpak/app/io.github.wivrn.wivrn:ro \
|
||||
--filesystem=/var/lib/flatpak/app/io.github.wivrn.wivrn:ro \
|
||||
--filesystem=xdg-config/openxr:ro \
|
||||
--filesystem=xdg-config/openvr:ro \
|
||||
com.valvesoftware.Steam
|
||||
```
|
||||
|
||||
Then create a symlink for the OpenXR configuration file (the directory `~/.var/app/com.valvesoftware.Steam/.config/openxr` will need to be created if it doesn't already exist):
|
||||
|
||||
```bash
|
||||
ln -s ~/.config/openxr/1 ~/.var/app/com.valvesoftware.Steam/.config/openxr/1
|
||||
```
|
||||
When using a user installation of flatpak Steam, use `override --user` instead of `override`.
|
||||
|
||||
### Audio
|
||||
When the headset is connected, WiVRn will create a virtual output device named WiVRn. It is not selected as default and you should either assign the application to the device when it is running, or mark it as default. To do so you can use `pavucontrol` or your desktop environment's configuration panel. Please note that in `pavucontrol` it will appear as a virtual device.
|
||||
When the headset is connected, WiVRn will create a virtual output device simply named "WiVRn. You must manually set this audio output to enabled/default. Please note that in `pavucontrol` it will appear as a virtual device.
|
||||
|
||||
For microphone, you first have to enable it on the settings tabs on the headset (and give permission when prompted). It will then appear as a virtual input device named WiVRn(microphone) and also needs to be assigned like for output device.
|
||||
To enable microphone, you first have to enable it on the settings tab on the VR headset (and give permission when prompted). It should appear as a virtual input device named "WiVRn(microphone)", and needs to be assigned as the input device (same way as output device).
|
||||
|
||||
|
||||
# Building
|
||||
@@ -99,19 +135,19 @@ Configuration can be done from the dashboard.
|
||||
See [configuration](docs/configuration.md) for editing the configuration manually.
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
## My computer is not seen by the headset
|
||||
<details><summary>My computer is not seen by the headset</summary>
|
||||
|
||||
If the server list is empty in the headset app:
|
||||
- Make sure your computer is connected on the same network as your headset
|
||||
- Check that avahi is running with `systemctl status avahi-daemon`, if it is not, enable it with `systemctl enable --now avahi-daemon`
|
||||
- If you have a firewall, check that port 5353 (UDP) is open
|
||||
- If you have a firewall, check that port 5353 (UDP) is open</details>
|
||||
|
||||
## My headset does not connect to my computer
|
||||
<details><summary>My headset does not connect to my computer</summary>
|
||||
|
||||
- If you have a firewall, check that port 9757 (UDP and TCP) is open
|
||||
- The server and client must be compatible:
|
||||
- The server and client must be the same version.</details>
|
||||
|
||||
## How do I use a wired connection?
|
||||
<details><summary>How do I use a wired connection?</summary>
|
||||
|
||||
- Make sure the WiVRn Server is installed and running on your computer
|
||||
- Make sure you have the WiVRn app installed on your headset
|
||||
@@ -125,13 +161,33 @@ If the server list is empty in the headset app:
|
||||
- `org.meumeu.wivrn.github.nighly` for Github nightlies (wirvn-apk [repository](https://github.com/WiVRn/WiVRn-APK/releases))
|
||||
- `org.meumeu.wivrn.github.testing` for Github CI builds
|
||||
- `org.meumeu.wivrn.local` for developer builds
|
||||
- You can now continue the pairing process as documented in the running section.
|
||||
- You can now continue the pairing process as documented in the running section.</details>
|
||||
|
||||
## How do I see server logs when using the dashboard?
|
||||
<details><summary>How do I see server logs when using the dashboard?</summary>
|
||||
|
||||
- Click Troubleshoot > Open server logs, or
|
||||
- Navigate to `${XDG_STATE_HOME}/wivrn/wivrn-dashboard` (with fallback to `${HOME}/.local/state` for `${XDG_STATE_HOME}`, or
|
||||
- For flatpak, navigate to `${HOME}/.var/app/io.github.wivrn.wivrn/.local/state/wivrn/wivrn-dashboard`.</details>
|
||||
|
||||
<details><summary>I have high motion latency, black borders following my view, hear corrupted audio or see a corrupted, pixelated image</summary>
|
||||
|
||||
- When connecting through USB, make sure the headset isn't connected through WiFi (switch off WiFi)
|
||||
- Reset the settings using the button at the bottom of the settings tab
|
||||
- Try switching to software encoding
|
||||
- Decrease the bitrate
|
||||
- Decrease the resolution in the WiVRn app
|
||||
- Connect through USB or use a better WiFi router.
|
||||
|
||||
Note: WiVRn isn't properly optimized for NVIDIA GPUs due to the lack of developers with NVIDIA hardware. Motion latency may be significantly worse at rendering resolutions higher than default.</details>
|
||||
|
||||
# Community Support
|
||||
|
||||
We are available on either **Discord** or **Matrix space**:
|
||||
|
||||
[](https://discord.gg/EHAYe3tTYa) [](https://matrix.to/#/#linux-vr-adventures:matrix.org)
|
||||
|
||||
Please use the `wivrn` chat room for questions or issues specific to WiVRn.
|
||||
|
||||
```
|
||||
journalctl -f --no-hostname -u io.github.wivrn.wivrn.desktop
|
||||
```
|
||||
|
||||
# Contributing
|
||||
|
||||
@@ -155,7 +211,7 @@ WiVRn uses the following software:
|
||||
- [HarfBuzz](https://harfbuzz.github.io/)
|
||||
- [librsvg](https://wiki.gnome.org/Projects/LibRsvg)
|
||||
- [Monado](https://monado.freedesktop.org/)
|
||||
- [nvenc](https://developer.nvidia.com/nvidia-video-codec-sdk) optional, for hardware encoding on Nvidia
|
||||
- [nvenc](https://developer.nvidia.com/nvidia-video-codec-sdk) optional, for hardware encoding on NVIDIA
|
||||
- [qCoro](https://qcoro.dev/)
|
||||
- [Qt 6](https://www.qt.io/) optional, for the dashboard
|
||||
- [spdlog](https://github.com/gabime/spdlog)
|
||||
|
||||
|
Before Width: | Height: | Size: 1023 KiB After Width: | Height: | Size: 1023 KiB |
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
|
||||
<svg
|
||||
fill="#000000"
|
||||
height="800px"
|
||||
width="800px"
|
||||
version="1.1"
|
||||
id="Layer_1"
|
||||
viewBox="0 0 512 512"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="default-environment.svg"
|
||||
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs2" /><sodipodi:namedview
|
||||
id="namedview2"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="2.235"
|
||||
inkscape:cx="400"
|
||||
inkscape:cy="400"
|
||||
inkscape:window-width="3840"
|
||||
inkscape:window-height="2058"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g1" />
|
||||
<g
|
||||
id="g2">
|
||||
<g
|
||||
id="g1">
|
||||
<path
|
||||
d="M0,0v512h512V0H0z M460.075,30.417l-43.548,43.547L372.98,30.417H460.075z M481.583,51.925v117.512L336.264,314.755 l-58.756-58.756L481.583,51.925z M395.02,95.472L95.472,395.019l-58.756-58.756L336.264,36.717L395.02,95.472z M299.547,30.417 L175.736,154.228L116.98,95.472l65.055-65.055H299.547z M30.417,30.417H139.02L30.417,139.02V30.417z M30.417,182.036 l65.055-65.055l58.756,58.756L30.417,299.546V182.036z M30.417,372.979l43.547,43.547l-43.547,43.547V372.979z M51.925,481.583 L256,277.508l58.756,58.756L169.437,481.583H51.925z M212.453,481.583l269.13-269.129v117.51L329.964,481.583H212.453z M372.981,481.583l43.546-43.547l43.547,43.547H372.981z M481.583,460.075l-43.547-43.547l43.547-43.547V460.075z"
|
||||
id="path1"
|
||||
inkscape:label="path1"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 930 B After Width: | Height: | Size: 930 B |
@@ -70,9 +70,6 @@
|
||||
"generator": "Aspose.3D 24.1.0",
|
||||
"version": "2.0"
|
||||
},
|
||||
"extensionsUsed": [
|
||||
"KHR_texture_basisu"
|
||||
],
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "data:application/octet-stream;base64,AAABAAIAAwAEAAUAAAAAAAAAIMEAAAAAAAAgwQAAAAAAAIA/AAAAACUAgD8AAAAAAAAgwQAAAAAAACBBAACgQAAAgD8AAAAAJQCAPwAAAAAAACBBAAAAAAAAIMEAAAAAAACAwAAAAAAlAIA/AAAAAAAAIEEAAAAAAAAgQQAAoEAAAIDAAAAAACUAgD8AAAAAAAAgQQAAAAAAACDBAAAAAAAAgMAAAAAAJQCAPwAAAAAAACDBAAAAAAAAIEEAAKBAAACAPwAAAAAlAIA/AAAAAAAAAAA=",
|
||||
@@ -82,9 +79,6 @@
|
||||
"images": [
|
||||
{
|
||||
"uri": "WoodFloor051_1K-JPG_Color.jpg"
|
||||
},
|
||||
{
|
||||
"uri": "WoodFloor051_1K-JPG_Color.ktx2"
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
@@ -129,12 +123,7 @@
|
||||
"textures": [
|
||||
{
|
||||
"sampler": 0,
|
||||
"source": 0,
|
||||
"extensions": {
|
||||
"KHR_texture_basisu": {
|
||||
"source": 1
|
||||
}
|
||||
}
|
||||
"source": 0
|
||||
}
|
||||
],
|
||||
"materials": [
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
|
||||
<svg
|
||||
viewBox="0 0 576 512"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="passthrough.svg"
|
||||
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="3.4921875"
|
||||
inkscape:cx="288.07159"
|
||||
inkscape:cy="256"
|
||||
inkscape:window-width="3840"
|
||||
inkscape:window-height="2058"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg1" />
|
||||
<!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.-->
|
||||
<path
|
||||
d="M96 64c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64L96 64zM464 336l73.5 58.8c4.2 3.4 9.4 5.2 14.8 5.2 13.1 0 23.7-10.6 23.7-23.7l0-240.6c0-13.1-10.6-23.7-23.7-23.7-5.4 0-10.6 1.8-14.8 5.2L464 176 464 336z"
|
||||
id="path1"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -1,168 +0,0 @@
|
||||
{
|
||||
"profileId": "generic-trigger-squeeze",
|
||||
"fallbackProfileIds": [],
|
||||
"layouts": {
|
||||
"left": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "generic-trigger-squeeze-left",
|
||||
"assetPath": "left.glb"
|
||||
},
|
||||
"right": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "generic-trigger-squeeze-right",
|
||||
"assetPath": "right.glb"
|
||||
},
|
||||
"none": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
},
|
||||
"xr_standard_squeeze_pressed_mirror": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_mirror_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_mirror_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_mirror_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "generic-trigger-squeeze-none",
|
||||
"assetPath": "none.glb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
{
|
||||
"profileId": "htc-vive-focus-3",
|
||||
"fallbackProfileIds": [
|
||||
"generic-trigger-squeeze-thumbstick"
|
||||
],
|
||||
"layouts": {
|
||||
"left": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "x_button",
|
||||
"visualResponses": {
|
||||
"x_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "x_button_pressed_value",
|
||||
"minNodeName": "x_button_pressed_min",
|
||||
"maxNodeName": "x_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"y-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "y_button",
|
||||
"visualResponses": {
|
||||
"y_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "y_button_pressed_value",
|
||||
"minNodeName": "y_button_pressed_min",
|
||||
"maxNodeName": "y_button_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "htc-vive-focus-3-left",
|
||||
"assetPath": "left.glb"
|
||||
},
|
||||
"right": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"a-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "a_button",
|
||||
"visualResponses": {
|
||||
"a_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "a_button_pressed_value",
|
||||
"minNodeName": "a_button_pressed_min",
|
||||
"maxNodeName": "a_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"b-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "b_button",
|
||||
"visualResponses": {
|
||||
"b_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "b_button_pressed_value",
|
||||
"minNodeName": "b_button_pressed_min",
|
||||
"maxNodeName": "b_button_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "htc-vive-focus-3-right",
|
||||
"assetPath": "right.glb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,330 +0,0 @@
|
||||
{
|
||||
"profileId": "meta-quest-touch-plus",
|
||||
"fallbackProfileIds": [
|
||||
"oculus-touch-v3",
|
||||
"oculus-touch",
|
||||
"generic-trigger-squeeze-thumbstick"
|
||||
],
|
||||
"layouts": {
|
||||
"left": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "x_button",
|
||||
"visualResponses": {
|
||||
"x_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "x_button_pressed_value",
|
||||
"minNodeName": "x_button_pressed_min",
|
||||
"maxNodeName": "x_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"y-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "y_button",
|
||||
"visualResponses": {
|
||||
"y_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "y_button_pressed_value",
|
||||
"minNodeName": "y_button_pressed_min",
|
||||
"maxNodeName": "y_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbrest": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 6
|
||||
},
|
||||
"rootNodeName": "thumbrest",
|
||||
"visualResponses": {
|
||||
"thumbrest_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "thumbrest_pressed_value",
|
||||
"minNodeName": "thumbrest_pressed_min",
|
||||
"maxNodeName": "thumbrest_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "meta-quest-touch-plus-left",
|
||||
"assetPath": "left.glb"
|
||||
},
|
||||
"right": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"a-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "a_button",
|
||||
"visualResponses": {
|
||||
"a_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "a_button_pressed_value",
|
||||
"minNodeName": "a_button_pressed_min",
|
||||
"maxNodeName": "a_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"b-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "b_button",
|
||||
"visualResponses": {
|
||||
"b_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "b_button_pressed_value",
|
||||
"minNodeName": "b_button_pressed_min",
|
||||
"maxNodeName": "b_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbrest": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 6
|
||||
},
|
||||
"rootNodeName": "thumbrest",
|
||||
"visualResponses": {
|
||||
"thumbrest_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "thumbrest_pressed_value",
|
||||
"minNodeName": "thumbrest_pressed_min",
|
||||
"maxNodeName": "thumbrest_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "meta-quest-touch-plus-right",
|
||||
"assetPath": "right.glb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,330 +0,0 @@
|
||||
{
|
||||
"profileId": "meta-quest-touch-pro",
|
||||
"fallbackProfileIds": [
|
||||
"oculus-touch-v2",
|
||||
"oculus-touch",
|
||||
"generic-trigger-squeeze-thumbstick"
|
||||
],
|
||||
"layouts": {
|
||||
"left": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "x_button",
|
||||
"visualResponses": {
|
||||
"x_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "x_button_pressed_value",
|
||||
"minNodeName": "x_button_pressed_min",
|
||||
"maxNodeName": "x_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"y-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "y_button",
|
||||
"visualResponses": {
|
||||
"y_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "y_button_pressed_value",
|
||||
"minNodeName": "y_button_pressed_min",
|
||||
"maxNodeName": "y_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbrest": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 6
|
||||
},
|
||||
"rootNodeName": "thumbrest",
|
||||
"visualResponses": {
|
||||
"thumbrest_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "thumbrest_pressed_value",
|
||||
"minNodeName": "thumbrest_pressed_min",
|
||||
"maxNodeName": "thumbrest_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "meta-quest-touch-pro-left",
|
||||
"assetPath": "left.glb"
|
||||
},
|
||||
"right": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"a-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "a_button",
|
||||
"visualResponses": {
|
||||
"a_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "a_button_pressed_value",
|
||||
"minNodeName": "a_button_pressed_min",
|
||||
"maxNodeName": "a_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"b-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "b_button",
|
||||
"visualResponses": {
|
||||
"b_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "b_button_pressed_value",
|
||||
"minNodeName": "b_button_pressed_min",
|
||||
"maxNodeName": "b_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbrest": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 6
|
||||
},
|
||||
"rootNodeName": "thumbrest",
|
||||
"visualResponses": {
|
||||
"thumbrest_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "thumbrest_pressed_value",
|
||||
"minNodeName": "thumbrest_pressed_min",
|
||||
"maxNodeName": "thumbrest_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "meta-quest-touch-pro-right",
|
||||
"assetPath": "right.glb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,329 +0,0 @@
|
||||
{
|
||||
"profileId": "oculus-touch-v2",
|
||||
"fallbackProfileIds": [
|
||||
"oculus-touch",
|
||||
"generic-trigger-squeeze-thumbstick"
|
||||
],
|
||||
"layouts": {
|
||||
"left": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "x_button",
|
||||
"visualResponses": {
|
||||
"x_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "x_button_pressed_value",
|
||||
"minNodeName": "x_button_pressed_min",
|
||||
"maxNodeName": "x_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"y-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "y_button",
|
||||
"visualResponses": {
|
||||
"y_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "y_button_pressed_value",
|
||||
"minNodeName": "y_button_pressed_min",
|
||||
"maxNodeName": "y_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbrest": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 6
|
||||
},
|
||||
"rootNodeName": "thumbrest",
|
||||
"visualResponses": {
|
||||
"thumbrest_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "thumbrest_pressed_value",
|
||||
"minNodeName": "thumbrest_pressed_min",
|
||||
"maxNodeName": "thumbrest_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "oculus-touch-v2-left",
|
||||
"assetPath": "left.glb"
|
||||
},
|
||||
"right": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"a-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "a_button",
|
||||
"visualResponses": {
|
||||
"a_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "a_button_pressed_value",
|
||||
"minNodeName": "a_button_pressed_min",
|
||||
"maxNodeName": "a_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"b-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "b_button",
|
||||
"visualResponses": {
|
||||
"b_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "b_button_pressed_value",
|
||||
"minNodeName": "b_button_pressed_min",
|
||||
"maxNodeName": "b_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbrest": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 6
|
||||
},
|
||||
"rootNodeName": "thumbrest",
|
||||
"visualResponses": {
|
||||
"thumbrest_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "thumbrest_pressed_value",
|
||||
"minNodeName": "thumbrest_pressed_min",
|
||||
"maxNodeName": "thumbrest_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "oculus-touch-v2-right",
|
||||
"assetPath": "right.glb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,330 +0,0 @@
|
||||
{
|
||||
"profileId": "oculus-touch-v3",
|
||||
"fallbackProfileIds": [
|
||||
"oculus-touch-v2",
|
||||
"oculus-touch",
|
||||
"generic-trigger-squeeze-thumbstick"
|
||||
],
|
||||
"layouts": {
|
||||
"left": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "x_button",
|
||||
"visualResponses": {
|
||||
"x_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "x_button_pressed_value",
|
||||
"minNodeName": "x_button_pressed_min",
|
||||
"maxNodeName": "x_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"y-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "y_button",
|
||||
"visualResponses": {
|
||||
"y_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "y_button_pressed_value",
|
||||
"minNodeName": "y_button_pressed_min",
|
||||
"maxNodeName": "y_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbrest": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 6
|
||||
},
|
||||
"rootNodeName": "thumbrest",
|
||||
"visualResponses": {
|
||||
"thumbrest_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "thumbrest_pressed_value",
|
||||
"minNodeName": "thumbrest_pressed_min",
|
||||
"maxNodeName": "thumbrest_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "oculus-touch-v3-left",
|
||||
"assetPath": "left.glb"
|
||||
},
|
||||
"right": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"a-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "a_button",
|
||||
"visualResponses": {
|
||||
"a_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "a_button_pressed_value",
|
||||
"minNodeName": "a_button_pressed_min",
|
||||
"maxNodeName": "a_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"b-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "b_button",
|
||||
"visualResponses": {
|
||||
"b_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "b_button_pressed_value",
|
||||
"minNodeName": "b_button_pressed_min",
|
||||
"maxNodeName": "b_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbrest": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 6
|
||||
},
|
||||
"rootNodeName": "thumbrest",
|
||||
"visualResponses": {
|
||||
"thumbrest_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "thumbrest_pressed_value",
|
||||
"minNodeName": "thumbrest_pressed_min",
|
||||
"maxNodeName": "thumbrest_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "oculus-touch-v3-right",
|
||||
"assetPath": "right.glb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
{
|
||||
"profileId": "pico-4",
|
||||
"fallbackProfileIds": [
|
||||
"generic-trigger-squeeze-thumbstick"
|
||||
],
|
||||
"layouts": {
|
||||
"left": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "x_button",
|
||||
"visualResponses": {
|
||||
"x_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "x_button_pressed_value",
|
||||
"minNodeName": "x_button_pressed_min",
|
||||
"maxNodeName": "x_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"y-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "y_button",
|
||||
"visualResponses": {
|
||||
"y_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "y_button_pressed_value",
|
||||
"minNodeName": "y_button_pressed_min",
|
||||
"maxNodeName": "y_button_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "pico-4-left",
|
||||
"assetPath": "left.glb"
|
||||
},
|
||||
"right": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"a-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "a_button",
|
||||
"visualResponses": {
|
||||
"a_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "a_button_pressed_value",
|
||||
"minNodeName": "a_button_pressed_min",
|
||||
"maxNodeName": "a_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"b-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "b_button",
|
||||
"visualResponses": {
|
||||
"b_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "b_button_pressed_value",
|
||||
"minNodeName": "b_button_pressed_min",
|
||||
"maxNodeName": "b_button_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "pico-4-right",
|
||||
"assetPath": "right.glb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
{
|
||||
"profileId": "pico-neo3",
|
||||
"fallbackProfileIds": [
|
||||
"generic-trigger-squeeze-thumbstick"
|
||||
],
|
||||
"layouts": {
|
||||
"left": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "x_button",
|
||||
"visualResponses": {
|
||||
"x_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "x_button_pressed_value",
|
||||
"minNodeName": "x_button_pressed_min",
|
||||
"maxNodeName": "x_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"y-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "y_button",
|
||||
"visualResponses": {
|
||||
"y_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "y_button_pressed_value",
|
||||
"minNodeName": "y_button_pressed_min",
|
||||
"maxNodeName": "y_button_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "pico-neo3-left",
|
||||
"assetPath": "left.glb"
|
||||
},
|
||||
"right": {
|
||||
"selectComponentId": "xr-standard-trigger",
|
||||
"components": {
|
||||
"xr-standard-trigger": {
|
||||
"type": "trigger",
|
||||
"gamepadIndices": {
|
||||
"button": 0
|
||||
},
|
||||
"rootNodeName": "xr_standard_trigger",
|
||||
"visualResponses": {
|
||||
"xr_standard_trigger_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_trigger_pressed_value",
|
||||
"minNodeName": "xr_standard_trigger_pressed_min",
|
||||
"maxNodeName": "xr_standard_trigger_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-squeeze": {
|
||||
"type": "squeeze",
|
||||
"gamepadIndices": {
|
||||
"button": 1
|
||||
},
|
||||
"rootNodeName": "xr_standard_squeeze",
|
||||
"visualResponses": {
|
||||
"xr_standard_squeeze_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_squeeze_pressed_value",
|
||||
"minNodeName": "xr_standard_squeeze_pressed_min",
|
||||
"maxNodeName": "xr_standard_squeeze_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"xr-standard-thumbstick": {
|
||||
"type": "thumbstick",
|
||||
"gamepadIndices": {
|
||||
"button": 3,
|
||||
"xAxis": 2,
|
||||
"yAxis": 3
|
||||
},
|
||||
"rootNodeName": "xr_standard_thumbstick",
|
||||
"visualResponses": {
|
||||
"xr_standard_thumbstick_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_xaxis_pressed": {
|
||||
"componentProperty": "xAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
|
||||
},
|
||||
"xr_standard_thumbstick_yaxis_pressed": {
|
||||
"componentProperty": "yAxis",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
|
||||
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
|
||||
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"a-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 4
|
||||
},
|
||||
"rootNodeName": "a_button",
|
||||
"visualResponses": {
|
||||
"a_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "a_button_pressed_value",
|
||||
"minNodeName": "a_button_pressed_min",
|
||||
"maxNodeName": "a_button_pressed_max"
|
||||
}
|
||||
}
|
||||
},
|
||||
"b-button": {
|
||||
"type": "button",
|
||||
"gamepadIndices": {
|
||||
"button": 5
|
||||
},
|
||||
"rootNodeName": "b_button",
|
||||
"visualResponses": {
|
||||
"b_button_pressed": {
|
||||
"componentProperty": "button",
|
||||
"states": [
|
||||
"default",
|
||||
"touched",
|
||||
"pressed"
|
||||
],
|
||||
"valueNodeProperty": "transform",
|
||||
"valueNodeName": "b_button_pressed_value",
|
||||
"minNodeName": "b_button_pressed_min",
|
||||
"maxNodeName": "b_button_pressed_max"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gamepadMapping": "xr-standard",
|
||||
"rootNodeName": "pico-neo3-right",
|
||||
"assetPath": "right.glb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
Snapdragon(TM) Game Super Resolution
|
||||
Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
|
||||
https://github.com/SnapdragonStudios/snapdragon-gsr
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
@@ -1,148 +0,0 @@
|
||||
{
|
||||
"asset":{
|
||||
"generator":"Khronos glTF Blender I/O v4.2.70",
|
||||
"version":"2.0"
|
||||
},
|
||||
"scene":0,
|
||||
"scenes":[
|
||||
{
|
||||
"name":"Scene",
|
||||
"nodes":[
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes":[
|
||||
{
|
||||
"mesh":0,
|
||||
"name":"Cylinder",
|
||||
"rotation":[
|
||||
0.7071068286895752,
|
||||
0,
|
||||
0,
|
||||
0.7071068286895752
|
||||
],
|
||||
"translation":[
|
||||
0,
|
||||
0,
|
||||
-0.5
|
||||
],
|
||||
"scale":[0.7,1,0.7]
|
||||
}
|
||||
],
|
||||
"materials":[
|
||||
{
|
||||
"name":"Material.001",
|
||||
"pbrMetallicRoughness":{
|
||||
"baseColorFactor":[0,0,0,0.5]
|
||||
},
|
||||
"emissiveTexture":{
|
||||
"index":0
|
||||
},
|
||||
"emissiveFactor": [ 2.0, 2.0, 2.0 ]
|
||||
}
|
||||
],
|
||||
"meshes":[
|
||||
{
|
||||
"name":"Cylinder.001",
|
||||
"primitives":[
|
||||
{
|
||||
"attributes":{
|
||||
"POSITION":0,
|
||||
"NORMAL":1,
|
||||
"TEXCOORD_0":2
|
||||
},
|
||||
"indices":3,
|
||||
"material":0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures":[
|
||||
{
|
||||
"sampler":0,
|
||||
"source":0
|
||||
}
|
||||
],
|
||||
"images":[
|
||||
{
|
||||
"mimeType":"image/png",
|
||||
"name":"Untitled",
|
||||
"uri":"ray.png"
|
||||
}
|
||||
],
|
||||
"accessors":[
|
||||
{
|
||||
"bufferView":0,
|
||||
"componentType":5126,
|
||||
"count":18,
|
||||
"max":[
|
||||
0.004000000189989805,
|
||||
0.5,
|
||||
0.004000000189989805
|
||||
],
|
||||
"min":[
|
||||
-0.004000000189989805,
|
||||
-0.5,
|
||||
-0.004000000189989805
|
||||
],
|
||||
"type":"VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView":1,
|
||||
"componentType":5126,
|
||||
"count":18,
|
||||
"type":"VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView":2,
|
||||
"componentType":5126,
|
||||
"count":18,
|
||||
"type":"VEC2"
|
||||
},
|
||||
{
|
||||
"bufferView":3,
|
||||
"componentType":5123,
|
||||
"count":48,
|
||||
"type":"SCALAR"
|
||||
}
|
||||
],
|
||||
"bufferViews":[
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":216,
|
||||
"byteOffset":0,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":216,
|
||||
"byteOffset":216,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":144,
|
||||
"byteOffset":432,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":96,
|
||||
"byteOffset":576,
|
||||
"target":34963
|
||||
}
|
||||
],
|
||||
"samplers":[
|
||||
{
|
||||
"magFilter":9729,
|
||||
"minFilter":9987
|
||||
}
|
||||
],
|
||||
"buffers":[
|
||||
{
|
||||
"byteLength":672,
|
||||
"uri":"ray.bin"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
{
|
||||
"asset":{
|
||||
"generator":"Khronos glTF Blender I/O v4.2.70",
|
||||
"version":"2.0"
|
||||
},
|
||||
"scene":0,
|
||||
"scenes":[
|
||||
{
|
||||
"name":"Scene",
|
||||
"nodes":[
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes":[
|
||||
{
|
||||
"mesh":0,
|
||||
"name":"Cylinder",
|
||||
"rotation":[
|
||||
0.7071068286895752,
|
||||
0,
|
||||
0,
|
||||
0.7071068286895752
|
||||
],
|
||||
"translation":[
|
||||
0,
|
||||
0,
|
||||
-0.5
|
||||
],
|
||||
"scale":[0.7,1,0.7]
|
||||
}
|
||||
],
|
||||
"materials":[
|
||||
{
|
||||
"name":"Material.001",
|
||||
"pbrMetallicRoughness":{
|
||||
"baseColorFactor":[0,0,0,0]
|
||||
},
|
||||
"emissiveTexture":{
|
||||
"index":0
|
||||
},
|
||||
"emissiveFactor": [ 1.0, 1.0, 1.0 ]
|
||||
}
|
||||
],
|
||||
"meshes":[
|
||||
{
|
||||
"name":"Cylinder.001",
|
||||
"primitives":[
|
||||
{
|
||||
"attributes":{
|
||||
"POSITION":0,
|
||||
"NORMAL":1,
|
||||
"TEXCOORD_0":2
|
||||
},
|
||||
"indices":3,
|
||||
"material":0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures":[
|
||||
{
|
||||
"sampler":0,
|
||||
"source":0
|
||||
}
|
||||
],
|
||||
"images":[
|
||||
{
|
||||
"mimeType":"image/png",
|
||||
"name":"Untitled",
|
||||
"uri":"ray.png"
|
||||
}
|
||||
],
|
||||
"accessors":[
|
||||
{
|
||||
"bufferView":0,
|
||||
"componentType":5126,
|
||||
"count":18,
|
||||
"max":[
|
||||
0.004000000189989805,
|
||||
0.5,
|
||||
0.004000000189989805
|
||||
],
|
||||
"min":[
|
||||
-0.004000000189989805,
|
||||
-0.5,
|
||||
-0.004000000189989805
|
||||
],
|
||||
"type":"VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView":1,
|
||||
"componentType":5126,
|
||||
"count":18,
|
||||
"type":"VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView":2,
|
||||
"componentType":5126,
|
||||
"count":18,
|
||||
"type":"VEC2"
|
||||
},
|
||||
{
|
||||
"bufferView":3,
|
||||
"componentType":5123,
|
||||
"count":48,
|
||||
"type":"SCALAR"
|
||||
}
|
||||
],
|
||||
"bufferViews":[
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":216,
|
||||
"byteOffset":0,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":216,
|
||||
"byteOffset":216,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":144,
|
||||
"byteOffset":432,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":96,
|
||||
"byteOffset":576,
|
||||
"target":34963
|
||||
}
|
||||
],
|
||||
"samplers":[
|
||||
{
|
||||
"magFilter":9729,
|
||||
"minFilter":9987
|
||||
}
|
||||
],
|
||||
"buffers":[
|
||||
{
|
||||
"byteLength":672,
|
||||
"uri":"ray.bin"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 581 B |
@@ -4,7 +4,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.7.3'
|
||||
classpath 'com.android.tools.build:gradle:8.13.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,45 +17,86 @@ allprojects {
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
task "generatePngs"() {
|
||||
group = 'Custom'
|
||||
|
||||
mkdir layout.buildDirectory.dir('generated_resources')
|
||||
["mipmap-mdpi", "mipmap-hdpi", "mipmap-xhdpi", "mipmap-xxhdpi", "mipmap-xxxhdpi", ].each {
|
||||
mkdir layout.buildDirectory.dir("generated_resources/${it}")
|
||||
}
|
||||
import javax.inject.Inject
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.process.ExecOperations
|
||||
|
||||
def css = project.hasProperty('wivrn_css') ? project.wivrn_css: "images/wivrn-local.css"
|
||||
abstract class GeneratePngsTask extends DefaultTask {
|
||||
@Inject
|
||||
abstract ExecOperations getExecOps()
|
||||
|
||||
exec {
|
||||
executable = 'rsvg-convert'
|
||||
args = [ "images/wivrn.svg", "-w", "48", "-h", "48", "-o", layout.buildDirectory.file('generated_resources/mipmap-mdpi/ic_wivrn_launcher.png').get().asFile, '--stylesheet=' + css ]
|
||||
}
|
||||
@InputFile
|
||||
abstract RegularFileProperty getSvg()
|
||||
|
||||
exec {
|
||||
executable = 'rsvg-convert'
|
||||
args = [ "images/wivrn.svg", "-w", "72", "-h", "72", "-o", layout.buildDirectory.file('generated_resources/mipmap-hdpi/ic_wivrn_launcher.png').get().asFile, '--stylesheet=' + css ]
|
||||
}
|
||||
@InputFile
|
||||
@Optional
|
||||
abstract RegularFileProperty getCss()
|
||||
|
||||
exec {
|
||||
executable = 'rsvg-convert'
|
||||
args = [ "images/wivrn.svg", "-w", "96", "-h", "96", "-o", layout.buildDirectory.file('generated_resources/mipmap-xhdpi/ic_wivrn_launcher.png').get().asFile, '--stylesheet=' + css ]
|
||||
}
|
||||
@OutputDirectory
|
||||
abstract DirectoryProperty getOutputDir()
|
||||
|
||||
exec {
|
||||
executable = 'rsvg-convert'
|
||||
args = [ "images/wivrn.svg", "-w", "144", "-h", "144", "-o", layout.buildDirectory.file('generated_resources/mipmap-xxhdpi/ic_wivrn_launcher.png').get().asFile, '--stylesheet=' + css ]
|
||||
}
|
||||
@TaskAction
|
||||
void generate() {
|
||||
def outDir = getOutputDir().get().asFile
|
||||
outDir.mkdirs()
|
||||
|
||||
exec {
|
||||
executable = 'rsvg-convert'
|
||||
args = [ "images/wivrn.svg", "-w", "192", "-h", "192", "-o", layout.buildDirectory.file('generated_resources/mipmap-xxxhdpi/ic_wivrn_launcher.png').get().asFile, '--stylesheet=' + css ]
|
||||
// Map of density → size
|
||||
def dpiConfigs = [
|
||||
"mipmap-mdpi" : 48,
|
||||
"mipmap-hdpi" : 72,
|
||||
"mipmap-xhdpi" : 96,
|
||||
"mipmap-xxhdpi" : 144,
|
||||
"mipmap-xxxhdpi": 192
|
||||
]
|
||||
|
||||
def cssFile = getCss().isPresent() ? getCss().get().asFile : null
|
||||
|
||||
dpiConfigs.each { dpi, size ->
|
||||
def dpiDir = new File(outDir, dpi)
|
||||
dpiDir.mkdirs()
|
||||
|
||||
def outputFile = new File(dpiDir, "ic_wivrn_launcher.png")
|
||||
|
||||
def argsList = [
|
||||
getSvg().get().asFile.absolutePath,
|
||||
"-w", size.toString(),
|
||||
"-h", size.toString(),
|
||||
"-o", outputFile.absolutePath
|
||||
]
|
||||
if (cssFile != null) {
|
||||
argsList.add("--stylesheet=${cssFile.absolutePath}")
|
||||
}
|
||||
|
||||
execOps.exec {
|
||||
executable = "rsvg-convert"
|
||||
args = argsList
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("generatePngs", GeneratePngsTask) {
|
||||
group = "Custom"
|
||||
|
||||
// configure defaults
|
||||
svg.set(layout.projectDirectory.file("images/wivrn.svg"))
|
||||
outputDir.set(layout.buildDirectory.dir("generated_resources"))
|
||||
|
||||
if (project.hasProperty("wivrn_css")) {
|
||||
css.set(layout.projectDirectory.file(project.wivrn_css))
|
||||
} else {
|
||||
css.set(layout.projectDirectory.file("images/wivrn-local.css"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
android {
|
||||
namespace "org.meumeu.wivrn"
|
||||
ndkVersion "28.1.13356709"
|
||||
namespace = "org.meumeu.wivrn"
|
||||
ndkVersion = "28.2.13676358"
|
||||
|
||||
lint {
|
||||
disable += "ExpiredTargetSdkVersion"
|
||||
@@ -66,24 +107,29 @@ android {
|
||||
// for Vulkan, need at least 24
|
||||
// for AImage_getHardwareBuffer, API 26
|
||||
minSdkVersion 29
|
||||
compileSdkVersion 32
|
||||
compileSdkVersion 34
|
||||
targetSdkVersion 32 // for Oculus Store
|
||||
|
||||
versionName = project.hasProperty('wivrn_version') ? wivrn_version : "1.0"
|
||||
versionCode = project.hasProperty('wivrn_versionCode') ? wivrn_versionCode.toInteger() : 1
|
||||
def showImguiDemo = project.hasProperty('wivrn_show_imgui_demo') ? wivrn_show_imgui_demo : 'OFF'
|
||||
def showDebugMenu = project.hasProperty('wivrn_show_debug_menu') ? wivrn_show_debug_menu : 'OFF'
|
||||
def compressGlb = project.hasProperty('wivrn_compress_glb') ? wivrn_compress_glb : 'OFF'
|
||||
def fetchcontentBaseDir = project.hasProperty('fetchcontent_base_dir') ? ['-DFETCHCONTENT_BASE_DIR=' + fetchcontent_base_dir] : []
|
||||
|
||||
externalNativeBuild {
|
||||
def css = project.hasProperty('wivrn_css') ? project.wivrn_css: "images/wivrn-local.css"
|
||||
|
||||
cmake {
|
||||
arguments '-DANDROID_TOOLCHAIN=clang',
|
||||
arguments = ['-DANDROID_TOOLCHAIN=clang',
|
||||
'-DANDROID_STL=c++_static',
|
||||
'-DCMAKE_ANDROID_NDK_VERSION=' + ndkVersion,
|
||||
'-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON',
|
||||
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
|
||||
'-DCMAKE_ANDROID_ASSETS_DIRECTORIES=' + layout.buildDirectory.dir("assets").get().asFile,
|
||||
'-DWIVRN_USE_SYSTEM_BOOST=OFF',
|
||||
'-DWIVRN_USE_SYSTEM_FREETYPE=OFF',
|
||||
'-DWIVRN_USE_ANDROID_BIN_LIBKTX=ON',
|
||||
'-DWIVRN_BUILD_CLIENT=ON',
|
||||
'-DWIVRN_BUILD_SERVER=OFF',
|
||||
'-DWIVRN_BUILD_SERVER_LIBRARY=OFF',
|
||||
@@ -92,9 +138,13 @@ android {
|
||||
'-DWIVRN_WERROR=ON',
|
||||
'-DWIVRN_SHOW_IMGUI_DEMO_WINDOW=' + showImguiDemo,
|
||||
'-DWIVRN_CLIENT_DEBUG_MENU=' + showDebugMenu,
|
||||
'-DWIVRN_CSS=' + css
|
||||
'-DWIVRN_CSS=' + css,
|
||||
'-DWIVRN_COMPRESS_GLB=' + compressGlb] +
|
||||
fetchcontentBaseDir
|
||||
resValue "string", "app_name", project.hasProperty('wivrn_app_name') ? project.wivrn_app_name : "WiVRn Local"
|
||||
abiFilters 'arm64-v8a'//, 'x86_64'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +155,7 @@ android {
|
||||
keyAlias "default_key"
|
||||
storePassword signingKeyPassword // Set in gradle.properties
|
||||
keyPassword signingKeyPassword
|
||||
enableV2Signing true
|
||||
enableV2Signing = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +163,7 @@ android {
|
||||
buildTypes {
|
||||
if (project.hasProperty("signingKeyPassword")) {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
signingConfig = signingConfigs.release
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,21 +201,22 @@ android {
|
||||
initWith debug
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments '-DUSE_ANDROID_VALIDATION_LAYER=ON'
|
||||
arguments '-DWIVRN_USE_ANDROID_VALIDATION_LAYER=ON'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions "device"
|
||||
buildTypes.all { variant ->
|
||||
sourceSets {
|
||||
"${variant.name}" {
|
||||
jniLibs.srcDirs layout.buildDirectory.dir("libs${variant.name.capitalize()}")
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
standard {
|
||||
dimension "device"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
abiFilters 'arm64-v8a'//, 'x86_64'
|
||||
}
|
||||
externalNativeBuild{
|
||||
cmake {
|
||||
arguments '-DANDROID_LIB_DIRECTORIES=' + layout.buildDirectory.dir("libs${variant.name.capitalize()}").get().asFile
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,13 +227,13 @@ android {
|
||||
java.srcDirs = ['client/java']
|
||||
res.srcDirs = [ 'resources', layout.buildDirectory.dir('generated_resources') ]
|
||||
|
||||
assets.srcDirs 'assets'
|
||||
assets.srcDirs = ['assets', layout.buildDirectory.dir("assets")]
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
version '3.30.3'
|
||||
version = '3.31.5'
|
||||
path 'CMakeLists.txt'
|
||||
}
|
||||
}
|
||||
@@ -193,18 +244,4 @@ android {
|
||||
// It probably works with merge${variant.name.capitalize()}Assets too
|
||||
tasks["generate${variant.name.capitalize()}Assets"].dependsOn "externalNativeBuild${variant.name.capitalize()}"
|
||||
}
|
||||
|
||||
productFlavors.all { variant ->
|
||||
sourceSets {
|
||||
"${variant.name}" {
|
||||
assets.srcDirs layout.buildDirectory.dir("assets${variant.name.capitalize()}")
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild{
|
||||
cmake {
|
||||
arguments '-DCMAKE_ANDROID_ASSETS_DIRECTORIES=' + layout.buildDirectory.dir("assets${variant.name.capitalize()}").get().asFile
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,31 @@ set(KTX_FEATURE_LOADTEST_APPS OFF)
|
||||
|
||||
set(FASTGLTF_COMPILE_AS_CPP20 ON)
|
||||
|
||||
FetchContent_MakeAvailable(simdjson spdlog glm fastgltf imgui stb implot uni-algo entt)
|
||||
set(SPIRV_REFLECT_EXECUTABLE OFF)
|
||||
set(SPIRV_REFLECT_STATIC_LIB ON)
|
||||
set(SPIRV_REFLECT_INSTALL OFF)
|
||||
|
||||
if (WIVRN_USE_LIBKTX)
|
||||
FetchContent_MakeAvailable(simdjson spdlog glm fastgltf imgui stb implot uni-algo entt spirv-reflect)
|
||||
if(ANDROID AND WIVRN_USE_ANDROID_BIN_LIBKTX)
|
||||
if(NOT EXISTS ${FETCHCONTENT_BASE_DIR}/KTX-Software-${KTX_VERSION}-Android.zip)
|
||||
file(DOWNLOAD
|
||||
https://github.com/KhronosGroup/KTX-Software/releases/download/${KTX_VERSION_FULL}/KTX-Software-${KTX_VERSION}-Android.zip
|
||||
${FETCHCONTENT_BASE_DIR}/KTX-Software-${KTX_VERSION}-Android.zip
|
||||
EXPECTED_HASH SHA256=9f84a395f37a185e2e21e77cfd3893e67271b616edf5feb39125f09ab4c06b29
|
||||
)
|
||||
endif()
|
||||
file(ARCHIVE_EXTRACT INPUT ${FETCHCONTENT_BASE_DIR}/KTX-Software-${KTX_VERSION}-Android.zip DESTINATION ${FETCHCONTENT_BASE_DIR})
|
||||
add_library(ktx INTERFACE)
|
||||
target_link_libraries(ktx INTERFACE ${FETCHCONTENT_BASE_DIR}/KTX-Software-${KTX_VERSION}-Android/${ANDROID_ABI}/lib/libktx.so)
|
||||
target_include_directories(ktx INTERFACE ${FETCHCONTENT_BASE_DIR}/KTX-Software-${KTX_VERSION}-Android/${ANDROID_ABI}/include)
|
||||
elseif(WIVRN_USE_SYSTEM_LIBKTX AND NOT ANDROID)
|
||||
else()
|
||||
FetchContent_MakeAvailable(libktx)
|
||||
endif()
|
||||
|
||||
if (NOT BOOST_FOUND)
|
||||
FetchContent_MakeAvailable(boost)
|
||||
endif()
|
||||
|
||||
include(FreetypeHarfbuzz)
|
||||
include(CompileGLSL)
|
||||
include(GenerateAssets)
|
||||
include(I18n)
|
||||
|
||||
add_library(stb INTERFACE)
|
||||
@@ -37,11 +50,30 @@ if(ANDROID)
|
||||
FetchContent_MakeAvailable(openxr_loader)
|
||||
target_link_libraries(wivrn openxr_loader)
|
||||
|
||||
# libcurl
|
||||
set(BUILD_CURL_EXE OFF)
|
||||
set(BUILD_TESTING OFF)
|
||||
set(CURL_DISABLE_INSTALL ON)
|
||||
set(CURL_USE_LIBPSL OFF)
|
||||
set(CURL_USE_LIBSSH2 OFF)
|
||||
set(BUILD_EXAMPLES OFF)
|
||||
|
||||
FetchContent_MakeAvailable(curl)
|
||||
target_link_libraries(wivrn libcurl_static)
|
||||
|
||||
target_link_libraries(wivrn native_app_glue)
|
||||
target_compile_definitions(wivrn PRIVATE -DXR_USE_PLATFORM_ANDROID -DVK_USE_PLATFORM_ANDROID_KHR)
|
||||
target_link_options(wivrn PRIVATE -Wl,--undefined=ANativeActivity_onCreate)
|
||||
|
||||
target_link_options(wivrn
|
||||
PRIVATE
|
||||
-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/android/exported_symbols.txt
|
||||
# This causes the linker to emit an error when a version script names a
|
||||
# symbol that is not found, rather than silently ignoring that line.
|
||||
-Wl,--no-undefined-version
|
||||
)
|
||||
set_target_properties(wivrn PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/android/exported_symbols.txt)
|
||||
|
||||
file(GLOB PLATFORM_SOURCE CONFIGURE_DEPENDS
|
||||
"android/*.cpp"
|
||||
"audio/android/*.cpp"
|
||||
@@ -51,15 +83,14 @@ if(ANDROID)
|
||||
else()
|
||||
add_executable(wivrn)
|
||||
|
||||
if (OpenXR_FOUND)
|
||||
if (WIVRN_USE_SYSTEM_OPENXR)
|
||||
target_link_libraries(wivrn OpenXR::openxr_loader OpenXR::headers)
|
||||
else()
|
||||
FetchContent_MakeAvailable(openxr_loader)
|
||||
target_link_libraries(wivrn openxr_loader)
|
||||
endif()
|
||||
|
||||
target_link_libraries(wivrn PkgConfig::LIBAV Fontconfig::Fontconfig)
|
||||
|
||||
target_link_libraries(wivrn PkgConfig::LIBAV_CLIENT Fontconfig::Fontconfig CURL::libcurl)
|
||||
|
||||
file(GLOB PLATFORM_SOURCE CONFIGURE_DEPENDS
|
||||
"decoder/ffmpeg/*.cpp")
|
||||
@@ -89,7 +120,7 @@ file(GLOB LOCAL_SOURCE CONFIGURE_DEPENDS
|
||||
|
||||
file(GLOB_RECURSE VULKAN_SHADERS CONFIGURE_DEPENDS "*.glsl")
|
||||
target_sources(wivrn PRIVATE ${LOCAL_SOURCE} ${VULKAN_SHADERS})
|
||||
wivrn_compile_glsl(wivrn ${VULKAN_SHADERS})
|
||||
wivrn_compile_glsl(wivrn SHADERS ${VULKAN_SHADERS})
|
||||
|
||||
target_link_libraries(wivrn
|
||||
Boost::locale
|
||||
@@ -99,8 +130,10 @@ target_link_libraries(wivrn
|
||||
FreetypeHarfbuzz
|
||||
glm::glm
|
||||
imspinner
|
||||
ktx
|
||||
simdjson
|
||||
spdlog::spdlog
|
||||
spirv-reflect-static
|
||||
stb
|
||||
uni-algo
|
||||
Vulkan::Vulkan
|
||||
@@ -108,10 +141,6 @@ target_link_libraries(wivrn
|
||||
wivrn-external
|
||||
)
|
||||
|
||||
if (WIVRN_USE_LIBKTX)
|
||||
target_link_libraries(wivrn ktx_read)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(wivrn PRIVATE -DXR_USE_GRAPHICS_API_VULKAN)
|
||||
target_compile_definitions(wivrn PRIVATE -DVMA_STATS_STRING_ENABLED=0)
|
||||
target_compile_definitions(wivrn PRIVATE -DGLM_ENABLE_EXPERIMENTAL)
|
||||
@@ -146,7 +175,7 @@ target_compile_definitions(wivrn-imgui PUBLIC IMGUI_ENABLE_FREETYPE)
|
||||
# target_compile_definitions(wivrn-imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS) # incompatible with implot
|
||||
# target_compile_definitions(wivrn-imgui PUBLIC IMGUI_ENABLE_FREETYPE_LUNASVG)
|
||||
target_compile_features(wivrn-imgui PRIVATE cxx_std_23)
|
||||
target_link_libraries(wivrn-imgui FreetypeHarfbuzz)
|
||||
target_link_libraries(wivrn-imgui FreetypeHarfbuzz Vulkan::Vulkan)
|
||||
|
||||
target_link_libraries(wivrn wivrn-imgui)
|
||||
|
||||
@@ -165,28 +194,29 @@ khronos_validation.enables = VK_VALIDATION_FEATURE_ENABLE_THREAD_SAFETY_EXT
|
||||
")
|
||||
endif()
|
||||
|
||||
if(USE_ANDROID_VALIDATION_LAYER)
|
||||
set(VVL_VERSION "1.3.231.1")
|
||||
if(WIVRN_USE_ANDROID_VALIDATION_LAYER)
|
||||
set(VVL_VERSION "1.4.321.0")
|
||||
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip)
|
||||
if(NOT EXISTS ${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip)
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip)
|
||||
file(CREATE_LINK ${CMAKE_SOURCE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip ${CMAKE_BINARY_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip SYMBOLIC)
|
||||
file(CREATE_LINK ${CMAKE_SOURCE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip ${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip SYMBOLIC)
|
||||
else()
|
||||
file(DOWNLOAD https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases/download/sdk-${VVL_VERSION}/android-binaries-${VVL_VERSION}.zip ${CMAKE_BINARY_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip
|
||||
EXPECTED_HASH SHA256=eec3a54222d6d33d4f787a13a45c60ac5b9e8d7bf795fc41e4242354a02e34ba)
|
||||
file(DOWNLOAD https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases/download/vulkan-sdk-${VVL_VERSION}/android-binaries-${VVL_VERSION}.zip
|
||||
${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip
|
||||
EXPECTED_HASH SHA256=75f2881ba7af0507c8cec13b4bf6c95556c6333485cdb8be41f608fccf762128)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(VVL_ZIPFILE ${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip)
|
||||
|
||||
file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip DESTINATION ${CMAKE_BINARY_DIR}/Vulkan-ValidationLayer)
|
||||
file(ARCHIVE_EXTRACT INPUT ${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip DESTINATION ${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayer)
|
||||
|
||||
add_library(vvl1 SHARED IMPORTED)
|
||||
set_property(TARGET vvl1 PROPERTY IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/Vulkan-ValidationLayer/${CMAKE_ANDROID_ARCH_ABI}/libVkLayer_khronos_validation.so)
|
||||
add_library(vvl2 SHARED IMPORTED)
|
||||
set_property(TARGET vvl2 PROPERTY IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/Vulkan-ValidationLayer/${CMAKE_ANDROID_ARCH_ABI}/libc++_shared.so)
|
||||
|
||||
target_link_libraries(wivrn vvl1 vvl2) # Hack to get gradle to package the validation layer in the APK
|
||||
file(COPY
|
||||
${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayer/android-binaries-${VVL_VERSION}/${CMAKE_ANDROID_ARCH_ABI}
|
||||
DESTINATION ${ANDROID_LIB_DIRECTORIES})
|
||||
else()
|
||||
# silence "Manually-specified variables were not used by the project" warning
|
||||
set(_unused ${ANDROID_LIB_DIRECTORIES})
|
||||
endif()
|
||||
|
||||
|
||||
@@ -224,62 +254,49 @@ endif()
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Generate assets from SVGs
|
||||
# Generate assets
|
||||
#
|
||||
file(REAL_PATH ${WIVRN_CSS} WIVRN_CSS_ABS BASE_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
||||
set(RSVG_OPTS "--stylesheet=${WIVRN_CSS_ABS}")
|
||||
|
||||
set(IMG_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../images)
|
||||
set(AST_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../assets)
|
||||
set(IMAGES_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../images)
|
||||
set(ASSETS_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../assets-source)
|
||||
|
||||
add_custom_command(OUTPUT ${ASSETS_DIR}/wivrn.png
|
||||
COMMAND ${RSVG_CONVERT} ${IMG_SRC_DIR}/wivrn.svg -w 540 -h 540 -o ${ASSETS_DIR}/wivrn.png ${RSVG_OPTS}
|
||||
DEPENDS ${IMG_SRC_DIR}/wivrn.svg ${WIVRN_CSS_ABS})
|
||||
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
|
||||
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn-pride.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn-pride.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
|
||||
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn-christmas.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn-christmas.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
|
||||
wivrn_rasterize_svg(SOURCE ${ASSETS_SRC_DIR}/passthrough.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/passthrough.png WIDTH 256 HEIGHT 256)
|
||||
wivrn_rasterize_svg(SOURCE ${ASSETS_SRC_DIR}/default-environment.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/default-environment.png WIDTH 256 HEIGHT 256)
|
||||
|
||||
add_custom_command(OUTPUT ${ASSETS_DIR}/wivrn-pride.png
|
||||
COMMAND ${RSVG_CONVERT} ${IMG_SRC_DIR}/wivrn-pride.svg -w 540 -h 540 -o ${ASSETS_DIR}/wivrn-pride.png ${RSVG_OPTS}
|
||||
DEPENDS ${IMG_SRC_DIR}/wivrn-pride.svg ${WIVRN_CSS_ABS})
|
||||
|
||||
add_custom_target(assets ALL DEPENDS
|
||||
${ASSETS_DIR}/wivrn.png
|
||||
${ASSETS_DIR}/wivrn-pride.png
|
||||
)
|
||||
|
||||
add_dependencies(wivrn assets)
|
||||
|
||||
if(ANDROID)
|
||||
find_program(TOKTX toktx REQUIRED)
|
||||
add_custom_command(OUTPUT ${ASSETS_DIR}/wivrn.ktx2
|
||||
COMMAND ${TOKTX} --encode astc --astc_blk_d 4x4 --astc_quality 100 --genmipmap ${ASSETS_DIR}/wivrn.ktx2 ${ASSETS_DIR}/wivrn.png
|
||||
DEPENDS ${ASSETS_DIR}/wivrn.png)
|
||||
add_custom_command(OUTPUT ${ASSETS_DIR}/wivrn-pride.ktx2
|
||||
COMMAND ${TOKTX} --encode astc --astc_blk_d 4x4 --astc_quality 100 --genmipmap ${ASSETS_DIR}/wivrn-pride.ktx2 ${ASSETS_DIR}/wivrn-pride.png
|
||||
DEPENDS ${ASSETS_DIR}/wivrn-pride.png)
|
||||
|
||||
add_custom_command(OUTPUT ${ASSETS_DIR}/default_icon.ktx2
|
||||
COMMAND ${TOKTX} --encode astc --astc_blk_d 4x4 --astc_quality 100 --genmipmap ${ASSETS_DIR}/wivrn-pride.ktx2 ${ASSETS_DIR}/default_icon.png
|
||||
DEPENDS ${ASSETS_DIR}/default_icon.png)
|
||||
|
||||
add_custom_command(OUTPUT ${ASSETS_DIR}/WoodFloor051_1K-JPG_Color.ktx2
|
||||
COMMAND ${TOKTX} --encode astc --astc_blk_d 12x12 --astc_quality 100 --genmipmap ${ASSETS_DIR}/WoodFloor051_1K-JPG_Color.ktx2 ${AST_SRC_DIR}/WoodFloor051_1K-JPG_Color.jpg
|
||||
DEPENDS ${AST_SRC_DIR}/WoodFloor051_1K-JPG_Color.jpg)
|
||||
|
||||
add_custom_command(OUTPUT ${ASSETS_DIR}/vr_splash.png
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${ASSETS_DIR}/wivrn.png ${ASSETS_DIR}/vr_splash.png
|
||||
DEPENDS ${ASSETS_DIR}/wivrn.png)
|
||||
|
||||
add_custom_target(assets-android ALL DEPENDS
|
||||
${ASSETS_DIR}/wivrn.ktx2
|
||||
${ASSETS_DIR}/wivrn-pride.ktx2
|
||||
${ASSETS_DIR}/WoodFloor051_1K-JPG_Color.ktx2
|
||||
${ASSETS_DIR}/vr_splash.png
|
||||
)
|
||||
add_dependencies(assets-android assets)
|
||||
add_dependencies(wivrn assets-android)
|
||||
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn.png DESTINATION ${ASSETS_DIR}/wivrn.ktx2 TARGET wivrn)
|
||||
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn-pride.png DESTINATION ${ASSETS_DIR}/wivrn-pride.ktx2 TARGET wivrn)
|
||||
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn-christmas.png DESTINATION ${ASSETS_DIR}/wivrn-christmas.ktx2 TARGET wivrn)
|
||||
wivrn_generate_ktx( SOURCE ${ASSETS_SRC_DIR}/default_icon.png DESTINATION ${ASSETS_DIR}/default_icon.ktx2 TARGET wivrn)
|
||||
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/passthrough.png DESTINATION ${ASSETS_DIR}/passthrough.ktx2 TARGET wivrn)
|
||||
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/default-environment.png DESTINATION ${ASSETS_DIR}/default-environment.ktx2 TARGET wivrn)
|
||||
if(WIVRN_COMPRESS_GLB)
|
||||
wivrn_gltf_transform_uastc(SOURCE ${ASSETS_SRC_DIR}/ground.glb DESTINATION ${ASSETS_DIR}/ground.glb TARGET wivrn ZSTD 20)
|
||||
else()
|
||||
wivrn_copy_file( SOURCE ${ASSETS_SRC_DIR}/ground.glb DESTINATION ${ASSETS_DIR}/ground.glb TARGET wivrn)
|
||||
endif()
|
||||
|
||||
wivrn_webxr_download()
|
||||
wivrn_webxr_controller(PROFILE generic-trigger-squeeze DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE htc-vive-focus-3 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE meta-quest-touch-plus DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE meta-quest-touch-pro DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE oculus-touch-v2 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE oculus-touch-v3 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE pico-4 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE pico-4u DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE pico-neo3 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
wivrn_webxr_controller(PROFILE samsung-galaxyxr DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
|
||||
|
||||
|
||||
# Add the VR splash screen (only used on Quest)
|
||||
if(ANDROID)
|
||||
wivrn_copy_file(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn.png DESTINATION ${ASSETS_DIR}/vr_splash.png TARGET wivrn)
|
||||
endif()
|
||||
|
||||
##############################################################################
|
||||
# Copy the assets to be able to find them when started from the build
|
||||
# directory
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
LIBAPP {
|
||||
global:
|
||||
ANativeActivity_onCreate;
|
||||
android_main;
|
||||
Java_org_meumeu_wivrn_BroadcastReceiver_onReceive;
|
||||
Java_org_meumeu_wivrn_MainActivity_onRequestPermissionsResult;
|
||||
Java_org_meumeu_wivrn_MainActivity_onActivityResult;
|
||||
Java_org_meumeu_wivrn_MainActivity_onNewIntent;
|
||||
local:
|
||||
*;
|
||||
};
|
||||
@@ -0,0 +1,427 @@
|
||||
#include "hid.h"
|
||||
|
||||
#include "scene.h"
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#define NUM_KEYCODES 226
|
||||
/// Maps Android KeyCodes to Linux key event codes
|
||||
static const int KEYCODE_TO_VK[NUM_KEYCODES] = {
|
||||
0, // KEYCODE_UNKNOWN
|
||||
0, // KEYCODE_SOFT_LEFT
|
||||
0, // KEYCODE_SOFT_RIGHT
|
||||
0, // KEYCODE_HOME
|
||||
0, // KEYCODE_BACK
|
||||
0, // KEYCODE_CALL
|
||||
0, // KEYCODE_ENDCALL
|
||||
KEY_0, // KEYCODE_0
|
||||
KEY_1, // KEYCODE_1
|
||||
KEY_2, // KEYCODE_2
|
||||
KEY_3, // KEYCODE_3
|
||||
KEY_4, // KEYCODE_4
|
||||
KEY_5, // KEYCODE_5
|
||||
KEY_6, // KEYCODE_6
|
||||
KEY_7, // KEYCODE_7
|
||||
KEY_8, // KEYCODE_8
|
||||
KEY_9, // KEYCODE_9
|
||||
0, // KEYCODE_STAR
|
||||
0, // KEYCODE_POUND
|
||||
KEY_UP, // KEYCODE_DPAD_UP
|
||||
KEY_DOWN, // KEYCODE_DPAD_DOWN
|
||||
KEY_LEFT, // KEYCODE_DPAD_LEFT
|
||||
KEY_RIGHT, // KEYCODE_DPAD_RIGHT
|
||||
0, // KEYCODE_DPAD_CENTER
|
||||
|
||||
// there's no way to discern between BT keyboard & device buttons using NDK,
|
||||
// so having these mapped consumes all events from the HMD volume rocker.
|
||||
// alternatively, move the handling to stream.cpp
|
||||
0, // KEYCODE_VOLUME_UP // KEY_VOLUMEUP
|
||||
0, // KEYCODE_VOLUME_DOWN // KEY_VOLUMEDOWN
|
||||
|
||||
0, // KEYCODE_POWER - device power button, do not consume
|
||||
0, // KEYCODE_CAMERA
|
||||
0, // KEYCODE_CLEAR
|
||||
KEY_A, // KEYCODE_A
|
||||
KEY_B, // KEYCODE_B
|
||||
KEY_C, // KEYCODE_C
|
||||
KEY_D, // KEYCODE_D
|
||||
KEY_E, // KEYCODE_E
|
||||
KEY_F, // KEYCODE_F
|
||||
KEY_G, // KEYCODE_G
|
||||
KEY_H, // KEYCODE_H
|
||||
KEY_I, // KEYCODE_I
|
||||
KEY_J, // KEYCODE_J
|
||||
KEY_K, // KEYCODE_K
|
||||
KEY_L, // KEYCODE_L
|
||||
KEY_M, // KEYCODE_M
|
||||
KEY_N, // KEYCODE_N
|
||||
KEY_O, // KEYCODE_O
|
||||
KEY_P, // KEYCODE_P
|
||||
KEY_Q, // KEYCODE_Q
|
||||
KEY_R, // KEYCODE_R
|
||||
KEY_S, // KEYCODE_S
|
||||
KEY_T, // KEYCODE_T
|
||||
KEY_U, // KEYCODE_U
|
||||
KEY_V, // KEYCODE_V
|
||||
KEY_W, // KEYCODE_W
|
||||
KEY_X, // KEYCODE_X
|
||||
KEY_Y, // KEYCODE_Y
|
||||
KEY_Z, // KEYCODE_Z
|
||||
KEY_COMMA, // KEYCODE_COMMA
|
||||
KEY_DOT, // KEYCODE_PERIOD
|
||||
KEY_LEFTALT, // KEYCODE_ALT_LEFT
|
||||
KEY_RIGHTALT, // KEYCODE_ALT_RIGHT
|
||||
KEY_LEFTSHIFT, // KEYCODE_SHIFT_LEFT
|
||||
KEY_RIGHTSHIFT, // KEYCODE_SHIFT_RIGHT
|
||||
KEY_TAB, // KEYCODE_TAB
|
||||
KEY_SPACE, // KEYCODE_SPACE
|
||||
0, // KEYCODE_SYM
|
||||
KEY_WWW, // KEYCODE_EXPLORER
|
||||
KEY_MAIL, // KEYCODE_ENVELOPE
|
||||
KEY_ENTER, // KEYCODE_ENTER
|
||||
KEY_BACKSPACE, // KEYCODE_DEL
|
||||
KEY_GRAVE, // KEYCODE_GRAVE
|
||||
KEY_MINUS, // KEYCODE_MINUS
|
||||
KEY_EQUAL, // KEYCODE_EQUALS
|
||||
KEY_LEFTBRACE, // KEYCODE_LEFT_BRACKET
|
||||
KEY_RIGHTBRACE, // KEYCODE_RIGHT_BRACKET
|
||||
KEY_BACKSLASH, // KEYCODE_BACKSLASH
|
||||
KEY_SEMICOLON, // KEYCODE_SEMICOLON
|
||||
KEY_APOSTROPHE, // KEYCODE_APOSTROPHE
|
||||
KEY_SLASH, // KEYCODE_SLASH
|
||||
0, // KEYCODE_AT
|
||||
0, // KEYCODE_NUM
|
||||
0, // KEYCODE_HEADSETHOOK
|
||||
0, // KEYCODE_FOCUS
|
||||
KEY_EQUAL, // KEYCODE_PLUS
|
||||
KEY_MENU, // KEYCODE_MENU
|
||||
0, // KEYCODE_NOTIFICATION
|
||||
KEY_SEARCH, // KEYCODE_SEARCH
|
||||
KEY_PLAYPAUSE, // KEYCODE_MEDIA_PLAY_PAUSE
|
||||
KEY_STOPCD, // KEYCODE_MEDIA_STOP
|
||||
KEY_NEXTSONG, // KEYCODE_MEDIA_NEXT
|
||||
KEY_PREVIOUSSONG, // KEYCODE_MEDIA_PREVIOUS
|
||||
KEY_REWIND, // KEYCODE_MEDIA_REWIND
|
||||
KEY_FASTFORWARD, // KEYCODE_MEDIA_FAST_FORWARD
|
||||
KEY_MUTE, // KEYCODE_MUTE
|
||||
KEY_PAGEUP, // KEYCODE_PAGE_UP
|
||||
KEY_PAGEDOWN, // KEYCODE_PAGE_DOWN
|
||||
0, // KEYCODE_PICTSYMBOLS
|
||||
0, // KEYCODE_SWITCH_CHARSET
|
||||
0, // KEYCODE_BUTTON_A
|
||||
0, // KEYCODE_BUTTON_B
|
||||
0, // KEYCODE_BUTTON_C
|
||||
0, // KEYCODE_BUTTON_X
|
||||
0, // KEYCODE_BUTTON_Y
|
||||
0, // KEYCODE_BUTTON_Z
|
||||
0, // KEYCODE_BUTTON_L1
|
||||
0, // KEYCODE_BUTTON_R1
|
||||
0, // KEYCODE_BUTTON_L2
|
||||
0, // KEYCODE_BUTTON_R2
|
||||
0, // KEYCODE_BUTTON_THUMBL
|
||||
0, // KEYCODE_BUTTON_THUMBR
|
||||
0, // KEYCODE_BUTTON_START
|
||||
0, // KEYCODE_BUTTON_SELECT
|
||||
0, // KEYCODE_BUTTON_MODE
|
||||
KEY_ESC, // KEYCODE_ESCAPE
|
||||
KEY_DELETE, // KEYCODE_FORWARD_DEL
|
||||
KEY_LEFTCTRL, // KEYCODE_CTRL_LEFT
|
||||
KEY_RIGHTCTRL, // KEYCODE_CTRL_RIGHT
|
||||
KEY_CAPSLOCK, // KEYCODE_CAPS_LOCK
|
||||
KEY_SCROLLLOCK, // KEYCODE_SCROLL_LOCK
|
||||
KEY_LEFTMETA, // KEYCODE_META_LEFT
|
||||
KEY_RIGHTMETA, // KEYCODE_META_RIGHT
|
||||
0, // KEYCODE_FUNCTION
|
||||
KEY_SYSRQ, // KEYCODE_SYSRQ
|
||||
KEY_PAUSE, // KEYCODE_BREAK
|
||||
KEY_HOME, // KEYCODE_MOVE_HOME
|
||||
KEY_END, // KEYCODE_MOVE_END
|
||||
KEY_INSERT, // KEYCODE_INSERT
|
||||
KEY_FORWARD, // KEYCODE_FORWARD
|
||||
KEY_PLAYCD, // KEYCODE_MEDIA_PLAY
|
||||
KEY_PAUSECD, // KEYCODE_MEDIA_PAUSE
|
||||
KEY_CLOSECD, // KEYCODE_MEDIA_CLOSE
|
||||
KEY_EJECTCD, // KEYCODE_MEDIA_EJECT
|
||||
KEY_RECORD, // KEYCODE_MEDIA_RECORD
|
||||
KEY_F1, // KEYCODE_F1
|
||||
KEY_F2, // KEYCODE_F2
|
||||
KEY_F3, // KEYCODE_F3
|
||||
KEY_F4, // KEYCODE_F4
|
||||
KEY_F5, // KEYCODE_F5
|
||||
KEY_F6, // KEYCODE_F6
|
||||
KEY_F7, // KEYCODE_F7
|
||||
KEY_F8, // KEYCODE_F8
|
||||
KEY_F9, // KEYCODE_F9
|
||||
KEY_F10, // KEYCODE_F10
|
||||
KEY_F11, // KEYCODE_F11
|
||||
KEY_F12, // KEYCODE_F12
|
||||
KEY_NUMLOCK, // KEYCODE_NUM_LOCK
|
||||
KEY_KP0, // KEYCODE_NUMPAD_0
|
||||
KEY_KP1, // KEYCODE_NUMPAD_1
|
||||
KEY_KP2, // KEYCODE_NUMPAD_2
|
||||
KEY_KP3, // KEYCODE_NUMPAD_3
|
||||
KEY_KP4, // KEYCODE_NUMPAD_4
|
||||
KEY_KP5, // KEYCODE_NUMPAD_5
|
||||
KEY_KP6, // KEYCODE_NUMPAD_6
|
||||
KEY_KP7, // KEYCODE_NUMPAD_7
|
||||
KEY_KP8, // KEYCODE_NUMPAD_8
|
||||
KEY_KP9, // KEYCODE_NUMPAD_9
|
||||
KEY_KPSLASH, // KEYCODE_NUMPAD_DIVIDE
|
||||
KEY_KPASTERISK, // KEYCODE_NUMPAD_MULTIPLY
|
||||
KEY_KPMINUS, // KEYCODE_NUMPAD_SUBTRACT
|
||||
KEY_KPPLUS, // KEYCODE_NUMPAD_ADD
|
||||
KEY_KPDOT, // KEYCODE_NUMPAD_DOT
|
||||
KEY_KPCOMMA, // KEYCODE_NUMPAD_COMMA
|
||||
KEY_KPENTER, // KEYCODE_NUMPAD_ENTER
|
||||
KEY_KPEQUAL, // KEYCODE_NUMPAD_EQUALS
|
||||
KEY_KPLEFTPAREN, // KEYCODE_NUMPAD_LEFT_PAREN
|
||||
KEY_KPRIGHTPAREN, // KEYCODE_NUMPAD_RIGHT_PAREN
|
||||
KEY_MUTE, // KEYCODE_VOLUME_MUTE
|
||||
0, // KEYCODE_INFO
|
||||
0, // KEYCODE_CHANNEL_UP
|
||||
0, // KEYCODE_CHANNEL_DOWN
|
||||
0, // KEYCODE_ZOOM_IN
|
||||
0, // KEYCODE_ZOOM_OUT
|
||||
0, // KEYCODE_TV
|
||||
0, // KEYCODE_WINDOW
|
||||
0, // KEYCODE_GUIDE
|
||||
0, // KEYCODE_DVR
|
||||
KEY_BOOKMARKS, // KEYCODE_BOOKMARK
|
||||
0, // KEYCODE_CAPTIONS
|
||||
0, // KEYCODE_SETTINGS
|
||||
0, // KEYCODE_TV_POWER
|
||||
0, // KEYCODE_TV_INPUT
|
||||
0, // KEYCODE_STB_POWER
|
||||
0, // KEYCODE_STB_INPUT
|
||||
0, // KEYCODE_AVR_POWER
|
||||
0, // KEYCODE_AVR_INPUT
|
||||
0, // KEYCODE_PROG_RED
|
||||
0, // KEYCODE_PROG_GREEN
|
||||
0, // KEYCODE_PROG_YELLOW
|
||||
0, // KEYCODE_PROG_BLUE
|
||||
0, // KEYCODE_APP_SWITCH
|
||||
0, // KEYCODE_BUTTON_1
|
||||
0, // KEYCODE_BUTTON_2
|
||||
0, // KEYCODE_BUTTON_3
|
||||
0, // KEYCODE_BUTTON_4
|
||||
0, // KEYCODE_BUTTON_5
|
||||
0, // KEYCODE_BUTTON_6
|
||||
0, // KEYCODE_BUTTON_7
|
||||
0, // KEYCODE_BUTTON_8
|
||||
0, // KEYCODE_BUTTON_9
|
||||
0, // KEYCODE_BUTTON_10
|
||||
0, // KEYCODE_BUTTON_11
|
||||
0, // KEYCODE_BUTTON_12
|
||||
0, // KEYCODE_BUTTON_13
|
||||
0, // KEYCODE_BUTTON_14
|
||||
0, // KEYCODE_BUTTON_15
|
||||
0, // KEYCODE_BUTTON_16
|
||||
KEY_LANGUAGE, // KEYCODE_LANGUAGE_SWITCH
|
||||
0, // KEYCODE_MANNER_MODE
|
||||
0, // KEYCODE_3D_MODE
|
||||
0, // KEYCODE_CONTACTS
|
||||
KEY_CALENDAR, // KEYCODE_CALENDAR
|
||||
0, // KEYCODE_MUSIC
|
||||
KEY_CALC, // KEYCODE_CALCULATOR
|
||||
KEY_ZENKAKUHANKAKU, // KEYCODE_ZENKAKU_HANKAKU
|
||||
0, // KEYCODE_EISU
|
||||
KEY_MUHENKAN, // KEYCODE_MUHENKAN
|
||||
KEY_HENKAN, // KEYCODE_HENKAN
|
||||
KEY_KATAKANAHIRAGANA, // KEYCODE_KATAKANA_HIRAGANA
|
||||
KEY_YEN, // KEYCODE_YEN
|
||||
KEY_RO, // KEYCODE_RO
|
||||
KEY_KATAKANAHIRAGANA, // KEYCODE_KANA
|
||||
KEY_ASSISTANT, // KEYCODE_ASSIST
|
||||
KEY_BRIGHTNESSDOWN, // KEYCODE_BRIGHTNESS_DOWN
|
||||
KEY_BRIGHTNESSUP, // KEYCODE_BRIGHTNESS_UP
|
||||
0, // KEYCODE_MEDIA_AUDIO_TRACK
|
||||
KEY_SLEEP, // KEYCODE_SLEEP
|
||||
KEY_WAKEUP, // KEYCODE_WAKEUP
|
||||
};
|
||||
|
||||
uint8_t key_code_to_vk(int16_t key_code)
|
||||
{
|
||||
if (key_code < 0 || key_code >= NUM_KEYCODES)
|
||||
return 0;
|
||||
return KEYCODE_TO_VK[key_code];
|
||||
}
|
||||
|
||||
bool android_hid::input_handler::handle_input(scene * current_scene, AInputEvent * event)
|
||||
{
|
||||
const int32_t type = AInputEvent_getType(event);
|
||||
const int32_t src = AInputEvent_getSource(event);
|
||||
const int32_t dev = AInputEvent_getDeviceId(event);
|
||||
|
||||
if (type == AINPUT_EVENT_TYPE_KEY)
|
||||
{
|
||||
int32_t flags = AKeyEvent_getFlags(event);
|
||||
if ((flags & AKEY_EVENT_FLAG_SOFT_KEYBOARD) != 0)
|
||||
return false; // ignore soft keyboards
|
||||
|
||||
if ((src & AINPUT_SOURCE_KEYBOARD) == 0)
|
||||
return false; // event is not from keyboard
|
||||
|
||||
int32_t keycode = AKeyEvent_getKeyCode(event);
|
||||
int32_t action = AKeyEvent_getAction(event);
|
||||
|
||||
bool pressed;
|
||||
switch (action)
|
||||
{
|
||||
case AKEY_EVENT_ACTION_DOWN:
|
||||
pressed = true;
|
||||
break;
|
||||
case AKEY_EVENT_ACTION_UP:
|
||||
pressed = false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t vk = key_code_to_vk(keycode);
|
||||
if (vk == 0)
|
||||
return false;
|
||||
|
||||
if (pressed)
|
||||
return current_scene->on_input_key_down(vk);
|
||||
else
|
||||
return current_scene->on_input_key_up(vk);
|
||||
}
|
||||
|
||||
if (type == AINPUT_EVENT_TYPE_MOTION)
|
||||
{
|
||||
// don't care about absolute mouse due to mapping difficulties
|
||||
if ((src & AINPUT_SOURCE_MOUSE_RELATIVE) == 0)
|
||||
return false;
|
||||
|
||||
int32_t actionMasked = AMotionEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK;
|
||||
switch (actionMasked)
|
||||
{
|
||||
case AMOTION_EVENT_ACTION_HOVER_MOVE: // mouse move with no buttons pressed
|
||||
case AMOTION_EVENT_ACTION_MOVE: { // mouse move with buttons pressed
|
||||
float x = AMotionEvent_getX(event, 0);
|
||||
float y = AMotionEvent_getY(event, 0);
|
||||
return current_scene->on_input_mouse_move(x, y);
|
||||
}
|
||||
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
|
||||
case AMOTION_EVENT_ACTION_BUTTON_RELEASE: {
|
||||
uint32_t buttons = (uint32_t)AMotionEvent_getButtonState(event);
|
||||
auto button_diff = buttons ^ buttons_before;
|
||||
bool ret_val = false;
|
||||
|
||||
for (uint8_t i = 0; i < 3; ++i)
|
||||
{
|
||||
auto i_shifted = (1u << i);
|
||||
if ((button_diff & i_shifted) != 0)
|
||||
{
|
||||
if ((buttons & i_shifted) != 0)
|
||||
ret_val = current_scene->on_input_button_down(i);
|
||||
else
|
||||
ret_val = current_scene->on_input_button_up(i);
|
||||
}
|
||||
}
|
||||
|
||||
buttons_before = buttons;
|
||||
return ret_val;
|
||||
}
|
||||
case AMOTION_EVENT_ACTION_SCROLL: {
|
||||
float h = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_HSCROLL, 0);
|
||||
float v = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_VSCROLL, 0);
|
||||
return current_scene->on_input_scroll(h, v);
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool try_clear_exception(JNIEnv * env, const char * where)
|
||||
{
|
||||
if (env->ExceptionCheck())
|
||||
{
|
||||
spdlog::error("[pointer_capture] Exception at {}", where);
|
||||
env->ExceptionDescribe(); // logs to logcat
|
||||
env->ExceptionClear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void make_decor_view_call(ANativeActivity * activity, const char * method_name)
|
||||
{
|
||||
if (!activity || !activity->vm || !activity->env || !activity->clazz)
|
||||
{
|
||||
spdlog::error("[pointer_capture] Invalid ANativeActivity* or missing VM/Activity");
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv * env = activity->env;
|
||||
jobject act = activity->clazz;
|
||||
jclass clsActivity = env->GetObjectClass(act);
|
||||
jclass clsWindow = 0;
|
||||
jobject window = 0;
|
||||
jclass clsView = 0;
|
||||
jobject decor = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (try_clear_exception(env, "GetObjectClass(Activity)") || not clsActivity)
|
||||
break; // goto cleanup
|
||||
|
||||
jmethodID midGetWindow = env->GetMethodID(clsActivity, "getWindow", "()Landroid/view/Window;");
|
||||
if (try_clear_exception(env, "Activity.getWindow() method lookup") || not midGetWindow)
|
||||
break; // goto cleanup
|
||||
|
||||
window = env->CallObjectMethod(act, midGetWindow);
|
||||
if (try_clear_exception(env, "Activity.getWindow() call") || not window)
|
||||
break; // goto cleanup
|
||||
|
||||
clsWindow = env->GetObjectClass(window);
|
||||
if (try_clear_exception(env, "GetObjectClass(Window)") || not clsWindow)
|
||||
break; // goto cleanup
|
||||
|
||||
jmethodID midGetDecor = env->GetMethodID(clsWindow, "getDecorView", "()Landroid/view/View;");
|
||||
if (try_clear_exception(env, "Window.getDecorView() method lookup") || not midGetDecor)
|
||||
break; // goto cleanup
|
||||
|
||||
decor = env->CallObjectMethod(window, midGetDecor);
|
||||
if (try_clear_exception(env, "Window.getDecorView() call") || not decor)
|
||||
break; // goto cleanup
|
||||
|
||||
clsView = env->GetObjectClass(decor);
|
||||
if (try_clear_exception(env, "GetObjectClass(DecorView)") || not clsView)
|
||||
break; // goto cleanup
|
||||
|
||||
jmethodID midAction = env->GetMethodID(clsView, method_name, "()V");
|
||||
if (try_clear_exception(env, "View method lookup") || not midAction)
|
||||
break; // goto cleanup
|
||||
|
||||
env->CallVoidMethod(decor, midAction);
|
||||
if (try_clear_exception(env, "View method call"))
|
||||
break; // goto cleanup
|
||||
|
||||
spdlog::info("[pointer_capture] {}() invoked successfully", method_name);
|
||||
} while (false);
|
||||
|
||||
// cleanup
|
||||
if (clsView)
|
||||
env->DeleteLocalRef(clsView);
|
||||
if (decor)
|
||||
env->DeleteLocalRef(decor);
|
||||
if (clsWindow)
|
||||
env->DeleteLocalRef(clsWindow);
|
||||
if (window)
|
||||
env->DeleteLocalRef(window);
|
||||
if (clsActivity)
|
||||
env->DeleteLocalRef(clsActivity);
|
||||
}
|
||||
|
||||
void android_hid::request_pointer_capture(ANativeActivity * activity)
|
||||
{
|
||||
make_decor_view_call(activity, "requestPointerCapture");
|
||||
}
|
||||
|
||||
void android_hid::release_pointer_capture(ANativeActivity * activity)
|
||||
{
|
||||
make_decor_view_call(activity, "releasePointerCapture");
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "scene.h"
|
||||
#include <android_native_app_glue.h>
|
||||
#include <cstdint>
|
||||
#include <linux/input-event-codes.h>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace android_hid
|
||||
{
|
||||
|
||||
void request_pointer_capture(ANativeActivity * activity);
|
||||
void release_pointer_capture(ANativeActivity * activity);
|
||||
|
||||
class input_handler
|
||||
{
|
||||
uint32_t buttons_before = 0;
|
||||
|
||||
public:
|
||||
bool handle_input(scene * current_scene, AInputEvent * event);
|
||||
};
|
||||
|
||||
} // namespace android_hid
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "intent.h"
|
||||
#include "application.h"
|
||||
#include <unordered_map>
|
||||
|
||||
static int next_request_code;
|
||||
static std::unordered_map<int, std::function<void(int, intent &&)>> callbacks;
|
||||
|
||||
intent::intent(const char * intent_type) :
|
||||
obj(jni::new_object<"android/content/Intent">(jni::string{intent_type}))
|
||||
{
|
||||
}
|
||||
|
||||
intent::intent(jobject jni_obj) :
|
||||
obj(jni_obj)
|
||||
{
|
||||
}
|
||||
|
||||
void intent::set_type(const char * type)
|
||||
{
|
||||
obj.call<jni::object<"android/content/Intent">>("setType", jni::string{type});
|
||||
}
|
||||
|
||||
void intent::add_category(const char * category)
|
||||
{
|
||||
obj.call<jni::object<"android/content/Intent">>("addCategory", jni::string{category});
|
||||
}
|
||||
|
||||
void intent::start(std::function<void(int, intent &&)> callback)
|
||||
{
|
||||
int request_code = next_request_code++;
|
||||
|
||||
callbacks.emplace(request_code, std::move(callback));
|
||||
|
||||
jni::object<""> activity(application::native_app()->activity->clazz);
|
||||
|
||||
activity.call<void>("startActivityForResult", obj, jni::Int{request_code});
|
||||
}
|
||||
|
||||
jni::object<"android/net/Uri"> intent::get_uri()
|
||||
{
|
||||
return obj.call<jni::object<"android/net/Uri">>("getData");
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default"))) void Java_org_meumeu_wivrn_MainActivity_onActivityResult(JNIEnv * env, jobject instance, int request_code, int result_code, jobject data_obj)
|
||||
{
|
||||
auto it = callbacks.find(request_code);
|
||||
if (it == callbacks.end())
|
||||
return;
|
||||
|
||||
it->second(result_code, intent{data_obj});
|
||||
|
||||
callbacks.erase(it);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "jnipp.h"
|
||||
#include <functional>
|
||||
|
||||
class intent
|
||||
{
|
||||
jni::object<"android/content/Intent"> obj;
|
||||
|
||||
public:
|
||||
intent(const char * intent_type);
|
||||
intent(jobject);
|
||||
|
||||
void set_type(const char * type);
|
||||
void add_category(const char * category);
|
||||
|
||||
void start(std::function<void(int, intent &&)> callback);
|
||||
|
||||
jni::object<"android/net/Uri"> get_uri();
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "jnipp.h"
|
||||
|
||||
namespace jni::details
|
||||
{
|
||||
void handle_java_exception()
|
||||
{
|
||||
auto & env = jni_thread::env();
|
||||
if (auto exc = env.ExceptionOccurred())
|
||||
{
|
||||
env.ExceptionClear();
|
||||
|
||||
std::string str = object<"java/lang/Object">{exc}.call<jni::string>("toString");
|
||||
|
||||
throw std::runtime_error("Java exception " + str);
|
||||
}
|
||||
}
|
||||
} // namespace jni::details
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <tuple>
|
||||
|
||||
#include <jni.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace jni
|
||||
{
|
||||
@@ -85,6 +86,30 @@ struct Void
|
||||
constexpr static const auto call_static_method = &_JNIEnv::CallStaticVoidMethod;
|
||||
};
|
||||
|
||||
struct Int
|
||||
{
|
||||
constexpr static auto static_field = &_JNIEnv::GetStaticIntField;
|
||||
constexpr static const auto call_method = &_JNIEnv::CallIntMethod;
|
||||
constexpr static const auto call_static_method = &_JNIEnv::CallStaticIntMethod;
|
||||
|
||||
static std::string type()
|
||||
{
|
||||
return "I";
|
||||
}
|
||||
|
||||
int value;
|
||||
|
||||
int handle() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
operator int() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
namespace details
|
||||
{
|
||||
|
||||
@@ -139,8 +164,17 @@ struct type_map<void>
|
||||
using type = jni::Void;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct type_map<int>
|
||||
{
|
||||
using type = jni::Int;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using type_map_t = type_map<T>::type;
|
||||
|
||||
void handle_java_exception();
|
||||
|
||||
} // namespace details
|
||||
|
||||
struct klass
|
||||
@@ -185,7 +219,17 @@ struct klass
|
||||
assert(method_id);
|
||||
auto handles = details::handle(std::forward<Args>(args)...);
|
||||
return R(std::apply([&](auto &... t) {
|
||||
return (env.*R1::call_static_method)(*this, method_id, t...);
|
||||
if constexpr (std::is_void_v<R>)
|
||||
{
|
||||
(env.*R1::call_static_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto res = (env.*R1::call_static_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
handles));
|
||||
}
|
||||
@@ -224,30 +268,6 @@ struct Bool
|
||||
}
|
||||
};
|
||||
|
||||
struct Int
|
||||
{
|
||||
constexpr static auto static_field = &_JNIEnv::GetStaticIntField;
|
||||
constexpr static const auto call_method = &_JNIEnv::CallIntMethod;
|
||||
constexpr static const auto call_static_method = &_JNIEnv::CallStaticIntMethod;
|
||||
|
||||
static std::string type()
|
||||
{
|
||||
return "I";
|
||||
}
|
||||
|
||||
int value;
|
||||
|
||||
int handle() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
operator int() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <details::string_literal Type>
|
||||
struct object
|
||||
{
|
||||
@@ -277,7 +297,17 @@ struct object
|
||||
assert(method_id);
|
||||
auto handles = details::handle(std::forward<Args>(args)...);
|
||||
return R(std::apply([&](auto &... t) {
|
||||
return (env.*R1::call_method)(*this, method_id, t...);
|
||||
if constexpr (std::is_void_v<R>)
|
||||
{
|
||||
(env.*R1::call_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto res = (env.*R1::call_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
handles));
|
||||
}
|
||||
@@ -290,7 +320,17 @@ struct object
|
||||
assert(method_id);
|
||||
auto handles = details::handle(std::forward<Args>(args)...);
|
||||
return R(std::apply([&](auto &... t) {
|
||||
return (env.*R1::call_method)(*this, method_id, t...);
|
||||
if constexpr (std::is_void_v<R>)
|
||||
{
|
||||
(env.*R1::call_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto res = (env.*R1::call_method)(*this, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
handles));
|
||||
}
|
||||
@@ -321,7 +361,9 @@ static object<Type> new_object(Args &&... args)
|
||||
assert(method_id);
|
||||
auto handles = details::handle(std::forward<Args>(args)...);
|
||||
return object<Type>(std::apply([&](auto &... t) {
|
||||
return env.NewObject(klass, method_id, t...);
|
||||
auto res = env.NewObject(klass, method_id, t...);
|
||||
details::handle_java_exception();
|
||||
return res;
|
||||
},
|
||||
handles));
|
||||
}
|
||||
|
||||
@@ -18,26 +18,32 @@
|
||||
*/
|
||||
|
||||
#include "application.h"
|
||||
#include "asset.h"
|
||||
|
||||
#include "hardware.h"
|
||||
#include "openxr/openxr.h"
|
||||
#include "scene.h"
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils/class_from_member.h"
|
||||
#include "utils/contains.h"
|
||||
#include "utils/files.h"
|
||||
#include "utils/i18n.h"
|
||||
#include "vk/check.h"
|
||||
#include "wifi_lock.h"
|
||||
#include "wivrn_config.h"
|
||||
#include "xr/actionset.h"
|
||||
#include "xr/check.h"
|
||||
#include "xr/htc_exts.h"
|
||||
#include "xr/htc_face_tracker.h"
|
||||
#include "xr/meta_body_tracking_fidelity.h"
|
||||
#include "xr/xr.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <algorithm>
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/url/parse.hpp>
|
||||
#include <chrono>
|
||||
#include <ctype.h>
|
||||
#include <exception>
|
||||
#include <magic_enum.hpp>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
@@ -65,9 +71,8 @@ using namespace std::chrono_literals;
|
||||
struct interaction_profile
|
||||
{
|
||||
std::string profile_name;
|
||||
std::vector<std::string> required_extensions;
|
||||
std::vector<const char *> required_extensions;
|
||||
XrVersion min_version = XR_MAKE_VERSION(1, 0, 0);
|
||||
XrVersion max_version = XR_MAKE_VERSION(2, 0, 0); // exclusive
|
||||
std::vector<std::string> input_sources;
|
||||
bool available;
|
||||
};
|
||||
@@ -134,8 +139,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/facebook/touch_controller_pro",
|
||||
.required_extensions = {"XR_FB_touch_controller_pro"},
|
||||
.max_version = XR_MAKE_VERSION(1, 1, 0),
|
||||
.required_extensions = {XR_FB_TOUCH_CONTROLLER_PRO_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/left/output/haptic_trigger_fb",
|
||||
@@ -247,8 +251,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/meta/touch_controller_plus",
|
||||
.required_extensions = {"XR_META_touch_controller_plus"},
|
||||
.max_version = XR_MAKE_VERSION(1, 1, 0),
|
||||
.required_extensions = {XR_META_TOUCH_CONTROLLER_PLUS_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -348,7 +351,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/bytedance/pico_neo3_controller",
|
||||
.required_extensions = {"XR_BD_controller_interaction"},
|
||||
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -391,7 +394,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/bytedance/pico4_controller",
|
||||
.required_extensions = {"XR_BD_controller_interaction"},
|
||||
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -434,7 +437,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/bytedance/pico4s_controller",
|
||||
.required_extensions = {"XR_BD_controller_interaction"},
|
||||
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -477,7 +480,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/htc/vive_focus3_controller",
|
||||
.required_extensions = {"XR_HTC_vive_focus3_controller_interaction"},
|
||||
.required_extensions = {XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/output/haptic",
|
||||
"/user/hand/right/output/haptic",
|
||||
@@ -519,7 +522,7 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/ext/hand_interaction_ext",
|
||||
.required_extensions = {"XR_EXT_hand_interaction"},
|
||||
.required_extensions = {XR_EXT_HAND_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/hand/left/input/aim/pose",
|
||||
"/user/hand/left/input/grip/pose",
|
||||
@@ -548,11 +551,14 @@ static std::vector<interaction_profile> interaction_profiles{
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/htc/vive_xr_tracker",
|
||||
.required_extensions = {"XR_HTC_vive_xr_tracker_interaction", "XR_HTC_path_enumeration"},
|
||||
.required_extensions = {
|
||||
XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME,
|
||||
XR_HTC_PATH_ENUMERATION_EXTENSION_NAME,
|
||||
},
|
||||
},
|
||||
interaction_profile{
|
||||
.profile_name = "/interaction_profiles/ext/eye_gaze_interaction",
|
||||
.required_extensions = {"XR_EXT_eye_gaze_interaction"},
|
||||
.required_extensions = {XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME},
|
||||
.input_sources = {
|
||||
"/user/eyes_ext/input/gaze_ext/pose",
|
||||
},
|
||||
@@ -649,6 +655,7 @@ VkBool32 application::vulkan_debug_report_callback(
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool my_error = true;
|
||||
if (level >= spdlog::level::warn)
|
||||
{
|
||||
bool validation_layer_found = false;
|
||||
@@ -659,10 +666,13 @@ VkBool32 application::vulkan_debug_report_callback(
|
||||
|
||||
if (validation_layer_found && i.library != "libVkLayer_khronos_validation.so")
|
||||
spdlog::log(level, "{:#016x}: {} + {:#x}", i.pc, i.library, i.pc - i.library_base);
|
||||
|
||||
if (i.library == "libopenxr_loader.so")
|
||||
my_error = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (level >= spdlog::level::err)
|
||||
if (level >= spdlog::level::err and my_error)
|
||||
abort();
|
||||
#endif
|
||||
|
||||
@@ -712,20 +722,20 @@ void application::initialize_vulkan()
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef __ANDROID__
|
||||
if (validation_layer_found)
|
||||
{
|
||||
spdlog::info("Using Vulkan validation layer");
|
||||
layers.push_back("VK_LAYER_KHRONOS_validation");
|
||||
}
|
||||
#endif
|
||||
bool debug_report_found = false;
|
||||
bool debug_utils_found = false;
|
||||
#endif
|
||||
|
||||
std::vector<const char *> instance_extensions{};
|
||||
std::unordered_set<std::string_view> optional_device_extensions{};
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool debug_report_found = false;
|
||||
bool debug_utils_found = false;
|
||||
#endif
|
||||
spdlog::info("Available Vulkan instance extensions:");
|
||||
std::vector<std::pair<std::string, int>> extensions;
|
||||
for (vk::ExtensionProperties & i: vk_context.enumerateInstanceExtensionProperties(nullptr))
|
||||
@@ -734,32 +744,33 @@ void application::initialize_vulkan()
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!strcmp(i.extensionName, VK_EXT_DEBUG_REPORT_EXTENSION_NAME))
|
||||
{
|
||||
debug_report_found = true;
|
||||
instance_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
||||
}
|
||||
|
||||
if (!strcmp(i.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME))
|
||||
if (!strcmp(i.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) and
|
||||
guess_model() != model::oculus_quest) // Quest 1 lies, the extension won't load
|
||||
{
|
||||
debug_utils_found = true;
|
||||
instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
std::ranges::sort(extensions);
|
||||
for (const auto & [extension_name, spec_version]: extensions)
|
||||
spdlog::info(" {} (version {})", extension_name, spec_version);
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (debug_utils_found && debug_report_found)
|
||||
{
|
||||
// debug_extensions_found = true;
|
||||
// spdlog::info("Using debug extensions");
|
||||
instance_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
||||
// instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
vk_device_extensions.push_back(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
||||
vk_device_extensions.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
|
||||
vk_device_extensions.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_IMG_FILTER_CUBIC_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
|
||||
optional_device_extensions.emplace(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
vk_device_extensions.push_back(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
|
||||
vk_device_extensions.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
|
||||
vk_device_extensions.push_back(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
|
||||
vk_device_extensions.push_back(VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
|
||||
vk_device_extensions.push_back(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
|
||||
@@ -874,13 +885,34 @@ void application::initialize_vulkan()
|
||||
.ppEnabledExtensionNames = vk_device_extensions.data(),
|
||||
.pEnabledFeatures = &device_features,
|
||||
},
|
||||
#ifdef __ANDROID__
|
||||
vk::PhysicalDeviceSamplerYcbcrConversionFeaturesKHR{
|
||||
.samplerYcbcrConversion = VK_TRUE,
|
||||
.samplerYcbcrConversion = true,
|
||||
},
|
||||
#endif
|
||||
vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR{},
|
||||
vk::PhysicalDeviceMultiviewFeaturesKHR{
|
||||
.multiview = true,
|
||||
},
|
||||
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT{}};
|
||||
|
||||
auto check_feature_flag = [&](auto feature_flag, const char * extension_name) -> bool {
|
||||
using FeatureStruct = class_from_member_t<decltype(feature_flag)>;
|
||||
|
||||
if (utils::contains(vk_device_extensions, extension_name) and
|
||||
vk_physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, FeatureStruct>().template get<FeatureStruct>().*feature_flag)
|
||||
{
|
||||
device_create_info.get<FeatureStruct>().*feature_flag = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
device_create_info.unlink<FeatureStruct>();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
check_feature_flag(&vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR::timelineSemaphore, VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
|
||||
check_feature_flag(&vk::PhysicalDeviceIndexTypeUint8FeaturesEXT::indexTypeUint8, VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
|
||||
|
||||
vk_device = xr_system_id.create_device(vk_physical_device, device_create_info.get());
|
||||
*vk_queue.lock() = vk_device.getQueue(vk_queue_family_index, 0);
|
||||
|
||||
@@ -902,10 +934,16 @@ void application::initialize_vulkan()
|
||||
pipeline_cache = vk::raii::PipelineCache(vk_device, pipeline_cache_info);
|
||||
|
||||
allocator.emplace(VmaAllocatorCreateInfo{
|
||||
.physicalDevice = *vk_physical_device,
|
||||
.device = *vk_device,
|
||||
.instance = *vk_instance,
|
||||
});
|
||||
.physicalDevice = *vk_physical_device,
|
||||
.device = *vk_device,
|
||||
.instance = *vk_instance,
|
||||
},
|
||||
#ifndef NDEBUG
|
||||
debug_utils_found
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
void application::log_views()
|
||||
@@ -952,8 +990,6 @@ void application::initialize_actions()
|
||||
{
|
||||
spdlog::debug("Initializing actions");
|
||||
|
||||
auto * htc_body = std::get_if<xr::htc_body_tracker>(&body_tracker);
|
||||
|
||||
// Build an action set with all possible input sources
|
||||
std::vector<XrActionSet> action_sets;
|
||||
xr_actionset = xr::actionset(xr_instance, "all_actions", "All actions");
|
||||
@@ -967,7 +1003,8 @@ void application::initialize_actions()
|
||||
std::vector<std::string> sources;
|
||||
for (auto & profile: interaction_profiles)
|
||||
{
|
||||
profile.available = utils::contains_all(xr_extensions, profile.required_extensions) and profile.min_version <= api_version and profile.max_version > api_version;
|
||||
profile.available = std::ranges::all_of(profile.required_extensions, [&](auto & ext) { return xr_instance.has_extension(ext); }) and
|
||||
profile.min_version <= api_version;
|
||||
|
||||
if (profile.profile_name.ends_with("khr/simple_controller"))
|
||||
{
|
||||
@@ -1008,15 +1045,15 @@ void application::initialize_actions()
|
||||
}
|
||||
if (add_palms)
|
||||
{
|
||||
if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or utils::contains(xr_extensions, XR_KHR_MAINTENANCE1_EXTENSION_NAME)) //
|
||||
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
|
||||
if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or xr_instance.has_extension(XR_KHR_MAINTENANCE1_EXTENSION_NAME)) //
|
||||
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
|
||||
and not utils::contains(profile.input_sources, "/user/hand/left/input/grip_surface/pose"))
|
||||
{
|
||||
spdlog::info("Adding grip_surface/pose for interaction profile {}", profile.profile_name);
|
||||
profile.input_sources.push_back("/user/hand/left/input/grip_surface/pose");
|
||||
profile.input_sources.push_back("/user/hand/right/input/grip_surface/pose");
|
||||
}
|
||||
else if (utils::contains(xr_extensions, XR_EXT_PALM_POSE_EXTENSION_NAME) //
|
||||
else if (xr_instance.has_extension(XR_EXT_PALM_POSE_EXTENSION_NAME) //
|
||||
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
|
||||
and not utils::contains(profile.input_sources, "/user/hand/left/input/palm_ext/pose"))
|
||||
{
|
||||
@@ -1026,15 +1063,29 @@ void application::initialize_actions()
|
||||
}
|
||||
}
|
||||
|
||||
// Dynamically add VIVE XR Trackers to the profile if available
|
||||
if (htc_body && utils::contains(profile.required_extensions, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME))
|
||||
// Patch profile to add pinch_ext/pose and poke_ext/pose
|
||||
if (xr_instance.has_extension(XR_EXT_HAND_INTERACTION_EXTENSION_NAME) //
|
||||
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
|
||||
and not utils::contains(profile.input_sources, "/user/hand/left/input/pinch_ext/pose"))
|
||||
{
|
||||
for (const auto & user_path: htc_body->get_paths())
|
||||
spdlog::info("Adding pinch_ext/pose for interaction profile {}", profile.profile_name);
|
||||
profile.input_sources.push_back("/user/hand/left/input/pinch_ext/pose");
|
||||
profile.input_sources.push_back("/user/hand/right/input/pinch_ext/pose");
|
||||
spdlog::info("Adding poke_ext/pose for interaction profile {}", profile.profile_name);
|
||||
profile.input_sources.push_back("/user/hand/left/input/poke_ext/pose");
|
||||
profile.input_sources.push_back("/user/hand/right/input/poke_ext/pose");
|
||||
}
|
||||
|
||||
// Dynamically add VIVE XR Trackers to the profile if available
|
||||
if (utils::contains(profile.required_extensions, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME) and
|
||||
xr_instance.has_extension(XR_HTC_PATH_ENUMERATION_EXTENSION_NAME))
|
||||
{
|
||||
XrPath tracker_profile = xr_instance.string_to_path("/interaction_profiles/htc/vive_xr_tracker");
|
||||
for (const auto & user_path: xr_instance.enumerate_paths_for_interaction_profile(tracker_profile))
|
||||
{
|
||||
for (const auto & input_path: htc_body->get_paths(user_path))
|
||||
{
|
||||
profile.input_sources.push_back(path_to_string(user_path) + path_to_string(input_path));
|
||||
}
|
||||
generic_trackers.emplace_back(user_path, nullptr);
|
||||
for (const auto & input_path: xr_instance.enumerate_paths_for_interaction_profile(tracker_profile, user_path))
|
||||
profile.input_sources.push_back(xr_instance.path_to_string(user_path) + xr_instance.path_to_string(input_path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,8 +1133,14 @@ void application::initialize_actions()
|
||||
spaces[size_t(xr::spaces::poke_right)] = xr_session.create_action_space(a);
|
||||
else if (name == "/user/eyes_ext/input/gaze_ext/pose")
|
||||
spaces[size_t(xr::spaces::eye_gaze)] = xr_session.create_action_space(a);
|
||||
else if (name.contains("/input/entity_htc/pose") && htc_body)
|
||||
htc_body->add(xr_session.create_action_space(a));
|
||||
else if (name.contains("/input/entity_htc/pose"))
|
||||
{
|
||||
for (auto & [path, action]: generic_trackers)
|
||||
{
|
||||
if (name.starts_with(xr_instance.path_to_string(path)))
|
||||
action = xr_session.create_action_space(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build an action set for each scene
|
||||
@@ -1120,7 +1177,7 @@ void application::initialize_actions()
|
||||
|
||||
xr_bindings.push_back(XrActionSuggestedBinding{
|
||||
.action = a,
|
||||
.binding = string_to_path(k.input_source)});
|
||||
.binding = xr_instance.string_to_path(k.input_source)});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1137,7 +1194,7 @@ void application::initialize_actions()
|
||||
|
||||
for (const auto & name: profile.input_sources)
|
||||
{
|
||||
xr_bindings.push_back({actions_by_name[name], string_to_path(name)});
|
||||
xr_bindings.push_back({actions_by_name[name], xr_instance.string_to_path(name)});
|
||||
}
|
||||
|
||||
try
|
||||
@@ -1157,57 +1214,65 @@ void application::initialize()
|
||||
{
|
||||
// LogLayersAndExtensions
|
||||
assert(!xr_instance);
|
||||
xr_extensions.clear();
|
||||
|
||||
// Required extensions
|
||||
xr_extensions.push_back(XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME);
|
||||
std::vector<const char *> xr_extensions{
|
||||
// Required extensions
|
||||
XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME,
|
||||
};
|
||||
|
||||
// Optional extensions
|
||||
std::vector<std::string> opt_extensions;
|
||||
opt_extensions.push_back(XR_KHR_LOCATE_SPACES_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_KHR_MAINTENANCE1_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_EXT_HAND_TRACKING_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_EXT_HAND_INTERACTION_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_HTC_FACIAL_TRACKING_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_HTC_PATH_ENUMERATION_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_FACE_TRACKING2_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_BODY_TRACKING_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_BD_BODY_TRACKING_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_EXT_PALM_POSE_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_KHR_COMPOSITION_LAYER_DEPTH_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_COMPOSITION_LAYER_DEPTH_TEST_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_KHR_COMPOSITION_LAYER_COLOR_SCALE_BIAS_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_EXT_USER_PRESENCE_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_KHR_VISIBILITY_MASK_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME);
|
||||
std::vector<const char *> opt_extensions{
|
||||
XR_KHR_COMPOSITION_LAYER_COLOR_SCALE_BIAS_EXTENSION_NAME,
|
||||
XR_KHR_COMPOSITION_LAYER_DEPTH_EXTENSION_NAME,
|
||||
XR_KHR_LOCATE_SPACES_EXTENSION_NAME,
|
||||
XR_KHR_MAINTENANCE1_EXTENSION_NAME,
|
||||
XR_KHR_VISIBILITY_MASK_EXTENSION_NAME,
|
||||
|
||||
XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME,
|
||||
XR_EXT_HAND_INTERACTION_EXTENSION_NAME,
|
||||
XR_EXT_HAND_TRACKING_EXTENSION_NAME,
|
||||
XR_EXT_PALM_POSE_EXTENSION_NAME,
|
||||
XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME,
|
||||
XR_EXT_USER_PRESENCE_EXTENSION_NAME,
|
||||
|
||||
XR_ANDROID_FACE_TRACKING_EXTENSION_NAME,
|
||||
|
||||
XR_BD_BODY_TRACKING_EXTENSION_NAME,
|
||||
|
||||
XR_FB_BODY_TRACKING_EXTENSION_NAME,
|
||||
XR_FB_COMPOSITION_LAYER_DEPTH_TEST_EXTENSION_NAME,
|
||||
XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME,
|
||||
XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME,
|
||||
XR_FB_FACE_TRACKING2_EXTENSION_NAME,
|
||||
XR_FB_PASSTHROUGH_EXTENSION_NAME,
|
||||
XR_FB_SWAPCHAIN_UPDATE_STATE_EXTENSION_NAME,
|
||||
|
||||
XR_HTC_PASSTHROUGH_EXTENSION_NAME,
|
||||
XR_HTC_PATH_ENUMERATION_EXTENSION_NAME,
|
||||
XR_HTC_FACIAL_TRACKING_EXTENSION_NAME,
|
||||
XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME,
|
||||
|
||||
XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME,
|
||||
XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME,
|
||||
XR_META_LOCAL_DIMMING_EXTENSION_NAME,
|
||||
};
|
||||
|
||||
for (const auto & i: interaction_profiles)
|
||||
opt_extensions.insert(opt_extensions.end(), i.required_extensions.begin(), i.required_extensions.end());
|
||||
|
||||
for (const auto & i: xr::instance::extensions())
|
||||
for (const auto & ext: xr::instance::extensions())
|
||||
{
|
||||
if (utils::contains(opt_extensions, i.extensionName))
|
||||
xr_extensions.push_back(i.extensionName);
|
||||
}
|
||||
|
||||
std::vector<const char *> extensions;
|
||||
for (const auto & i: xr_extensions)
|
||||
{
|
||||
extensions.push_back(i.c_str());
|
||||
auto it = std::find_if(opt_extensions.begin(),
|
||||
opt_extensions.end(),
|
||||
[&ext](const char * i) { return strcmp(i, ext.extensionName) == 0; });
|
||||
if (it != opt_extensions.end())
|
||||
xr_extensions.push_back(*it);
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
xr_instance =
|
||||
xr::instance(app_info.name, app_info.native_app->activity->vm, app_info.native_app->activity->clazz, extensions);
|
||||
xr::instance(app_info.name, app_info.native_app->activity->vm, app_info.native_app->activity->clazz, xr_extensions);
|
||||
#else
|
||||
xr_instance = xr::instance(app_info.name, extensions);
|
||||
xr_instance = xr::instance(app_info.name, xr_extensions);
|
||||
#endif
|
||||
|
||||
spdlog::info("Created OpenXR instance, runtime {}, version {}, API version {}",
|
||||
@@ -1230,21 +1295,16 @@ void application::initialize()
|
||||
spdlog::info(" Orientation tracking: {}", (bool)properties.trackingProperties.orientationTracking);
|
||||
spdlog::info(" Position tracking: {}", (bool)properties.trackingProperties.positionTracking);
|
||||
|
||||
if (utils::contains(xr_extensions, XR_EXT_HAND_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemHandTrackingPropertiesEXT hand_tracking_properties = xr_system_id.hand_tracking_properties();
|
||||
spdlog::info(" Hand tracking support: {}", (bool)hand_tracking_properties.supportsHandTracking);
|
||||
hand_tracking_supported = hand_tracking_properties.supportsHandTracking;
|
||||
}
|
||||
spdlog::info(" Hand tracking support: {}", xr_system_id.hand_tracking_supported());
|
||||
|
||||
if (utils::contains(xr_extensions, XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME))
|
||||
if (xr_instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_properties = xr_system_id.eye_gaze_interaction_properties();
|
||||
spdlog::info(" Eye gaze support: {}", (bool)eye_gaze_properties.supportsEyeGazeInteraction);
|
||||
eye_gaze_supported = eye_gaze_properties.supportsEyeGazeInteraction;
|
||||
}
|
||||
|
||||
if (utils::contains(xr_extensions, XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
|
||||
if (xr_instance.has_extension(XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
|
||||
{
|
||||
spdlog::info(" OpenXR post-processing extension support: true");
|
||||
openxr_post_processing_supported = true;
|
||||
@@ -1252,23 +1312,39 @@ void application::initialize()
|
||||
|
||||
switch (xr_system_id.passthrough_supported())
|
||||
{
|
||||
case xr::system::passthrough_type::no_passthrough:
|
||||
case xr::passthrough_type::none:
|
||||
spdlog::info(" Passthrough: not supported");
|
||||
break;
|
||||
case xr::system::passthrough_type::bw:
|
||||
case xr::passthrough_type::bw:
|
||||
spdlog::info(" Passthrough: black and white");
|
||||
break;
|
||||
case xr::system::passthrough_type::color:
|
||||
case xr::passthrough_type::color:
|
||||
spdlog::info(" Passthrough: color");
|
||||
break;
|
||||
}
|
||||
|
||||
spdlog::info(" Face tracker: {}", magic_enum::enum_name(xr_system_id.face_tracker_supported()));
|
||||
spdlog::info(" Body tracker: {}", magic_enum::enum_name(xr_system_id.body_tracker_supported()));
|
||||
|
||||
// Log view configurations and blend modes
|
||||
log_views();
|
||||
|
||||
initialize_vulkan();
|
||||
|
||||
xr_session = xr::session(xr_instance, xr_system_id, vk_instance, vk_physical_device, vk_device, vk_queue_family_index);
|
||||
xr_session = xr::session(xr_instance, xr_system_id, vk_instance, vk_physical_device, vk_device, vk_queue, vk_queue_family_index);
|
||||
|
||||
spaces[size_t(xr::spaces::view)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_VIEW);
|
||||
spaces[size_t(xr::spaces::world)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE);
|
||||
|
||||
config.emplace(xr_system_id, xr_session);
|
||||
|
||||
// HTC face tracker fails if created later
|
||||
// we can destroy it right away, it actually stores static handles
|
||||
if (xr_system_id.face_tracker_supported() == xr::face_tracker_type::htc)
|
||||
{
|
||||
auto props = xr_system_id.htc_face_tracking_properties();
|
||||
xr::htc_face_tracker(xr_instance, xr_session, props.supportEyeFacialTracking, props.supportLipFacialTracking);
|
||||
}
|
||||
|
||||
{
|
||||
auto spaces = xr_session.get_reference_spaces();
|
||||
@@ -1277,70 +1353,6 @@ void application::initialize()
|
||||
spdlog::info(" {}", xr::to_string(i));
|
||||
}
|
||||
|
||||
spaces[size_t(xr::spaces::view)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_VIEW);
|
||||
spaces[size_t(xr::spaces::world)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE);
|
||||
|
||||
config.emplace(xr_system_id);
|
||||
|
||||
if (hand_tracking_supported)
|
||||
{
|
||||
left_hand = xr_session.create_hand_tracker(XR_HAND_LEFT_EXT);
|
||||
right_hand = xr_session.create_hand_tracker(XR_HAND_RIGHT_EXT);
|
||||
}
|
||||
|
||||
if (utils::contains(xr_extensions, XR_FB_FACE_TRACKING2_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemFaceTrackingProperties2FB fb_face2_properties = xr_system_id.fb_face_tracking2_properties();
|
||||
spdlog::info(" FB face tracking support: {}", (bool)fb_face2_properties.supportsVisualFaceTracking);
|
||||
if (fb_face2_properties.supportsVisualFaceTracking)
|
||||
face_tracker.emplace<xr::fb_face_tracker2>(xr_instance, xr_session);
|
||||
}
|
||||
|
||||
if (std::holds_alternative<std::monostate>(face_tracker) && utils::contains(xr_extensions, XR_HTC_FACIAL_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemFacialTrackingPropertiesHTC htc_face_properties = xr_system_id.htc_face_tracking_properties();
|
||||
spdlog::info(" HTC eye tracking support: {}", (bool)htc_face_properties.supportEyeFacialTracking);
|
||||
spdlog::info(" HTC lip tracking support: {}", (bool)htc_face_properties.supportLipFacialTracking);
|
||||
if (htc_face_properties.supportEyeFacialTracking || htc_face_properties.supportLipFacialTracking)
|
||||
face_tracker.emplace<xr::htc_face_tracker>(xr_instance, xr_session, htc_face_properties.supportEyeFacialTracking, htc_face_properties.supportLipFacialTracking);
|
||||
}
|
||||
|
||||
if (std::holds_alternative<std::monostate>(face_tracker) && eye_gaze_supported)
|
||||
{
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
spdlog::info(" PICO face tracking support: true");
|
||||
face_tracker.emplace<xr::pico_face_tracker>(xr_instance, xr_session);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (utils::contains_all(xr_extensions, std::array{XR_FB_BODY_TRACKING_EXTENSION_NAME, XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME, XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME}))
|
||||
{
|
||||
XrSystemBodyTrackingPropertiesFB fb_body_properties = xr_system_id.fb_body_tracking_properties();
|
||||
spdlog::info(" FB body tracking support: {}", (bool)fb_body_properties.supportsBodyTracking);
|
||||
if (fb_body_properties.supportsBodyTracking)
|
||||
body_tracker.emplace<xr::fb_body_tracker>(xr_instance, xr_session);
|
||||
}
|
||||
|
||||
if (std::holds_alternative<std::monostate>(body_tracker) && utils::contains_all(xr_extensions, std::array{XR_HTC_PATH_ENUMERATION_EXTENSION_NAME, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME}))
|
||||
{
|
||||
spdlog::info(" HTC body tracking support: true");
|
||||
body_tracker.emplace<xr::htc_body_tracker>(xr_instance, xr_session);
|
||||
}
|
||||
|
||||
if (std::holds_alternative<std::monostate>(body_tracker) && utils::contains(xr_extensions, XR_BD_BODY_TRACKING_EXTENSION_NAME))
|
||||
{
|
||||
XrSystemBodyTrackingPropertiesBD bd_body_properties = xr_system_id.bd_body_tracking_properties();
|
||||
spdlog::info(" PICO body tracking support: {}", (bool)bd_body_properties.supportsBodyTracking);
|
||||
if (bd_body_properties.supportsBodyTracking)
|
||||
body_tracker.emplace<xr::pico_body_tracker>(xr_instance, xr_session);
|
||||
}
|
||||
|
||||
vk::CommandPoolCreateInfo cmdpool_create_info;
|
||||
cmdpool_create_info.queueFamilyIndex = vk_queue_family_index;
|
||||
cmdpool_create_info.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer;
|
||||
@@ -1348,56 +1360,53 @@ void application::initialize()
|
||||
vk_cmdpool = vk::raii::CommandPool{vk_device, cmdpool_create_info};
|
||||
|
||||
initialize_actions();
|
||||
load_locale();
|
||||
}
|
||||
|
||||
void application::load_locale()
|
||||
{
|
||||
gen.add_messages_domain("wivrn");
|
||||
std::locale loc = gen("");
|
||||
|
||||
messages_info.encoding = "UTF-8";
|
||||
if (config->locale.empty())
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
jni::klass java_util_Locale("java/util/Locale");
|
||||
auto default_locale = java_util_Locale.call<jni::object<"java/util/Locale">>("getDefault");
|
||||
jni::klass java_util_Locale("java/util/Locale");
|
||||
auto default_locale = java_util_Locale.call<jni::object<"java/util/Locale">>("getDefault");
|
||||
|
||||
// if (auto language = default_locale.call<jni::string>("toString"))
|
||||
if (auto language = default_locale.call<jni::string>("getLanguage"))
|
||||
messages_info.language = language;
|
||||
|
||||
if (auto country = default_locale.call<jni::string>("getCountry"))
|
||||
messages_info.country = country;
|
||||
|
||||
messages_info.encoding = "UTF-8";
|
||||
// if (auto language = default_locale.call<jni::string>("toString"))
|
||||
if (auto language = default_locale.call<jni::string>("getLanguage"))
|
||||
messages_info.language = language;
|
||||
|
||||
if (auto country = default_locale.call<jni::string>("getCountry"))
|
||||
messages_info.country = country;
|
||||
#else
|
||||
auto & facet = std::use_facet<boost::locale::info>(loc);
|
||||
messages_info.language = facet.language();
|
||||
messages_info.country = facet.country();
|
||||
messages_info.encoding = "UTF-8";
|
||||
auto & facet = std::use_facet<boost::locale::info>(loc);
|
||||
messages_info.language = facet.language();
|
||||
messages_info.country = facet.country();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pos = config->locale.find("_");
|
||||
messages_info.language = config->locale.substr(0, pos);
|
||||
if (pos != std::string::npos)
|
||||
messages_info.country = config->locale.substr(pos + 1);
|
||||
}
|
||||
|
||||
spdlog::info("Current locale: language {}, country {}, encoding {}", messages_info.language, messages_info.country, messages_info.encoding);
|
||||
|
||||
messages_info.paths.push_back("locale");
|
||||
|
||||
messages_info.domains.push_back(boost::locale::gnu_gettext::messages_info::domain("wivrn"));
|
||||
messages_info.callback = [](const std::string & file_name, const std::string & encoding) {
|
||||
std::vector<char> buffer;
|
||||
try
|
||||
{
|
||||
asset file(file_name);
|
||||
buffer.resize(file.size());
|
||||
memcpy(buffer.data(), file.data(), file.size());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
return buffer;
|
||||
};
|
||||
|
||||
messages_info.callback = open_locale_file;
|
||||
loc = std::locale(loc, boost::locale::gnu_gettext::create_messages_facet<char>(messages_info));
|
||||
|
||||
std::locale::global(loc);
|
||||
}
|
||||
|
||||
std::pair<XrAction, XrActionType> application::get_action(const std::string & requested_name)
|
||||
std::pair<XrAction, XrActionType> application::get_action(std::string_view requested_name)
|
||||
{
|
||||
for (const auto & [action, type, name]: instance().actions)
|
||||
{
|
||||
@@ -1517,6 +1526,26 @@ application::application(application_info info) :
|
||||
}
|
||||
};
|
||||
|
||||
// capture pointer to receive relative mouse events
|
||||
app_info.native_app->activity->callbacks->onWindowFocusChanged = [](ANativeActivity * activity, int has_focus) {
|
||||
if (has_focus)
|
||||
android_hid::request_pointer_capture(activity);
|
||||
else
|
||||
android_hid::release_pointer_capture(activity);
|
||||
};
|
||||
|
||||
app_info.native_app->onInputEvent = [](android_app * app, AInputEvent * event) {
|
||||
auto app_instance = static_cast<application *>(app->userData);
|
||||
|
||||
std::unique_lock _{app_instance->scene_stack_lock};
|
||||
if (!app_instance->scene_stack.empty())
|
||||
{
|
||||
auto scene = app_instance->scene_stack.back();
|
||||
return app_instance->input_handler.handle_input(scene.get(), event) ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
wifi = wifi_lock::make_wifi_lock(app_info.native_app->activity->clazz);
|
||||
|
||||
// Initialize the loader for this platform
|
||||
@@ -1595,15 +1624,21 @@ void application::loop()
|
||||
poll_events();
|
||||
|
||||
auto scene = current_scene();
|
||||
if (!is_session_running())
|
||||
if (not is_session_running())
|
||||
{
|
||||
if (scene)
|
||||
if (not timestamp_unsynchronized)
|
||||
timestamp_unsynchronized = std::chrono::steady_clock::now();
|
||||
|
||||
if (scene and std::chrono::steady_clock::now() - *timestamp_unsynchronized > 3s)
|
||||
scene->set_focused(false);
|
||||
|
||||
// Throttle loop since xrWaitFrame won't be called.
|
||||
std::this_thread::sleep_for(250ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
timestamp_unsynchronized.reset();
|
||||
|
||||
if (scene)
|
||||
{
|
||||
poll_actions();
|
||||
@@ -1626,6 +1661,7 @@ void application::loop()
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::info("Last scene was popped");
|
||||
exit_requested = true;
|
||||
}
|
||||
}
|
||||
@@ -1654,6 +1690,7 @@ void application::run()
|
||||
exit_requested = true;
|
||||
}
|
||||
}
|
||||
spdlog::info("Exiting application_thread");
|
||||
});
|
||||
|
||||
// Read all pending events.
|
||||
@@ -1672,17 +1709,19 @@ void application::run()
|
||||
|
||||
if (app_info.native_app->destroyRequested)
|
||||
{
|
||||
spdlog::info("app_info.native_app->destroyRequested is true");
|
||||
exit_requested = true;
|
||||
}
|
||||
}
|
||||
|
||||
spdlog::info("Exiting normally");
|
||||
|
||||
application_thread.join();
|
||||
}
|
||||
#else
|
||||
void application::run()
|
||||
{
|
||||
struct sigaction act
|
||||
{};
|
||||
struct sigaction act{};
|
||||
act.sa_handler = [](int) {
|
||||
instance().exit_requested = true;
|
||||
};
|
||||
@@ -1872,16 +1911,10 @@ void application::poll_events()
|
||||
switch (e.header.type)
|
||||
{
|
||||
case XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING: {
|
||||
spdlog::info("Received XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING");
|
||||
exit_requested = true;
|
||||
}
|
||||
break;
|
||||
case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED: {
|
||||
if (auto * htc_body = std::get_if<xr::htc_body_tracker>(&body_tracker))
|
||||
{
|
||||
htc_body->update_active();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING:
|
||||
break;
|
||||
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "android/hid.h"
|
||||
#include <android_native_app_glue.h>
|
||||
#endif
|
||||
|
||||
@@ -28,14 +29,11 @@
|
||||
#include "utils/thread_safe.h"
|
||||
#include "vk/vk_allocator.h"
|
||||
#include "wifi_lock.h"
|
||||
#include "xr/fb_body_tracker.h"
|
||||
#include "xr/fb_face_tracker2.h"
|
||||
#include "xr/hand_tracker.h"
|
||||
#include "xr/htc_body_tracker.h"
|
||||
#include "xr/htc_face_tracker.h"
|
||||
#include "xr/pico_body_tracker.h"
|
||||
#include "xr/pico_face_tracker.h"
|
||||
#include "xr/xr.h"
|
||||
#include "xr/actionset.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
#include "xr/swapchain.h"
|
||||
#include "xr/system.h"
|
||||
#include <atomic>
|
||||
#include <boost/locale/generator.hpp>
|
||||
#include <boost/locale/gnu_gettext.hpp>
|
||||
@@ -84,6 +82,8 @@ class application : public singleton<application>
|
||||
#ifdef __ANDROID__
|
||||
ANativeWindow * native_window = nullptr;
|
||||
bool resumed = false;
|
||||
|
||||
android_hid::input_handler input_handler{};
|
||||
#endif
|
||||
|
||||
static inline const char engine_name[] = "No engine";
|
||||
@@ -126,12 +126,7 @@ class application : public singleton<application>
|
||||
xr::actionset xr_actionset;
|
||||
std::vector<std::tuple<XrAction, XrActionType, std::string>> actions;
|
||||
|
||||
bool hand_tracking_supported = false;
|
||||
xr::hand_tracker left_hand;
|
||||
xr::hand_tracker right_hand;
|
||||
|
||||
std::variant<std::monostate, xr::fb_face_tracker2, xr::htc_face_tracker, xr::pico_face_tracker> face_tracker;
|
||||
std::variant<std::monostate, xr::fb_body_tracker, xr::htc_body_tracker, xr::pico_body_tracker> body_tracker;
|
||||
std::vector<std::pair<XrPath, xr::space>> generic_trackers;
|
||||
|
||||
bool eye_gaze_supported = false;
|
||||
|
||||
@@ -140,8 +135,9 @@ class application : public singleton<application>
|
||||
bool session_running = false;
|
||||
bool session_focused = false;
|
||||
bool session_visible = false;
|
||||
std::optional<std::chrono::steady_clock::time_point> timestamp_unsynchronized; // Timestamp when session_synchronized becomes false
|
||||
|
||||
bool debug_extensions_found = false;
|
||||
std::vector<std::string> xr_extensions;
|
||||
std::vector<const char *> vk_device_extensions;
|
||||
std::atomic<bool> exit_requested = false;
|
||||
std::filesystem::path config_path;
|
||||
@@ -240,7 +236,7 @@ public:
|
||||
{
|
||||
return instance().actions;
|
||||
}
|
||||
static std::pair<XrAction, XrActionType> get_action(const std::string & name);
|
||||
static std::pair<XrAction, XrActionType> get_action(std::string_view name);
|
||||
|
||||
static std::optional<std::pair<glm::vec3, glm::quat>> locate_controller(XrSpace space, XrSpace reference, XrTime time)
|
||||
{
|
||||
@@ -271,16 +267,6 @@ public:
|
||||
return std::make_pair(position, orientation);
|
||||
}
|
||||
|
||||
static XrPath string_to_path(const std::string & s)
|
||||
{
|
||||
return instance().xr_instance.string_to_path(s);
|
||||
}
|
||||
|
||||
static std::string path_to_string(XrPath p)
|
||||
{
|
||||
return instance().xr_instance.path_to_string(p);
|
||||
}
|
||||
|
||||
void run();
|
||||
|
||||
static void push_scene(std::shared_ptr<scene>);
|
||||
@@ -351,16 +337,6 @@ public:
|
||||
// #endif
|
||||
}
|
||||
|
||||
static XrTime now()
|
||||
{
|
||||
return instance().xr_instance.now();
|
||||
}
|
||||
|
||||
static uint32_t queue_family_index()
|
||||
{
|
||||
return instance().vk_queue_family_index;
|
||||
}
|
||||
|
||||
static thread_safe<vk::raii::Queue> & get_queue()
|
||||
{
|
||||
return instance().vk_queue;
|
||||
@@ -376,26 +352,26 @@ public:
|
||||
return intent;
|
||||
}
|
||||
|
||||
static vk::raii::PhysicalDevice & get_physical_device()
|
||||
{
|
||||
return instance().vk_physical_device;
|
||||
}
|
||||
|
||||
static const vk::PhysicalDeviceProperties & get_physical_device_properties()
|
||||
{
|
||||
return instance().physical_device_properties;
|
||||
}
|
||||
|
||||
static vk::raii::Device & get_device()
|
||||
{
|
||||
return instance().vk_device;
|
||||
}
|
||||
|
||||
static vk::raii::Instance & get_vulkan_instance()
|
||||
{
|
||||
return instance().vk_instance;
|
||||
}
|
||||
|
||||
static vk::raii::PhysicalDevice & get_physical_device()
|
||||
{
|
||||
return instance().vk_physical_device;
|
||||
}
|
||||
|
||||
static xr::system & get_system()
|
||||
{
|
||||
return instance().xr_system_id;
|
||||
}
|
||||
|
||||
static vk::raii::PipelineCache & get_pipeline_cache()
|
||||
{
|
||||
return instance().pipeline_cache;
|
||||
@@ -416,21 +392,6 @@ public:
|
||||
return instance().last_scene_cpu_time;
|
||||
}
|
||||
|
||||
static bool get_hand_tracking_supported()
|
||||
{
|
||||
return instance().hand_tracking_supported;
|
||||
}
|
||||
|
||||
static bool get_face_tracking_supported()
|
||||
{
|
||||
return !std::holds_alternative<std::monostate>(instance().face_tracker);
|
||||
}
|
||||
|
||||
static bool get_body_tracking_supported()
|
||||
{
|
||||
return !std::holds_alternative<std::monostate>(instance().body_tracker);
|
||||
}
|
||||
|
||||
static bool get_eye_gaze_supported()
|
||||
{
|
||||
return instance().eye_gaze_supported;
|
||||
@@ -441,29 +402,9 @@ public:
|
||||
return instance().openxr_post_processing_supported;
|
||||
}
|
||||
|
||||
static xr::hand_tracker & get_left_hand()
|
||||
static auto & get_generic_trackers()
|
||||
{
|
||||
return instance().left_hand;
|
||||
}
|
||||
|
||||
static xr::hand_tracker & get_right_hand()
|
||||
{
|
||||
return instance().right_hand;
|
||||
}
|
||||
|
||||
static auto & get_face_tracker()
|
||||
{
|
||||
return instance().face_tracker;
|
||||
}
|
||||
|
||||
static auto & get_body_tracker()
|
||||
{
|
||||
return instance().body_tracker;
|
||||
}
|
||||
|
||||
static const std::vector<std::string> & get_xr_extensions()
|
||||
{
|
||||
return instance().xr_extensions;
|
||||
return instance().generic_trackers;
|
||||
}
|
||||
|
||||
static const std::vector<const char *> & get_vk_device_extensions()
|
||||
@@ -486,4 +427,6 @@ public:
|
||||
{
|
||||
return instance().messages_info;
|
||||
}
|
||||
|
||||
void load_locale();
|
||||
};
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2024 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "asset.h"
|
||||
#include "application.h"
|
||||
#include "utils/files.h"
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/asset_manager.h>
|
||||
|
||||
asset::asset(const std::filesystem::path & path)
|
||||
{
|
||||
spdlog::debug("Loading Android asset {}", path.string());
|
||||
android_asset = AAssetManager_open(application::asset_manager(), path.c_str(), AASSET_MODE_BUFFER);
|
||||
|
||||
if (!android_asset)
|
||||
throw std::runtime_error("Cannot open Android asset " + path.string());
|
||||
|
||||
bytes = std::span<const std::byte>{reinterpret_cast<const std::byte *>(AAsset_getBuffer(android_asset)), (size_t)AAsset_getLength64(android_asset)};
|
||||
}
|
||||
|
||||
asset::asset(asset && other) :
|
||||
android_asset(other.android_asset)
|
||||
{
|
||||
other.android_asset = nullptr;
|
||||
}
|
||||
|
||||
asset & asset::operator=(asset && other)
|
||||
{
|
||||
std::swap(android_asset, other.android_asset);
|
||||
return *this;
|
||||
}
|
||||
|
||||
asset::~asset()
|
||||
{
|
||||
if (android_asset)
|
||||
AAsset_close(android_asset);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static std::filesystem::path get_exe_path()
|
||||
{
|
||||
// Linux only: see https://stackoverflow.com/a/1024937
|
||||
return std::filesystem::read_symlink("/proc/self/exe");
|
||||
}
|
||||
|
||||
static std::filesystem::path get_asset_root()
|
||||
{
|
||||
const char * path = std::getenv("WIVRN_ASSET_ROOT");
|
||||
if (path && strcmp(path, ""))
|
||||
return path;
|
||||
|
||||
return get_exe_path().parent_path().parent_path() / "share" / "wivrn" / "assets";
|
||||
}
|
||||
|
||||
static std::filesystem::path get_locale_root()
|
||||
{
|
||||
const char * path = std::getenv("WIVRN_LOCALE_ROOT");
|
||||
if (path && strcmp(path, ""))
|
||||
return path;
|
||||
|
||||
return get_exe_path().parent_path().parent_path() / "share" / "locale";
|
||||
}
|
||||
|
||||
std::filesystem::path asset::asset_root()
|
||||
{
|
||||
static std::filesystem::path root = get_asset_root();
|
||||
return root;
|
||||
}
|
||||
|
||||
std::filesystem::path asset::locale_root()
|
||||
{
|
||||
static std::filesystem::path root = get_locale_root();
|
||||
return root;
|
||||
}
|
||||
|
||||
asset::asset(const std::filesystem::path & path)
|
||||
{
|
||||
assert(path.is_relative());
|
||||
|
||||
// TODO mmap
|
||||
// TODO load only once if it is already loaded
|
||||
|
||||
spdlog::debug("Loading file asset {}", path.string());
|
||||
|
||||
if (path.native().starts_with("locale/"))
|
||||
{
|
||||
bytes = utils::read_whole_file<std::byte>(locale_root() / path.native().substr(7));
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = utils::read_whole_file<std::byte>(asset_root() / path);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,9 @@
|
||||
|
||||
#include "configuration.h"
|
||||
#include "application.h"
|
||||
#include "utils/contains.h"
|
||||
#include "utils/json_string.h"
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <magic_enum.hpp>
|
||||
@@ -27,61 +30,16 @@
|
||||
#include "android/permissions.h"
|
||||
#endif
|
||||
|
||||
static std::string json_string(const std::string & in)
|
||||
{
|
||||
std::string out;
|
||||
out.reserve(in.size() + 2);
|
||||
|
||||
out += '"';
|
||||
|
||||
for (char c: in)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '\b':
|
||||
out += "\\b";
|
||||
break;
|
||||
|
||||
case '\f':
|
||||
out += "\\f";
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
out += "\\n";
|
||||
break;
|
||||
|
||||
case '\r':
|
||||
out += "\\r";
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
out += "\\t";
|
||||
break;
|
||||
|
||||
case '"':
|
||||
out += "\\\"";
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
out += "\\\\";
|
||||
break;
|
||||
|
||||
default:
|
||||
out += c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out += '"';
|
||||
|
||||
return out;
|
||||
}
|
||||
// If no refresh rate is configured, don't select a too high one
|
||||
static const float max_default_rate = 100;
|
||||
|
||||
bool configuration::check_feature(feature f) const
|
||||
{
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
auto & system = application::get_system();
|
||||
|
||||
auto it = features.find(f);
|
||||
if (it == features.end())
|
||||
return false;
|
||||
@@ -94,7 +52,7 @@ bool configuration::check_feature(feature f) const
|
||||
case feature::microphone:
|
||||
break;
|
||||
case feature::hand_tracking:
|
||||
if (not application::get_hand_tracking_supported())
|
||||
if (not system.hand_tracking_supported())
|
||||
return false;
|
||||
break;
|
||||
case feature::eye_gaze:
|
||||
@@ -102,50 +60,12 @@ bool configuration::check_feature(feature f) const
|
||||
return false;
|
||||
break;
|
||||
case feature::face_tracking:
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_focus_vision:
|
||||
case model::htc_vive_xr_elite:
|
||||
if (not std::holds_alternative<xr::htc_face_tracker>(application::get_face_tracker()))
|
||||
return false;
|
||||
break;
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
if (not std::holds_alternative<xr::pico_face_tracker>(application::get_face_tracker()))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
if (not std::holds_alternative<xr::fb_face_tracker2>(application::get_face_tracker()))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if (system.face_tracker_supported() == xr::face_tracker_type::none)
|
||||
return false;
|
||||
break;
|
||||
case feature::body_tracking:
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::meta_quest_3:
|
||||
case model::meta_quest_3s:
|
||||
if (not std::holds_alternative<xr::fb_body_tracker>(application::get_body_tracker()))
|
||||
return false;
|
||||
break;
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_xr_elite:
|
||||
case model::htc_vive_focus_vision:
|
||||
if (not std::holds_alternative<xr::htc_body_tracker>(application::get_body_tracker()))
|
||||
return false;
|
||||
break;
|
||||
case model::pico_neo_3:
|
||||
case model::pico_4:
|
||||
case model::pico_4s:
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
if (not std::holds_alternative<xr::pico_body_tracker>(application::get_body_tracker()))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (system.body_tracker_supported() == xr::body_tracker_type::none)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -179,14 +99,46 @@ void configuration::set_feature(feature f, bool state)
|
||||
save();
|
||||
}
|
||||
|
||||
configuration::configuration(xr::system & system)
|
||||
configuration::configuration(xr::system & system, xr::session & session)
|
||||
{
|
||||
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
|
||||
features[feature::hand_tracking] = application::get_hand_tracking_supported();
|
||||
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
|
||||
features[feature::hand_tracking] = system.hand_tracking_supported();
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::oculus_quest:
|
||||
case model::oculus_quest_2:
|
||||
case model::meta_quest_pro:
|
||||
case model::meta_quest_3:
|
||||
case model::meta_quest_3s:
|
||||
high_power_mode = false;
|
||||
break;
|
||||
case model::pico_neo_3:
|
||||
case model::pico_4:
|
||||
case model::pico_4s:
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_xr_elite:
|
||||
case model::htc_vive_focus_vision:
|
||||
case model::lynx_r1:
|
||||
case model::samsung_galaxy_xr:
|
||||
case model::unknown:
|
||||
high_power_mode = true;
|
||||
break;
|
||||
}
|
||||
|
||||
const auto & rates = session.get_refresh_rates();
|
||||
for (auto rate: rates)
|
||||
{
|
||||
if (rate >= max_default_rate)
|
||||
break;
|
||||
preferred_refresh_rate = rate;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
simdjson::dom::parser parser;
|
||||
simdjson::dom::element root = parser.load(application::get_config_path() / "client.json");
|
||||
simdjson::dom::element root = parser.load((application::get_config_path() / "client.json").native());
|
||||
for (simdjson::dom::object i: simdjson::dom::array(root["servers"]))
|
||||
{
|
||||
server_data data{
|
||||
@@ -206,7 +158,11 @@ configuration::configuration(xr::system & system)
|
||||
}
|
||||
|
||||
if (auto val = root["preferred_refresh_rate"]; val.is_double())
|
||||
preferred_refresh_rate = val.get_double();
|
||||
{
|
||||
float f = val.get_double();
|
||||
if (f == 0 or utils::contains(rates, f))
|
||||
preferred_refresh_rate = f;
|
||||
}
|
||||
|
||||
if (auto val = root["minimum_refresh_rate"]; val.is_double())
|
||||
minimum_refresh_rate = val.get_double();
|
||||
@@ -214,12 +170,30 @@ configuration::configuration(xr::system & system)
|
||||
if (auto val = root["resolution_scale"]; val.is_double())
|
||||
resolution_scale = val.get_double();
|
||||
|
||||
if (auto val = root["stream_scale"]; val.is_double())
|
||||
stream_scale = val.get_double();
|
||||
|
||||
if (auto val = root["codec"]; val.is_string())
|
||||
{
|
||||
const auto codec_str = val.get_string().value();
|
||||
for (const auto & [c, name]: magic_enum::enum_entries<wivrn::video_codec>())
|
||||
{
|
||||
if (codec_str == name)
|
||||
{
|
||||
codec = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (auto val = root["bit_depth"]; val.is_uint64())
|
||||
bit_depth = val.get_uint64();
|
||||
|
||||
if (auto val = root["bitrate_bps"]; val.is_number())
|
||||
bitrate_bps = val.get_uint64();
|
||||
|
||||
if (auto val = root["enable_stream_gui"]; val.is_bool())
|
||||
enable_stream_gui = val.get_bool();
|
||||
|
||||
if (auto val = root["sgsr"]; val.is_object())
|
||||
parse_sgsr_options(val.get_object());
|
||||
|
||||
if (auto val = root["openxr_post_processing"]; val.is_object())
|
||||
parse_openxr_post_processing_options(val.get_object());
|
||||
|
||||
@@ -243,7 +217,7 @@ configuration::configuration(xr::system & system)
|
||||
features[i] = val.get_bool();
|
||||
}
|
||||
|
||||
if (system.passthrough_supported() == xr::system::passthrough_type::no_passthrough)
|
||||
if (system.passthrough_supported() == xr::passthrough_type::none)
|
||||
passthrough_enabled = false;
|
||||
|
||||
if (auto val = root["override_foveation_enable"]; val.is_bool())
|
||||
@@ -257,41 +231,25 @@ configuration::configuration(xr::system & system)
|
||||
|
||||
if (auto val = root["first_run"]; val.is_bool())
|
||||
first_run = val.get_bool();
|
||||
|
||||
if (auto val = root["locale"]; val.is_string())
|
||||
locale = val.get_string().value();
|
||||
|
||||
if (auto val = root["environment_model"]; val.is_string())
|
||||
environment_model = (std::string_view)val.get_string();
|
||||
|
||||
if (auto val = root["high_power_mode"]; val.is_bool())
|
||||
high_power_mode = val.get_bool();
|
||||
|
||||
if (auto val = root["extended_config"]; val.is_bool())
|
||||
extended_config = val.get_bool();
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
spdlog::warn("Cannot read configuration: {}", e.what());
|
||||
|
||||
// Restore default configuration
|
||||
servers.clear();
|
||||
preferred_refresh_rate.reset();
|
||||
minimum_refresh_rate.reset();
|
||||
resolution_scale = 1.4;
|
||||
sgsr = {};
|
||||
openxr_post_processing = {};
|
||||
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
|
||||
}
|
||||
}
|
||||
|
||||
void configuration::parse_sgsr_options(simdjson::simdjson_result<simdjson::dom::object> sgsr_root)
|
||||
{
|
||||
sgsr = {};
|
||||
if (auto val = sgsr_root["enabled"]; val.is_bool())
|
||||
sgsr.enabled = val.get_bool();
|
||||
|
||||
if (auto val = sgsr_root["upscaling_factor"]; val.is_double())
|
||||
sgsr.upscaling_factor = val.get_double();
|
||||
|
||||
if (auto val = sgsr_root["use_edge_direction"]; val.is_bool())
|
||||
sgsr.use_edge_direction = val.get_bool();
|
||||
|
||||
if (auto val = sgsr_root["edge_threshold"]; val.is_double())
|
||||
sgsr.edge_threshold = val.get_double();
|
||||
|
||||
if (auto val = sgsr_root["edge_sharpness"]; val.is_double())
|
||||
sgsr.edge_sharpness = val.get_double();
|
||||
}
|
||||
|
||||
void configuration::parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> openxr_post_processing_root)
|
||||
{
|
||||
openxr_post_processing = {};
|
||||
@@ -307,17 +265,6 @@ static std::ostream & operator<<(std::ostream & stream, feature f)
|
||||
return stream << "\"" << magic_enum::enum_name(f) << "\"";
|
||||
}
|
||||
|
||||
static std::ostream & write_sgsr(std::ofstream & stream, const configuration::sgsr_settings & sgsr)
|
||||
{
|
||||
stream << "{\"enabled\":" << std::boolalpha << sgsr.enabled;
|
||||
stream << ",\"upscaling_factor\":" << sgsr.upscaling_factor;
|
||||
stream << ",\"use_edge_direction\":" << std::boolalpha << sgsr.use_edge_direction;
|
||||
stream << ",\"edge_threshold\":" << sgsr.edge_threshold;
|
||||
stream << ",\"edge_sharpness\":" << sgsr.edge_sharpness;
|
||||
stream << "}";
|
||||
return stream;
|
||||
}
|
||||
|
||||
static std::ostream & write_openxr_post_processing(std::ofstream & stream, const configuration::openxr_post_processing_settings & openxr_post_processing)
|
||||
{
|
||||
stream << "{\"super_sampling\":" << openxr_post_processing.super_sampling;
|
||||
@@ -355,13 +302,16 @@ void configuration::save()
|
||||
std::ofstream json(application::get_config_path() / "client.json");
|
||||
|
||||
json << "{\"servers\":[" << servers_str << "]";
|
||||
if (preferred_refresh_rate)
|
||||
json << ",\"preferred_refresh_rate\":" << *preferred_refresh_rate;
|
||||
json << ",\"preferred_refresh_rate\":" << preferred_refresh_rate;
|
||||
if (minimum_refresh_rate)
|
||||
json << ",\"minimum_refresh_rate\":" << *minimum_refresh_rate;
|
||||
json << ",\"resolution_scale\":" << resolution_scale;
|
||||
json << ",\"sgsr\":";
|
||||
write_sgsr(json, sgsr);
|
||||
if (stream_scale)
|
||||
json << ",\"stream_scale\":" << *stream_scale;
|
||||
if (codec)
|
||||
json << ",\"codec\":" << json_string(magic_enum::enum_name(*codec));
|
||||
json << ",\"bit_depth\":" << (uint64_t)bit_depth;
|
||||
json << ",\"bitrate_bps\":" << bitrate_bps;
|
||||
json << ",\"openxr_post_processing\":";
|
||||
write_openxr_post_processing(json, openxr_post_processing);
|
||||
json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
|
||||
@@ -376,5 +326,23 @@ void configuration::save()
|
||||
json << ",\"override_foveation_pitch\":" << override_foveation_pitch;
|
||||
json << ",\"override_foveation_distance\":" << override_foveation_distance;
|
||||
json << ",\"first_run\":" << std::boolalpha << first_run;
|
||||
json << ",\"locale\":" << json_string(locale);
|
||||
json << ",\"environment_model\":" << json_string(environment_model);
|
||||
json << ",\"high_power_mode\":" << std::boolalpha << high_power_mode;
|
||||
json << ",\"extended_config\":" << std::boolalpha << extended_config;
|
||||
json << "}";
|
||||
}
|
||||
|
||||
void configuration::set_stream_scale(float val)
|
||||
{
|
||||
stream_scale = val;
|
||||
}
|
||||
|
||||
float configuration::get_stream_scale() const
|
||||
{
|
||||
if (stream_scale)
|
||||
return *stream_scale;
|
||||
if (check_feature(feature::eye_gaze))
|
||||
return 0.3;
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "hardware.h"
|
||||
#include "wivrn_discover.h"
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
@@ -30,8 +31,9 @@
|
||||
|
||||
namespace xr
|
||||
{
|
||||
class session;
|
||||
class system;
|
||||
}
|
||||
} // namespace xr
|
||||
|
||||
class configuration
|
||||
{
|
||||
@@ -47,9 +49,13 @@ public:
|
||||
};
|
||||
|
||||
std::map<std::string, server_data> servers;
|
||||
std::optional<float> preferred_refresh_rate;
|
||||
float preferred_refresh_rate = 0;
|
||||
std::optional<float> minimum_refresh_rate;
|
||||
float resolution_scale = 1.4;
|
||||
float resolution_scale = 1.0;
|
||||
std::optional<wivrn::video_codec> codec;
|
||||
uint32_t bitrate_bps = 50'000'000;
|
||||
uint8_t bit_depth = 10;
|
||||
|
||||
bool passthrough_enabled = false;
|
||||
bool mic_unprocessed_audio = false;
|
||||
|
||||
@@ -58,17 +64,6 @@ public:
|
||||
|
||||
bool enable_stream_gui = true;
|
||||
|
||||
// Snapdragon Game Super Resolution
|
||||
struct sgsr_settings
|
||||
{
|
||||
bool enabled = false;
|
||||
float upscaling_factor = 1.5;
|
||||
bool use_edge_direction = true;
|
||||
float edge_threshold = 4.0;
|
||||
float edge_sharpness = 2.0;
|
||||
};
|
||||
sgsr_settings sgsr{};
|
||||
|
||||
// XR_FB_composition_layer_settings extension flags
|
||||
struct openxr_post_processing_settings
|
||||
{
|
||||
@@ -79,25 +74,42 @@ public:
|
||||
|
||||
std::string virtual_keyboard_layout = "QWERTY";
|
||||
|
||||
std::string environment_model = "assets://ground.glb";
|
||||
|
||||
bool override_foveation_enable = false;
|
||||
float override_foveation_pitch = 10 * M_PI / 180;
|
||||
float override_foveation_pitch = -10 * M_PI / 180;
|
||||
float override_foveation_distance = 3;
|
||||
|
||||
bool high_power_mode;
|
||||
|
||||
// Allow unsafe config values
|
||||
bool extended_config = false;
|
||||
|
||||
bool first_run = true;
|
||||
|
||||
std::string locale;
|
||||
|
||||
bool check_feature(feature f) const;
|
||||
void set_feature(feature f, bool state);
|
||||
|
||||
private:
|
||||
mutable std::mutex mutex;
|
||||
std::map<feature, bool> features;
|
||||
std::optional<float> stream_scale;
|
||||
|
||||
void parse_sgsr_options(simdjson::simdjson_result<simdjson::dom::object> root);
|
||||
void parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> root);
|
||||
|
||||
public:
|
||||
configuration(xr::system &);
|
||||
configuration(xr::system &, xr::session &);
|
||||
configuration() = default;
|
||||
|
||||
void save();
|
||||
|
||||
void set_stream_scale(float);
|
||||
float get_stream_scale() const;
|
||||
|
||||
uint32_t max_bitrate() const
|
||||
{
|
||||
return extended_config ? 800'000'000u : 200'000'000u;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <glm/glm.hpp>
|
||||
#include <imgui.h>
|
||||
@@ -26,7 +27,7 @@
|
||||
namespace constants::gui
|
||||
{
|
||||
// Minimum distance between a GUI layer and a fingertip/controller to register a click
|
||||
constexpr float min_pointer_distance = -0.1;
|
||||
constexpr float min_controller_distance = -0.02;
|
||||
|
||||
// Font to use (desktop only)
|
||||
constexpr const char font_name[] = "Noto Sans";
|
||||
@@ -39,19 +40,21 @@ constexpr int font_size_large = 75;
|
||||
constexpr float scroll_ratio = 10;
|
||||
|
||||
// Threshold on the trigger value to register a click
|
||||
constexpr float trigger_click_thd = 0.8;
|
||||
constexpr float trigger_click_thd = 0.7;
|
||||
|
||||
// Thresholds on the distance between the fingertip and GUI layers
|
||||
constexpr float fingertip_distance_hovering_thd = 0.15;
|
||||
constexpr float fingertip_distance_touching_thd = 0.0;
|
||||
// Thresholds on the distance between the fingertip and GUI layers (positive: in front of the GUI, negative: behind the GUI)
|
||||
constexpr float palm_distance_close_thd_lo = 0.18; // Distance to switch between touch and aim interaction
|
||||
constexpr float palm_distance_close_thd_hi = 0.22; // Distance to switch between touch and aim interaction
|
||||
constexpr float fingertip_distance_touching_thd_hi = -0.01; // Distance to register a click
|
||||
constexpr float fingertip_distance_touching_thd_lo = -0.15; // Distance to register a click
|
||||
constexpr float fingertip_distance_stick_thd = -0.02; // Max distance where the fingertip is moved to be on the GUI
|
||||
|
||||
// Minimum scroll value to enable a controller
|
||||
constexpr float scroll_value_thd = 0.01;
|
||||
|
||||
// Pointer radius
|
||||
constexpr float pointer_radius_in = 10;
|
||||
constexpr float pointer_radius_out = 12;
|
||||
constexpr float pointer_thickness = 4;
|
||||
constexpr float pointer_thickness = 2;
|
||||
constexpr float pointer_radius_in = 6;
|
||||
|
||||
// Pointer transparency
|
||||
constexpr float pointer_alpha = 0.8;
|
||||
@@ -59,15 +62,21 @@ constexpr float pointer_alpha_disabled = 0.25;
|
||||
constexpr float pointer_fading_distance = 40;
|
||||
|
||||
// Pointer color
|
||||
constexpr uint32_t pointer_color_pressed = 0xffff3300;
|
||||
constexpr uint32_t pointer_color_unpressed = 0xffffffff;
|
||||
constexpr uint32_t pointer_color = 0x40ffffff;
|
||||
constexpr uint32_t pointer_color_border = 0xff000000;
|
||||
} // namespace constants::gui
|
||||
|
||||
namespace constants::lobby
|
||||
{
|
||||
// Position and orientation of the GUI layers
|
||||
constexpr float gui_pitch = -0.2;
|
||||
constexpr auto gui_pitches = std::to_array<std::pair<float, float>>({
|
||||
{-90, -90},
|
||||
{-50, -90},
|
||||
{-30, -12},
|
||||
{30, -12},
|
||||
{50, 78},
|
||||
{90, 78},
|
||||
});
|
||||
constexpr float keyboard_pitch = -0.6;
|
||||
constexpr glm::vec3 popup_position = {0, 0, 0.05};
|
||||
constexpr glm::vec3 keyboard_position = {0, -0.3, 0.1};
|
||||
@@ -76,7 +85,8 @@ constexpr glm::vec3 keyboard_position = {0, -0.3, 0.1};
|
||||
constexpr float near_plane = 0.02;
|
||||
|
||||
// Recenter gesture thresholds
|
||||
constexpr float recenter_cosangle_min = 0.8;
|
||||
constexpr float recenter_cos_palm_angle_min = 0.7;
|
||||
constexpr float recenter_cos_fingertip_angle_max = 0.3;
|
||||
constexpr float recenter_distance_up = 0.3;
|
||||
constexpr float recenter_distance_front = 0.2;
|
||||
|
||||
@@ -98,7 +108,8 @@ constexpr int zindex_passthrough = -2;
|
||||
constexpr int zindex_lobby = -1;
|
||||
constexpr int zindex_gui = 0;
|
||||
constexpr int zindex_controllers = 1;
|
||||
constexpr int zindex_recenter_tip = 2;
|
||||
constexpr int zindex_tooltip = 2;
|
||||
constexpr int zindex_recenter_tip = 3;
|
||||
} // namespace constants::lobby
|
||||
|
||||
namespace constants::stream
|
||||
@@ -106,9 +117,12 @@ namespace constants::stream
|
||||
constexpr float fade_delay = 3;
|
||||
constexpr float fade_duration = 0.25;
|
||||
|
||||
constexpr float urgent_fade_delay = 5;
|
||||
constexpr ImVec4 urgent_border_color = {8.f, .6f, 0.f, .8f};
|
||||
|
||||
// Dimming for the streamed video when the GUI is interactable
|
||||
constexpr float dimming_scale = 0.7;
|
||||
constexpr float dimming_bias = 0.15;
|
||||
constexpr float dimming_scale = 0.4;
|
||||
constexpr float dimming_bias = 0.01;
|
||||
} // namespace constants::stream
|
||||
|
||||
namespace constants::style
|
||||
@@ -119,7 +133,7 @@ constexpr float window_rounding = 10;
|
||||
|
||||
constexpr ImVec2 tooltip_padding = {5, 5};
|
||||
constexpr float tooltip_rounding = 0;
|
||||
constexpr float tooltip_distance = 10;
|
||||
constexpr glm::vec3 tooltip_distance = {0, 0.004, 0.005};
|
||||
|
||||
constexpr ImVec2 button_size = {220, 80};
|
||||
constexpr ImVec2 icon_button_size = {80, 80};
|
||||
|
||||
@@ -42,6 +42,7 @@ struct wivrn::android::decoder::mapped_hardware_buffer
|
||||
{
|
||||
vk::raii::DeviceMemory memory = nullptr;
|
||||
vk::raii::Image vimage = nullptr;
|
||||
vk::Extent2D extent{};
|
||||
vk::raii::ImageView image_view = nullptr;
|
||||
vk::ImageLayout layout = vk::ImageLayout::eUndefined;
|
||||
};
|
||||
@@ -59,8 +60,11 @@ const char * mime(wivrn::video_codec codec)
|
||||
return "video/hevc";
|
||||
case c::av1:
|
||||
return "video/av01";
|
||||
case c::raw:
|
||||
break;
|
||||
}
|
||||
assert(false);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
void check(media_status_t status, const char * msg)
|
||||
@@ -72,6 +76,27 @@ void check(media_status_t status, const char * msg)
|
||||
}
|
||||
}
|
||||
|
||||
struct android_blit_handle : public decoder::blit_handle
|
||||
{
|
||||
std::shared_ptr<wivrn::android::decoder::mapped_hardware_buffer> vk_data;
|
||||
std::shared_ptr<AImageReader> image_reader;
|
||||
AImage_ptr aimage;
|
||||
android_blit_handle(
|
||||
const wivrn::from_headset::feedback & feedback,
|
||||
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info,
|
||||
vk::ImageView image_view,
|
||||
vk::Image image,
|
||||
vk::Extent2D extent,
|
||||
vk::ImageLayout & current_layout,
|
||||
decltype(vk_data) vk_data,
|
||||
decltype(image_reader) image_reader,
|
||||
decltype(aimage) aimage) :
|
||||
decoder::blit_handle(feedback, view_info, image_view, image, extent, current_layout),
|
||||
vk_data(vk_data),
|
||||
image_reader(image_reader),
|
||||
aimage(std::move(aimage)) {}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace wivrn::android
|
||||
@@ -80,19 +105,21 @@ namespace wivrn::android
|
||||
decoder::decoder(
|
||||
vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & physical_device,
|
||||
const wivrn::to_headset::video_stream_description::item & description,
|
||||
float fps,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
uint8_t stream_index,
|
||||
std::weak_ptr<scenes::stream> weak_scene,
|
||||
shard_accumulator * accumulator) :
|
||||
description(description), stream_index(stream_index), fps(fps), device(device), weak_scene(weak_scene), accumulator(accumulator)
|
||||
stream_index(stream_index), device(device), weak_scene(weak_scene), accumulator(accumulator)
|
||||
{
|
||||
spdlog::info("hbm_mutex.native_handle() = {}", (void *)hbm_mutex.native_handle());
|
||||
|
||||
auto width = description.width;
|
||||
auto height = description.height / (stream_index == 2 ? 2 : 1);
|
||||
|
||||
AImageReader * ir;
|
||||
check(AImageReader_newWithUsage(
|
||||
description.video_width,
|
||||
description.video_height,
|
||||
width,
|
||||
height,
|
||||
AIMAGE_FORMAT_PRIVATE,
|
||||
AHARDWAREBUFFER_USAGE_CPU_READ_NEVER | AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE,
|
||||
scenes::stream::image_buffer_size + 4 /* maxImages */,
|
||||
@@ -108,18 +135,18 @@ decoder::decoder(
|
||||
"vkGetAndroidHardwareBufferPropertiesANDROID");
|
||||
{
|
||||
AMediaFormat_ptr format(AMediaFormat_new());
|
||||
AMediaFormat_setString(format.get(), AMEDIAFORMAT_KEY_MIME, mime(description.codec));
|
||||
AMediaFormat_setString(format.get(), AMEDIAFORMAT_KEY_MIME, mime(description.codec[stream_index]));
|
||||
// AMediaFormat_setInt32(format.get(), "vendor.qti-ext-dec-low-latency.enable", 1); // Qualcomm low
|
||||
// latency mode
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, description.video_width);
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_HEIGHT, description.video_height);
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(fps));
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, width);
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_HEIGHT, height);
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(description.fps));
|
||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_PRIORITY, 0);
|
||||
|
||||
media_codec.reset(AMediaCodec_createDecoderByType(mime(description.codec)));
|
||||
media_codec.reset(AMediaCodec_createDecoderByType(mime(description.codec[stream_index])));
|
||||
|
||||
if (not media_codec)
|
||||
throw std::runtime_error(std::string("Cannot create decoder for MIME type ") + mime(description.codec));
|
||||
throw std::runtime_error(std::string("Cannot create decoder for MIME type ") + mime(description.codec[stream_index]));
|
||||
|
||||
char * codec_name;
|
||||
check(AMediaCodec_getName(media_codec.get(), &codec_name), "AMediaCodec_getName");
|
||||
@@ -222,7 +249,7 @@ void decoder::push_data(std::span<std::span<const uint8_t>> data, uint64_t frame
|
||||
current_input_buffer = input_buffer{};
|
||||
}
|
||||
|
||||
void decoder::frame_completed(wivrn::from_headset::feedback & feedback, const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info)
|
||||
void decoder::frame_completed(const wivrn::from_headset::feedback & feedback, const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info)
|
||||
{
|
||||
if (not media_codec)
|
||||
{
|
||||
@@ -255,7 +282,7 @@ void decoder::on_image_available(AImageReader * reader)
|
||||
assert(reader == image_reader.get());
|
||||
// Executed on image reader thread
|
||||
|
||||
decltype(blit_handle::aimage) image;
|
||||
decltype(android_blit_handle::aimage) image;
|
||||
try
|
||||
{
|
||||
AImage * tmp;
|
||||
@@ -280,13 +307,14 @@ void decoder::on_image_available(AImageReader * reader)
|
||||
|
||||
auto vk_data = map_hardware_buffer(image.get());
|
||||
|
||||
auto handle = std::make_shared<decoder::blit_handle>(
|
||||
auto handle = std::make_shared<android_blit_handle>(
|
||||
info->feedback,
|
||||
info->view_info,
|
||||
vk_data->image_view,
|
||||
*vk_data->image_view,
|
||||
*vk_data->vimage,
|
||||
&vk_data->layout,
|
||||
vk_data,
|
||||
vk_data->extent,
|
||||
vk_data->layout,
|
||||
std::move(vk_data),
|
||||
image_reader,
|
||||
std::move(image));
|
||||
|
||||
@@ -338,11 +366,8 @@ void decoder::create_sampler(const AHardwareBuffer_Desc & buffer_desc, vk::Andro
|
||||
};
|
||||
|
||||
// suggested values from decoder don't actually read the metadata, so it's garbage
|
||||
if (description.range)
|
||||
ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>().ycbcrRange = vk::SamplerYcbcrRange(*description.range);
|
||||
|
||||
if (description.color_model)
|
||||
ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>().ycbcrModel = vk::SamplerYcbcrModelConversion(*description.color_model);
|
||||
ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>().ycbcrRange = vk::SamplerYcbcrRange::eItuFull;
|
||||
ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>().ycbcrModel = vk::SamplerYcbcrModelConversion::eYcbcr709;
|
||||
|
||||
ycbcr_conversion = vk::raii::SamplerYcbcrConversion(device, ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>());
|
||||
|
||||
@@ -388,7 +413,7 @@ std::shared_ptr<decoder::mapped_hardware_buffer> decoder::map_hardware_buffer(AI
|
||||
if (!*ycbcr_sampler || memcmp(&ahb_format, &format_properties, sizeof(format_properties)))
|
||||
{
|
||||
memcpy(&ahb_format, &format_properties, sizeof(format_properties));
|
||||
extent = {buffer_desc.width, buffer_desc.height};
|
||||
spdlog::info("decoded image size: {}x{}", buffer_desc.width, buffer_desc.height);
|
||||
create_sampler(buffer_desc, ahb_format);
|
||||
hardware_buffer_map.clear();
|
||||
// TODO tell the reprojector to recreate the pipeline
|
||||
@@ -466,6 +491,10 @@ std::shared_ptr<decoder::mapped_hardware_buffer> decoder::map_hardware_buffer(AI
|
||||
handle->vimage = std::move(vimage);
|
||||
handle->image_view = std::move(image_view);
|
||||
handle->memory = std::move(memory);
|
||||
handle->extent = vk::Extent2D{
|
||||
.width = buffer_desc.width,
|
||||
.height = buffer_desc.height,
|
||||
};
|
||||
|
||||
hardware_buffer_map[hardware_buffer] = handle;
|
||||
return handle;
|
||||
@@ -514,11 +543,6 @@ void decoder::on_media_output_available(AMediaCodec * media_codec, void * userda
|
||||
});
|
||||
}
|
||||
|
||||
void decoder::blit_handle::deleter::operator()(AImage * aimage)
|
||||
{
|
||||
AImage_delete(aimage);
|
||||
}
|
||||
|
||||
static bool hardware_accelerated(AMediaCodec * media_codec)
|
||||
{
|
||||
// MediaCodecInfo has isHardwareAccelerated, but this does not exist in NDK.
|
||||
@@ -542,17 +566,16 @@ static bool hardware_accelerated(AMediaCodec * media_codec)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<wivrn::video_codec> decoder::supported_codecs()
|
||||
void decoder::supported_codecs(std::vector<wivrn::video_codec> & result)
|
||||
{
|
||||
std::vector<wivrn::video_codec> result;
|
||||
// Make sure we update this code when codecs are changed
|
||||
static_assert(magic_enum::enum_count<wivrn::video_codec>() == 3);
|
||||
static_assert(magic_enum::enum_count<wivrn::video_codec>() == 4);
|
||||
|
||||
// In order or preference, from preferred to least preferred
|
||||
for (auto codec: {
|
||||
wivrn::video_codec::av1,
|
||||
wivrn::video_codec::h264,
|
||||
wivrn::video_codec::h265,
|
||||
wivrn::video_codec::h264,
|
||||
})
|
||||
{
|
||||
AMediaCodec_ptr media_codec(AMediaCodec_createDecoderByType(mime(codec)));
|
||||
@@ -563,8 +586,6 @@ std::vector<wivrn::video_codec> decoder::supported_codecs()
|
||||
|
||||
spdlog::info("video codec {}: {}supported", magic_enum::enum_name(codec), supported ? "" : "NOT ");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace wivrn::android
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "decoder/decoder.h"
|
||||
#include "utils/sync_queue.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include <functional>
|
||||
@@ -59,40 +60,19 @@ class stream;
|
||||
|
||||
namespace wivrn::android
|
||||
{
|
||||
class decoder
|
||||
class decoder : public wivrn::decoder
|
||||
{
|
||||
public:
|
||||
struct mapped_hardware_buffer;
|
||||
|
||||
struct blit_handle
|
||||
{
|
||||
struct deleter
|
||||
{
|
||||
void operator()(AImage *);
|
||||
};
|
||||
wivrn::from_headset::feedback feedback;
|
||||
wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
||||
vk::raii::ImageView & image_view;
|
||||
vk::Image image = nullptr;
|
||||
vk::ImageLayout * current_layout = nullptr;
|
||||
|
||||
std::shared_ptr<mapped_hardware_buffer> vk_data;
|
||||
|
||||
std::shared_ptr<AImageReader> image_reader;
|
||||
AImage_ptr aimage;
|
||||
};
|
||||
|
||||
private:
|
||||
wivrn::to_headset::video_stream_description::item description;
|
||||
uint8_t stream_index;
|
||||
float fps;
|
||||
|
||||
vk::raii::Device & device;
|
||||
|
||||
vk::AndroidHardwareBufferFormatPropertiesANDROID ahb_format;
|
||||
vk::raii::SamplerYcbcrConversion ycbcr_conversion = nullptr;
|
||||
vk::raii::Sampler ycbcr_sampler = nullptr;
|
||||
vk::Extent2D extent{};
|
||||
|
||||
std::mutex hbm_mutex;
|
||||
std::shared_ptr<AImageReader> image_reader;
|
||||
@@ -141,38 +121,24 @@ private:
|
||||
public:
|
||||
decoder(vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & physical_device,
|
||||
const wivrn::to_headset::video_stream_description::item & description,
|
||||
float fps,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
uint8_t stream_index,
|
||||
std::weak_ptr<scenes::stream> scene,
|
||||
shard_accumulator * accumulator);
|
||||
|
||||
decoder(const decoder &) = delete;
|
||||
decoder(decoder &&) = delete;
|
||||
~decoder();
|
||||
|
||||
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial);
|
||||
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial) override;
|
||||
|
||||
void frame_completed(
|
||||
wivrn::from_headset::feedback & feedback,
|
||||
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info);
|
||||
const wivrn::from_headset::feedback & feedback,
|
||||
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info) override;
|
||||
|
||||
const auto & desc() const
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
vk::Sampler sampler()
|
||||
vk::Sampler sampler() override
|
||||
{
|
||||
return *ycbcr_sampler;
|
||||
}
|
||||
|
||||
vk::Extent2D image_size()
|
||||
{
|
||||
return extent;
|
||||
}
|
||||
|
||||
static std::vector<wivrn::video_codec> supported_codecs();
|
||||
static void supported_codecs(std::vector<wivrn::video_codec> &);
|
||||
};
|
||||
|
||||
} // namespace wivrn::android
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "decoder/android/android_decoder.h"
|
||||
#else
|
||||
#include "decoder/ffmpeg/ffmpeg_decoder.h"
|
||||
#endif
|
||||
#include "decoder/raw_decoder.h"
|
||||
|
||||
wivrn::decoder::~decoder() = default;
|
||||
|
||||
std::shared_ptr<wivrn::decoder> wivrn::decoder::make(
|
||||
vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & phys_dev,
|
||||
uint32_t vk_queue_family_index,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
uint8_t stream_index,
|
||||
std::weak_ptr<scenes::stream> scene,
|
||||
shard_accumulator * acc)
|
||||
{
|
||||
switch (description.codec[stream_index])
|
||||
{
|
||||
case h264:
|
||||
case h265:
|
||||
case av1:
|
||||
#ifdef __ANDROID__
|
||||
return std::make_shared<wivrn::android::decoder>(
|
||||
device,
|
||||
phys_dev,
|
||||
description,
|
||||
stream_index,
|
||||
scene,
|
||||
acc);
|
||||
#else
|
||||
return std::make_shared<wivrn::ffmpeg::decoder>(
|
||||
device,
|
||||
phys_dev,
|
||||
description,
|
||||
stream_index,
|
||||
scene,
|
||||
acc);
|
||||
#endif
|
||||
case raw:
|
||||
return std::make_shared<wivrn::raw_decoder>(
|
||||
device,
|
||||
phys_dev,
|
||||
vk_queue_family_index,
|
||||
description,
|
||||
stream_index,
|
||||
scene,
|
||||
acc);
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
static std::vector<wivrn::video_codec> supported_codecs_()
|
||||
{
|
||||
std::vector<wivrn::video_codec> res;
|
||||
#ifdef __ANDROID__
|
||||
wivrn::android::decoder::supported_codecs(res);
|
||||
#else
|
||||
wivrn::ffmpeg::decoder::supported_codecs(res);
|
||||
#endif
|
||||
res.push_back(wivrn::video_codec::raw);
|
||||
return res;
|
||||
}
|
||||
|
||||
const std::vector<wivrn::video_codec> & wivrn::decoder::supported_codecs()
|
||||
{
|
||||
static std::vector<wivrn::video_codec> res = supported_codecs_();
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
namespace scenes
|
||||
{
|
||||
class stream;
|
||||
}
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
class shard_accumulator;
|
||||
class decoder
|
||||
{
|
||||
public:
|
||||
struct blit_handle
|
||||
{
|
||||
wivrn::from_headset::feedback feedback;
|
||||
wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
||||
vk::ImageView image_view = nullptr;
|
||||
vk::Image image = nullptr;
|
||||
vk::Extent2D extent{};
|
||||
vk::ImageLayout & current_layout;
|
||||
vk::Semaphore semaphore = nullptr;
|
||||
uint64_t * semaphore_val = nullptr;
|
||||
};
|
||||
|
||||
public:
|
||||
static std::shared_ptr<decoder> make(
|
||||
vk::raii::Device &,
|
||||
vk::raii::PhysicalDevice &,
|
||||
uint32_t vk_queue_family_index,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
uint8_t stream_index,
|
||||
std::weak_ptr<scenes::stream>,
|
||||
shard_accumulator *);
|
||||
virtual ~decoder();
|
||||
virtual void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial) = 0;
|
||||
|
||||
virtual void frame_completed(
|
||||
const from_headset::feedback & feedback,
|
||||
const to_headset::video_stream_data_shard::view_info_t & view_info) = 0;
|
||||
|
||||
virtual vk::Sampler sampler() = 0;
|
||||
|
||||
static const std::vector<wivrn::video_codec> & supported_codecs();
|
||||
};
|
||||
} // namespace wivrn
|
||||
@@ -56,29 +56,65 @@ static AVCodecID codec_id(wivrn::video_codec codec)
|
||||
return AV_CODEC_ID_HEVC;
|
||||
case c::av1:
|
||||
return AV_CODEC_ID_AV1;
|
||||
case c::raw:
|
||||
break;
|
||||
}
|
||||
assert(false);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
decoder::blit_handle::~blit_handle()
|
||||
struct decoder::ffmpeg_blit_handle : public wivrn::decoder::blit_handle
|
||||
{
|
||||
std::unique_lock lock(self->mutex);
|
||||
if (image_index < 0)
|
||||
return;
|
||||
int image_index;
|
||||
wivrn::ffmpeg::decoder * self;
|
||||
|
||||
self->free_images.push_back(image_index);
|
||||
}
|
||||
ffmpeg_blit_handle(
|
||||
const wivrn::from_headset::feedback & feedback,
|
||||
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info,
|
||||
vk::ImageView image_view,
|
||||
vk::Image image,
|
||||
vk::Extent2D extent,
|
||||
vk::ImageLayout & current_layout,
|
||||
int image_index,
|
||||
wivrn::ffmpeg::decoder * self) :
|
||||
wivrn::decoder::blit_handle{
|
||||
feedback,
|
||||
view_info,
|
||||
image_view,
|
||||
image,
|
||||
extent,
|
||||
current_layout,
|
||||
},
|
||||
image_index(image_index),
|
||||
self(self)
|
||||
{}
|
||||
|
||||
~ffmpeg_blit_handle()
|
||||
{
|
||||
std::unique_lock lock(self->mutex);
|
||||
if (image_index < 0)
|
||||
return;
|
||||
|
||||
self->free_images.push_back(image_index);
|
||||
}
|
||||
};
|
||||
|
||||
decoder::decoder(
|
||||
vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & physical_device,
|
||||
const wivrn::to_headset::video_stream_description::item & description,
|
||||
float fps,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
uint8_t stream_index,
|
||||
std::weak_ptr<scenes::stream> scene,
|
||||
shard_accumulator * accumulator) :
|
||||
device(device), description(description), codec(nullptr, free_codec_context), sws(nullptr, sws_freeContext), weak_scene(scene), accumulator(accumulator)
|
||||
device(device),
|
||||
codec(nullptr, free_codec_context),
|
||||
sws(nullptr, sws_freeContext),
|
||||
weak_scene(scene),
|
||||
accumulator(accumulator),
|
||||
extent{
|
||||
.width = description.width,
|
||||
.height = description.height / (stream_index == 2 ? 2u : 1u),
|
||||
}
|
||||
{
|
||||
free_images.resize(image_count);
|
||||
|
||||
@@ -90,8 +126,8 @@ decoder::decoder(
|
||||
.imageType = vk::ImageType::e2D,
|
||||
.format = vk::Format::eA8B8G8R8SrgbPack32,
|
||||
.extent = {
|
||||
.width = description.width,
|
||||
.height = description.height,
|
||||
.width = extent.width,
|
||||
.height = extent.height,
|
||||
.depth = 1,
|
||||
},
|
||||
.mipLevels = 1,
|
||||
@@ -108,7 +144,6 @@ decoder::decoder(
|
||||
decoded_images[i].image = image_allocation(device, image_info, alloc_info);
|
||||
|
||||
decoded_images[i].image.map();
|
||||
extent = vk::Extent2D{description.width, description.height};
|
||||
|
||||
vk::ImageSubresource resource;
|
||||
resource.aspectMask = vk::ImageAspectFlagBits::eColor;
|
||||
@@ -133,7 +168,7 @@ decoder::decoder(
|
||||
decoded_images[i].current_layout = vk::ImageLayout::eUndefined;
|
||||
}
|
||||
|
||||
auto avcodec = avcodec_find_decoder(codec_id(description.codec));
|
||||
auto avcodec = avcodec_find_decoder(codec_id(description.codec[stream_index]));
|
||||
if (avcodec == nullptr)
|
||||
{
|
||||
throw std::runtime_error{"avcodec_find_decoder failed"};
|
||||
@@ -161,6 +196,8 @@ decoder::decoder(
|
||||
|
||||
void decoder::push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial)
|
||||
{
|
||||
if (frame_index != this->frame_index)
|
||||
packet.clear();
|
||||
for (const auto & d: data)
|
||||
packet.insert(packet.end(), d.begin(), d.end());
|
||||
this->frame_index = frame_index;
|
||||
@@ -200,7 +237,7 @@ void decoder::frame_completed(const wivrn::from_headset::feedback & feedback, co
|
||||
|
||||
if (!sws)
|
||||
{
|
||||
sws.reset(sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format, description.width, description.height, AV_PIX_FMT_RGB0, SWS_BILINEAR, nullptr, nullptr, nullptr));
|
||||
sws.reset(sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format, extent.width, extent.height, AV_PIX_FMT_RGB0, SWS_BILINEAR, nullptr, nullptr, nullptr));
|
||||
}
|
||||
|
||||
std::unique_lock lock(mutex);
|
||||
@@ -221,12 +258,13 @@ void decoder::frame_completed(const wivrn::from_headset::feedback & feedback, co
|
||||
if (res == 0)
|
||||
throw std::runtime_error{"sws_scale failed"};
|
||||
|
||||
auto handle = std::make_shared<decoder::blit_handle>(
|
||||
auto handle = std::make_shared<ffmpeg_blit_handle>(
|
||||
feedback,
|
||||
view_info,
|
||||
decoded_images[index].image_view,
|
||||
(vk::Image)decoded_images[index].image,
|
||||
&decoded_images[index].current_layout,
|
||||
*decoded_images[index].image_view,
|
||||
decoded_images[index].image,
|
||||
extent,
|
||||
decoded_images[index].current_layout,
|
||||
index,
|
||||
this);
|
||||
|
||||
@@ -234,13 +272,12 @@ void decoder::frame_completed(const wivrn::from_headset::feedback & feedback, co
|
||||
scene->push_blit_handle(accumulator, std::move(handle));
|
||||
}
|
||||
|
||||
std::vector<wivrn::video_codec> decoder::supported_codecs()
|
||||
void decoder::supported_codecs(std::vector<wivrn::video_codec> & res)
|
||||
{
|
||||
return {
|
||||
wivrn::video_codec::h264,
|
||||
wivrn::video_codec::h265,
|
||||
wivrn::video_codec::av1,
|
||||
};
|
||||
// As long as we do software decoding, prefer faster ones
|
||||
res.push_back(wivrn::video_codec::h264);
|
||||
res.push_back(wivrn::video_codec::h265);
|
||||
res.push_back(wivrn::video_codec::av1);
|
||||
}
|
||||
|
||||
} // namespace wivrn::ffmpeg
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "decoder/decoder.h"
|
||||
#include "vk/allocation.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include <memory>
|
||||
@@ -46,24 +47,10 @@ class stream;
|
||||
|
||||
namespace wivrn::ffmpeg
|
||||
{
|
||||
class decoder
|
||||
class decoder : public wivrn::decoder
|
||||
{
|
||||
public:
|
||||
struct blit_handle
|
||||
{
|
||||
wivrn::from_headset::feedback feedback;
|
||||
wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
||||
vk::raii::ImageView & image_view;
|
||||
vk::Image image = nullptr;
|
||||
vk::ImageLayout * current_layout = nullptr;
|
||||
|
||||
int image_index;
|
||||
decoder * self;
|
||||
|
||||
~blit_handle();
|
||||
};
|
||||
|
||||
private:
|
||||
struct ffmpeg_blit_handle;
|
||||
static const int image_count = 12;
|
||||
struct image
|
||||
{
|
||||
@@ -78,53 +65,37 @@ private:
|
||||
vk::raii::Sampler rgb_sampler = nullptr;
|
||||
|
||||
std::array<image, image_count> decoded_images;
|
||||
vk::Extent2D extent{};
|
||||
std::vector<int> free_images;
|
||||
|
||||
wivrn::to_headset::video_stream_description::item description;
|
||||
|
||||
std::unique_ptr<AVCodecContext, void (*)(AVCodecContext *)> codec;
|
||||
std::unique_ptr<SwsContext, void (*)(SwsContext *)> sws;
|
||||
std::vector<uint8_t> packet;
|
||||
uint64_t frame_index;
|
||||
std::weak_ptr<scenes::stream> weak_scene;
|
||||
shard_accumulator * accumulator;
|
||||
const vk::Extent2D extent;
|
||||
|
||||
std::mutex mutex;
|
||||
|
||||
public:
|
||||
decoder(vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & physical_device,
|
||||
const wivrn::to_headset::video_stream_description::item & description,
|
||||
float fps,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
uint8_t stream_index,
|
||||
std::weak_ptr<scenes::stream> scene,
|
||||
shard_accumulator * accumulator);
|
||||
|
||||
decoder(const decoder &) = delete;
|
||||
decoder(decoder &&) = delete;
|
||||
|
||||
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial);
|
||||
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial) override;
|
||||
|
||||
void frame_completed(
|
||||
const wivrn::from_headset::feedback & feedback,
|
||||
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info);
|
||||
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info) override;
|
||||
|
||||
const auto & desc() const
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
vk::Sampler sampler()
|
||||
vk::Sampler sampler() override
|
||||
{
|
||||
return *rgb_sampler;
|
||||
}
|
||||
|
||||
vk::Extent2D image_size()
|
||||
{
|
||||
return extent;
|
||||
}
|
||||
|
||||
static std::vector<wivrn::video_codec> supported_codecs();
|
||||
static void supported_codecs(std::vector<wivrn::video_codec> &);
|
||||
};
|
||||
} // namespace wivrn::ffmpeg
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "raw_decoder.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "scenes/stream.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct raw_blit_handle : public wivrn::decoder::blit_handle
|
||||
{
|
||||
std::atomic_bool & free;
|
||||
|
||||
raw_blit_handle(
|
||||
const wivrn::from_headset::feedback & feedback,
|
||||
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info,
|
||||
vk::ImageView image_view,
|
||||
vk::Image image,
|
||||
vk::Extent2D extent,
|
||||
vk::ImageLayout & current_layout,
|
||||
vk::Semaphore semaphore,
|
||||
uint64_t & semaphore_val,
|
||||
std::atomic_bool & free) :
|
||||
wivrn::decoder::blit_handle{feedback, view_info, image_view, image, extent, current_layout, semaphore, &semaphore_val},
|
||||
free(free) {}
|
||||
~raw_blit_handle()
|
||||
{
|
||||
free = true;
|
||||
};
|
||||
};
|
||||
|
||||
vk::raii::Sampler make_sampler(
|
||||
vk::raii::Device & device,
|
||||
vk::SamplerYcbcrConversion ycbcr_conversion)
|
||||
{
|
||||
vk::StructureChain info{
|
||||
vk::SamplerCreateInfo{
|
||||
.magFilter = vk::Filter::eNearest,
|
||||
.minFilter = vk::Filter::eNearest,
|
||||
.mipmapMode = vk::SamplerMipmapMode::eNearest,
|
||||
.addressModeU = vk::SamplerAddressMode::eClampToEdge,
|
||||
.addressModeV = vk::SamplerAddressMode::eClampToEdge,
|
||||
.addressModeW = vk::SamplerAddressMode::eClampToEdge,
|
||||
.maxAnisotropy = 1,
|
||||
},
|
||||
vk::SamplerYcbcrConversionInfo{
|
||||
.conversion = ycbcr_conversion,
|
||||
},
|
||||
};
|
||||
if (ycbcr_conversion == VK_NULL_HANDLE)
|
||||
info.unlink<vk::SamplerYcbcrConversionInfo>();
|
||||
return vk::raii::Sampler(device, info.get());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
raw_decoder::raw_decoder(
|
||||
vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & physical_device,
|
||||
uint32_t vk_queue_family_index,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
uint8_t stream_index,
|
||||
std::weak_ptr<scenes::stream> scene,
|
||||
shard_accumulator * accumulator) :
|
||||
device(device),
|
||||
ycbcr_conversion(stream_index == 2 ? nullptr : vk::raii::SamplerYcbcrConversion(device, {
|
||||
.format = vk::Format::eG8B8R82Plane420Unorm,
|
||||
.ycbcrModel = vk::SamplerYcbcrModelConversion::eYcbcr709,
|
||||
.ycbcrRange = vk::SamplerYcbcrRange::eItuFull,
|
||||
.chromaFilter = vk::Filter::eNearest,
|
||||
})),
|
||||
sampler_(make_sampler(device, *ycbcr_conversion)),
|
||||
command_pool(device, vk::CommandPoolCreateInfo{
|
||||
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer,
|
||||
.queueFamilyIndex = vk_queue_family_index,
|
||||
}),
|
||||
cmd(device.allocateCommandBuffers(vk::CommandBufferAllocateInfo{
|
||||
.commandPool = *command_pool,
|
||||
.commandBufferCount = 1,
|
||||
})[0]
|
||||
.release()),
|
||||
fence(device, vk::FenceCreateInfo{.flags = vk::FenceCreateFlagBits::eSignaled}),
|
||||
stream_index(stream_index),
|
||||
extent{
|
||||
.width = description.width,
|
||||
.height = description.height / (stream_index == 2 ? 2u : 1u),
|
||||
},
|
||||
weak_scene(scene),
|
||||
accumulator(accumulator)
|
||||
{
|
||||
vk::DeviceSize buffer_size = extent.width * extent.height;
|
||||
vk::Format format{};
|
||||
switch (stream_index)
|
||||
{
|
||||
case 0: // colour left
|
||||
case 1: // colour right
|
||||
buffer_size += buffer_size / 2;
|
||||
format = vk::Format::eG8B8R82Plane420Unorm;
|
||||
break;
|
||||
case 2: // alpha (monochrome)
|
||||
format = vk::Format::eR8Unorm;
|
||||
break;
|
||||
}
|
||||
for (auto & i: input)
|
||||
{
|
||||
i = buffer_allocation(
|
||||
device,
|
||||
{
|
||||
.size = buffer_size,
|
||||
.usage = vk::BufferUsageFlagBits::eTransferSrc,
|
||||
},
|
||||
{
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
"raw stream buffer");
|
||||
}
|
||||
input_pos = (uint8_t *)input[0].map();
|
||||
|
||||
for (auto & item: image_pool)
|
||||
{
|
||||
item.image = image_allocation(
|
||||
device,
|
||||
vk::ImageCreateInfo{
|
||||
.imageType = vk::ImageType::e2D,
|
||||
.format = format,
|
||||
.extent = {
|
||||
.width = extent.width,
|
||||
.height = extent.height,
|
||||
.depth = 1,
|
||||
},
|
||||
.mipLevels = 1,
|
||||
.arrayLayers = 1,
|
||||
.tiling = vk::ImageTiling::eOptimal,
|
||||
.usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst,
|
||||
},
|
||||
{
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
"raw image");
|
||||
|
||||
vk::SamplerYcbcrConversionInfo conv{
|
||||
.conversion = *ycbcr_conversion,
|
||||
};
|
||||
vk::ImageViewCreateInfo view_info{
|
||||
.pNext = format == vk::Format::eG8B8R82Plane420Unorm ? &conv : nullptr,
|
||||
.image = item.image,
|
||||
.viewType = vk::ImageViewType::e2D,
|
||||
.format = format,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.levelCount = 1,
|
||||
.layerCount = 1,
|
||||
},
|
||||
};
|
||||
item.view_full = vk::raii::ImageView(device, view_info);
|
||||
|
||||
item.semaphore = vk::raii::Semaphore(
|
||||
device,
|
||||
vk::StructureChain{
|
||||
vk::SemaphoreCreateInfo{},
|
||||
vk::SemaphoreTypeCreateInfo{
|
||||
.semaphoreType = vk::SemaphoreType::eTimeline,
|
||||
},
|
||||
}
|
||||
.get());
|
||||
}
|
||||
}
|
||||
|
||||
void raw_decoder::push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial)
|
||||
{
|
||||
if (frame_index != current_frame)
|
||||
{
|
||||
input_pos = (uint8_t *)input[0].map();
|
||||
current_frame = frame_index;
|
||||
}
|
||||
for (const auto & item: data)
|
||||
{
|
||||
memcpy(input_pos, item.data(), item.size_bytes());
|
||||
input_pos += item.size();
|
||||
}
|
||||
}
|
||||
|
||||
void raw_decoder::frame_completed(
|
||||
const from_headset::feedback & feedback,
|
||||
const to_headset::video_stream_data_shard::view_info_t & view_info)
|
||||
{
|
||||
auto item = get_free();
|
||||
if (not item)
|
||||
{
|
||||
spdlog::warn("No image available in pool, discard frame");
|
||||
return;
|
||||
}
|
||||
|
||||
auto handle = std::make_shared<raw_blit_handle>(
|
||||
feedback,
|
||||
view_info,
|
||||
*item->view_full,
|
||||
item->image,
|
||||
extent,
|
||||
item->current_layout,
|
||||
*item->semaphore,
|
||||
item->semaphore_val,
|
||||
item->free);
|
||||
|
||||
auto res = device.waitForFences(*fence, true, UINT64_MAX);
|
||||
if (res != vk::Result::eSuccess)
|
||||
spdlog::warn("waitForFences failed");
|
||||
|
||||
cmd.reset();
|
||||
cmd.begin({.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit});
|
||||
|
||||
if (item->current_layout != vk::ImageLayout::eTransferDstOptimal)
|
||||
{
|
||||
item->current_layout = vk::ImageLayout::eTransferDstOptimal;
|
||||
vk::ImageMemoryBarrier barrier{
|
||||
.srcAccessMask = vk::AccessFlagBits::eNone,
|
||||
.dstAccessMask = vk::AccessFlagBits::eMemoryWrite,
|
||||
.oldLayout = vk::ImageLayout::eUndefined,
|
||||
.newLayout = item->current_layout,
|
||||
.image = item->image,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.levelCount = 1,
|
||||
.layerCount = 1,
|
||||
},
|
||||
};
|
||||
cmd.pipelineBarrier(
|
||||
vk::PipelineStageFlagBits::eAllCommands,
|
||||
vk::PipelineStageFlagBits::eTransfer,
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
barrier);
|
||||
}
|
||||
|
||||
std::array regions{
|
||||
vk::BufferImageCopy{
|
||||
.imageSubresource = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::ePlane0,
|
||||
.layerCount = 1,
|
||||
},
|
||||
.imageExtent = {
|
||||
.width = extent.width,
|
||||
.height = extent.height,
|
||||
.depth = 1,
|
||||
},
|
||||
},
|
||||
vk::BufferImageCopy{
|
||||
.bufferOffset = vk::DeviceSize(extent.width * extent.height),
|
||||
.imageSubresource = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::ePlane1,
|
||||
.layerCount = 1,
|
||||
},
|
||||
.imageExtent = {
|
||||
.width = extent.width / 2u,
|
||||
.height = extent.height / 2u,
|
||||
.depth = 1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
cmd.copyBufferToImage(
|
||||
input[0],
|
||||
item->image,
|
||||
item->current_layout,
|
||||
stream_index < 2 ? 2 : 1,
|
||||
regions.data());
|
||||
|
||||
vk::ImageMemoryBarrier barrier{
|
||||
.srcAccessMask = vk::AccessFlagBits::eMemoryWrite,
|
||||
.dstAccessMask = vk::AccessFlagBits::eMemoryRead,
|
||||
.oldLayout = item->current_layout,
|
||||
.newLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||
.image = item->image,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.levelCount = 1,
|
||||
.layerCount = 1,
|
||||
},
|
||||
};
|
||||
item->current_layout = barrier.newLayout;
|
||||
cmd.pipelineBarrier(
|
||||
vk::PipelineStageFlagBits::eTransfer,
|
||||
vk::PipelineStageFlagBits::eFragmentShader,
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
barrier);
|
||||
|
||||
cmd.end();
|
||||
|
||||
device.resetFences(*fence);
|
||||
application::get_queue().lock()->submit(
|
||||
vk::StructureChain{
|
||||
vk::SubmitInfo{
|
||||
.commandBufferCount = 1,
|
||||
.pCommandBuffers = &cmd,
|
||||
.signalSemaphoreCount = 1,
|
||||
.pSignalSemaphores = &*item->semaphore,
|
||||
},
|
||||
vk::TimelineSemaphoreSubmitInfo{
|
||||
.signalSemaphoreValueCount = 1,
|
||||
.pSignalSemaphoreValues = &++item->semaphore_val,
|
||||
},
|
||||
}
|
||||
.get(),
|
||||
*fence);
|
||||
|
||||
if (auto scene = weak_scene.lock())
|
||||
scene->push_blit_handle(accumulator, std::move(handle));
|
||||
|
||||
std::swap(input[0], input[1]);
|
||||
input_pos = (uint8_t *)input[0].map();
|
||||
}
|
||||
|
||||
raw_decoder::image * raw_decoder::get_free()
|
||||
{
|
||||
for (auto & item: image_pool)
|
||||
{
|
||||
if (item.free.exchange(false))
|
||||
return &item;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<wivrn::video_codec> raw_decoder::supported_codecs()
|
||||
{
|
||||
return {video_codec::raw};
|
||||
}
|
||||
} // namespace wivrn
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
#include "vk/allocation.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
class raw_decoder : public decoder
|
||||
{
|
||||
private:
|
||||
static const int image_count = 5;
|
||||
struct image
|
||||
{
|
||||
image_allocation image;
|
||||
vk::raii::ImageView view_full = nullptr;
|
||||
vk::ImageLayout current_layout = vk::ImageLayout::eUndefined;
|
||||
std::atomic_bool free = true;
|
||||
vk::raii::Semaphore semaphore = nullptr;
|
||||
uint64_t semaphore_val = 0;
|
||||
};
|
||||
|
||||
vk::raii::Device & device;
|
||||
vk::raii::SamplerYcbcrConversion ycbcr_conversion;
|
||||
vk::raii::Sampler sampler_;
|
||||
|
||||
vk::raii::CommandPool command_pool;
|
||||
vk::CommandBuffer cmd;
|
||||
vk::raii::Fence fence;
|
||||
|
||||
uint8_t stream_index;
|
||||
const vk::Extent2D extent;
|
||||
|
||||
std::array<image, image_count> image_pool;
|
||||
|
||||
std::weak_ptr<scenes::stream> weak_scene;
|
||||
shard_accumulator * accumulator;
|
||||
|
||||
uint64_t current_frame = 0;
|
||||
std::array<buffer_allocation, 2> input;
|
||||
uint8_t * input_pos;
|
||||
from_headset::feedback feedback;
|
||||
|
||||
public:
|
||||
raw_decoder(vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & physical_device,
|
||||
uint32_t vk_queue_family_index,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
uint8_t stream_index,
|
||||
std::weak_ptr<scenes::stream> scene,
|
||||
shard_accumulator * accumulator);
|
||||
|
||||
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial) override;
|
||||
|
||||
void frame_completed(
|
||||
const wivrn::from_headset::feedback & feedback,
|
||||
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info) override;
|
||||
|
||||
vk::Sampler sampler() override
|
||||
{
|
||||
return *sampler_;
|
||||
}
|
||||
|
||||
static std::vector<wivrn::video_codec> supported_codecs();
|
||||
|
||||
private:
|
||||
image * get_free();
|
||||
};
|
||||
|
||||
} // namespace wivrn
|
||||
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
|
||||
#include "shard_accumulator.h"
|
||||
#include "application.h"
|
||||
#include "scenes/stream.h"
|
||||
#include "scenes/stream.h" // IWYU pragma: keep
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "xr/instance.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
@@ -55,7 +55,7 @@ static bool is_complete(const shard_set & shards)
|
||||
const auto & frame = shards.data;
|
||||
if (frame.empty())
|
||||
return false;
|
||||
if (not(frame.back() and frame.back()->flags & video_stream_data_shard::end_of_frame))
|
||||
if (not(frame.back() and frame.back()->timing_info))
|
||||
return false;
|
||||
for (const auto & shard: frame)
|
||||
if (not shard)
|
||||
@@ -63,10 +63,10 @@ static bool is_complete(const shard_set & shards)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<uint16_t> shard_set::insert(data_shard && shard)
|
||||
std::optional<uint16_t> shard_set::insert(data_shard && shard, xr::instance & instance)
|
||||
{
|
||||
if (empty())
|
||||
feedback.received_first_packet = application::now();
|
||||
feedback.received_first_packet = instance.now();
|
||||
|
||||
auto idx = shard.shard_idx;
|
||||
if (idx >= data.size())
|
||||
@@ -99,7 +99,7 @@ static void debug_why_not_sent(const shard_set & shards)
|
||||
++missing;
|
||||
}
|
||||
|
||||
bool end = frame.back() and frame.back()->flags & video_stream_data_shard::end_of_frame;
|
||||
bool end = frame.back() and frame.back()->timing_info;
|
||||
spdlog::info("frame {} was not sent with {} data shards, {}{} missing", frame_idx, data, end ? "" : "at least ", missing);
|
||||
}
|
||||
|
||||
@@ -121,12 +121,12 @@ void shard_accumulator::push_shard(video_stream_data_shard && shard)
|
||||
}
|
||||
else if (frame_diff == 0)
|
||||
{
|
||||
auto shard_idx = current.insert(std::move(shard));
|
||||
auto shard_idx = current.insert(std::move(shard), instance);
|
||||
try_submit_frame(shard_idx);
|
||||
}
|
||||
else if (frame_diff == 1)
|
||||
{
|
||||
next.insert(std::move(shard));
|
||||
next.insert(std::move(shard), instance);
|
||||
if (is_complete(next))
|
||||
{
|
||||
debug_why_not_sent(current);
|
||||
@@ -185,13 +185,13 @@ void shard_accumulator::try_submit_frame(uint16_t shard_idx)
|
||||
for (size_t idx = shard_idx; idx < last_idx; ++idx)
|
||||
payload.emplace_back(data_shards[idx]->payload);
|
||||
|
||||
bool frame_complete = last_idx == data_shards.size() and data_shards.back()->flags & video_stream_data_shard::end_of_frame;
|
||||
decoder->push_data(payload, data_shards[shard_idx]->frame_idx, not frame_complete);
|
||||
bool frame_complete = last_idx == data_shards.size() and data_shards.back()->timing_info;
|
||||
decoder_->push_data(payload, data_shards[shard_idx]->frame_idx, not frame_complete);
|
||||
|
||||
if (not frame_complete)
|
||||
return;
|
||||
|
||||
current.feedback.received_last_packet = application::now();
|
||||
current.feedback.received_last_packet = instance.now();
|
||||
current.feedback.sent_to_decoder = current.feedback.received_last_packet;
|
||||
data_shard::timing_info_t timing_info = data_shards.back()->timing_info.value_or(data_shard::timing_info_t{});
|
||||
current.feedback.encode_begin = timing_info.encode_begin;
|
||||
@@ -206,7 +206,7 @@ void shard_accumulator::try_submit_frame(uint16_t shard_idx)
|
||||
}
|
||||
|
||||
// Try to extract a frame
|
||||
decoder->frame_completed(current.feedback, *data_shards.front()->view_info);
|
||||
decoder_->frame_completed(current.feedback, *data_shards.front()->view_info);
|
||||
|
||||
send_feedback(current.feedback);
|
||||
|
||||
@@ -216,7 +216,7 @@ void shard_accumulator::try_submit_frame(uint16_t shard_idx)
|
||||
void shard_accumulator::send_feedback(wivrn::from_headset::feedback & feedback)
|
||||
{
|
||||
if (not feedback.received_last_packet)
|
||||
feedback.received_first_packet = application::now();
|
||||
feedback.received_first_packet = instance.now();
|
||||
auto scene = weak_scene.lock();
|
||||
if (scene)
|
||||
scene->send_feedback(feedback);
|
||||
|
||||
@@ -19,27 +19,30 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "decoder/android/android_decoder.h"
|
||||
using decoder_impl = ::wivrn::android::decoder;
|
||||
#else
|
||||
#include "decoder/ffmpeg/ffmpeg_decoder.h"
|
||||
using decoder_impl = ::wivrn::ffmpeg::decoder;
|
||||
#endif
|
||||
|
||||
#include "decoder.h"
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
namespace xr
|
||||
{
|
||||
class instance;
|
||||
}
|
||||
|
||||
namespace scenes
|
||||
{
|
||||
class stream;
|
||||
}
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
class shard_accumulator
|
||||
{
|
||||
std::shared_ptr<decoder_impl> decoder;
|
||||
std::shared_ptr<decoder> decoder_;
|
||||
|
||||
public:
|
||||
using data_shard = wivrn::to_headset::video_stream_data_shard;
|
||||
@@ -50,7 +53,7 @@ public:
|
||||
void reset(uint64_t frame_index);
|
||||
bool empty() const;
|
||||
|
||||
std::optional<uint16_t> insert(data_shard &&);
|
||||
std::optional<uint16_t> insert(data_shard &&, xr::instance & instance);
|
||||
|
||||
wivrn::from_headset::feedback feedback{};
|
||||
|
||||
@@ -70,41 +73,34 @@ private:
|
||||
shard_set current;
|
||||
shard_set next;
|
||||
std::weak_ptr<scenes::stream> weak_scene;
|
||||
xr::instance & instance;
|
||||
|
||||
public:
|
||||
explicit shard_accumulator(
|
||||
vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice & physical_device,
|
||||
const wivrn::to_headset::video_stream_description::item & description,
|
||||
float fps,
|
||||
xr::instance & instance,
|
||||
uint32_t vk_queue_family_index,
|
||||
const wivrn::to_headset::video_stream_description & description,
|
||||
std::weak_ptr<scenes::stream> scene,
|
||||
uint8_t stream_index) :
|
||||
decoder(std::make_shared<decoder_impl>(device, physical_device, description, fps, stream_index, scene, this)),
|
||||
decoder_(decoder::make(device, physical_device, vk_queue_family_index, description, stream_index, scene, this)),
|
||||
current(stream_index),
|
||||
next(stream_index),
|
||||
weak_scene(scene)
|
||||
weak_scene(scene),
|
||||
instance(instance)
|
||||
{
|
||||
next.reset(1);
|
||||
}
|
||||
|
||||
void push_shard(wivrn::to_headset::video_stream_data_shard &&);
|
||||
|
||||
auto & desc() const
|
||||
{
|
||||
return decoder->desc();
|
||||
}
|
||||
|
||||
vk::Sampler sampler()
|
||||
{
|
||||
return decoder->sampler();
|
||||
return decoder_->sampler();
|
||||
}
|
||||
|
||||
vk::Extent2D image_size()
|
||||
{
|
||||
return decoder->image_size();
|
||||
}
|
||||
|
||||
using blit_handle = decoder_impl::blit_handle;
|
||||
using blit_handle = decoder::blit_handle;
|
||||
|
||||
private:
|
||||
void try_submit_frame(std::optional<uint16_t> shard_idx);
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "file_picker.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "utils/mapped_file.h"
|
||||
#include <exception>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "android/intent.h"
|
||||
#endif
|
||||
|
||||
std::future<file_picker_result> file_picker::open()
|
||||
{
|
||||
// Put it in a shared_ptr because clang does not support std::move_only_function
|
||||
auto promise = std::make_shared<std::promise<file_picker_result>>();
|
||||
auto future = promise->get_future();
|
||||
|
||||
#ifdef __ANDROID__
|
||||
// https://developer.android.com/training/data-storage/shared/documents-files#open
|
||||
// https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT
|
||||
// https://developer.android.com/guide/components/intents-common#OpenFile
|
||||
|
||||
intent open_doc{"android.intent.action.OPEN_DOCUMENT"}; // Intent.ACTION_OPEN_DOCUMENT
|
||||
open_doc.set_type("*/*");
|
||||
open_doc.add_category("android.intent.category.OPENABLE"); // Intent.CATEGORY_OPENABLE
|
||||
open_doc.start([promise](int result_code, intent && data) mutable {
|
||||
try
|
||||
{
|
||||
if (result_code == -1 /* Activity.RESULT_OK */)
|
||||
{
|
||||
auto uri = data.get_uri();
|
||||
auto uri_string = (std::string)uri.call<jni::string>("toString");
|
||||
|
||||
jni::object<""> activity(application::native_app()->activity->clazz);
|
||||
auto content_resolver = activity.call<jni::object<"android/content/ContentResolver">>("getContentResolver");
|
||||
|
||||
content_resolver.call<void>("takePersistableUriPermission", uri, jni::Int{1} /* Intent.FLAG_GRANT_READ_URI_PERMISSION */);
|
||||
|
||||
auto pfd = content_resolver.call<jni::object<"android/os/ParcelFileDescriptor">>("openFileDescriptor", uri, jni::string{"r"});
|
||||
int fd = pfd.call<int>("getFd");
|
||||
|
||||
// The file descriptor is owned by the ParcelFileDescriptor, dup it before
|
||||
// passing it to mapped_file to ensure the original fd is not closed
|
||||
promise->set_value({
|
||||
.accepted = true,
|
||||
.path = uri_string,
|
||||
.file = utils::mapped_file{fd},
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
promise->set_value({.accepted = false});
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
promise->set_exception(std::current_exception());
|
||||
}
|
||||
});
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
return future;
|
||||
}
|
||||
|
||||
void file_picker::display()
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
// No-op on Android, the file picker is displayed by the OS
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/mapped_file.h"
|
||||
#include <future>
|
||||
|
||||
struct file_picker_result
|
||||
{
|
||||
bool accepted = false;
|
||||
std::filesystem::path path;
|
||||
utils::mapped_file file;
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return accepted;
|
||||
}
|
||||
};
|
||||
|
||||
class file_picker
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] std::future<file_picker_result> open();
|
||||
void display();
|
||||
};
|
||||
@@ -103,6 +103,11 @@ static model guess_model_()
|
||||
if (model == "VIVE XR Series")
|
||||
return model::htc_vive_xr_elite;
|
||||
}
|
||||
if (manufacturer == "samsung")
|
||||
{
|
||||
if (model == "SM-I610")
|
||||
return model::samsung_galaxy_xr;
|
||||
}
|
||||
|
||||
spdlog::info("Unknown model, manufacturer={}, model={}, device={}", manufacturer, model, device);
|
||||
#endif
|
||||
@@ -165,6 +170,8 @@ XrViewConfigurationView override_view(XrViewConfigurationView view, model m)
|
||||
return scale_view(view, 2448);
|
||||
case model::htc_vive_xr_elite:
|
||||
return scale_view(view, 1920);
|
||||
case model::samsung_galaxy_xr:
|
||||
return scale_view(view, 3552);
|
||||
case model::lynx_r1:
|
||||
case model::unknown:
|
||||
return view;
|
||||
@@ -191,6 +198,7 @@ bool need_srgb_conversion(model m)
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_focus_vision:
|
||||
case model::htc_vive_xr_elite:
|
||||
case model::samsung_galaxy_xr:
|
||||
case model::unknown:
|
||||
return true;
|
||||
}
|
||||
@@ -204,6 +212,27 @@ const char * permission_name(feature f)
|
||||
case feature::microphone:
|
||||
return "android.permission.RECORD_AUDIO";
|
||||
case feature::hand_tracking:
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::samsung_galaxy_xr:
|
||||
return "android.permission.HAND_TRACKING";
|
||||
case model::oculus_quest:
|
||||
case model::oculus_quest_2:
|
||||
case model::meta_quest_pro:
|
||||
case model::meta_quest_3:
|
||||
case model::meta_quest_3s:
|
||||
case model::pico_neo_3:
|
||||
case model::pico_4:
|
||||
case model::pico_4s:
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_focus_vision:
|
||||
case model::htc_vive_xr_elite:
|
||||
case model::lynx_r1:
|
||||
case model::unknown:
|
||||
break;
|
||||
}
|
||||
return nullptr;
|
||||
case feature::eye_gaze:
|
||||
switch (guess_model())
|
||||
@@ -220,6 +249,8 @@ const char * permission_name(feature f)
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
return "com.picovr.permission.EYE_TRACKING";
|
||||
case model::samsung_galaxy_xr:
|
||||
return "android.permission.EYE_TRACKING_FINE";
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_focus_vision:
|
||||
case model::htc_vive_xr_elite:
|
||||
@@ -243,6 +274,8 @@ const char * permission_name(feature f)
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
return "com.picovr.permission.FACE_TRACKING";
|
||||
case model::samsung_galaxy_xr:
|
||||
return "android.permission.FACE_TRACKING";
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_focus_vision:
|
||||
case model::htc_vive_xr_elite:
|
||||
@@ -286,14 +319,17 @@ std::string controller_name()
|
||||
case model::pico_neo_3:
|
||||
return "pico-neo3";
|
||||
case model::pico_4:
|
||||
case model::pico_4s: // TODO: split when we have the pico-4s 3d model
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise:
|
||||
return "pico-4";
|
||||
case model::pico_4s:
|
||||
return "pico-4u";
|
||||
case model::htc_vive_focus_3:
|
||||
case model::htc_vive_focus_vision:
|
||||
case model::htc_vive_xr_elite:
|
||||
return "htc-vive-focus-3";
|
||||
case model::samsung_galaxy_xr:
|
||||
return "samsung-galaxyxr";
|
||||
case model::lynx_r1:
|
||||
case model::unknown:
|
||||
return "generic-trigger-squeeze";
|
||||
@@ -340,10 +376,10 @@ std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::
|
||||
return {{0, -0.006, -0.025}, glm::angleAxis(glm::radians(-15.f), glm::vec3{1, 0, 0})};
|
||||
|
||||
case xr::spaces::aim_left:
|
||||
return {{-0.010, 0, 0.025}, {1, 0, 0, 0}};
|
||||
return {{-0.010, 0, 0.02}, {1, 0, 0, 0}};
|
||||
|
||||
case xr::spaces::aim_right:
|
||||
return {{0.010, 0, 0.025}, {1, 0, 0, 0}};
|
||||
return {{0.010, 0, 0.02}, {1, 0, 0, 0}};
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -357,10 +393,8 @@ std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::
|
||||
return {{0, -0.010, -0.025}, glm::angleAxis(glm::radians(-12.f), glm::vec3{1, 0, 0})};
|
||||
|
||||
case xr::spaces::aim_left:
|
||||
return {{0, 0, 0.03}, {1, 0, 0, 0}};
|
||||
|
||||
case xr::spaces::aim_right:
|
||||
return {{0, 0, 0.03}, {1, 0, 0, 0}};
|
||||
return {{0, 0, -0.03}, {1, 0, 0, 0}};
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -391,6 +425,28 @@ std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::
|
||||
break;
|
||||
}
|
||||
|
||||
else if (profile == "pico-neo3")
|
||||
switch (space)
|
||||
{
|
||||
case xr::spaces::grip_left:
|
||||
case xr::spaces::grip_right:
|
||||
return {{0, 0.005, -0.051}, glm::angleAxis(glm::radians(-29.400f), glm::vec3{1, 0, 0})};
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
else if (profile == "samsung-galaxyxr")
|
||||
switch (space)
|
||||
{
|
||||
case xr::spaces::grip_left:
|
||||
return {{-0.005, 0.000, 0.035}, {1, 0, 0, 0}};
|
||||
case xr::spaces::grip_right:
|
||||
return {{0.005, 0.000, 0.035}, {1, 0, 0, 0}};
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return {{0, 0, 0}, {1, 0, 0, 0}};
|
||||
}
|
||||
|
||||
@@ -403,9 +459,9 @@ std::string controller_ray_model_name()
|
||||
case model::htc_vive_xr_elite:
|
||||
// XR Elite's runtime always assume alpha is unpremultiplied in the composition layers
|
||||
// Assume it's the same for all HTC headsets
|
||||
return "ray-htc.gltf";
|
||||
return "assets://ray-htc.glb";
|
||||
|
||||
default:
|
||||
return "ray.gltf";
|
||||
return "assets://ray.glb";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ enum class model
|
||||
htc_vive_xr_elite,
|
||||
htc_vive_focus_vision,
|
||||
lynx_r1,
|
||||
samsung_galaxy_xr,
|
||||
unknown
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ public class MainActivity extends android.app.NativeActivity
|
||||
@Override
|
||||
public native void onNewIntent(android.content.Intent intent);
|
||||
|
||||
@Override
|
||||
public native void onActivityResult(int requestCode, int resultCode, android.content.Intent data);
|
||||
|
||||
private android.content.BroadcastReceiver BatteryInfoReceiver = null;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "libcurl.h"
|
||||
|
||||
#include "utils/mapped_file.h"
|
||||
#include "utils/named_thread.h"
|
||||
#include "version.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
#include <curl/multi.h>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <magic_enum.hpp>
|
||||
#include <mutex>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <stdexcept>
|
||||
#include <system_error>
|
||||
#include <thread>
|
||||
|
||||
libcurl::transfer::~transfer() {}
|
||||
libcurl::transfer_file::~transfer_file() {}
|
||||
libcurl::transfer_buffer::~transfer_buffer() {}
|
||||
|
||||
libcurl::libcurl()
|
||||
{
|
||||
if (CURLcode rc = curl_global_init(CURL_GLOBAL_DEFAULT); rc != CURLE_OK)
|
||||
{
|
||||
throw std::runtime_error{fmt::format("Cannot initialize libcurl: {}", curl_easy_strerror(rc))};
|
||||
|
||||
curl_version_info_data * data = curl_version_info(CURLVERSION_NOW);
|
||||
if (not(data->features & CURL_VERSION_THREADSAFE))
|
||||
spdlog::warn("libcurl features do not include CURL_VERSION_THREADSAFE");
|
||||
}
|
||||
|
||||
multi = curl_multi_init();
|
||||
if (not multi)
|
||||
{
|
||||
spdlog::error("curl_multi_init failed");
|
||||
return;
|
||||
}
|
||||
|
||||
curl_thread = utils::named_thread("curl_thread", &libcurl::curl_thread_fn, this);
|
||||
}
|
||||
|
||||
void libcurl::curl_thread_fn()
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
// For Android, read all the certificates at start-up, the file names are not
|
||||
// in the correct format for the current verion of OpenSSL.
|
||||
// See https://stackoverflow.com/questions/25253823/how-to-make-ssl-peer-verify-work-on-android
|
||||
std::string ca_bundle;
|
||||
for (const std::filesystem::directory_entry & entry: std::filesystem::directory_iterator{"/system/etc/security/cacerts"})
|
||||
{
|
||||
if (not entry.is_regular_file())
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
utils::mapped_file cert{entry.path()};
|
||||
ca_bundle += cert;
|
||||
|
||||
// Make sure there is a newline before the next certificate
|
||||
if (ca_bundle != "" and ca_bundle.back() != '\n')
|
||||
ca_bundle += '\n';
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
curl_blob ca_bundle_info{
|
||||
.data = ca_bundle.data(),
|
||||
.len = ca_bundle.size(),
|
||||
.flags = CURL_BLOB_NOCOPY,
|
||||
};
|
||||
#endif
|
||||
|
||||
std::string user_agent = std::string("WiVRn/") + wivrn::git_version;
|
||||
|
||||
// We can't use auto here because of curl_easy_setopt
|
||||
size_t (*write_callback)(void *, size_t, size_t, void *) = [](void * buffer, size_t size, size_t nmemb, void * userp) -> size_t {
|
||||
auto & xfer = *reinterpret_cast<libcurl::transfer *>(userp);
|
||||
|
||||
if (xfer.content_length < 0)
|
||||
{
|
||||
curl_off_t content_length;
|
||||
curl_easy_getinfo(xfer.curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &content_length);
|
||||
xfer.content_length = content_length;
|
||||
}
|
||||
|
||||
xfer.progress += size * nmemb;
|
||||
return xfer.write(buffer, size * nmemb);
|
||||
};
|
||||
|
||||
std::vector<std::shared_ptr<transfer>> current_transfers;
|
||||
while (not quit)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Wait for something to happen (network, new download, cancelled download)
|
||||
int numfds;
|
||||
if (CURLMcode rc = curl_multi_poll(multi, NULL, 0, 10000, &numfds); rc != CURLM_OK)
|
||||
throw std::runtime_error{fmt::format("curl_multi_poll failed: ", curl_multi_strerror(rc))};
|
||||
|
||||
// Only lock the mutex after curl_multi_poll
|
||||
std::unique_lock _{lock};
|
||||
|
||||
int still_running;
|
||||
if (CURLMcode rc = curl_multi_perform(multi, &still_running); rc != CURLM_OK)
|
||||
throw std::runtime_error{fmt::format("curl_multi_perform failed: ", curl_multi_strerror(rc))};
|
||||
|
||||
CURLMsg * msg;
|
||||
int msgs_in_queue;
|
||||
while ((msg = curl_multi_info_read(multi, &msgs_in_queue)) != nullptr)
|
||||
{
|
||||
auto iter = std::ranges::find_if(
|
||||
current_transfers,
|
||||
[&](std::shared_ptr<transfer> & x) {
|
||||
return x->curl == msg->easy_handle;
|
||||
});
|
||||
|
||||
if (iter == current_transfers.end())
|
||||
{
|
||||
spdlog::error("Received {} ({}) for an unknown transfer", magic_enum::enum_name(msg->msg), (int)msg->msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto & xfer = **iter;
|
||||
switch (msg->msg)
|
||||
{
|
||||
case CURLMSG_NONE: // Not used
|
||||
case CURLMSG_LAST: // Not used
|
||||
break;
|
||||
|
||||
case CURLMSG_DONE: // msg->easy_handle has finished
|
||||
xfer.curl_code = msg->data.result;
|
||||
curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &xfer.response_code);
|
||||
|
||||
if (msg->data.result == CURLE_OK)
|
||||
{
|
||||
xfer.current_state = state::done;
|
||||
xfer.finish();
|
||||
}
|
||||
else
|
||||
{
|
||||
xfer.current_state = state::error;
|
||||
xfer.cancel();
|
||||
}
|
||||
|
||||
curl_multi_remove_handle(multi, msg->easy_handle);
|
||||
curl_easy_cleanup(msg->easy_handle);
|
||||
current_transfers.erase(iter);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
for (std::shared_ptr<transfer> & xfer: pending_transfers)
|
||||
{
|
||||
// See https://curl.se/libcurl/c/libcurl-tutorial.html and https://curl.se/libcurl/c/curl_easy_setopt.html
|
||||
curl_easy_setopt(xfer->curl, CURLOPT_URL, xfer->url.c_str());
|
||||
curl_easy_setopt(xfer->curl, CURLOPT_FOLLOWLOCATION, 1); // Older versions of libcurl don't have the constant CURLFOLLOW_ALL
|
||||
curl_easy_setopt(xfer->curl, CURLOPT_FILETIME, 1); // Request remote file time
|
||||
curl_easy_setopt(xfer->curl, CURLOPT_FAILONERROR, 1); // CURLE_HTTP_RETURNED_ERROR on HTTP error
|
||||
curl_easy_setopt(xfer->curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
curl_easy_setopt(xfer->curl, CURLOPT_WRITEDATA, xfer.get());
|
||||
curl_easy_setopt(xfer->curl, CURLOPT_USERAGENT, user_agent.c_str());
|
||||
|
||||
#ifdef __ANDROID__
|
||||
curl_easy_setopt(xfer->curl, CURLOPT_CAINFO_BLOB, &ca_bundle_info);
|
||||
#endif
|
||||
|
||||
curl_multi_add_handle(multi, xfer->curl);
|
||||
current_transfers.push_back(std::move(xfer));
|
||||
}
|
||||
|
||||
for (std::shared_ptr<transfer> handle: pending_cancellations)
|
||||
{
|
||||
auto iter = std::ranges::find(current_transfers, handle);
|
||||
|
||||
// If the transfer cannot be found, it means it has already finished, this is not an error
|
||||
if (iter != current_transfers.end())
|
||||
{
|
||||
auto & xfer = **iter;
|
||||
xfer.current_state = state::cancelled;
|
||||
xfer.cancel();
|
||||
|
||||
curl_multi_remove_handle(multi, handle->curl);
|
||||
curl_easy_cleanup(handle->curl);
|
||||
current_transfers.erase(iter);
|
||||
|
||||
spdlog::info("Cancelled transfer from {}", xfer.url);
|
||||
}
|
||||
}
|
||||
|
||||
pending_transfers.clear();
|
||||
pending_cancellations.clear();
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
spdlog::error("Exception in curl thread: {}", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_lock _{lock};
|
||||
for (auto & xfer: current_transfers)
|
||||
{
|
||||
xfer->current_state = state::cancelled;
|
||||
xfer->cancel();
|
||||
curl_multi_remove_handle(multi, xfer->curl);
|
||||
curl_easy_cleanup(xfer->curl);
|
||||
}
|
||||
|
||||
if (CURLMcode rc = curl_multi_cleanup(multi); rc != CURLM_OK)
|
||||
spdlog::warn("curl_multi_cleanup failed: {}", curl_multi_strerror(rc));
|
||||
}
|
||||
|
||||
libcurl::~libcurl()
|
||||
{
|
||||
quit = true;
|
||||
curl_multi_wakeup(multi);
|
||||
|
||||
if (curl_thread.joinable())
|
||||
curl_thread.join();
|
||||
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
void libcurl::curl_handle::sync()
|
||||
{
|
||||
if (lib and handle)
|
||||
{
|
||||
std::unique_lock _{lib->lock};
|
||||
|
||||
current_state = handle->current_state;
|
||||
curl_code = handle->curl_code;
|
||||
response_code = handle->response_code;
|
||||
content_length = handle->content_length;
|
||||
progress = handle->progress;
|
||||
|
||||
if (current_state == state::done)
|
||||
{
|
||||
if (auto h = dynamic_cast<transfer_buffer *>(handle.get()))
|
||||
{
|
||||
response = h->buffer;
|
||||
}
|
||||
else if (auto h = dynamic_cast<transfer_file *>(handle.get()))
|
||||
{
|
||||
path = h->final_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void libcurl::curl_handle::cancel()
|
||||
{
|
||||
if (lib and handle)
|
||||
{
|
||||
{
|
||||
std::unique_lock _{lib->lock};
|
||||
lib->pending_cancellations.emplace_back(handle);
|
||||
if (handle->current_state == state::transferring)
|
||||
handle->current_state = state::cancelling;
|
||||
}
|
||||
|
||||
curl_multi_wakeup(lib->multi);
|
||||
}
|
||||
}
|
||||
|
||||
size_t libcurl::transfer_file::write(void * data, size_t size) noexcept
|
||||
{
|
||||
stream.write(reinterpret_cast<const char *>(data), size);
|
||||
if (not stream)
|
||||
return CURL_WRITEFUNC_ERROR;
|
||||
return size;
|
||||
}
|
||||
|
||||
void libcurl::transfer_file::finish() noexcept
|
||||
{
|
||||
stream.close();
|
||||
std::filesystem::rename(temporary_path, final_path);
|
||||
|
||||
curl_off_t remote_timestamp;
|
||||
if (curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &remote_timestamp) == CURLE_OK)
|
||||
{
|
||||
auto time = std::chrono::file_clock::from_sys(std::chrono::system_clock::from_time_t(remote_timestamp));
|
||||
std::filesystem::last_write_time(final_path, time);
|
||||
}
|
||||
}
|
||||
|
||||
void libcurl::transfer_file::cancel() noexcept
|
||||
{
|
||||
std::error_code ec;
|
||||
std::filesystem::remove(temporary_path, ec);
|
||||
}
|
||||
|
||||
libcurl::curl_handle libcurl::download(std::string url, std::filesystem::path path)
|
||||
{
|
||||
auto xfer = std::make_shared<transfer_file>();
|
||||
xfer->curl = curl_easy_init();
|
||||
xfer->url = url;
|
||||
xfer->final_path = path;
|
||||
xfer->temporary_path = path.native() + ".partial";
|
||||
xfer->stream.open(xfer->temporary_path, std::ios::out);
|
||||
xfer->current_state = state::transferring;
|
||||
|
||||
std::unique_lock _{lock};
|
||||
pending_transfers.push_back(xfer);
|
||||
|
||||
// The curl thread needs to be woken up to pick up the newly added handle without waiting for the timeout
|
||||
curl_multi_wakeup(multi);
|
||||
|
||||
return {this, xfer, path};
|
||||
}
|
||||
|
||||
size_t libcurl::transfer_buffer::write(void * data, size_t size) noexcept
|
||||
{
|
||||
buffer.append(reinterpret_cast<const char *>(data), size);
|
||||
return size;
|
||||
}
|
||||
|
||||
void libcurl::transfer_buffer::finish() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void libcurl::transfer_buffer::cancel() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
libcurl::curl_handle libcurl::download(std::string url)
|
||||
{
|
||||
auto xfer = std::make_shared<transfer_buffer>();
|
||||
xfer->curl = curl_easy_init();
|
||||
xfer->url = url;
|
||||
xfer->current_state = state::transferring;
|
||||
|
||||
std::unique_lock _{lock};
|
||||
pending_transfers.push_back(xfer);
|
||||
|
||||
// The curl thread needs to be woken up to pick up the newly added handle without waiting for the timeout
|
||||
curl_multi_wakeup(multi);
|
||||
|
||||
return {this, xfer};
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <curl/curl.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
class libcurl
|
||||
{
|
||||
friend class curl_handle;
|
||||
|
||||
public:
|
||||
enum class state
|
||||
{
|
||||
reset,
|
||||
transferring,
|
||||
cancelling,
|
||||
cancelled,
|
||||
error,
|
||||
done,
|
||||
};
|
||||
|
||||
private:
|
||||
struct transfer
|
||||
{
|
||||
CURL * curl;
|
||||
std::string url;
|
||||
|
||||
state current_state = state::reset;
|
||||
CURLcode curl_code = CURLE_OK;
|
||||
long response_code = 0;
|
||||
int64_t content_length = -1;
|
||||
int64_t progress = 0;
|
||||
|
||||
transfer() = default;
|
||||
|
||||
// A pointer to a transfer struct is used as a user pointer for curl callbacks,
|
||||
// make sure it never moves
|
||||
transfer(const transfer &) = delete;
|
||||
transfer(transfer &&) = delete;
|
||||
transfer operator=(const transfer &) = delete;
|
||||
transfer operator=(transfer &&) = delete;
|
||||
virtual ~transfer();
|
||||
|
||||
virtual size_t write(void * data, size_t size) noexcept = 0;
|
||||
virtual void finish() noexcept = 0;
|
||||
virtual void cancel() noexcept = 0;
|
||||
};
|
||||
|
||||
struct transfer_file : transfer
|
||||
{
|
||||
virtual ~transfer_file();
|
||||
|
||||
std::filesystem::path temporary_path;
|
||||
std::filesystem::path final_path;
|
||||
std::fstream stream;
|
||||
|
||||
size_t write(void * data, size_t size) noexcept override;
|
||||
void finish() noexcept override;
|
||||
void cancel() noexcept override;
|
||||
};
|
||||
|
||||
struct transfer_buffer : transfer
|
||||
{
|
||||
virtual ~transfer_buffer();
|
||||
|
||||
std::string buffer;
|
||||
|
||||
size_t write(void * data, size_t size) noexcept override;
|
||||
void finish() noexcept override;
|
||||
void cancel() noexcept override;
|
||||
};
|
||||
|
||||
public:
|
||||
libcurl();
|
||||
libcurl(const libcurl &) = delete;
|
||||
libcurl(libcurl &&) = delete;
|
||||
libcurl operator=(const libcurl &) = delete;
|
||||
libcurl operator=(libcurl &&) = delete;
|
||||
~libcurl();
|
||||
|
||||
// Handle returned by the download() functions, it allows cancelling an ongoing transfer
|
||||
// by calling cancel() or destroying the handle
|
||||
class curl_handle
|
||||
{
|
||||
private:
|
||||
libcurl * lib = nullptr;
|
||||
std::shared_ptr<transfer> handle;
|
||||
|
||||
std::filesystem::path path;
|
||||
std::string response;
|
||||
|
||||
state current_state = state::reset;
|
||||
CURLcode curl_code = CURLE_OK;
|
||||
int response_code = 0;
|
||||
int64_t content_length = -1;
|
||||
int64_t progress = 0;
|
||||
|
||||
friend class libcurl;
|
||||
|
||||
curl_handle(libcurl * lib, std::shared_ptr<transfer> handle, std::filesystem::path path = {}) :
|
||||
lib(lib), handle(handle), path(std::move(path)) {}
|
||||
|
||||
public:
|
||||
curl_handle() = default;
|
||||
curl_handle(const curl_handle &) = delete;
|
||||
curl_handle & operator=(const curl_handle &) = delete;
|
||||
curl_handle(curl_handle && other) :
|
||||
lib(other.lib),
|
||||
handle(other.handle),
|
||||
path(std::move(other.path)),
|
||||
response(std::move(other.response)),
|
||||
current_state(other.current_state),
|
||||
curl_code(other.curl_code),
|
||||
response_code(other.response_code),
|
||||
content_length(other.content_length),
|
||||
progress(other.progress)
|
||||
{
|
||||
other.lib = nullptr;
|
||||
other.handle = nullptr;
|
||||
}
|
||||
|
||||
curl_handle & operator=(curl_handle && other)
|
||||
{
|
||||
std::swap(lib, other.lib);
|
||||
std::swap(handle, other.handle);
|
||||
path = std::move(other.path);
|
||||
response = std::move(other.response);
|
||||
current_state = other.current_state;
|
||||
curl_code = other.curl_code;
|
||||
response_code = other.response_code;
|
||||
content_length = other.content_length;
|
||||
progress = other.progress;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~curl_handle()
|
||||
{
|
||||
cancel();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
*this = curl_handle{};
|
||||
}
|
||||
|
||||
void sync();
|
||||
void cancel();
|
||||
|
||||
state get_state() const
|
||||
{
|
||||
return current_state;
|
||||
}
|
||||
|
||||
CURLcode get_curl_code() const
|
||||
{
|
||||
return curl_code;
|
||||
}
|
||||
|
||||
int get_response_code() const
|
||||
{
|
||||
return response_code;
|
||||
}
|
||||
|
||||
int64_t get_content_length() const
|
||||
{
|
||||
return content_length;
|
||||
}
|
||||
|
||||
int64_t get_progress() const
|
||||
{
|
||||
return progress;
|
||||
}
|
||||
|
||||
const std::string & get_response() const // Only if started by download(url) and state is done
|
||||
{
|
||||
assert(current_state == state::done);
|
||||
return response;
|
||||
}
|
||||
|
||||
std::span<const std::byte> get_response_bytes() const // Only if started by download(url) and state is done
|
||||
{
|
||||
assert(current_state == state::done);
|
||||
return {reinterpret_cast<const std::byte *>(response.data()), response.size()};
|
||||
}
|
||||
|
||||
const std::filesystem::path & get_path() const // Only if started by download(url, path) and state is done
|
||||
{
|
||||
assert(current_state == state::done);
|
||||
return path;
|
||||
}
|
||||
|
||||
const std::string & get_url() const
|
||||
{
|
||||
return handle->url;
|
||||
}
|
||||
};
|
||||
|
||||
// Start a download, data is saved on the filesystem
|
||||
// Keep the returned handle or the transfer will be immediately cancelled
|
||||
curl_handle download(std::string url, std::filesystem::path path);
|
||||
|
||||
// Start a download, data is buffered and can be fetched through the get_response() function of the curl_handle
|
||||
// Keep the returned handle or the transfer will be immediately cancelled
|
||||
curl_handle download(std::string url);
|
||||
|
||||
private:
|
||||
std::thread curl_thread;
|
||||
void curl_thread_fn();
|
||||
|
||||
std::atomic<bool> quit{false};
|
||||
CURLM * multi;
|
||||
|
||||
std::mutex lock; // Locks pending_transfers, pending_cancellations and all struct transfers created by this instance
|
||||
std::vector<std::shared_ptr<transfer>> pending_transfers;
|
||||
std::vector<std::shared_ptr<transfer>> pending_cancellations;
|
||||
};
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "animation.h"
|
||||
#include "render/scene_components.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <entt/entt.hpp>
|
||||
#include <glm/ext/quaternion_geometric.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
glm::vec3 interp(const glm::vec3 & a, const glm::vec3 & b, float t)
|
||||
{
|
||||
return a + t * (b - a);
|
||||
}
|
||||
|
||||
glm::quat interp(const glm::quat & a, const glm::quat & b, float t)
|
||||
{
|
||||
float d = glm::dot(a, b);
|
||||
|
||||
if (d > 0.99999)
|
||||
{
|
||||
return a + t * (b - a);
|
||||
}
|
||||
else
|
||||
{
|
||||
float θ = std::acos(std::abs(d));
|
||||
|
||||
float sinθ = std::sin(θ);
|
||||
float sinθt = std::sin(θ * t);
|
||||
float sinθ1_t = std::sin(θ * (1 - t));
|
||||
|
||||
return sinθ1_t / sinθ * a + std::copysign(sinθt / sinθ, d) * b;
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec3 cubic_spline(const glm::vec3 & a, const glm::vec3 & va, const glm::vec3 & vb, const glm::vec3 & b, float t, float td)
|
||||
{
|
||||
float t2 = t * t;
|
||||
float t3 = t2 * t;
|
||||
|
||||
return (2 * t3 - 3 * t2 + 1) * a +
|
||||
td * (t3 - 2 * t2 + t) * va +
|
||||
(3 * t2 - 2 * t3) * b +
|
||||
td * (t3 - t2) * vb;
|
||||
}
|
||||
|
||||
glm::quat cubic_spline(const glm::quat & a, const glm::quat & vb, const glm::quat & va, const glm::quat & b, float t, float td)
|
||||
{
|
||||
float t2 = t * t;
|
||||
float t3 = t2 * t;
|
||||
|
||||
return glm::normalize((2 * t3 - 3 * t2 + 1) * a +
|
||||
td * (t3 - 2 * t2 + t) * vb +
|
||||
(3 * t2 - 2 * t3) * b +
|
||||
td * (t3 - t2) * va);
|
||||
}
|
||||
|
||||
template <auto components::node::* Field>
|
||||
void apply_track(entt::registry & scene, const components::animation_track_impl<Field> & track, float current_time)
|
||||
{
|
||||
entt::entity target = track.target;
|
||||
auto interpolation = track.interpolation;
|
||||
auto field = track.field;
|
||||
auto & value = scene.get<components::node>(track.target).*field;
|
||||
|
||||
// Find the first keyframe with a timestamp strictly greater than the current time
|
||||
size_t k = std::ranges::upper_bound(track.timestamp, current_time) - track.timestamp.begin();
|
||||
if (k == 0)
|
||||
{
|
||||
value = track.value[0];
|
||||
return;
|
||||
}
|
||||
|
||||
switch (interpolation)
|
||||
{
|
||||
case components::animation_track_base::interpolation_t::step:
|
||||
value = track.value[k - 1];
|
||||
break;
|
||||
|
||||
case components::animation_track_base::interpolation_t::linear:
|
||||
if (k == track.timestamp.size())
|
||||
value = track.value[k - 1];
|
||||
else
|
||||
{
|
||||
float t = (current_time - track.timestamp[k - 1]) / (track.timestamp[k] - track.timestamp[k - 1]);
|
||||
const auto & a = track.value[k - 1];
|
||||
const auto & b = track.value[k];
|
||||
value = interp(a, b, t);
|
||||
}
|
||||
break;
|
||||
|
||||
case components::animation_track_base::interpolation_t::cubic_spline:
|
||||
if (k == track.timestamp.size())
|
||||
value = track.value[k - 1];
|
||||
else
|
||||
{
|
||||
float t = (current_time - track.timestamp[k - 1]) / (track.timestamp[k] - track.timestamp[k - 1]);
|
||||
const auto & a = track.value[3 * k - 2]; // v_k in gltf spec
|
||||
const auto & vb = track.value[3 * k - 1]; // b_k
|
||||
const auto & va = track.value[3 * k]; // a_k+1
|
||||
const auto & b = track.value[3 * k + 1]; // v_k+1
|
||||
|
||||
value = cubic_spline(a, va, vb, b, t, track.timestamp[k] - track.timestamp[k - 1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void renderer::animate(entt::registry & scene, float dt)
|
||||
{
|
||||
for (auto && [entity, animation]: scene.view<components::animation>().each())
|
||||
{
|
||||
if (not animation.playing)
|
||||
continue;
|
||||
|
||||
animation.current_time += dt;
|
||||
if (animation.current_time > animation.duration)
|
||||
{
|
||||
if (animation.looping)
|
||||
animation.current_time = std::fmod(animation.current_time, animation.duration);
|
||||
else
|
||||
animation.current_time = animation.duration;
|
||||
}
|
||||
else if (animation.current_time < 0)
|
||||
animation.current_time = 0;
|
||||
|
||||
for (const auto & track: animation.tracks)
|
||||
std::visit([&](auto & track) { apply_track(scene, track, animation.current_time); }, track);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,11 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "actionset.h"
|
||||
#include "error.h"
|
||||
#include "instance.h"
|
||||
#include "session.h"
|
||||
#include "swapchain.h"
|
||||
#include "system.h"
|
||||
#include "xr/check.h"
|
||||
#include "xr/to_string.h"
|
||||
#include <entt/entity/fwd.hpp>
|
||||
|
||||
namespace renderer
|
||||
{
|
||||
void animate(entt::registry & registry, float dt);
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "application.h"
|
||||
#include "utils/alignment.h"
|
||||
#include "utils/contains.h"
|
||||
#include "vk/allocation.h"
|
||||
#include <fastgltf/tools.hpp>
|
||||
#include <fastgltf/types.hpp>
|
||||
@@ -30,6 +31,8 @@ class gpu_buffer
|
||||
{
|
||||
std::vector<std::byte> bytes;
|
||||
vk::PhysicalDeviceLimits limits;
|
||||
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT feat_uint8;
|
||||
|
||||
fastgltf::Asset & asset;
|
||||
vk::BufferUsageFlags usage;
|
||||
|
||||
@@ -59,8 +62,15 @@ class gpu_buffer
|
||||
}
|
||||
|
||||
public:
|
||||
gpu_buffer(vk::PhysicalDeviceProperties properties, fastgltf::Asset & asset) :
|
||||
limits(properties.limits), asset(asset), usage(0) {}
|
||||
gpu_buffer(vk::raii::PhysicalDevice physical_device, fastgltf::Asset & asset) :
|
||||
asset(asset),
|
||||
usage(0)
|
||||
{
|
||||
limits = physical_device.getProperties().limits;
|
||||
|
||||
if (utils::contains(application::instance().get_vk_device_extensions(), VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME))
|
||||
std::tie(std::ignore, feat_uint8) = physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceIndexTypeUint8FeaturesEXT>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t add_uniform(const T & data_to_add)
|
||||
@@ -80,7 +90,7 @@ public:
|
||||
return add(alignment, data_to_add);
|
||||
}
|
||||
|
||||
size_t add_indices(const fastgltf::Accessor & accessor)
|
||||
std::pair<size_t, vk::IndexType> add_indices(const fastgltf::Accessor & accessor)
|
||||
{
|
||||
usage |= vk::BufferUsageFlagBits::eIndexBuffer;
|
||||
|
||||
@@ -91,7 +101,11 @@ public:
|
||||
std::vector<uint8_t> indices(accessor.count);
|
||||
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
|
||||
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
|
||||
return add(4, indices);
|
||||
|
||||
if (feat_uint8.indexTypeUint8)
|
||||
return {add(4, indices), vk::IndexType::eUint8EXT};
|
||||
else
|
||||
return {add(4, std::vector<uint16_t>{indices.begin(), indices.end()}), vk::IndexType::eUint16};
|
||||
}
|
||||
|
||||
case fastgltf::ComponentType::Short:
|
||||
@@ -99,7 +113,7 @@ public:
|
||||
std::vector<uint16_t> indices(accessor.count);
|
||||
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
|
||||
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
|
||||
return add(4, indices);
|
||||
return {add(4, indices), vk::IndexType::eUint16};
|
||||
}
|
||||
|
||||
case fastgltf::ComponentType::Int:
|
||||
@@ -107,7 +121,7 @@ public:
|
||||
std::vector<uint32_t> indices(accessor.count);
|
||||
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
|
||||
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
|
||||
return add(4, indices);
|
||||
return {add(4, indices), vk::IndexType::eUint32};
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -115,10 +129,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
buffer_allocation copy_to_gpu()
|
||||
buffer_allocation copy_to_gpu(vk::raii::Device & device)
|
||||
{
|
||||
buffer_allocation gpu_buffer{
|
||||
application::get_device(),
|
||||
device,
|
||||
vk::BufferCreateInfo{
|
||||
.size = bytes.size(),
|
||||
.usage = usage},
|
||||
|
||||
@@ -18,18 +18,19 @@
|
||||
*/
|
||||
|
||||
#include "image_loader.h"
|
||||
#include "wivrn_config.h"
|
||||
|
||||
#if WIVRN_USE_LIBKTX
|
||||
#include <ktxvulkan.h>
|
||||
#endif
|
||||
#include <chrono>
|
||||
#include "application.h"
|
||||
#include "utils/thread_safe.h"
|
||||
#include "vk/allocation.h"
|
||||
#include "vk/vk_allocator.h"
|
||||
#include <cstdint>
|
||||
#include <ktx.h>
|
||||
#include <ktxvulkan.h>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <spdlog/fmt/chrono.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
@@ -48,28 +49,150 @@ namespace
|
||||
{
|
||||
struct image_resources
|
||||
{
|
||||
image_allocation allocation;
|
||||
vk::Image image;
|
||||
image_allocation image;
|
||||
vk::raii::ImageView image_view = nullptr;
|
||||
};
|
||||
|
||||
#if WIVRN_USE_LIBKTX
|
||||
struct ktx_image_resources
|
||||
class KTXTexture2
|
||||
{
|
||||
ktxVulkanTexture ktx_texture;
|
||||
VkDevice device;
|
||||
vk::Image image;
|
||||
vk::raii::ImageView image_view = nullptr;
|
||||
private:
|
||||
ktxTexture2 * handle_ = nullptr;
|
||||
|
||||
ktx_image_resources() = default;
|
||||
ktx_image_resources(const ktx_image_resources &) = delete;
|
||||
ktx_image_resources & operator=(const ktx_image_resources &) = delete;
|
||||
~ktx_image_resources()
|
||||
public:
|
||||
KTXTexture2() = default;
|
||||
|
||||
explicit KTXTexture2(ktxTexture2 * handle) :
|
||||
handle_{handle} {}
|
||||
|
||||
KTXTexture2(const KTXTexture2 &) = delete;
|
||||
KTXTexture2 & operator=(const KTXTexture2 &) = delete;
|
||||
|
||||
KTXTexture2(KTXTexture2 && other) noexcept :
|
||||
handle_{other.handle_}
|
||||
{
|
||||
ktxVulkanTexture_Destruct(&ktx_texture, device, nullptr);
|
||||
other.handle_ = nullptr;
|
||||
}
|
||||
|
||||
KTXTexture2 & operator=(KTXTexture2 && other) &
|
||||
{
|
||||
std::swap(handle_, other.handle_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~KTXTexture2()
|
||||
{
|
||||
if (handle_)
|
||||
{
|
||||
ktxTexture_Destroy(ktxTexture(handle_));
|
||||
handle_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ktxTexture2 ** operator&()
|
||||
{
|
||||
return &handle_;
|
||||
}
|
||||
|
||||
operator ktxTexture2 *()
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
|
||||
ktxTexture2 * operator->() const
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace libktx_vma_glue
|
||||
{
|
||||
thread_safe<std::map<uint64_t, VmaAllocation>> allocations;
|
||||
|
||||
uint64_t add(VmaAllocation allocation)
|
||||
{
|
||||
auto allocs = allocations.lock();
|
||||
|
||||
uint64_t allocation_id = allocs->empty() ? 1 : (allocs->rbegin()->first + 1);
|
||||
allocs->emplace(allocation_id, allocation);
|
||||
return allocation_id;
|
||||
}
|
||||
|
||||
VmaAllocation find(uint64_t allocation_id)
|
||||
{
|
||||
auto allocs = allocations.lock();
|
||||
auto iter = allocs->find(allocation_id);
|
||||
assert(iter != allocs->end());
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
VmaAllocation release(uint64_t allocation_id)
|
||||
{
|
||||
auto allocs = allocations.lock();
|
||||
auto iter = allocs->find(allocation_id);
|
||||
assert(iter != allocs->end());
|
||||
|
||||
VmaAllocation allocation = iter->second;
|
||||
allocs->erase(iter);
|
||||
return allocation;
|
||||
}
|
||||
|
||||
VmaAllocation remove(uint64_t allocation_id)
|
||||
{
|
||||
auto allocs = allocations.lock();
|
||||
auto iter = allocs->find(allocation_id);
|
||||
assert(iter != allocs->end());
|
||||
|
||||
auto allocation = iter->second;
|
||||
allocs->erase(iter);
|
||||
|
||||
return allocation;
|
||||
}
|
||||
|
||||
ktxVulkanTexture_subAllocatorCallbacks suballocator_callbacks{
|
||||
// Adapted from https://github.com/KhronosGroup/KTX-Software/blob/main/tests/loadtests/vkloadtests/VulkanLoadTestSample.cpp
|
||||
.allocMemFuncPtr = [](VkMemoryAllocateInfo * allocation_info, VkMemoryRequirements * memory_requirements, uint64_t * number_of_pages) -> uint64_t {
|
||||
VmaAllocationCreateInfo info{};
|
||||
|
||||
static const vk::PhysicalDeviceMemoryProperties memory_properties = application::instance().get_physical_device().getMemoryProperties();
|
||||
|
||||
if ((memory_properties.memoryTypes[allocation_info->memoryTypeIndex].propertyFlags & vk::MemoryPropertyFlagBits::eHostVisible) ||
|
||||
(memory_properties.memoryTypes[allocation_info->memoryTypeIndex].propertyFlags & vk::MemoryPropertyFlagBits::eHostCoherent))
|
||||
{
|
||||
info.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
|
||||
info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
||||
}
|
||||
|
||||
VmaAllocation allocation;
|
||||
VkResult result = vmaAllocateMemory(vk_allocator::instance(), memory_requirements, &info, &allocation, nullptr);
|
||||
if (result != VK_SUCCESS)
|
||||
return 0;
|
||||
|
||||
return add(allocation);
|
||||
},
|
||||
.bindBufferFuncPtr = [](VkBuffer buffer, uint64_t allocation_id) -> VkResult {
|
||||
return vmaBindBufferMemory(vk_allocator::instance(), find(allocation_id), buffer);
|
||||
},
|
||||
.bindImageFuncPtr = [](VkImage image, uint64_t allocation_id) -> VkResult {
|
||||
return vmaBindImageMemory(vk_allocator::instance(), find(allocation_id), image);
|
||||
},
|
||||
.memoryMapFuncPtr = [](uint64_t allocation_id, uint64_t, VkDeviceSize * map_length, void ** data) -> VkResult {
|
||||
auto allocation = find(allocation_id);
|
||||
|
||||
VmaAllocationInfo info{};
|
||||
vmaGetAllocationInfo(vk_allocator::instance(), allocation, &info);
|
||||
|
||||
*map_length = info.size;
|
||||
return vmaMapMemory(vk_allocator::instance(), allocation, data);
|
||||
},
|
||||
.memoryUnmapFuncPtr = [](uint64_t allocation_id, uint64_t) { vmaUnmapMemory(vk_allocator::instance(), find(allocation_id)); },
|
||||
.freeMemFuncPtr = [](uint64_t allocation_id) { vmaFreeMemory(vk_allocator::instance(), remove(allocation_id)); },
|
||||
};
|
||||
} // namespace libktx_vma_glue
|
||||
|
||||
template <typename T>
|
||||
constexpr vk::Format formats[4] = {vk::Format::eUndefined, vk::Format::eUndefined, vk::Format::eUndefined, vk::Format::eUndefined};
|
||||
@@ -162,24 +285,120 @@ int bytes_per_pixel(vk::Format format)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
image_loader::image_loader(vk::raii::PhysicalDevice physical_device, vk::raii::Device & device, thread_safe<vk::raii::Queue> & queue, vk::raii::CommandPool & cb_pool) :
|
||||
image_loader::image_loader(vk::raii::Device & device, vk::raii::PhysicalDevice physical_device, thread_safe<vk::raii::Queue> & queue, uint32_t queue_family_index) :
|
||||
device(device),
|
||||
queue(queue),
|
||||
cb_pool(cb_pool)
|
||||
cb_pool(device,
|
||||
vk::CommandPoolCreateInfo{
|
||||
.flags = vk::CommandPoolCreateFlagBits::eTransient | vk::CommandPoolCreateFlagBits::eResetCommandBuffer,
|
||||
.queueFamilyIndex = queue_family_index,
|
||||
})
|
||||
{
|
||||
#if WIVRN_USE_LIBKTX
|
||||
ktxVulkanDeviceInfo_Construct(&vdi, *physical_device, *device, *queue.get_unsafe(), *cb_pool, nullptr);
|
||||
#endif
|
||||
// Assume we will always use the same queue
|
||||
static thread_safe<vk::raii::Queue> * q = &queue;
|
||||
|
||||
ktxVulkanFunctions vulkan_functions{
|
||||
.vkGetInstanceProcAddr = &vkGetInstanceProcAddr,
|
||||
.vkGetDeviceProcAddr = &vkGetDeviceProcAddr,
|
||||
.vkQueueSubmit = [](VkQueue queue,
|
||||
uint32_t submitCount,
|
||||
const VkSubmitInfo * pSubmits,
|
||||
VkFence fence) -> VkResult {
|
||||
assert(q and (VkQueue) * q->get_unsafe() == queue);
|
||||
auto _ = q->lock();
|
||||
|
||||
return vkQueueSubmit(queue, submitCount, pSubmits, fence);
|
||||
},
|
||||
.vkQueueWaitIdle = [](VkQueue queue) -> VkResult {
|
||||
// libktx only uses vkQueueWaitIdle when the tiling is not VK_IMAGE_TILING_OPTIMAL
|
||||
abort();
|
||||
},
|
||||
};
|
||||
|
||||
ktxVulkanDeviceInfo_ConstructEx(
|
||||
&vdi,
|
||||
*application::get_vulkan_instance(),
|
||||
*physical_device,
|
||||
*device,
|
||||
*queue.get_unsafe(),
|
||||
*cb_pool,
|
||||
nullptr, // Allocation callbacks
|
||||
&vulkan_functions);
|
||||
|
||||
std::array<std::tuple<vk::Format, ktx_transcode_fmt_e, bool>, 6> formats{{
|
||||
{vk::Format::eAstc4x4SrgbBlock, KTX_TTF_ASTC_4x4_RGBA, true},
|
||||
{vk::Format::eAstc4x4UnormBlock, KTX_TTF_ASTC_4x4_RGBA, false},
|
||||
{vk::Format::eBc7SrgbBlock, KTX_TTF_BC7_RGBA, true},
|
||||
{vk::Format::eBc7UnormBlock, KTX_TTF_BC7_RGBA, false},
|
||||
{vk::Format::eR8G8B8A8Srgb, KTX_TTF_RGBA32, true},
|
||||
{vk::Format::eR8G8B8Unorm, KTX_TTF_RGBA32, false},
|
||||
}};
|
||||
|
||||
for (auto [vk_format, ktx_format, srgb]: formats)
|
||||
{
|
||||
auto prop = physical_device.getFormatProperties(vk_format);
|
||||
|
||||
if (prop.optimalTilingFeatures & vk::FormatFeatureFlagBits::eSampledImage)
|
||||
{
|
||||
if (srgb)
|
||||
supported_srgb_formats.emplace_back(vk_format, ktx_format);
|
||||
else
|
||||
supported_linear_formats.emplace_back(vk_format, ktx_format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
image_loader::~image_loader()
|
||||
{
|
||||
#if WIVRN_USE_LIBKTX
|
||||
ktxVulkanDeviceInfo_Destruct(&vdi);
|
||||
#endif
|
||||
}
|
||||
|
||||
void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::Format format)
|
||||
template <typename T>
|
||||
float alpha_scale;
|
||||
template <>
|
||||
float alpha_scale<uint8_t> = 1. / 255.;
|
||||
template <>
|
||||
float alpha_scale<uint16_t> = 1. / 65535.;
|
||||
template <>
|
||||
float alpha_scale<float> = 1.;
|
||||
|
||||
template <typename T>
|
||||
void premultiply_alpha_aux(T * destination, const T * source, int n)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
float alpha = source[4 * i + 3] * alpha_scale<T>;
|
||||
|
||||
destination[4 * i + 0] = source[4 * i + 0] * alpha;
|
||||
destination[4 * i + 1] = source[4 * i + 1] * alpha;
|
||||
destination[4 * i + 2] = source[4 * i + 2] * alpha;
|
||||
destination[4 * i + 3] = source[4 * i + 3];
|
||||
}
|
||||
}
|
||||
|
||||
static void premultiply_alpha(void * destination, const void * source, vk::Extent3D extent, vk::Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case vk::Format::eR8G8B8A8Srgb: // TODO: sRGB
|
||||
case vk::Format::eR8G8B8A8Unorm:
|
||||
premultiply_alpha_aux<uint8_t>((uint8_t *)destination, (const uint8_t *)source, extent.width * extent.height * extent.depth);
|
||||
break;
|
||||
|
||||
case vk::Format::eR16G16B16A16Unorm:
|
||||
premultiply_alpha_aux<uint16_t>((uint16_t *)destination, (const uint16_t *)source, extent.width * extent.height * extent.depth);
|
||||
break;
|
||||
|
||||
case vk::Format::eR32G32B32A32Sfloat:
|
||||
premultiply_alpha_aux<float>((float *)destination, (const float *)source, extent.width * extent.height * extent.depth);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
loaded_image image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::Format format, const std::string & name, bool premultiply)
|
||||
{
|
||||
auto cb = std::move(device.allocateCommandBuffers({
|
||||
.commandPool = *cb_pool,
|
||||
@@ -191,14 +410,7 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
|
||||
assert(format != vk::Format::eUndefined);
|
||||
|
||||
this->format = format;
|
||||
this->extent = extent;
|
||||
if (extent.depth > 1)
|
||||
image_view_type = vk::ImageViewType::e3D;
|
||||
else
|
||||
image_view_type = vk::ImageViewType::e2D;
|
||||
|
||||
num_mipmaps = std::floor(std::log2(std::max(extent.width, extent.height))) + 1;
|
||||
uint32_t num_mipmaps = std::floor(std::log2(std::max(extent.width, extent.height))) + 1;
|
||||
|
||||
size_t byte_size = extent.width * extent.height * extent.depth * bytes_per_pixel(format);
|
||||
|
||||
@@ -212,14 +424,17 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
"image_loader::do_load (staging)"};
|
||||
name + " (staging)"};
|
||||
|
||||
if (premultiply)
|
||||
premultiply_alpha(staging_buffer.map(), pixels, extent, format);
|
||||
else
|
||||
memcpy(staging_buffer.map(), pixels, byte_size);
|
||||
|
||||
memcpy(staging_buffer.map(), pixels, byte_size);
|
||||
staging_buffer.unmap();
|
||||
|
||||
// Allocate image
|
||||
auto r = std::make_shared<image_resources>();
|
||||
r->allocation = image_allocation{
|
||||
image_allocation image{
|
||||
device,
|
||||
vk::ImageCreateInfo{
|
||||
.imageType = vk::ImageType::e2D,
|
||||
@@ -235,9 +450,7 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
.flags = 0,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
|
||||
},
|
||||
"image_loader::do_load"};
|
||||
|
||||
r->image = (vk::Image)r->allocation;
|
||||
name};
|
||||
|
||||
// Transition all mipmap levels layout to eTransferDstOptimal
|
||||
cb.pipelineBarrier(
|
||||
@@ -251,7 +464,7 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
.dstAccessMask = vk::AccessFlagBits::eTransferWrite,
|
||||
.oldLayout = vk::ImageLayout::eUndefined,
|
||||
.newLayout = vk::ImageLayout::eTransferDstOptimal,
|
||||
.image = r->image,
|
||||
.image = image,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = 0,
|
||||
@@ -264,7 +477,7 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
// Copy image data
|
||||
cb.copyBufferToImage(
|
||||
staging_buffer,
|
||||
r->image,
|
||||
image,
|
||||
vk::ImageLayout::eTransferDstOptimal,
|
||||
vk::BufferImageCopy{
|
||||
.bufferOffset = 0,
|
||||
@@ -300,7 +513,7 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
.dstAccessMask = vk::AccessFlagBits::eShaderRead,
|
||||
.oldLayout = vk::ImageLayout::eTransferDstOptimal,
|
||||
.newLayout = vk::ImageLayout::eTransferSrcOptimal,
|
||||
.image = r->image,
|
||||
.image = image,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = level - 1,
|
||||
@@ -312,9 +525,9 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
|
||||
// Blit level n-1 to level n
|
||||
cb.blitImage(
|
||||
r->image,
|
||||
image,
|
||||
vk::ImageLayout::eTransferSrcOptimal,
|
||||
r->image,
|
||||
image,
|
||||
vk::ImageLayout::eTransferDstOptimal,
|
||||
vk::ImageBlit{
|
||||
.srcSubresource = {.aspectMask = vk::ImageAspectFlagBits::eColor, .mipLevel = level - 1, .baseArrayLayer = 0, .layerCount = 1},
|
||||
@@ -342,7 +555,7 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
.dstAccessMask = vk::AccessFlagBits::eShaderRead,
|
||||
.oldLayout = vk::ImageLayout::eTransferSrcOptimal,
|
||||
.newLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||
.image = r->image,
|
||||
.image = image,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = level - 1,
|
||||
@@ -368,7 +581,7 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
.dstAccessMask = vk::AccessFlagBits::eShaderRead,
|
||||
.oldLayout = vk::ImageLayout::eTransferDstOptimal,
|
||||
.newLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||
.image = r->image,
|
||||
.image = image,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = num_mipmaps - 1,
|
||||
@@ -386,10 +599,16 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
if (auto result = device.waitForFences(*fence, true, 1'000'000'000); result != vk::Result::eSuccess)
|
||||
throw std::runtime_error("vkWaitForfences: " + vk::to_string(result));
|
||||
|
||||
r->image_view = vk::raii::ImageView{
|
||||
vk::ImageViewType image_view_type;
|
||||
if (extent.depth > 1)
|
||||
image_view_type = vk::ImageViewType::e3D;
|
||||
else
|
||||
image_view_type = vk::ImageViewType::e2D;
|
||||
|
||||
vk::raii::ImageView image_view{
|
||||
device,
|
||||
vk::ImageViewCreateInfo{
|
||||
.image = r->image,
|
||||
.image = image,
|
||||
.viewType = image_view_type,
|
||||
.format = format,
|
||||
.subresourceRange = {
|
||||
@@ -402,76 +621,89 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
||||
},
|
||||
};
|
||||
|
||||
image_view = std::shared_ptr<vk::raii::ImageView>(r, &r->image_view);
|
||||
return loaded_image{
|
||||
.image = std::move(image),
|
||||
.image_view = std::move(image_view),
|
||||
.format = format,
|
||||
.extent = extent,
|
||||
.num_mipmaps = num_mipmaps,
|
||||
.image_view_type = image_view_type,
|
||||
.is_alpha_premultiplied = premultiply,
|
||||
};
|
||||
}
|
||||
|
||||
void image_loader::do_load_ktx(std::span<const std::byte> bytes)
|
||||
loaded_image image_loader::do_load_ktx(std::span<const std::byte> bytes, bool srgb, const std::string & name, const std::filesystem::path & output_file)
|
||||
{
|
||||
#if WIVRN_USE_LIBKTX
|
||||
ktxTexture * texture;
|
||||
KTXTexture2 texture{};
|
||||
// KTX_TEXTURE_CREATE_CHECK_GLTF_BASISU_BIT checks that the file is compatible with the KHR_texture_basisu glTF extension
|
||||
// ktxResult err = ktxTexture2_CreateFromMemory(reinterpret_cast<const uint8_t *>(bytes.data()), bytes.size(), KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &texture);
|
||||
ktxResult err = ktxTexture2_CreateFromMemory(reinterpret_cast<const uint8_t *>(bytes.data()), bytes.size(), 0, &texture);
|
||||
// ktxResult err = ktxTexture2_CreateFromMemory(reinterpret_cast<const uint8_t *>(bytes.data()), bytes.size(), KTX_TEXTURE_CREATE_CHECK_GLTF_BASISU_BIT | KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &texture);
|
||||
|
||||
if (err != KTX_SUCCESS)
|
||||
{
|
||||
spdlog::warn("ktxTexture2_CreateFromMemory: error {}", ktxErrorString(err));
|
||||
throw std::runtime_error("ktxTexture2_CreateFromMemory");
|
||||
}
|
||||
|
||||
if (ktxTexture2_NeedsTranscoding(texture))
|
||||
{
|
||||
auto format = srgb ? supported_srgb_formats.front() : supported_linear_formats.front();
|
||||
|
||||
if (ktxTexture2_TranscodeBasis(texture, format.second, 0) != KTX_SUCCESS)
|
||||
{
|
||||
spdlog::warn("ktxTexture2_TranscodeBasis: error {}", ktxErrorString(err));
|
||||
throw std::runtime_error("ktxTexture2_TranscodeBasis");
|
||||
}
|
||||
|
||||
if (output_file != "")
|
||||
{
|
||||
spdlog::debug("Saving transcoded texture to {}", output_file.native());
|
||||
const char writer[] = "WiVRn";
|
||||
ktxHashList_DeleteKVPair(&texture->kvDataHead, KTX_WRITER_KEY);
|
||||
ktxHashList_AddKVPair(&texture->kvDataHead, KTX_WRITER_KEY, sizeof(writer), writer);
|
||||
|
||||
err = ktxTexture2_WriteToNamedFile(texture, output_file.c_str());
|
||||
if (err != KTX_SUCCESS)
|
||||
{
|
||||
spdlog::warn("ktxTexture2_WriteToNamedFile: error {}", ktxErrorString(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ktxVulkanTexture vk_texture;
|
||||
|
||||
ktxResult err = ktxTexture_CreateFromMemory(reinterpret_cast<const uint8_t *>(bytes.data()), bytes.size(), /*KTX_TEXTURE_CREATE_CHECK_GLTF_BASISU_BIT*/ 0, &texture);
|
||||
|
||||
if (err != KTX_SUCCESS)
|
||||
{
|
||||
spdlog::warn("ktxTexture_CreateFromMemory: error {}", (int)err);
|
||||
throw std::runtime_error("ktxTexture_CreateFromMemory");
|
||||
}
|
||||
|
||||
if (ktxTexture_NeedsTranscoding(texture))
|
||||
{
|
||||
// TODO
|
||||
spdlog::warn("ktxTexture_NeedsTranscoding");
|
||||
throw std::runtime_error("ktxTexture_NeedsTranscoding");
|
||||
}
|
||||
|
||||
{
|
||||
auto _ = queue.lock(); // ktxTexture_VkUploadEx uses the queue internally (in ktxTexture_VkUploadEx_WithSuballocator)
|
||||
// TODO: patch vkloader.c to accept a mutex
|
||||
err = ktxTexture_VkUploadEx(texture, &vdi, &vk_texture, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
err = ktxTexture2_VkUploadEx_WithSuballocator(texture, &vdi, &vk_texture, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, &libktx_vma_glue::suballocator_callbacks);
|
||||
}
|
||||
|
||||
if (err != KTX_SUCCESS)
|
||||
{
|
||||
// TODO try uncompressing the texture
|
||||
ktxTexture_Destroy(texture);
|
||||
spdlog::warn("ktxTexture_CreateFromMemory: error {}", (int)err);
|
||||
throw std::runtime_error("ktxTexture_VkUploadEx");
|
||||
spdlog::warn("ktxTexture2_VkUploadEx: {}", ktxErrorString(err));
|
||||
throw std::runtime_error("ktxTexture2_VkUploadEx");
|
||||
}
|
||||
|
||||
format = vk::Format(vk_texture.imageFormat);
|
||||
extent = vk::Extent3D(texture->baseWidth, texture->baseHeight, texture->baseDepth);
|
||||
image_view_type = vk::ImageViewType(vk_texture.viewType);
|
||||
num_mipmaps = texture->numLevels;
|
||||
|
||||
ktxTexture_Destroy(texture);
|
||||
|
||||
auto r = std::make_shared<ktx_image_resources>();
|
||||
|
||||
r->ktx_texture = vk_texture;
|
||||
r->device = *device;
|
||||
r->image = vk::Image(vk_texture.image);
|
||||
r->image_view = vk::raii::ImageView{
|
||||
device,
|
||||
vk::ImageViewCreateInfo{
|
||||
.image = r->image,
|
||||
.viewType = image_view_type,
|
||||
.format = format,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = num_mipmaps,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = 1,
|
||||
},
|
||||
},
|
||||
return loaded_image{
|
||||
.image{libktx_vma_glue::release(vk_texture.allocationId), device, vk_texture.image, name}, // Take over ownership of vk_texture, do not call ktxTexture2_destruct
|
||||
.image_view{
|
||||
device,
|
||||
vk::ImageViewCreateInfo{
|
||||
.image = vk_texture.image,
|
||||
.viewType = vk::ImageViewType(vk_texture.viewType),
|
||||
.format = vk::Format(vk_texture.imageFormat),
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = texture->numLevels,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = 1,
|
||||
},
|
||||
}},
|
||||
.format = vk::Format(vk_texture.imageFormat),
|
||||
.extent{vk::Extent3D(texture->baseWidth, texture->baseHeight, texture->baseDepth)},
|
||||
.num_mipmaps = texture->numLevels,
|
||||
.image_view_type = vk::ImageViewType(vk_texture.viewType),
|
||||
.is_alpha_premultiplied = ktxTexture2_GetPremultipliedAlpha(texture),
|
||||
};
|
||||
|
||||
image_view = std::shared_ptr<vk::raii::ImageView>(r, &r->image_view);
|
||||
#else
|
||||
throw std::runtime_error("Compiled without KTX support");
|
||||
#endif
|
||||
}
|
||||
|
||||
static constexpr bool starts_with(std::span<const std::byte> data, std::span<const uint8_t> prefix)
|
||||
@@ -479,102 +711,65 @@ static constexpr bool starts_with(std::span<const std::byte> data, std::span<con
|
||||
return data.size() >= prefix.size() && !memcmp(data.data(), prefix.data(), prefix.size());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void premultiply_alpha_aux(T * pixels, float alpha_scale, int width, int height)
|
||||
loaded_image image_loader::do_load_image(std::span<const std::byte> bytes, bool srgb, const std::string & name, bool premultiply)
|
||||
{
|
||||
for (int i = 0, n = width * height; i < n; i++)
|
||||
const stbi_uc * image_data = (const stbi_uc *)bytes.data();
|
||||
size_t image_size = bytes.size();
|
||||
|
||||
int w, h, num_channels, channels_in_file;
|
||||
stbi_ptr pixels;
|
||||
|
||||
if (!stbi_info_from_memory(image_data, image_size, &w, &h, &num_channels))
|
||||
throw std::runtime_error("Unsupported image format");
|
||||
|
||||
assert(num_channels >= 1 && num_channels <= 4);
|
||||
|
||||
if (num_channels == 3)
|
||||
num_channels = 4;
|
||||
|
||||
vk::Format format;
|
||||
if (stbi_is_hdr_from_memory(image_data, image_size))
|
||||
{
|
||||
float alpha = pixels[4 * i + 3] * alpha_scale;
|
||||
|
||||
pixels[4 * i + 0] = pixels[4 * i + 0] * alpha;
|
||||
pixels[4 * i + 1] = pixels[4 * i + 1] * alpha;
|
||||
pixels[4 * i + 2] = pixels[4 * i + 2] * alpha;
|
||||
pixels = stbi_ptr(stbi_loadf_from_memory(image_data, image_size, &w, &h, &channels_in_file, num_channels));
|
||||
format = get_format<float>(num_channels);
|
||||
}
|
||||
}
|
||||
|
||||
static void premultiply_alpha(void * pixels, vk::Extent3D extent, vk::Format format)
|
||||
{
|
||||
switch (format)
|
||||
else if (stbi_is_16_bit_from_memory(image_data, image_size))
|
||||
{
|
||||
case vk::Format::eR8G8B8A8Srgb: // TODO: sRGB
|
||||
case vk::Format::eR8G8B8A8Unorm:
|
||||
premultiply_alpha_aux<uint8_t>((uint8_t *)pixels, 1. / 255., extent.width, extent.height);
|
||||
break;
|
||||
|
||||
case vk::Format::eR16G16B16A16Unorm:
|
||||
premultiply_alpha_aux<uint16_t>((uint16_t *)pixels, 1. / 65535., extent.width, extent.height);
|
||||
break;
|
||||
|
||||
case vk::Format::eR32G32B32A32Sfloat:
|
||||
premultiply_alpha_aux<float>((float *)pixels, 1, extent.width, extent.height);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
pixels = stbi_ptr(stbi_load_16_from_memory(image_data, image_size, &w, &h, &channels_in_file, num_channels));
|
||||
format = get_format<uint16_t>(num_channels);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixels = stbi_ptr(stbi_load_from_memory(image_data, image_size, &w, &h, &channels_in_file, num_channels));
|
||||
format = srgb ? get_format_srgb(num_channels) : get_format<uint8_t>(num_channels);
|
||||
}
|
||||
|
||||
vk::Extent3D extent{
|
||||
.width = uint32_t(w),
|
||||
.height = uint32_t(h),
|
||||
.depth = 1,
|
||||
};
|
||||
|
||||
return do_load_raw(pixels.get(), extent, format, name, premultiply);
|
||||
}
|
||||
|
||||
// Load a PNG/JPEG/KTX2 file
|
||||
void image_loader::load(std::span<const std::byte> bytes, bool srgb)
|
||||
loaded_image image_loader::load(std::span<const std::byte> bytes, bool srgb, const std::string & name, bool premultiply, const std::filesystem::path & output_file)
|
||||
{
|
||||
const uint8_t ktx1_magic[] = {0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A};
|
||||
const uint8_t ktx2_magic[] = {0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A};
|
||||
|
||||
if (starts_with(bytes, ktx1_magic) || starts_with(bytes, ktx2_magic))
|
||||
{
|
||||
do_load_ktx(bytes);
|
||||
}
|
||||
return do_load_ktx(bytes, srgb, name, output_file);
|
||||
else
|
||||
{
|
||||
const stbi_uc * image_data = (const stbi_uc *)bytes.data();
|
||||
size_t image_size = bytes.size();
|
||||
|
||||
int w, h, num_channels, channels_in_file;
|
||||
stbi_ptr pixels;
|
||||
|
||||
if (!stbi_info_from_memory(image_data, image_size, &w, &h, &num_channels))
|
||||
throw std::runtime_error("Unsupported image format");
|
||||
|
||||
assert(num_channels >= 1 && num_channels <= 4);
|
||||
|
||||
if (num_channels == 3)
|
||||
num_channels = 4;
|
||||
|
||||
if (stbi_is_hdr_from_memory(image_data, image_size))
|
||||
{
|
||||
pixels = stbi_ptr(stbi_loadf_from_memory(image_data, image_size, &w, &h, &channels_in_file, num_channels));
|
||||
format = get_format<float>(num_channels);
|
||||
}
|
||||
else if (stbi_is_16_bit_from_memory(image_data, image_size))
|
||||
{
|
||||
pixels = stbi_ptr(stbi_load_16_from_memory(image_data, image_size, &w, &h, &channels_in_file, num_channels));
|
||||
format = get_format<uint16_t>(num_channels);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixels = stbi_ptr(stbi_load_from_memory(image_data, image_size, &w, &h, &channels_in_file, num_channels));
|
||||
format = srgb ? get_format_srgb(num_channels) : get_format<uint8_t>(num_channels);
|
||||
}
|
||||
|
||||
extent.width = w;
|
||||
extent.height = h;
|
||||
extent.depth = 1;
|
||||
|
||||
premultiply_alpha(pixels.get(), extent, format);
|
||||
|
||||
do_load_raw(pixels.get(), extent, format);
|
||||
}
|
||||
return do_load_image(bytes, srgb, name, premultiply);
|
||||
}
|
||||
|
||||
// Load raw pixel data
|
||||
void image_loader::load(const void * pixels, size_t size, vk::Extent3D extent_, vk::Format format_)
|
||||
loaded_image image_loader::load(const void * pixels, size_t size, vk::Extent3D extent, vk::Format format, const std::string & name, bool premultiply)
|
||||
{
|
||||
extent = extent_;
|
||||
format = format_;
|
||||
image_view_type = vk::ImageViewType::e2D;
|
||||
|
||||
if (size < extent.width * extent.height * extent.depth * bytes_per_pixel(format))
|
||||
throw std::invalid_argument("size");
|
||||
|
||||
do_load_raw(pixels, extent_, format_);
|
||||
return do_load_raw(pixels, extent, format, name, premultiply);
|
||||
}
|
||||
|
||||
@@ -22,73 +22,78 @@
|
||||
#include "utils/thread_safe.h"
|
||||
#include "vk/allocation.h"
|
||||
#include "vk/fwd.h"
|
||||
#include "wivrn_config.h"
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <memory>
|
||||
#include <ktxvulkan.h>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
#if WIVRN_USE_LIBKTX
|
||||
#include <ktxvulkan.h>
|
||||
#endif
|
||||
struct loaded_image
|
||||
{
|
||||
image_allocation image;
|
||||
vk::raii::ImageView image_view;
|
||||
|
||||
vk::Format format;
|
||||
vk::Extent3D extent;
|
||||
uint32_t num_mipmaps;
|
||||
vk::ImageViewType image_view_type;
|
||||
bool is_alpha_premultiplied;
|
||||
};
|
||||
|
||||
struct image_loader
|
||||
{
|
||||
vk::Image image;
|
||||
vk::Format format;
|
||||
vk::Extent3D extent;
|
||||
vk::ImageViewType image_view_type;
|
||||
|
||||
std::shared_ptr<vk::raii::ImageView> image_view;
|
||||
|
||||
uint32_t num_mipmaps;
|
||||
|
||||
image_loader(vk::raii::PhysicalDevice physical_device, vk::raii::Device & device, thread_safe<vk::raii::Queue> & queue, vk::raii::CommandPool & cb_pool);
|
||||
image_loader(vk::raii::Device & device, vk::raii::PhysicalDevice physical_device, thread_safe<vk::raii::Queue> & queue, uint32_t queue_family_index);
|
||||
image_loader(const image_loader &) = delete;
|
||||
image_loader & operator=(const image_loader &) = delete;
|
||||
~image_loader();
|
||||
|
||||
// Load a PNG/JPEG/KTX2 file
|
||||
void load(std::span<const std::byte> bytes, bool srgb);
|
||||
loaded_image load(std::span<const std::byte> bytes, bool srgb, const std::string & name = "", bool premultiply = false, const std::filesystem::path & output_file = "");
|
||||
|
||||
// Load raw pixel data
|
||||
void load(const void * pixels, size_t size, vk::Extent3D extent, vk::Format format);
|
||||
loaded_image load(const void * pixels, size_t size, vk::Extent3D extent, vk::Format format, const std::string & name = "", bool premultiply = false);
|
||||
|
||||
template <typename T>
|
||||
void load(std::span<T> pixels, vk::Extent3D extent, vk::Format format)
|
||||
loaded_image load(std::span<T> pixels, vk::Extent3D extent, vk::Format format, const std::string & name = "", bool premultiply = false)
|
||||
{
|
||||
load(pixels.data(), pixels.size() * sizeof(T), extent, format);
|
||||
return load(pixels.data(), pixels.size() * sizeof(T), extent, format, name);
|
||||
}
|
||||
|
||||
template <typename T, size_t N>
|
||||
void load(const std::array<T, N> & pixels, vk::Extent3D extent, vk::Format format)
|
||||
loaded_image load(const std::array<T, N> & pixels, vk::Extent3D extent, vk::Format format, const std::string & name = "", bool premultiply = false)
|
||||
{
|
||||
load(pixels.data(), pixels.size() * sizeof(T), extent, format);
|
||||
return load(pixels.data(), pixels.size() * sizeof(T), extent, format, name);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void load(const std::vector<T> & pixels, vk::Extent3D extent, vk::Format format)
|
||||
loaded_image load(const std::vector<T> & pixels, vk::Extent3D extent, vk::Format format, const std::string & name = "", bool premultiply = false)
|
||||
{
|
||||
load(pixels.data(), pixels.size() * sizeof(T), extent, format);
|
||||
return load(pixels.data(), pixels.size() * sizeof(T), extent, format, name);
|
||||
}
|
||||
|
||||
std::shared_ptr<loaded_image> operator()(std::span<const std::byte> bytes, bool srgb, const std::string & name = "", bool premultiply = false)
|
||||
{
|
||||
return std::make_shared<loaded_image>(load(bytes, srgb, name, premultiply));
|
||||
}
|
||||
|
||||
private:
|
||||
#if WIVRN_USE_LIBKTX
|
||||
ktxVulkanDeviceInfo vdi;
|
||||
#endif
|
||||
|
||||
vk::raii::Device & device;
|
||||
thread_safe<vk::raii::Queue> & queue;
|
||||
vk::raii::CommandPool & cb_pool;
|
||||
vk::raii::CommandPool cb_pool;
|
||||
|
||||
std::vector<std::pair<vk::Format, ktx_transcode_fmt_e>> supported_srgb_formats;
|
||||
std::vector<std::pair<vk::Format, ktx_transcode_fmt_e>> supported_linear_formats;
|
||||
|
||||
buffer_allocation staging_buffer;
|
||||
|
||||
void do_load_raw(const void * pixels, vk::Extent3D extent, vk::Format format);
|
||||
loaded_image do_load_raw(const void * pixels, vk::Extent3D extent, vk::Format format, const std::string & name, bool premultiply);
|
||||
|
||||
void do_load_ktx(std::span<const std::byte> bytes);
|
||||
|
||||
void create_image_view();
|
||||
loaded_image do_load_image(std::span<const std::byte> bytes, bool srgb, const std::string & name, bool premultiply);
|
||||
loaded_image do_load_ktx(std::span<const std::byte> bytes, bool srgb, const std::string & name, const std::filesystem::path & output_file = "");
|
||||
};
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "image_writer.h"
|
||||
|
||||
#include "utils/thread_safe.h"
|
||||
#include <cassert>
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
void write_image(
|
||||
vk::raii::Device & device,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
uint32_t queue_family_index,
|
||||
const std::filesystem::path & path,
|
||||
vk::Image image,
|
||||
const vk::ImageCreateInfo & info)
|
||||
{
|
||||
assert(info.usage & vk::ImageUsageFlagBits::eTransferSrc);
|
||||
assert(info.extent.depth == 1);
|
||||
assert(info.format == vk::Format::eR8G8B8A8Srgb);
|
||||
|
||||
buffer_allocation output_buffer{
|
||||
device,
|
||||
vk::BufferCreateInfo{
|
||||
.size = info.extent.height * info.extent.width * 4,
|
||||
.usage = vk::BufferUsageFlagBits::eTransferDst,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
|
||||
.usage = VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
"Saved image buffer"};
|
||||
|
||||
vk::raii::CommandPool cp{
|
||||
device,
|
||||
vk::CommandPoolCreateInfo{
|
||||
.queueFamilyIndex = queue_family_index,
|
||||
}};
|
||||
|
||||
vk::raii::CommandBuffer command_buffer = std::move(device.allocateCommandBuffers(
|
||||
{
|
||||
.commandPool = *cp,
|
||||
.level = vk::CommandBufferLevel::ePrimary,
|
||||
.commandBufferCount = 1,
|
||||
})[0]);
|
||||
|
||||
vk::raii::Fence fence = device.createFence({});
|
||||
|
||||
command_buffer.begin(vk::CommandBufferBeginInfo{});
|
||||
|
||||
command_buffer.pipelineBarrier(
|
||||
vk::PipelineStageFlagBits::eColorAttachmentOutput,
|
||||
vk::PipelineStageFlagBits::eTransfer,
|
||||
vk::DependencyFlags{},
|
||||
{},
|
||||
{},
|
||||
vk::ImageMemoryBarrier{
|
||||
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite,
|
||||
.dstAccessMask = vk::AccessFlagBits::eTransferRead,
|
||||
.oldLayout = vk::ImageLayout::eColorAttachmentOptimal,
|
||||
.newLayout = vk::ImageLayout::eTransferSrcOptimal,
|
||||
.image = image,
|
||||
.subresourceRange = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = 1,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = 1,
|
||||
},
|
||||
});
|
||||
|
||||
command_buffer.copyImageToBuffer(
|
||||
image,
|
||||
vk::ImageLayout::eTransferSrcOptimal,
|
||||
output_buffer,
|
||||
vk::BufferImageCopy{
|
||||
.bufferOffset = 0,
|
||||
.bufferRowLength = 0,
|
||||
.bufferImageHeight = 0,
|
||||
.imageSubresource = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.mipLevel = 0,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = 1,
|
||||
},
|
||||
.imageOffset = {0, 0, 0},
|
||||
.imageExtent = info.extent,
|
||||
});
|
||||
|
||||
command_buffer.end();
|
||||
queue.lock()->submit(vk::SubmitInfo{
|
||||
.commandBufferCount = 1,
|
||||
.pCommandBuffers = &*command_buffer,
|
||||
},
|
||||
*fence);
|
||||
|
||||
if (auto result = device.waitForFences(*fence, true, 1'000'000'000); result == vk::Result::eSuccess)
|
||||
stbi_write_png(path.c_str(), info.extent.width, info.extent.height, 4, output_buffer.data(), 0);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/thread_safe.h"
|
||||
#include "vk/allocation.h"
|
||||
#include <filesystem>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
void write_image(
|
||||
vk::raii::Device & device,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
uint32_t queue_family_index,
|
||||
const std::filesystem::path & path,
|
||||
vk::Image image,
|
||||
const vk::ImageCreateInfo & info);
|
||||
|
||||
inline void write_image(
|
||||
vk::raii::Device & device,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
uint32_t queue_family_index,
|
||||
const std::filesystem::path & path,
|
||||
const image_allocation & image)
|
||||
{
|
||||
write_image(device, queue, queue_family_index, path, (vk::Image)image, image.info());
|
||||
}
|
||||
@@ -16,15 +16,17 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#include "imgui_impl.h"
|
||||
#include "implot.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "asset.h"
|
||||
#include "constants.h"
|
||||
#include "image_loader.h"
|
||||
#include "openxr/openxr.h"
|
||||
#include "utils/mapped_file.h"
|
||||
#include "utils/ranges.h"
|
||||
#include "utils/strings.h"
|
||||
#include "vulkan/vulkan_enums.hpp"
|
||||
#include "vulkan/vulkan_handles.hpp"
|
||||
#include "vulkan/vulkan_to_string.hpp"
|
||||
@@ -35,6 +37,7 @@
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <glm/gtc/matrix_access.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <limits>
|
||||
@@ -43,8 +46,6 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "IconsFontAwesome6.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/font.h>
|
||||
#include <android/font_matcher.h>
|
||||
@@ -146,7 +147,7 @@ static bool in_viewport(const imgui_context::viewport & viewport, ImVec2 positio
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool window_intersects_viewport(ImGuiWindow * window, imgui_context::viewport & viewport)
|
||||
static bool window_intersects_viewport(ImGuiWindow * window, const imgui_context::viewport & viewport)
|
||||
{
|
||||
ImRect w{window->Pos.x, window->Pos.y, window->Pos.x + window->Size.x, window->Pos.y + window->Size.y};
|
||||
ImRect v(viewport.vp_origin.x, viewport.vp_origin.y, viewport.vp_origin.x + viewport.vp_size.x, viewport.vp_origin.y + viewport.vp_size.y);
|
||||
@@ -157,7 +158,7 @@ static bool window_intersects_viewport(ImGuiWindow * window, imgui_context::view
|
||||
static float distance_to_window(ImGuiWindow * window, ImVec2 position)
|
||||
{
|
||||
if (window->Hidden or not window->Active)
|
||||
return std::numeric_limits<float>::infinity();
|
||||
return std::numeric_limits<float>::max();
|
||||
|
||||
float dx;
|
||||
if (position.x < window->Pos.x)
|
||||
@@ -178,16 +179,48 @@ static float distance_to_window(ImGuiWindow * window, ImVec2 position)
|
||||
return std::hypot(dx, dy);
|
||||
}
|
||||
|
||||
static const std::array layout_bindings = {
|
||||
vk::DescriptorSetLayoutBinding{
|
||||
.binding = 0,
|
||||
.descriptorType = vk::DescriptorType::eCombinedImageSampler,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = vk::ShaderStageFlagBits::eFragment,
|
||||
}};
|
||||
|
||||
imgui_textures::imgui_textures(
|
||||
vk::raii::PhysicalDevice physical_device,
|
||||
vk::raii::Device & device,
|
||||
uint32_t queue_family_index,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
std::shared_ptr<image_cache_type> image_cache) :
|
||||
physical_device(physical_device),
|
||||
device(device),
|
||||
queue(queue),
|
||||
ds_layout(device, vk::DescriptorSetLayoutCreateInfo{.bindingCount = layout_bindings.size(), .pBindings = layout_bindings.data()}),
|
||||
command_pool(device,
|
||||
vk::CommandPoolCreateInfo{
|
||||
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer | vk::CommandPoolCreateFlagBits::eTransient,
|
||||
.queueFamilyIndex = queue_family_index,
|
||||
}),
|
||||
image_cache(image_cache),
|
||||
descriptor_pool(device, ds_layout, layout_bindings)
|
||||
{
|
||||
if (not image_cache)
|
||||
this->image_cache = std::make_shared<image_cache_type>(device, physical_device, queue, queue_family_index);
|
||||
}
|
||||
|
||||
imgui_textures::~imgui_textures()
|
||||
{
|
||||
device.waitIdle();
|
||||
}
|
||||
|
||||
std::vector<std::pair<ImVec2, float>> imgui_context::ray_plane_intersection(const imgui_context::controller_state & in) const
|
||||
{
|
||||
if (!in.active)
|
||||
return {};
|
||||
|
||||
std::vector<std::pair<ImVec2, float>> intersections;
|
||||
|
||||
for (const auto & i: layers_)
|
||||
{
|
||||
if (i.space != xr::spaces::world)
|
||||
if (i.space != xr::spaces::world or i.tooltip_viewport)
|
||||
continue;
|
||||
|
||||
auto M = glm::transpose(glm::mat3_cast(i.orientation)); // world-to-plane transform
|
||||
@@ -207,7 +240,10 @@ std::vector<std::pair<ImVec2, float>> imgui_context::ray_plane_intersection(cons
|
||||
// => ray_start.z + distance × ray_dir.z = 0
|
||||
float distance = -ray_start.z / ray_dir.z;
|
||||
|
||||
if (distance < constants::gui::min_pointer_distance)
|
||||
if (distance < constants::gui::min_controller_distance and in.source == ImGuiMouseSource_VRController)
|
||||
continue;
|
||||
|
||||
if (distance < constants::gui::fingertip_distance_touching_thd_lo and in.source == ImGuiMouseSource_VRHandTracking)
|
||||
continue;
|
||||
|
||||
coord.x = ray_start.x + distance * ray_dir.x;
|
||||
@@ -289,39 +325,28 @@ imgui_context::imgui_frame & imgui_context::get_frame(vk::Image destination)
|
||||
return frame;
|
||||
}
|
||||
|
||||
static const std::array layout_bindings = {
|
||||
vk::DescriptorSetLayoutBinding{
|
||||
.binding = 0,
|
||||
.descriptorType = vk::DescriptorType::eCombinedImageSampler,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = vk::ShaderStageFlagBits::eFragment,
|
||||
}};
|
||||
|
||||
imgui_context::imgui_context(
|
||||
vk::raii::PhysicalDevice physical_device,
|
||||
vk::raii::Device & device,
|
||||
uint32_t queue_family_index,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
std::span<controller> controllers_,
|
||||
xr::swapchain & swapchain,
|
||||
std::vector<viewport> layers) :
|
||||
physical_device(physical_device),
|
||||
device(device),
|
||||
xr::swapchain && swapchain_,
|
||||
std::vector<viewport> layers,
|
||||
std::shared_ptr<image_cache_type> image_cache) :
|
||||
imgui_textures(
|
||||
physical_device,
|
||||
device,
|
||||
queue_family_index,
|
||||
queue,
|
||||
image_cache),
|
||||
queue_family_index(queue_family_index),
|
||||
queue(queue),
|
||||
ds_layout(device, vk::DescriptorSetLayoutCreateInfo{.bindingCount = layout_bindings.size(), .pBindings = layout_bindings.data()}),
|
||||
descriptor_pool(device, ds_layout, layout_bindings),
|
||||
renderpass(create_renderpass(device, swapchain.format(), true)),
|
||||
command_pool(device,
|
||||
vk::CommandPoolCreateInfo{
|
||||
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer | vk::CommandPoolCreateFlagBits::eTransient,
|
||||
.queueFamilyIndex = queue_family_index,
|
||||
}),
|
||||
command_buffers(swapchain.images().size()),
|
||||
size(swapchain.extent().width, swapchain.extent().height),
|
||||
format(swapchain.format()),
|
||||
renderpass(create_renderpass(device, swapchain_.format(), true)),
|
||||
command_buffers(swapchain_.images().size()),
|
||||
size(swapchain_.extent().width, swapchain_.extent().height),
|
||||
format(swapchain_.format()),
|
||||
layers_(std::move(layers)),
|
||||
swapchain(swapchain),
|
||||
swapchain(std::move(swapchain_)),
|
||||
context(ImGui::CreateContext()),
|
||||
plot_context(ImPlot::CreateContext()),
|
||||
io((ImGui::SetCurrentContext(context), ImGui::GetIO())),
|
||||
@@ -345,17 +370,19 @@ imgui_context::imgui_context(
|
||||
|
||||
ImGui_ImplVulkan_InitInfo init_info = {
|
||||
.Instance = *application::get_vulkan_instance(),
|
||||
.PhysicalDevice = *application::get_physical_device(),
|
||||
.Device = *application::get_device(),
|
||||
.QueueFamily = application::queue_family_index(),
|
||||
.PhysicalDevice = *physical_device,
|
||||
.Device = *device,
|
||||
.QueueFamily = queue_family_index,
|
||||
.Queue = *queue.get_unsafe(),
|
||||
.RenderPass = *renderpass,
|
||||
.DescriptorPoolSize = 100,
|
||||
.MinImageCount = 2,
|
||||
.ImageCount = (uint32_t)swapchain.images().size(), // used to cycle between VkBuffers in ImGui_ImplVulkan_RenderDrawData
|
||||
.MSAASamples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.PipelineCache = *application::get_pipeline_cache(),
|
||||
.Subpass = 0,
|
||||
.DescriptorPoolSize = 100,
|
||||
.PipelineInfoMain = {
|
||||
.RenderPass = *renderpass,
|
||||
.Subpass = 0,
|
||||
.MSAASamples = VK_SAMPLE_COUNT_1_BIT,
|
||||
},
|
||||
.Allocator = nullptr,
|
||||
.CheckVkResultFn = check_vk_result,
|
||||
};
|
||||
@@ -490,26 +517,26 @@ static std::vector<std::string> find_font(std::u16string sample_text, const std:
|
||||
|
||||
void imgui_context::initialize_fonts()
|
||||
{
|
||||
std::u16string sample_text = u"Hello world";
|
||||
|
||||
const auto & locale = application::get_messages_info();
|
||||
auto it = glyph_set_per_language.find(locale.language + "_" + locale.country);
|
||||
if (it == glyph_set_per_language.end())
|
||||
it = glyph_set_per_language.find(locale.language);
|
||||
|
||||
if (it != glyph_set_per_language.end())
|
||||
for (char16_t c: it->second)
|
||||
sample_text += c;
|
||||
|
||||
// Load Fonts
|
||||
auto fonts = find_font(sample_text, application::get_messages_info().language);
|
||||
for (auto & i: fonts)
|
||||
std::vector<std::string> fonts;
|
||||
for (auto & [code, glyphs]: glyph_set_per_language)
|
||||
{
|
||||
spdlog::info("Font {}", i);
|
||||
std::u16string sample_text = u"Hello world";
|
||||
|
||||
for (char16_t c: glyphs)
|
||||
sample_text += c;
|
||||
auto language = code.substr(0, code.find("_"));
|
||||
|
||||
// Load Fonts
|
||||
for (auto && i: find_font(sample_text, language))
|
||||
{
|
||||
spdlog::info("Font for {} {}", code, i);
|
||||
if (not std::ranges::contains(fonts, i))
|
||||
fonts.push_back(std::move(i));
|
||||
}
|
||||
}
|
||||
|
||||
asset font_awesome_regular("Font Awesome 6 Free-Regular-400.otf");
|
||||
asset font_awesome_solid("Font Awesome 6 Free-Solid-900.otf");
|
||||
utils::mapped_file font_awesome_regular("assets://Font Awesome 6 Free-Regular-400.otf");
|
||||
utils::mapped_file font_awesome_solid("assets://Font Awesome 6 Free-Solid-900.otf");
|
||||
|
||||
ImFontConfig config;
|
||||
config.FontDataOwnedByAtlas = false;
|
||||
@@ -533,97 +560,125 @@ std::vector<imgui_context::controller_state> imgui_context::read_controllers_sta
|
||||
size_t new_focused_controller = focused_controller;
|
||||
|
||||
std::vector<controller_state> new_states;
|
||||
new_states.resize(controllers.size());
|
||||
if (not controllers_enabled)
|
||||
return new_states;
|
||||
|
||||
aim_interaction = {1, 1};
|
||||
|
||||
// Get the hand/controller state from OpenXR
|
||||
for (auto && [index, controller]: utils::enumerate(controllers))
|
||||
for (const auto & [controller, state, current_aim_interaction]: std::ranges::zip_view(controllers, new_states, aim_interaction))
|
||||
{
|
||||
auto & [ctrl, state] = controller;
|
||||
|
||||
controller_state & new_state = new_states.emplace_back();
|
||||
|
||||
if (not controllers_enabled)
|
||||
continue;
|
||||
const auto & ctrl = controller.first;
|
||||
std::pair<std::optional<ImVec2>, float> index_tip_position{{}, std::numeric_limits<float>::max()};
|
||||
std::pair<std::optional<ImVec2>, float> palm_position{{}, std::numeric_limits<float>::max()};
|
||||
std::pair<std::optional<ImVec2>, float> controller_position{{}, std::numeric_limits<float>::max()};
|
||||
|
||||
// First hands, so we can set aim_interaction
|
||||
current_aim_interaction = 1;
|
||||
if (ctrl.hand)
|
||||
{
|
||||
if (auto joints = ctrl.hand->locate(world, display_time))
|
||||
{
|
||||
XrHandJointLocationEXT & index_tip = (*joints)[XR_HAND_JOINT_INDEX_TIP_EXT].first;
|
||||
if (index_tip.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
XrHandJointLocationEXT & palm = (*joints)[XR_HAND_JOINT_PALM_EXT].first;
|
||||
|
||||
if (index_tip.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
{
|
||||
new_state.aim_position = {
|
||||
index_tip.pose.position.x,
|
||||
index_tip.pose.position.y,
|
||||
index_tip.pose.position.z};
|
||||
// aim_orientation is ignored by ray_plane_intersection() for hands
|
||||
|
||||
new_state.active = true;
|
||||
new_state.source = ImGuiMouseSource_VRHandTracking;
|
||||
index_tip_position = compute_pointer_position(controller_state{
|
||||
.aim_position = {
|
||||
index_tip.pose.position.x,
|
||||
index_tip.pose.position.y,
|
||||
index_tip.pose.position.z,
|
||||
},
|
||||
// aim_orientation is ignored by ray_plane_intersection() for hands
|
||||
.source = ImGuiMouseSource_VRHandTracking,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
if (palm.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
{
|
||||
palm_position = compute_pointer_position(controller_state{
|
||||
.aim_position = {
|
||||
palm.pose.position.x,
|
||||
palm.pose.position.y,
|
||||
palm.pose.position.z,
|
||||
},
|
||||
.source = ImGuiMouseSource_VRHandTracking,
|
||||
});
|
||||
}
|
||||
|
||||
if (index_tip_position.second < constants::gui::fingertip_distance_touching_thd_hi and
|
||||
index_tip_position.second > constants::gui::fingertip_distance_touching_thd_lo)
|
||||
state.fingertip_touching = true;
|
||||
|
||||
if (palm_position.second < constants::gui::palm_distance_close_thd_lo)
|
||||
current_aim_interaction = 0;
|
||||
else if (palm_position.second > constants::gui::palm_distance_close_thd_hi)
|
||||
current_aim_interaction = 1;
|
||||
else
|
||||
current_aim_interaction =
|
||||
(palm_position.second - constants::gui::palm_distance_close_thd_lo) /
|
||||
(constants::gui::palm_distance_close_thd_hi - constants::gui::palm_distance_close_thd_lo);
|
||||
}
|
||||
}
|
||||
|
||||
new_state.source = ImGuiMouseSource_VRController;
|
||||
|
||||
// Then controllers
|
||||
if (auto location = application::locate_controller(ctrl.aim, world, display_time))
|
||||
{
|
||||
new_state.active = true;
|
||||
new_state.aim_position = location->first + glm::mat3_cast(location->second * ctrl.offset.second) * ctrl.offset.first;
|
||||
new_state.aim_orientation = location->second * ctrl.offset.second;
|
||||
controller_position = compute_pointer_position(controller_state{
|
||||
.aim_position = location->first + glm::mat3_cast(location->second * ctrl.offset.second) * ctrl.offset.first,
|
||||
.aim_orientation = location->second * ctrl.offset.second,
|
||||
.source = ImGuiMouseSource_VRController,
|
||||
});
|
||||
|
||||
if (ctrl.trigger)
|
||||
if (current_aim_interaction == 1)
|
||||
{
|
||||
auto trigger = application::read_action_float(ctrl.trigger).value_or(std::pair{0, 0});
|
||||
new_state.trigger_value = trigger.second;
|
||||
if (ctrl.trigger)
|
||||
{
|
||||
auto trigger = application::read_action_float(ctrl.trigger).value_or(std::pair{0, 0});
|
||||
state.trigger_value = trigger.second;
|
||||
|
||||
// TODO tunable
|
||||
/*if (new_state.trigger_value < 0.5)
|
||||
new_state.trigger_clicked = false;
|
||||
else */
|
||||
if (new_state.trigger_value > constants::gui::trigger_click_thd)
|
||||
new_state.trigger_clicked = true;
|
||||
}
|
||||
if (state.trigger_value > constants::gui::trigger_click_thd)
|
||||
state.trigger_clicked = true;
|
||||
}
|
||||
|
||||
if (ctrl.scroll)
|
||||
{
|
||||
if (auto act = application::read_action_vec2(ctrl.scroll); act)
|
||||
new_state.scroll_value = {-act->second.x * scroll_scale, act->second.y * scroll_scale};
|
||||
else
|
||||
new_state.scroll_value = {0, 0};
|
||||
if (ctrl.scroll)
|
||||
{
|
||||
if (auto act = application::read_action_vec2(ctrl.scroll); act)
|
||||
state.scroll_value = {-act->second.x * scroll_scale, act->second.y * scroll_scale};
|
||||
else
|
||||
state.scroll_value = {0, 0};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute the position in imgui frame according to the currently displayed windows (from the last frame)
|
||||
for (auto & state: new_states)
|
||||
{
|
||||
compute_pointer_position(state);
|
||||
|
||||
if (state.source == ImGuiMouseSource_VRHandTracking)
|
||||
if (current_aim_interaction == 0 or not controller_position.first)
|
||||
state.pointer_position = index_tip_position.first;
|
||||
else if (current_aim_interaction == 1 or not index_tip_position.first)
|
||||
state.pointer_position = controller_position.first;
|
||||
else
|
||||
{
|
||||
if (state.hover_distance < constants::gui::fingertip_distance_hovering_thd)
|
||||
state.fingertip_hovering = true;
|
||||
|
||||
if (state.hover_distance < constants::gui::fingertip_distance_touching_thd)
|
||||
state.fingertip_touching = true;
|
||||
assert(index_tip_position.first);
|
||||
assert(controller_position.first);
|
||||
state.pointer_position = *index_tip_position.first + (*controller_position.first - *index_tip_position.first) * current_aim_interaction;
|
||||
}
|
||||
|
||||
if (current_aim_interaction < 1)
|
||||
state.source = ImGuiMouseSource_VRHandTracking;
|
||||
else
|
||||
state.source = ImGuiMouseSource_VRController;
|
||||
}
|
||||
|
||||
return new_states;
|
||||
}
|
||||
|
||||
void imgui_context::compute_pointer_position(imgui_context::controller_state & state)
|
||||
std::pair<std::optional<ImVec2>, float> imgui_context::compute_pointer_position(const imgui_context::controller_state & state) const
|
||||
{
|
||||
auto intersections = ray_plane_intersection(state);
|
||||
|
||||
if (intersections.empty())
|
||||
{
|
||||
state.hover_distance = std::numeric_limits<float>::infinity();
|
||||
state.pointer_position = std::nullopt;
|
||||
return;
|
||||
}
|
||||
return {std::nullopt, std::numeric_limits<float>::max()};
|
||||
|
||||
if (ImGuiWindow * modal_popup = ImGui::GetTopMostAndVisiblePopupModal())
|
||||
{
|
||||
@@ -638,17 +693,12 @@ void imgui_context::compute_pointer_position(imgui_context::controller_state & s
|
||||
for (auto [position, distance]: intersections)
|
||||
{
|
||||
if (in_viewport(i, position))
|
||||
{
|
||||
state.hover_distance = distance;
|
||||
state.pointer_position = position;
|
||||
return;
|
||||
}
|
||||
return {position, distance};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state.hover_distance = std::numeric_limits<float>::infinity();
|
||||
state.pointer_position = std::nullopt;
|
||||
return {std::nullopt, std::numeric_limits<float>::max()};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -661,16 +711,12 @@ void imgui_context::compute_pointer_position(imgui_context::controller_state & s
|
||||
continue;
|
||||
|
||||
if (in_window(window, position))
|
||||
{
|
||||
state.hover_distance = distance;
|
||||
state.pointer_position = position;
|
||||
return;
|
||||
}
|
||||
return {position, distance};
|
||||
}
|
||||
}
|
||||
|
||||
// If the pointer isn't in any window, take the farthest one
|
||||
std::tie(state.pointer_position, state.hover_distance) = intersections.back();
|
||||
return intersections.back();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,6 +754,13 @@ size_t imgui_context::choose_focused_controller(const std::vector<controller_sta
|
||||
return index;
|
||||
}
|
||||
|
||||
// scrolling?
|
||||
for (auto && [index, state]: utils::enumerate(new_states))
|
||||
{
|
||||
if (glm::length(state.scroll_value) > constants::gui::scroll_value_thd)
|
||||
return index;
|
||||
}
|
||||
|
||||
// Else, keep the last controller active
|
||||
return focused_controller;
|
||||
}
|
||||
@@ -718,7 +771,7 @@ void imgui_context::new_frame(XrTime display_time)
|
||||
ImPlot::SetCurrentContext(plot_context);
|
||||
|
||||
if (last_display_time)
|
||||
io.DeltaTime = std::min((display_time - last_display_time) * 1e-9f, 0.0166f);
|
||||
io.DeltaTime = std::clamp((display_time - last_display_time) * 1e-9f, 0.001f, 0.0166f);
|
||||
last_display_time = display_time;
|
||||
|
||||
// Uses the window list from last frame
|
||||
@@ -792,7 +845,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
|
||||
application::haptic_start(haptic_output, XR_NULL_PATH, 10'000'000, 1000, 1);
|
||||
}
|
||||
|
||||
vk::Image destination = swapchain.images()[image_index].image;
|
||||
vk::Image destination = swapchain.image(image_index);
|
||||
|
||||
ImGui::SetCurrentContext(context);
|
||||
ImPlot::SetCurrentContext(plot_context);
|
||||
@@ -856,7 +909,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
|
||||
}
|
||||
|
||||
// Compute the distance to the closest window
|
||||
float distance = std::numeric_limits<float>::infinity();
|
||||
float distance = std::numeric_limits<float>::max();
|
||||
for (ImGuiWindow * window: context->Windows)
|
||||
{
|
||||
distance = std::min(distance, distance_to_window(window, *position));
|
||||
@@ -864,20 +917,18 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
|
||||
|
||||
float alpha = std::clamp<float>(1 - distance / constants::gui::pointer_fading_distance, 0, 1);
|
||||
|
||||
if (&controller == &controllers[focused_controller])
|
||||
if (focused_controller != (size_t)-1 and &controller == &controllers[focused_controller])
|
||||
alpha *= constants::gui::pointer_alpha;
|
||||
else
|
||||
alpha *= constants::gui::pointer_alpha_disabled;
|
||||
|
||||
ImU32 color_pressed = ImGui::GetColorU32(constants::gui::pointer_color_pressed, alpha);
|
||||
ImU32 color_unpressed = ImGui::GetColorU32(constants::gui::pointer_color_unpressed, alpha);
|
||||
|
||||
bool pressed = controller.second.trigger_clicked || controller.second.fingertip_touching;
|
||||
float radius_in = constants::gui::pointer_radius_in;
|
||||
float radius_out = radius_in + constants::gui::pointer_thickness * 0.5;
|
||||
|
||||
ImDrawList * draw_list = ImGui::GetForegroundDrawList();
|
||||
draw_list->PushClipRect(clip_rect_min, clip_rect_max);
|
||||
draw_list->AddCircleFilled(*position, constants::gui::pointer_radius_in, pressed ? color_pressed : color_unpressed);
|
||||
draw_list->AddCircle(*position, constants::gui::pointer_radius_out, ImGui::GetColorU32(constants::gui::pointer_color_border, alpha), 0, constants::gui::pointer_thickness);
|
||||
draw_list->AddCircleFilled(*position, radius_in, ImGui::GetColorU32(constants::gui::pointer_color, alpha));
|
||||
draw_list->AddCircle(*position, radius_out, ImGui::GetColorU32(constants::gui::pointer_color_border, alpha), 0, constants::gui::pointer_thickness);
|
||||
draw_list->PopClipRect();
|
||||
}
|
||||
}
|
||||
@@ -932,15 +983,47 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
|
||||
for (auto & i: layers_)
|
||||
{
|
||||
bool visible = false;
|
||||
|
||||
ImRect layer_rect(
|
||||
i.vp_origin.x,
|
||||
i.vp_origin.y,
|
||||
i.vp_origin.x + i.vp_size.x,
|
||||
i.vp_origin.y + i.vp_size.y);
|
||||
|
||||
ImRect all_windows_rect{
|
||||
std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::lowest(),
|
||||
std::numeric_limits<float>::lowest(),
|
||||
};
|
||||
|
||||
for (ImGuiWindow * window: context->Windows)
|
||||
{
|
||||
if (window->Active and not window->Hidden and window_intersects_viewport(window, i))
|
||||
ImRect window_rect{
|
||||
window->Pos.x,
|
||||
window->Pos.y,
|
||||
window->Pos.x + window->Size.x,
|
||||
window->Pos.y + window->Size.y};
|
||||
|
||||
if (window->Active and not window->Hidden and layer_rect.Overlaps(window_rect))
|
||||
{
|
||||
visible = true;
|
||||
break;
|
||||
|
||||
// Take the union of all visible windows in this layer
|
||||
all_windows_rect.Add(window_rect);
|
||||
}
|
||||
}
|
||||
|
||||
// Take the intersection with the layer
|
||||
all_windows_rect.ClipWithFull(layer_rect);
|
||||
|
||||
glm::vec2 pixel_size = i.size / glm::vec2(i.vp_size);
|
||||
glm::vec2 all_windows_center(all_windows_rect.GetCenter().x, all_windows_rect.GetCenter().y);
|
||||
glm::vec2 layer_center(layer_rect.GetCenter().x, layer_rect.GetCenter().y);
|
||||
|
||||
glm::vec3 new_position = i.position + i.orientation * glm::vec3((all_windows_center - layer_center) * pixel_size, 0);
|
||||
glm::vec2 new_size = glm::vec2(all_windows_rect.GetWidth(), all_windows_rect.GetHeight()) * pixel_size;
|
||||
|
||||
if (not visible)
|
||||
continue;
|
||||
|
||||
@@ -955,12 +1038,12 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
|
||||
.swapchain = swapchain,
|
||||
.imageRect = {
|
||||
.offset = {
|
||||
.x = i.vp_origin.x,
|
||||
.y = i.vp_origin.y,
|
||||
.x = int(all_windows_rect.Min.x),
|
||||
.y = int(all_windows_rect.Min.y),
|
||||
},
|
||||
.extent = {
|
||||
.width = i.vp_size.x,
|
||||
.height = i.vp_size.y,
|
||||
.width = int(all_windows_rect.Max.x - all_windows_rect.Min.x),
|
||||
.height = int(all_windows_rect.Max.y - all_windows_rect.Min.y),
|
||||
}},
|
||||
},
|
||||
.pose = {
|
||||
@@ -971,14 +1054,14 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
|
||||
.w = i.orientation.w,
|
||||
},
|
||||
.position = {
|
||||
.x = i.position.x,
|
||||
.y = i.position.y,
|
||||
.z = i.position.z,
|
||||
.x = new_position.x,
|
||||
.y = new_position.y,
|
||||
.z = new_position.z,
|
||||
},
|
||||
},
|
||||
.size = {
|
||||
.width = i.size.x,
|
||||
.height = i.size.y,
|
||||
.width = new_size.x,
|
||||
.height = new_size.y,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -986,6 +1069,50 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
|
||||
return quads;
|
||||
}
|
||||
|
||||
std::vector<imgui_context::window_viewport> imgui_context::windows()
|
||||
{
|
||||
std::vector<imgui_context::window_viewport> w;
|
||||
|
||||
for (const imgui_context::viewport & layer: layers_)
|
||||
{
|
||||
if (layer.space != xr::spaces::world)
|
||||
continue;
|
||||
|
||||
ImRect v(layer.vp_origin.x, layer.vp_origin.y, layer.vp_origin.x + layer.vp_size.x, layer.vp_origin.y + layer.vp_size.y);
|
||||
|
||||
for (ImGuiWindow * window: context->Windows)
|
||||
{
|
||||
if (not window->Active or window->Hidden or (window->Flags & ImGuiWindowFlags_ChildWindow))
|
||||
continue;
|
||||
|
||||
if (not window_intersects_viewport(window, layer))
|
||||
continue;
|
||||
|
||||
// The window intersects the viewport: compute the window position in the real world
|
||||
ImVec2 max = ImMin(v.Max, window->Pos + window->Size);
|
||||
ImVec2 min = ImMax(v.Min, window->Pos);
|
||||
ImVec2 center = (min + max) / 2;
|
||||
|
||||
w.push_back(window_viewport{
|
||||
.space = layer.space,
|
||||
.position = layer.position +
|
||||
glm::mat3_cast(layer.orientation) *
|
||||
glm::vec3(
|
||||
((center.x - layer.vp_origin.x) / layer.vp_size.x - 0.5) * layer.size.x,
|
||||
(-(center.y - layer.vp_origin.y) / layer.vp_size.y + 0.5) * layer.size.y,
|
||||
0),
|
||||
.orientation = layer.orientation,
|
||||
.size = {
|
||||
(max.x - min.x) * layer.size.x / layer.vp_size.x,
|
||||
(max.y - min.y) * layer.size.y / layer.vp_size.y,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
void imgui_context::vibrate_on_hover()
|
||||
{
|
||||
if (ImGui::IsItemHovered())
|
||||
@@ -1020,22 +1147,26 @@ imgui_context::~imgui_context()
|
||||
ImGui::DestroyContext(context);
|
||||
}
|
||||
|
||||
ImTextureID imgui_context::load_texture(const std::string & filename, vk::raii::Sampler && sampler)
|
||||
ImTextureID imgui_textures::load_texture(const std::string & filename, vk::raii::Sampler && sampler)
|
||||
{
|
||||
return load_texture(std::span<const std::byte>{asset{filename}}, std::move(sampler));
|
||||
return load_texture(utils::mapped_file{filename}, std::move(sampler), filename);
|
||||
}
|
||||
|
||||
ImTextureID imgui_context::load_texture(const std::span<const std::byte> & bytes, vk::raii::Sampler && sampler)
|
||||
ImTextureID imgui_textures::load_texture(const std::span<const std::byte> & bytes, vk::raii::Sampler && sampler, const std::string & name)
|
||||
{
|
||||
bool srgb = true;
|
||||
image_loader loader(physical_device, device, queue, command_pool);
|
||||
loader.load(bytes, srgb);
|
||||
|
||||
std::shared_ptr<loaded_image> image;
|
||||
if (name == "")
|
||||
image = image_cache->load_uncached(bytes, srgb, "", true /* premultiply alpha */);
|
||||
else
|
||||
image = image_cache->load(name, bytes, srgb, name, true /* premultiply alpha */);
|
||||
|
||||
std::shared_ptr<vk::raii::DescriptorSet> ds = descriptor_pool.allocate();
|
||||
|
||||
vk::DescriptorImageInfo image_info{
|
||||
.sampler = *sampler,
|
||||
.imageView = **loader.image_view,
|
||||
.imageView = *image->image_view,
|
||||
.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||
};
|
||||
|
||||
@@ -1053,15 +1184,14 @@ ImTextureID imgui_context::load_texture(const std::span<const std::byte> & bytes
|
||||
id,
|
||||
texture_data{
|
||||
.sampler = std::move(sampler),
|
||||
// .image = std::move(loader.image),
|
||||
.image_view = std::move(loader.image_view),
|
||||
.image = image,
|
||||
.descriptor_set = std::move(ds),
|
||||
});
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
ImTextureID imgui_context::load_texture(const std::span<const std::byte> & bytes)
|
||||
ImTextureID imgui_textures::load_texture(const std::span<const std::byte> & bytes, const std::string & name)
|
||||
{
|
||||
return load_texture(
|
||||
bytes,
|
||||
@@ -1076,10 +1206,11 @@ ImTextureID imgui_context::load_texture(const std::span<const std::byte> & bytes
|
||||
.addressModeW = vk::SamplerAddressMode::eClampToEdge,
|
||||
.borderColor = vk::BorderColor::eFloatTransparentBlack,
|
||||
},
|
||||
});
|
||||
},
|
||||
name);
|
||||
}
|
||||
|
||||
ImTextureID imgui_context::load_texture(const std::string & filename)
|
||||
ImTextureID imgui_textures::load_texture(const std::string & filename)
|
||||
{
|
||||
return load_texture(
|
||||
filename,
|
||||
@@ -1097,7 +1228,7 @@ ImTextureID imgui_context::load_texture(const std::string & filename)
|
||||
});
|
||||
}
|
||||
|
||||
void imgui_context::free_texture(ImTextureID texture)
|
||||
void imgui_textures::free_texture(ImTextureID texture)
|
||||
{
|
||||
textures.erase(texture);
|
||||
}
|
||||
@@ -1134,34 +1265,32 @@ void imgui_context::tooltip(std::string_view text)
|
||||
// FIXME: this is incorrect if we use the docking branch of imgui
|
||||
ImGuiViewport * viewport = ImGui::GetMainViewport();
|
||||
auto & current_layer = layer(ImGui::GetMousePos());
|
||||
auto pos_backup = viewport->Pos;
|
||||
auto size_backup = viewport->Size;
|
||||
viewport->Pos = ImVec2(current_layer.vp_origin.x, current_layer.vp_origin.y);
|
||||
viewport->Size = ImVec2(current_layer.vp_size.x, current_layer.vp_size.y);
|
||||
|
||||
ImVec2 pos{
|
||||
assert(std::ranges::contains(layers_, true, &viewport::tooltip_viewport));
|
||||
auto & tooltip_layer = *std::ranges::find(layers_, true, &viewport::tooltip_viewport);
|
||||
|
||||
// Get the item position before drawing the tooltip (top center)
|
||||
ImVec2 item_position{
|
||||
(ImGui::GetItemRectMin().x + ImGui::GetItemRectMax().x) / 2,
|
||||
ImGui::GetItemRectMin().y - constants::style::tooltip_distance,
|
||||
ImGui::GetItemRectMin().y,
|
||||
};
|
||||
|
||||
auto pos_backup = viewport->Pos;
|
||||
auto size_backup = viewport->Size;
|
||||
viewport->Pos = ImVec2(tooltip_layer.vp_origin.x, tooltip_layer.vp_origin.y);
|
||||
viewport->Size = ImVec2(tooltip_layer.vp_size.x, tooltip_layer.vp_size.y);
|
||||
|
||||
// Draw the tooltip in the tooltip layer
|
||||
// Clamp position to avoid overflowing on the left or the right
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::tooltip_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, constants::style::tooltip_rounding);
|
||||
|
||||
// Clamp position to avoid overflowing on the left or the right
|
||||
auto & style = ImGui::GetStyle();
|
||||
const ImVec2 text_size = ImGui::CalcTextSize(text.data(), text.data() + text.size(), true);
|
||||
const ImVec2 size = {text_size.x + style.WindowPadding.x * 2.0f, text_size.y + style.WindowPadding.y * 2.0f};
|
||||
pos.x = std::clamp<float>(pos.x, viewport->Pos.x + size.x / 2, viewport->Pos.x + viewport->Size.x - size.x / 2);
|
||||
ImVec2 pivot = {0.5, 1};
|
||||
const ImVec2 tooltip_size = {text_size.x + style.WindowPadding.x * 2.0f, text_size.y + style.WindowPadding.y * 2.0f};
|
||||
|
||||
// Move tooltip below the item if it overflows on the top
|
||||
if (pos.y - size.y <= viewport->Pos.y)
|
||||
{
|
||||
pos.y = ImGui::GetItemRectMax().y + constants::style::tooltip_distance;
|
||||
pivot.y = 0;
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot);
|
||||
ImGui::SetNextWindowPos(viewport->Pos + viewport->Size * 0.5, ImGuiCond_Always, {0.5, 0.5});
|
||||
ImGui::SetNextWindowSizeConstraints({0, 0}, viewport->Size);
|
||||
if (ImGui::BeginTooltip())
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, 0xffffffff);
|
||||
@@ -1169,9 +1298,161 @@ void imgui_context::tooltip(std::string_view text)
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
viewport->Pos = pos_backup;
|
||||
viewport->Size = size_backup;
|
||||
|
||||
// Compute the tooltip position
|
||||
glm::quat tooltip_orientation = current_layer.orientation;
|
||||
auto M = glm::mat3_cast(tooltip_orientation);
|
||||
|
||||
float pixel_size = current_layer.size.y / current_layer.vp_size.y;
|
||||
glm::vec3 tooltip_position_centre = rw_from_vp(item_position) + M * (glm::vec3(0, tooltip_size.y / 2, 0) * pixel_size + constants::style::tooltip_distance);
|
||||
|
||||
// Position the tooltip layer
|
||||
tooltip_layer.position = tooltip_position_centre;
|
||||
tooltip_layer.orientation = tooltip_orientation;
|
||||
}
|
||||
|
||||
// https://github.com/ocornut/imgui/issues/3379#issuecomment-2943903877
|
||||
void ScrollWhenDragging()
|
||||
{
|
||||
ImVec2 delta{0.0f, -ImGui::GetIO().MouseDelta.y};
|
||||
const ImGuiMouseButton mouse_button = ImGuiMouseButton_Left;
|
||||
|
||||
ImGuiContext & g = *ImGui::GetCurrentContext();
|
||||
ImGuiWindow * window = g.CurrentWindow;
|
||||
ImGuiID id = window->GetID("##scrolldraggingoverlay");
|
||||
ImGui::KeepAliveID(id);
|
||||
|
||||
static int active_id;
|
||||
static ImVec2 cumulated_delta;
|
||||
|
||||
bool HoveredIdAllowOverlap_backup = std::exchange(g.HoveredIdAllowOverlap, true);
|
||||
bool ActiveIdAllowOverlap_backup = std::exchange(g.ActiveIdAllowOverlap, true);
|
||||
if (active_id == 0 and ImGui::ItemHoverable(window->Rect(), 0, g.CurrentItemFlags) and ImGui::IsMouseClicked(mouse_button, ImGuiInputFlags_None, /*id*/ ImGuiKeyOwner_Any))
|
||||
{
|
||||
active_id = id;
|
||||
|
||||
// Don't scroll on the first step, in case the active controller just changed
|
||||
delta = {};
|
||||
cumulated_delta = {};
|
||||
}
|
||||
|
||||
if (not g.IO.MouseDown[mouse_button])
|
||||
active_id = 0;
|
||||
|
||||
if (active_id == id)
|
||||
{
|
||||
if (delta.x != 0.0f)
|
||||
ImGui::SetScrollX(window, window->Scroll.x + delta.x);
|
||||
if (delta.y != 0.0f)
|
||||
ImGui::SetScrollY(window, window->Scroll.y + delta.y);
|
||||
|
||||
cumulated_delta += delta;
|
||||
if (std::max(std::abs(cumulated_delta.x), std::abs(cumulated_delta.y)) > 50)
|
||||
ImGui::ClearActiveID();
|
||||
}
|
||||
|
||||
g.HoveredIdAllowOverlap = HoveredIdAllowOverlap_backup;
|
||||
g.ActiveIdAllowOverlap = ActiveIdAllowOverlap_backup;
|
||||
}
|
||||
|
||||
void CenterTextH(const std::string & text)
|
||||
{
|
||||
float win_width = ImGui::GetWindowSize().x;
|
||||
|
||||
std::vector<std::string> lines = utils::split(text);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {0, 0});
|
||||
for (const auto & i: lines)
|
||||
{
|
||||
float text_width = ImGui::CalcTextSize(i.c_str()).x;
|
||||
ImGui::SetCursorPosX((win_width - text_width) / 2);
|
||||
ImGui::Text("%s", i.c_str());
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::Dummy({}); // Make sure the original vertical ItemSpacing is respected
|
||||
}
|
||||
|
||||
void CenterTextHV(const std::string & text)
|
||||
{
|
||||
ImVec2 size = ImGui::GetWindowSize();
|
||||
|
||||
std::vector<std::string> lines = utils::split(text);
|
||||
|
||||
float text_height = 0;
|
||||
for (const auto & i: lines)
|
||||
text_height += ImGui::CalcTextSize(i.c_str()).y;
|
||||
|
||||
ImGui::SetCursorPosY((size.y - text_height) / 2);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {0, 0});
|
||||
for (const auto & i: lines)
|
||||
{
|
||||
float text_width = ImGui::CalcTextSize(i.c_str()).x;
|
||||
ImGui::SetCursorPosX((size.x - text_width) / 2);
|
||||
ImGui::Text("%s", i.c_str());
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void InputText(const char * label, std::string & text, const ImVec2 & size, ImGuiInputTextFlags flags)
|
||||
{
|
||||
auto callback = [](ImGuiInputTextCallbackData * data) -> int {
|
||||
std::string & text = *reinterpret_cast<std::string *>(data->UserData);
|
||||
|
||||
if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
|
||||
{
|
||||
assert(text.data() == data->Buf);
|
||||
text.resize(data->BufTextLen);
|
||||
data->Buf = text.data();
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
ImGui::InputTextEx(label, nullptr, text.data(), text.size() + 1, size, flags | ImGuiInputTextFlags_CallbackResize, callback, &text);
|
||||
}
|
||||
|
||||
bool RadioButtonWithoutCheckBox(const std::string & label, bool active, ImVec2 size_arg)
|
||||
{
|
||||
ImGuiWindow * window = ImGui::GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiContext & g = *GImGui;
|
||||
const ImGuiStyle & style = g.Style;
|
||||
const ImGuiID id = window->GetID(label.c_str());
|
||||
const ImVec2 label_size = ImGui::CalcTextSize(label.c_str(), NULL, true);
|
||||
|
||||
const ImVec2 pos = window->DC.CursorPos;
|
||||
|
||||
ImVec2 size = ImGui::CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f);
|
||||
|
||||
const ImRect bb(pos, pos + size);
|
||||
ImGui::ItemSize(bb, style.FramePadding.y);
|
||||
if (!ImGui::ItemAdd(bb, id))
|
||||
return false;
|
||||
|
||||
bool hovered, held;
|
||||
bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held);
|
||||
|
||||
ImGuiCol_ col;
|
||||
if ((held && hovered) || active)
|
||||
col = ImGuiCol_ButtonActive;
|
||||
else if (hovered)
|
||||
col = ImGuiCol_ButtonHovered;
|
||||
else
|
||||
col = ImGuiCol_Button;
|
||||
|
||||
ImGui::RenderNavHighlight(bb, id);
|
||||
ImGui::RenderFrame(bb.Min, bb.Max, ImGui::GetColorU32(col), true, style.FrameRounding);
|
||||
|
||||
ImVec2 TextAlign{0, 0.5f};
|
||||
ImGui::RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label.c_str(), NULL, &label_size, TextAlign, &bb);
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label.c_str(), g.LastItemData.StatusFlags);
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "image_loader.h"
|
||||
#include "render/growable_descriptor_pool.h"
|
||||
#include "utils/cache.h"
|
||||
#include "utils/thread_safe.h"
|
||||
#include "wivrn_config.h"
|
||||
#include "xr/hand_tracker.h"
|
||||
@@ -36,7 +38,45 @@
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
class imgui_context
|
||||
class imgui_textures
|
||||
{
|
||||
struct texture_data
|
||||
{
|
||||
vk::raii::Sampler sampler;
|
||||
std::shared_ptr<loaded_image> image;
|
||||
std::shared_ptr<vk::raii::DescriptorSet> descriptor_set;
|
||||
};
|
||||
|
||||
protected:
|
||||
vk::raii::PhysicalDevice physical_device;
|
||||
vk::raii::Device & device;
|
||||
thread_safe<vk::raii::Queue> & queue;
|
||||
vk::raii::DescriptorSetLayout ds_layout;
|
||||
vk::raii::CommandPool command_pool;
|
||||
|
||||
using image_cache_type = utils::cache<std::string, loaded_image, image_loader>;
|
||||
std::shared_ptr<image_cache_type> image_cache;
|
||||
|
||||
private:
|
||||
growable_descriptor_pool descriptor_pool;
|
||||
std::unordered_map<ImTextureID, texture_data> textures;
|
||||
|
||||
public:
|
||||
imgui_textures(
|
||||
vk::raii::PhysicalDevice physical_device,
|
||||
vk::raii::Device & device,
|
||||
uint32_t queue_family_index,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
std::shared_ptr<image_cache_type> image_cache = {});
|
||||
~imgui_textures();
|
||||
ImTextureID load_texture(const std::string & filename, vk::raii::Sampler && sampler);
|
||||
ImTextureID load_texture(const std::string & filename);
|
||||
ImTextureID load_texture(const std::span<const std::byte> & bytes, vk::raii::Sampler && sampler, const std::string & name = "");
|
||||
ImTextureID load_texture(const std::span<const std::byte> & bytes, const std::string & name = "");
|
||||
void free_texture(ImTextureID);
|
||||
};
|
||||
|
||||
class imgui_context : public imgui_textures
|
||||
{
|
||||
struct command_buffer
|
||||
{
|
||||
@@ -44,13 +84,6 @@ class imgui_context
|
||||
vk::raii::Fence fence = nullptr;
|
||||
};
|
||||
|
||||
struct texture_data
|
||||
{
|
||||
vk::raii::Sampler sampler;
|
||||
std::shared_ptr<vk::raii::ImageView> image_view;
|
||||
std::shared_ptr<vk::raii::DescriptorSet> descriptor_set;
|
||||
};
|
||||
|
||||
public:
|
||||
struct imgui_frame
|
||||
{
|
||||
@@ -76,8 +109,6 @@ public:
|
||||
|
||||
struct controller_state
|
||||
{
|
||||
bool active = false;
|
||||
|
||||
glm::vec3 aim_position = {0, 0, 0};
|
||||
glm::quat aim_orientation = {1, 0, 0, 0};
|
||||
|
||||
@@ -85,11 +116,10 @@ public:
|
||||
glm::vec2 scroll_value = {0, 0};
|
||||
|
||||
std::optional<ImVec2> pointer_position;
|
||||
float hover_distance = 1e10;
|
||||
// float hover_distance = 1e10;
|
||||
|
||||
bool squeeze_clicked = false;
|
||||
bool trigger_clicked = false;
|
||||
bool fingertip_hovering = false;
|
||||
bool fingertip_touching = false;
|
||||
ImGuiMouseSource source = ImGuiMouseSource_Mouse;
|
||||
};
|
||||
@@ -107,6 +137,7 @@ public:
|
||||
glm::ivec2 vp_size;
|
||||
|
||||
bool always_show_cursor = false; // Show the cursor in this viewport even if there is a modal popup elsewhere (eg. this is a virtual keyboard)
|
||||
bool tooltip_viewport = false; // Choose this viewport to display the tooltip, ignore mouse events
|
||||
|
||||
int z_index = 0;
|
||||
|
||||
@@ -116,19 +147,20 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct window_viewport
|
||||
{
|
||||
// Position of this window in the world
|
||||
xr::spaces space;
|
||||
glm::vec3 position;
|
||||
glm::quat orientation;
|
||||
glm::vec2 size;
|
||||
};
|
||||
|
||||
private:
|
||||
vk::raii::PhysicalDevice physical_device;
|
||||
vk::raii::Device & device;
|
||||
uint32_t queue_family_index;
|
||||
thread_safe<vk::raii::Queue> & queue;
|
||||
|
||||
vk::raii::Pipeline pipeline = nullptr;
|
||||
vk::raii::DescriptorSetLayout ds_layout;
|
||||
growable_descriptor_pool descriptor_pool;
|
||||
vk::raii::RenderPass renderpass;
|
||||
vk::raii::CommandPool command_pool;
|
||||
|
||||
std::unordered_map<ImTextureID, texture_data> textures;
|
||||
|
||||
std::vector<imgui_frame> frames;
|
||||
imgui_frame & get_frame(vk::Image destination);
|
||||
@@ -146,7 +178,7 @@ private:
|
||||
|
||||
std::vector<viewport> layers_;
|
||||
|
||||
xr::swapchain & swapchain;
|
||||
xr::swapchain swapchain;
|
||||
int image_index;
|
||||
|
||||
ImGuiContext * context;
|
||||
@@ -162,6 +194,8 @@ private:
|
||||
bool button_pressed = false;
|
||||
bool fingertip_touching = false;
|
||||
|
||||
std::array<float, 2> aim_interaction = {1, 1}; // left, right, floating point to fade the cursor position between poking and hand interaction
|
||||
|
||||
ImGuiID hovered_item = 0; // Hovered item in the current frame, reset at the beginning of the frame
|
||||
ImGuiID hovered_item_prev = 0; // Hovered item at the previous frame
|
||||
|
||||
@@ -181,8 +215,9 @@ public:
|
||||
uint32_t queue_family_index,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
std::span<controller> controllers,
|
||||
xr::swapchain & swapchain,
|
||||
std::vector<viewport> layers);
|
||||
xr::swapchain && swapchain,
|
||||
std::vector<viewport> layers,
|
||||
std::shared_ptr<imgui_textures::image_cache_type> image_cache);
|
||||
|
||||
~imgui_context();
|
||||
|
||||
@@ -191,6 +226,8 @@ public:
|
||||
return layers_;
|
||||
}
|
||||
|
||||
std::vector<window_viewport> windows();
|
||||
|
||||
viewport & layer(ImVec2 position);
|
||||
|
||||
void new_frame(XrTime display_time);
|
||||
@@ -202,16 +239,11 @@ public:
|
||||
}
|
||||
|
||||
std::vector<std::pair<ImVec2, float>> ray_plane_intersection(const controller_state & in) const;
|
||||
void compute_pointer_position(controller_state & state);
|
||||
[[nodiscard]] std::pair<std::optional<ImVec2>, float> compute_pointer_position(const controller_state & state) const;
|
||||
|
||||
// Convert position from viewport coordinates to real-world
|
||||
glm::vec3 rw_from_vp(const ImVec2 & position);
|
||||
|
||||
ImTextureID load_texture(const std::string & filename, vk::raii::Sampler && sampler);
|
||||
ImTextureID load_texture(const std::string & filename);
|
||||
ImTextureID load_texture(const std::span<const std::byte> & bytes, vk::raii::Sampler && sampler);
|
||||
ImTextureID load_texture(const std::span<const std::byte> & bytes);
|
||||
void free_texture(ImTextureID);
|
||||
void set_current();
|
||||
|
||||
bool is_modal_popup_shown() const;
|
||||
@@ -220,4 +252,27 @@ public:
|
||||
void set_hovered_item();
|
||||
void set_controllers_enabled(bool value);
|
||||
void tooltip(std::string_view text);
|
||||
std::array<bool, 2> is_aim_interaction() const
|
||||
{
|
||||
return {aim_interaction[0] == 1, aim_interaction[1] == 1};
|
||||
}
|
||||
};
|
||||
|
||||
void ScrollWhenDragging();
|
||||
|
||||
void CenterTextH(const std::string & text);
|
||||
|
||||
void CenterTextHV(const std::string & text);
|
||||
|
||||
void InputText(const char * label, std::string & text, const ImVec2 & size, ImGuiInputTextFlags flags);
|
||||
|
||||
bool RadioButtonWithoutCheckBox(const std::string & label, bool active, ImVec2 size_arg);
|
||||
|
||||
template <typename T, typename U>
|
||||
static bool RadioButtonWithoutCheckBox(const std::string & label, T & v, U v_button, ImVec2 size_arg)
|
||||
{
|
||||
const bool pressed = RadioButtonWithoutCheckBox(label, v == v_button, size_arg);
|
||||
if (pressed)
|
||||
v = v_button;
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <inplace_vector.hpp>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include <entt/entity/entity.hpp>
|
||||
@@ -28,6 +32,7 @@
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
#include "utils/magic_hash.h"
|
||||
#include "vertex_layout.h"
|
||||
#include "vk/allocation.h"
|
||||
|
||||
namespace renderer
|
||||
@@ -51,6 +56,14 @@ struct texture
|
||||
|
||||
struct material
|
||||
{
|
||||
struct alignas(16) texture_info
|
||||
{
|
||||
alignas(4) uint32_t texcoord = 0;
|
||||
alignas(4) float rotation = 0;
|
||||
alignas(8) glm::vec2 offset = {0, 0};
|
||||
alignas(8) glm::vec2 scale = {1, 1};
|
||||
};
|
||||
|
||||
struct gpu_data
|
||||
{
|
||||
glm::vec4 base_color_factor = glm::vec4(1, 1, 1, 1);
|
||||
@@ -58,15 +71,14 @@ struct material
|
||||
float metallic_factor = 1;
|
||||
float roughness_factor = 1;
|
||||
float occlusion_strength = 0;
|
||||
float normal_scale = 0;
|
||||
float normal_scale = 1;
|
||||
float alpha_cutoff = 0.5;
|
||||
|
||||
uint32_t base_color_texcoord = 0;
|
||||
uint32_t metallic_roughness_texcoord = 0;
|
||||
uint32_t occlusion_texcoord = 0;
|
||||
uint32_t emissive_texcoord = 0;
|
||||
uint32_t normal_texcoord = 0;
|
||||
|
||||
// TODO: add fastgltf::TextureTransform?
|
||||
texture_info base_color;
|
||||
texture_info metallic_roughness;
|
||||
texture_info occlusion;
|
||||
texture_info emissive;
|
||||
texture_info normal;
|
||||
};
|
||||
|
||||
std::shared_ptr<texture> base_color_texture;
|
||||
@@ -78,9 +90,9 @@ struct material
|
||||
// Disable back face culling with this material
|
||||
bool double_sided = true;
|
||||
|
||||
// TODO transparency
|
||||
// fastgltf::AlphaMode alphaMode;
|
||||
// float alpha_cutoff;
|
||||
bool blend_enable = false;
|
||||
bool depth_test_enable = true;
|
||||
bool depth_write_enable = true;
|
||||
|
||||
gpu_data staging;
|
||||
|
||||
@@ -88,17 +100,8 @@ struct material
|
||||
std::shared_ptr<buffer_allocation> buffer;
|
||||
size_t offset;
|
||||
|
||||
// The descriptor set is managed by the scene renderer, it is updated whenever ds_dirty is true
|
||||
// Bindings 0-4: textures
|
||||
// Binding 5: uniform buffer
|
||||
std::shared_ptr<vk::raii::DescriptorSet> ds;
|
||||
|
||||
// Set to true to update the descriptor set at the next frame
|
||||
bool ds_dirty;
|
||||
|
||||
std::string name;
|
||||
std::string shader_name = "lit";
|
||||
bool blend_enable = true;
|
||||
std::string fragment_shader = "lit.frag";
|
||||
};
|
||||
|
||||
struct primitive
|
||||
@@ -108,7 +111,13 @@ struct primitive
|
||||
uint32_t vertex_count;
|
||||
vk::IndexType index_type;
|
||||
vk::DeviceSize index_offset;
|
||||
vk::DeviceSize vertex_offset;
|
||||
beman::inplace_vector::inplace_vector<vk::DeviceSize, 8> vertex_offset; // See VkPhysicalDeviceLimits::maxVertexInputBindings
|
||||
vertex_layout layout;
|
||||
|
||||
glm::vec3 obb_min;
|
||||
glm::vec3 obb_max;
|
||||
|
||||
std::string vertex_shader;
|
||||
|
||||
// See also material::double_sided
|
||||
vk::CullModeFlagBits cull_mode = vk::CullModeFlagBits::eNone;
|
||||
@@ -118,34 +127,12 @@ struct primitive
|
||||
std::shared_ptr<material> material_;
|
||||
};
|
||||
|
||||
// TODO make sure the mesh cannot be changed while it is used
|
||||
struct mesh
|
||||
{
|
||||
std::vector<primitive> primitives;
|
||||
std::shared_ptr<buffer_allocation> buffer;
|
||||
};
|
||||
|
||||
// TODO move vertex class in .cpp, put vertex description in the primitive
|
||||
struct vertex
|
||||
{
|
||||
glm::vec3 position;
|
||||
glm::vec3 normal;
|
||||
glm::vec3 tangent;
|
||||
std::array<glm::vec2, 2> texcoord;
|
||||
glm::vec4 color;
|
||||
std::array<glm::vec4, 1> joints;
|
||||
std::array<glm::vec4, 1> weights;
|
||||
|
||||
struct description
|
||||
{
|
||||
vk::VertexInputBindingDescription binding;
|
||||
std::vector<vk::VertexInputAttributeDescription> attributes;
|
||||
std::vector<std::string> attribute_names;
|
||||
|
||||
vk::PipelineVertexInputStateCreateFlags flags{};
|
||||
};
|
||||
|
||||
static description describe();
|
||||
};
|
||||
} // namespace renderer
|
||||
|
||||
namespace std
|
||||
@@ -169,17 +156,79 @@ struct node
|
||||
bool visible = true;
|
||||
uint32_t layer_mask = -1;
|
||||
|
||||
std::array<glm::vec4, 4> clipping_planes;
|
||||
|
||||
// TODO: separate component?
|
||||
std::vector<std::pair<entt::entity, glm::mat4>> joints; // Node index, inverse bind matrix of each joint
|
||||
|
||||
std::vector<std::byte> extra_shader_data;
|
||||
template <typename T>
|
||||
void set_extra_shader_data(const T & data)
|
||||
{
|
||||
extra_shader_data.resize(sizeof(std::decay_t<T>));
|
||||
memcpy(extra_shader_data.data(), &data, sizeof(std::decay_t<T>));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T & get_extra_shader_data()
|
||||
{
|
||||
assert(extra_shader_data.size() == sizeof(std::decay_t<T>));
|
||||
return *reinterpret_cast<T *>(extra_shader_data.data());
|
||||
}
|
||||
|
||||
// For internal use by the renderer
|
||||
glm::mat4 transform_to_root;
|
||||
bool global_visible;
|
||||
bool reverse_side;
|
||||
uint32_t global_layer_mask;
|
||||
};
|
||||
|
||||
struct animation_track_base
|
||||
{
|
||||
enum class interpolation_t
|
||||
{
|
||||
step,
|
||||
linear,
|
||||
cubic_spline,
|
||||
};
|
||||
|
||||
entt::entity target;
|
||||
interpolation_t interpolation;
|
||||
};
|
||||
|
||||
template <auto node::* Field>
|
||||
struct animation_track_impl : animation_track_base
|
||||
{
|
||||
static const constexpr auto field = Field;
|
||||
using type = std::remove_reference_t<decltype(std::declval<node>().*field)>;
|
||||
|
||||
std::vector<float> timestamp;
|
||||
std::vector<type> value;
|
||||
};
|
||||
|
||||
using animation_track_position = animation_track_impl<&node::position>;
|
||||
using animation_track_orientation = animation_track_impl<&node::orientation>;
|
||||
using animation_track_scale = animation_track_impl<&node::scale>;
|
||||
|
||||
static_assert(std::is_same_v<animation_track_position::type, glm::vec3>);
|
||||
static_assert(std::is_same_v<animation_track_orientation::type, glm::quat>);
|
||||
static_assert(std::is_same_v<animation_track_scale::type, glm::vec3>);
|
||||
|
||||
struct animation
|
||||
{
|
||||
std::string name;
|
||||
std::vector<
|
||||
std::variant<
|
||||
animation_track_position,
|
||||
animation_track_orientation,
|
||||
animation_track_scale>>
|
||||
tracks;
|
||||
|
||||
float duration = 0;
|
||||
|
||||
float current_time = 0;
|
||||
bool playing = true;
|
||||
bool looping = true;
|
||||
};
|
||||
|
||||
} // namespace components
|
||||
|
||||
entt::entity find_node_by_name(entt::registry & scene, std::string_view name);
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <entt/core/fwd.hpp>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
#include "scene_components.h"
|
||||
@@ -31,17 +33,29 @@ class scene_loader
|
||||
thread_safe<vk::raii::Queue> & queue;
|
||||
uint32_t queue_family_index;
|
||||
std::shared_ptr<renderer::material> default_material;
|
||||
std::filesystem::path texture_cache;
|
||||
|
||||
std::shared_ptr<entt::registry> operator()(
|
||||
std::span<const std::byte> data,
|
||||
const std::string & name = "",
|
||||
const std::filesystem::path & parent_path = "",
|
||||
const std::filesystem::path & gltf_texture_cache = "",
|
||||
std::function<void(float)> progress_cb = {});
|
||||
|
||||
public:
|
||||
scene_loader(vk::raii::Device & device, vk::raii::PhysicalDevice physical_device, thread_safe<vk::raii::Queue> & queue, uint32_t queue_family_index, std::shared_ptr<renderer::material> default_material) :
|
||||
device(device),
|
||||
physical_device(physical_device),
|
||||
queue(queue),
|
||||
queue_family_index(queue_family_index),
|
||||
default_material(default_material)
|
||||
{}
|
||||
scene_loader(
|
||||
vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice physical_device,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
uint32_t queue_family_index,
|
||||
std::shared_ptr<renderer::material> default_material,
|
||||
std::filesystem::path texture_cache);
|
||||
|
||||
entt::registry operator()(const std::filesystem::path & gltf_path);
|
||||
scene_loader(const scene_loader &) = default;
|
||||
|
||||
void add_prefab(entt::registry & scene, const entt::registry & prefab, entt::entity root = entt::null);
|
||||
std::shared_ptr<entt::registry> operator()(
|
||||
const std::filesystem::path & gltf_path,
|
||||
std::function<void(float)> progress_cb = {});
|
||||
|
||||
void clear_texture_cache();
|
||||
};
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "render/vertex_layout.h"
|
||||
#include "utils/cache.h"
|
||||
#include "vk/shader.h"
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <glm/mat4x4.hpp>
|
||||
@@ -32,7 +35,6 @@
|
||||
|
||||
#include "vk/allocation.h"
|
||||
|
||||
#include "render/growable_descriptor_pool.h"
|
||||
#include "render/scene_components.h"
|
||||
#include "utils/thread_safe.h"
|
||||
|
||||
@@ -42,6 +44,7 @@ struct renderpass_info
|
||||
vk::Format depth_format;
|
||||
bool keep_depth_buffer;
|
||||
vk::SampleCountFlagBits msaa_samples = vk::SampleCountFlagBits::e1;
|
||||
uint32_t multiview_count;
|
||||
|
||||
bool operator==(const renderpass_info & other) const noexcept = default;
|
||||
};
|
||||
@@ -50,7 +53,9 @@ struct pipeline_info
|
||||
{
|
||||
renderpass_info renderpass;
|
||||
|
||||
std::string shader_name;
|
||||
std::string vertex_shader_name;
|
||||
std::string fragment_shader_name;
|
||||
renderer::vertex_layout vertex_layout;
|
||||
|
||||
vk::CullModeFlags cull_mode = vk::CullModeFlagBits::eNone;
|
||||
vk::FrontFace front_face = vk::FrontFace::eClockwise;
|
||||
@@ -75,7 +80,6 @@ struct output_image_info
|
||||
vk::Extent2D output_size;
|
||||
VkImage color;
|
||||
VkImage depth;
|
||||
uint32_t base_array_layer;
|
||||
|
||||
bool operator==(const output_image_info & other) const noexcept = default;
|
||||
};
|
||||
@@ -99,12 +103,16 @@ struct hash<output_image_info> : utils::magic_hash<output_image_info>
|
||||
{};
|
||||
} // namespace std
|
||||
|
||||
struct image_loader;
|
||||
|
||||
class scene_renderer
|
||||
{
|
||||
vk::raii::PhysicalDevice physical_device;
|
||||
vk::raii::Device & device;
|
||||
vk::PhysicalDeviceProperties physical_device_properties;
|
||||
thread_safe<vk::raii::Queue> & queue;
|
||||
uint32_t queue_family_index;
|
||||
vk::raii::CommandPool cb_pool;
|
||||
|
||||
// Destination images
|
||||
struct output_image
|
||||
@@ -119,30 +127,37 @@ class scene_renderer
|
||||
vk::raii::ImageView multisample_view = nullptr;
|
||||
};
|
||||
|
||||
struct renderpass
|
||||
{
|
||||
vk::raii::RenderPass renderpass = nullptr;
|
||||
vk::AttachmentReference color_attachment;
|
||||
vk::AttachmentReference depth_attachment;
|
||||
std::optional<vk::AttachmentReference> resolve_attachment; // Only used if MSAA is enabled
|
||||
std::optional<vk::AttachmentReference> fragment_density_attachment; // Only used if fragment density map is enabled
|
||||
int attachment_count;
|
||||
};
|
||||
|
||||
// Initialization functions
|
||||
output_image create_output_image_data(const output_image_info & info);
|
||||
vk::raii::RenderPass create_renderpass(const renderpass_info & info);
|
||||
renderpass create_renderpass(const renderpass_info & info);
|
||||
vk::raii::PipelineLayout create_pipeline_layout(std::span<vk::DescriptorSetLayout> layouts);
|
||||
vk::raii::Pipeline create_pipeline(const pipeline_info & info);
|
||||
|
||||
std::shared_ptr<renderer::texture> create_default_texture(vk::raii::CommandPool & cb_pool, std::vector<uint8_t> pixel);
|
||||
std::shared_ptr<renderer::material> create_default_material(vk::raii::CommandPool & cb_pool);
|
||||
std::shared_ptr<renderer::texture> create_default_texture(image_loader & loader, std::vector<uint8_t> pixel, const std::string & name);
|
||||
std::shared_ptr<renderer::material> create_default_material();
|
||||
vk::raii::DescriptorSetLayout create_descriptor_set_layout(std::span<vk::DescriptorSetLayoutBinding> bindings, vk::DescriptorSetLayoutCreateFlags flags = {});
|
||||
|
||||
// Caches
|
||||
std::unordered_map<renderpass_info, vk::raii::RenderPass> renderpasses;
|
||||
std::unordered_map<renderpass_info, renderpass> renderpasses;
|
||||
std::unordered_map<output_image_info, output_image> output_images;
|
||||
std::unordered_map<pipeline_info, vk::raii::Pipeline> pipelines;
|
||||
utils::cache<std::string, shader, shader_loader> shader_cache;
|
||||
|
||||
output_image & get_output_image_data(const output_image_info & info);
|
||||
vk::raii::Pipeline & get_pipeline(const pipeline_info & info);
|
||||
vk::raii::RenderPass & get_renderpass(const renderpass_info & info);
|
||||
renderpass & get_renderpass(const renderpass_info & info);
|
||||
|
||||
vk::raii::DescriptorSetLayout layout_0; // Descriptor set 0: per-frame/view data (UBO) and per-instance data (UBO + SSBO)
|
||||
vk::raii::DescriptorSetLayout layout_1; // Descriptor set 1: per-material data (5 combined image samplers and 1 uniform buffer)
|
||||
|
||||
// Descriptor set 1: per-material data (5 combined image samplers and 1 uniform buffer)
|
||||
growable_descriptor_pool ds_pool_material;
|
||||
vk::raii::DescriptorSetLayout layout_0; // Descriptor set 0: per-frame/view data (UBO), per-instance data (UBO + SSBO), per-material data (5 combined image samplers and 1 uniform buffer)
|
||||
|
||||
vk::raii::PipelineLayout pipeline_layout = nullptr;
|
||||
|
||||
@@ -164,12 +179,12 @@ class scene_renderer
|
||||
// roughness_factor 1.0
|
||||
// occlusion_strength 0.0
|
||||
// normal_scale 0.0
|
||||
// alpha_cutoff 0.5
|
||||
std::shared_ptr<renderer::material> default_material;
|
||||
|
||||
struct frame_gpu_data
|
||||
{
|
||||
glm::mat4 view;
|
||||
glm::mat4 proj;
|
||||
std::array<glm::mat4, 2> view;
|
||||
glm::vec4 light_position;
|
||||
glm::vec4 ambient_color;
|
||||
glm::vec4 light_color;
|
||||
@@ -178,11 +193,28 @@ class scene_renderer
|
||||
struct instance_gpu_data
|
||||
{
|
||||
glm::mat4 model;
|
||||
glm::mat4 modelview;
|
||||
glm::mat4 modelviewproj;
|
||||
std::array<glm::vec4, 4> clipping_planes;
|
||||
std::array<glm::mat4, 2> modelview;
|
||||
std::array<glm::mat4, 2> modelviewproj;
|
||||
};
|
||||
|
||||
struct debug_draw_vertex
|
||||
{
|
||||
glm::vec4 position;
|
||||
glm::vec4 colour;
|
||||
};
|
||||
|
||||
std::vector<debug_draw_vertex> debug_draw_vertices;
|
||||
|
||||
public:
|
||||
struct stats
|
||||
{
|
||||
size_t count_primitives;
|
||||
size_t count_culled_primitives;
|
||||
size_t count_triangles;
|
||||
size_t count_culled_triangles;
|
||||
};
|
||||
|
||||
private:
|
||||
struct per_frame_resources
|
||||
{
|
||||
vk::raii::Fence fence = nullptr;
|
||||
@@ -194,6 +226,11 @@ class scene_renderer
|
||||
// device local, host visible, host coherent
|
||||
size_t uniform_buffer_offset;
|
||||
buffer_allocation uniform_buffer;
|
||||
|
||||
buffer_allocation debug_draw;
|
||||
|
||||
// Statistics
|
||||
stats frame_stats;
|
||||
};
|
||||
|
||||
std::vector<per_frame_resources> frame_resources;
|
||||
@@ -203,8 +240,6 @@ class scene_renderer
|
||||
|
||||
per_frame_resources & current_frame();
|
||||
|
||||
void update_material_descriptor_set(renderer::material & material);
|
||||
|
||||
public:
|
||||
static vk::Format find_usable_image_format(
|
||||
vk::raii::PhysicalDevice physical_device,
|
||||
@@ -219,7 +254,7 @@ public:
|
||||
vk::raii::Device & device,
|
||||
vk::raii::PhysicalDevice physical_device,
|
||||
thread_safe<vk::raii::Queue> & queue,
|
||||
vk::raii::CommandPool & cb_pool,
|
||||
uint32_t queue_family_index,
|
||||
int frames_in_flight = 2);
|
||||
|
||||
~scene_renderer();
|
||||
@@ -240,9 +275,19 @@ public:
|
||||
vk::Format depth_format,
|
||||
vk::Image color_buffer,
|
||||
vk::Image depth_buffer,
|
||||
std::span<frame_info> info);
|
||||
std::span<frame_info> info,
|
||||
bool render_debug_draws = false);
|
||||
void end_frame();
|
||||
|
||||
void debug_draw_clear();
|
||||
// void debug_draw(std::span<glm::vec3> line, glm::vec4 color);
|
||||
void debug_draw_box(const glm::mat4 & model, glm::vec3 min, glm::vec3 max, glm::vec4 color);
|
||||
|
||||
const stats & last_frame_stats() const
|
||||
{
|
||||
return frame_resources[current_frame_index].frame_stats;
|
||||
}
|
||||
|
||||
double get_gpu_time() const
|
||||
{
|
||||
return gpu_time_s;
|
||||
|
||||
@@ -139,46 +139,42 @@ text_rasterizer::text_rasterizer(vk::raii::Device & device, vk::raii::PhysicalDe
|
||||
|
||||
image_allocation text_rasterizer::create_image(vk::Extent2D size)
|
||||
{
|
||||
image_allocation alloc{device,
|
||||
vk::ImageCreateInfo{
|
||||
.imageType = vk::ImageType::e2D,
|
||||
.format = text::format,
|
||||
.extent = {
|
||||
.width = size.width,
|
||||
.height = size.height,
|
||||
.depth = 1,
|
||||
},
|
||||
.mipLevels = 1,
|
||||
.arrayLayers = 1,
|
||||
.samples = vk::SampleCountFlagBits::e1,
|
||||
.tiling = vk::ImageTiling::eOptimal,
|
||||
.usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst,
|
||||
.sharingMode = vk::SharingMode::eExclusive,
|
||||
.initialLayout = vk::ImageLayout::eUndefined,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.flags = 0,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
}};
|
||||
|
||||
application::set_debug_reports_name<vk::Image>(alloc, "text_rasterizer image");
|
||||
return alloc;
|
||||
return {device,
|
||||
vk::ImageCreateInfo{
|
||||
.imageType = vk::ImageType::e2D,
|
||||
.format = text::format,
|
||||
.extent = {
|
||||
.width = size.width,
|
||||
.height = size.height,
|
||||
.depth = 1,
|
||||
},
|
||||
.mipLevels = 1,
|
||||
.arrayLayers = 1,
|
||||
.samples = vk::SampleCountFlagBits::e1,
|
||||
.tiling = vk::ImageTiling::eOptimal,
|
||||
.usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst,
|
||||
.sharingMode = vk::SharingMode::eExclusive,
|
||||
.initialLayout = vk::ImageLayout::eUndefined,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.flags = 0,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
"text_rasterizer image"};
|
||||
}
|
||||
|
||||
buffer_allocation text_rasterizer::create_buffer(size_t size)
|
||||
{
|
||||
buffer_allocation alloc{device,
|
||||
vk::BufferCreateInfo{
|
||||
.size = size,
|
||||
.usage = vk::BufferUsageFlagBits::eTransferSrc,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
}};
|
||||
application::set_debug_reports_name<vk::Buffer>(alloc, "text_rasterizer buffer");
|
||||
|
||||
return alloc;
|
||||
return {device,
|
||||
vk::BufferCreateInfo{
|
||||
.size = size,
|
||||
.usage = vk::BufferUsageFlagBits::eTransferSrc,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
"text_rasterizer buffer"};
|
||||
}
|
||||
|
||||
text_rasterizer::~text_rasterizer()
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/magic_hash.h"
|
||||
#include <cstddef>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <vulkan/vulkan_format_traits.hpp>
|
||||
|
||||
namespace renderer
|
||||
{
|
||||
struct vertex_layout
|
||||
{
|
||||
std::vector<vk::VertexInputBindingDescription> bindings;
|
||||
std::vector<vk::VertexInputAttributeDescription> attributes;
|
||||
std::vector<std::string> attribute_names;
|
||||
|
||||
void add_attribute(std::string name, vk::Format format, uint32_t binding, uint32_t location, vk::VertexInputRate input_rate, int array_size = 1)
|
||||
{
|
||||
size_t texel_size = vk::blockSize(format);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (auto iter = std::ranges::find(bindings, binding, &vk::VertexInputBindingDescription::binding); iter == bindings.end())
|
||||
bindings.push_back(vk::VertexInputBindingDescription{
|
||||
.binding = binding,
|
||||
.stride = (uint32_t)(texel_size * array_size),
|
||||
.inputRate = input_rate,
|
||||
});
|
||||
else
|
||||
{
|
||||
offset = iter->stride;
|
||||
iter->stride += texel_size * array_size;
|
||||
}
|
||||
|
||||
for (int index = 0; index < array_size; index++)
|
||||
{
|
||||
attributes.push_back(vk::VertexInputAttributeDescription{
|
||||
.location = location + index,
|
||||
.binding = binding,
|
||||
.format = format,
|
||||
.offset = (uint32_t)(offset + index * texel_size),
|
||||
});
|
||||
|
||||
if (array_size == 1)
|
||||
attribute_names.push_back(name);
|
||||
else
|
||||
attribute_names.push_back(name + "_" + std::to_string(index));
|
||||
}
|
||||
}
|
||||
|
||||
void add_vertex_attribute(std::string name, vk::Format format, uint32_t binding, uint32_t location, int array_size = 1)
|
||||
{
|
||||
add_attribute(std::move(name), format, binding, location, vk::VertexInputRate::eVertex, array_size);
|
||||
}
|
||||
|
||||
bool operator==(const vertex_layout & other) const noexcept = default;
|
||||
};
|
||||
} // namespace renderer
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<renderer::vertex_layout> : utils::magic_hash<renderer::vertex_layout>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct hash<vk::VertexInputBindingDescription> : utils::magic_hash<vk::VertexInputBindingDescription>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct hash<vk::VertexInputAttributeDescription> : utils::magic_hash<vk::VertexInputAttributeDescription>
|
||||
{};
|
||||
} // namespace std
|
||||
@@ -18,16 +18,17 @@
|
||||
*/
|
||||
|
||||
#include "scene.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "render/scene_loader.h"
|
||||
#include "render/scene_components.h"
|
||||
#include "utils/contains.h"
|
||||
#include "utils/i18n.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "utils/ranges.h"
|
||||
#include <entt/core/fwd.hpp>
|
||||
#include <magic_enum.hpp>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
#include <vulkan/vulkan_structs.hpp>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
// TODO remove constants
|
||||
@@ -37,7 +38,7 @@ std::vector<scene::meta *> scene::scene_registry;
|
||||
|
||||
scene::~scene() {}
|
||||
|
||||
scene::scene(key, const meta & current_meta, std::span<const vk::Format> supported_color_formats, std::span<const vk::Format> supported_depth_formats) :
|
||||
scene::scene(key, const meta & current_meta, std::span<const vk::Format> supported_color_formats, std::span<const vk::Format> supported_depth_formats, scene * parent_scene) :
|
||||
instance(application::instance().xr_instance),
|
||||
system(application::instance().xr_system_id),
|
||||
session(application::instance().xr_session),
|
||||
@@ -47,12 +48,10 @@ scene::scene(key, const meta & current_meta, std::span<const vk::Format> support
|
||||
device(application::instance().vk_device),
|
||||
physical_device(application::instance().vk_physical_device),
|
||||
queue(application::instance().vk_queue),
|
||||
commandpool(application::instance().vk_cmdpool),
|
||||
queue_family_index(application::instance().vk_queue_family_index),
|
||||
commandpool(application::instance().vk_cmdpool),
|
||||
current_meta(current_meta)
|
||||
{
|
||||
passthrough_supported = system.passthrough_supported();
|
||||
|
||||
swapchain_format = vk::Format::eUndefined;
|
||||
spdlog::info("Supported swapchain formats:");
|
||||
|
||||
@@ -89,6 +88,19 @@ scene::scene(key, const meta & current_meta, std::span<const vk::Format> support
|
||||
instance.has_extension(XR_FB_COMPOSITION_LAYER_DEPTH_TEST_EXTENSION_NAME);
|
||||
|
||||
composition_layer_color_scale_bias_supported = instance.has_extension(XR_KHR_COMPOSITION_LAYER_COLOR_SCALE_BIAS_EXTENSION_NAME);
|
||||
|
||||
if (parent_scene)
|
||||
{
|
||||
renderer = parent_scene->renderer;
|
||||
gltf_cache = parent_scene->gltf_cache;
|
||||
image_cache = parent_scene->image_cache;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer = std::make_shared<scene_renderer>(device, physical_device, queue, queue_family_index);
|
||||
gltf_cache = std::make_shared<gltf_cache_type>(device, physical_device, queue, queue_family_index, renderer->get_default_material(), application::get_cache_path() / "textures");
|
||||
image_cache = std::make_shared<image_cache_type>(device, physical_device, queue, queue_family_index);
|
||||
}
|
||||
}
|
||||
|
||||
void scene::set_focused(bool status)
|
||||
@@ -142,24 +154,19 @@ void scene::render_world(
|
||||
uint32_t height,
|
||||
bool keep_depth_buffer,
|
||||
uint32_t layer_mask,
|
||||
XrColor4f clear_color)
|
||||
XrColor4f clear_color,
|
||||
bool render_debug_draws)
|
||||
{
|
||||
std::vector<scene_renderer::frame_info> frames;
|
||||
frames.reserve(views.size());
|
||||
assert(views.size() <= layer::max_views);
|
||||
beman::inplace_vector::inplace_vector<scene_renderer::frame_info, layer::max_views> frames;
|
||||
beman::inplace_vector::inplace_vector<XrCompositionLayerProjectionView, layer::max_views> composition_layer_color;
|
||||
beman::inplace_vector::inplace_vector<XrCompositionLayerDepthInfoKHR, layer::max_views> composition_layer_depth;
|
||||
|
||||
// TODO inplace vector
|
||||
std::vector<XrCompositionLayerProjectionView> composition_layer_color;
|
||||
std::vector<XrCompositionLayerDepthInfoKHR> composition_layer_depth;
|
||||
|
||||
composition_layer_color.reserve(views.size());
|
||||
if (keep_depth_buffer)
|
||||
composition_layer_depth.reserve(views.size());
|
||||
|
||||
auto [color_swapchain, color_image] = [&]() -> std::pair<XrSwapchain, vk::Image> {
|
||||
auto [color_swapchain, color_image] = [&]() -> std::tuple<XrSwapchain, vk::Image> {
|
||||
xr::swapchain & color_swapchain = get_swapchain(swapchain_format, width, height, 1, views.size());
|
||||
|
||||
int color_image_index = color_swapchain.acquire();
|
||||
vk::Image color_image = color_swapchain.images()[color_image_index].image;
|
||||
vk::Image color_image = color_swapchain.image(color_image_index);
|
||||
color_swapchain.wait();
|
||||
return {color_swapchain, color_image};
|
||||
}();
|
||||
@@ -170,7 +177,7 @@ void scene::render_world(
|
||||
xr::swapchain & depth_swapchain = get_swapchain(depth_format, width, height, 1, views.size());
|
||||
|
||||
int depth_image_index = depth_swapchain.acquire();
|
||||
vk::Image depth_image = depth_swapchain.images()[depth_image_index].image;
|
||||
vk::Image depth_image = depth_swapchain.image(depth_image_index);
|
||||
depth_swapchain.wait();
|
||||
return {depth_swapchain, depth_image};
|
||||
}
|
||||
@@ -213,9 +220,10 @@ void scene::render_world(
|
||||
},
|
||||
.minDepth = 0,
|
||||
.maxDepth = 1,
|
||||
.nearZ = std::numeric_limits<float>::infinity(),
|
||||
.nearZ = std::bit_cast<float>(0x7f800000), // infinity
|
||||
.farZ = constants::lobby::near_plane,
|
||||
});
|
||||
static_assert(std::numeric_limits<float>::is_iec559);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,17 +238,19 @@ void scene::render_world(
|
||||
depth_format,
|
||||
color_image,
|
||||
depth_image,
|
||||
frames);
|
||||
frames,
|
||||
render_debug_draws);
|
||||
|
||||
add_projection_layer(
|
||||
XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT,
|
||||
space,
|
||||
std::move(composition_layer_color),
|
||||
std::move(composition_layer_depth));
|
||||
composition_layer_color,
|
||||
composition_layer_depth);
|
||||
}
|
||||
|
||||
xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size)
|
||||
{
|
||||
// Look for an exact match
|
||||
for (swapchain_entry & entry: swapchains)
|
||||
{
|
||||
if (not entry.used and
|
||||
@@ -256,17 +266,25 @@ xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t h
|
||||
}
|
||||
|
||||
spdlog::info("Creating new swapchain: {}, {}x{}, {} sample(s), {} level(s)", magic_enum::enum_name(format), width, height, sample_count, array_size);
|
||||
swapchain_entry new_swapchain{
|
||||
.format = format,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.sample_count = sample_count,
|
||||
.array_size = array_size,
|
||||
.used = true,
|
||||
.swapchain = xr::swapchain(
|
||||
instance,
|
||||
session,
|
||||
device,
|
||||
format,
|
||||
width,
|
||||
height,
|
||||
sample_count,
|
||||
array_size)};
|
||||
spdlog::info("Created swapchain");
|
||||
|
||||
return swapchains.emplace_back(swapchain_entry{
|
||||
.format = format,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.sample_count = sample_count,
|
||||
.array_size = array_size,
|
||||
.used = true,
|
||||
.swapchain = xr::swapchain(session, device, format, width, height, sample_count, array_size),
|
||||
})
|
||||
.swapchain;
|
||||
return swapchains.emplace_back(std::move(new_swapchain)).swapchain;
|
||||
}
|
||||
|
||||
void scene::clear_swapchains()
|
||||
@@ -309,8 +327,8 @@ void scene::render_start(bool passthrough, XrTime predicted_display_time_)
|
||||
void scene::add_projection_layer(
|
||||
XrCompositionLayerFlags flags,
|
||||
XrSpace space,
|
||||
std::vector<XrCompositionLayerProjectionView> && color_views,
|
||||
std::vector<XrCompositionLayerDepthInfoKHR> && depth_views)
|
||||
std::span<XrCompositionLayerProjectionView> color_views,
|
||||
std::span<XrCompositionLayerDepthInfoKHR> depth_views)
|
||||
{
|
||||
layers.push_back(layer{
|
||||
.composition_layer = XrCompositionLayerProjection{
|
||||
@@ -321,8 +339,8 @@ void scene::add_projection_layer(
|
||||
.viewCount = (uint32_t)color_views.size(),
|
||||
.views = nullptr,
|
||||
},
|
||||
.color_views = std::move(color_views),
|
||||
.depth_views = std::move(depth_views),
|
||||
.color_views{color_views.begin(), color_views.end()},
|
||||
.depth_views{depth_views.begin(), depth_views.end()},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -436,20 +454,137 @@ void scene::render_end()
|
||||
session.end_frame(predicted_display_time, openxr_layers, blend_mode);
|
||||
}
|
||||
|
||||
std::pair<entt::entity, components::node &> scene::load_gltf(const std::filesystem::path & path, uint32_t layer_mask)
|
||||
template <typename T>
|
||||
void copy_components(entt::registry & scene, const entt::registry & prefab, const std::unordered_map<entt::entity, entt::entity> & entity_map)
|
||||
{
|
||||
auto entity = world.create();
|
||||
auto & node = world.emplace<components::node>(entity);
|
||||
for (const auto & [entity, component]: prefab.view<T>().each())
|
||||
{
|
||||
scene.emplace<T>(entity_map.at(entity), component);
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<entt::entity, components::node &> scene::add_gltf(std::shared_ptr<entt::registry> gltf, uint32_t layer_mask)
|
||||
{
|
||||
auto root = world.create();
|
||||
auto & node = world.emplace<components::node>(root);
|
||||
node.layer_mask = layer_mask;
|
||||
|
||||
assert(renderer);
|
||||
scene_loader loader(device, physical_device, queue, application::queue_family_index(), renderer->get_default_material());
|
||||
auto prefab_entities = gltf->view<entt::entity>();
|
||||
|
||||
loader.add_prefab(world, loader(path), entity);
|
||||
std::vector<entt::entity> scene_entities{prefab_entities.size()};
|
||||
world.create(scene_entities.begin(), scene_entities.end());
|
||||
|
||||
return {entity, node};
|
||||
std::unordered_map<entt::entity, entt::entity> entity_map; // key: prefab entity, value: scene entity
|
||||
|
||||
entity_map.emplace(entt::null, root);
|
||||
for (auto [prefab_entity, scene_entity]: std::ranges::zip_view(prefab_entities, scene_entities))
|
||||
entity_map.emplace(prefab_entity, scene_entity);
|
||||
|
||||
copy_components<components::node>(world, *gltf, entity_map);
|
||||
copy_components<components::animation>(world, *gltf, entity_map);
|
||||
|
||||
// update links
|
||||
for (auto [prefab_entity, scene_entity]: entity_map)
|
||||
{
|
||||
if (prefab_entity == entt::null)
|
||||
continue;
|
||||
|
||||
auto * node = world.try_get<components::node>(scene_entity);
|
||||
auto * anim = world.try_get<components::animation>(scene_entity);
|
||||
|
||||
if (node)
|
||||
{
|
||||
node->parent = entity_map.at(node->parent);
|
||||
|
||||
for (auto & joint: node->joints)
|
||||
{
|
||||
joint.first = entity_map.at(joint.first);
|
||||
}
|
||||
}
|
||||
|
||||
if (anim)
|
||||
{
|
||||
for (auto & track: anim->tracks)
|
||||
{
|
||||
std::visit(utils::overloaded{[&](auto & t) { t.target = entity_map.at(t.target); }}, track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {root, node};
|
||||
}
|
||||
|
||||
std::shared_ptr<entt::registry> scene::load_gltf(const std::filesystem::path & path, std::function<void(float)> progress_cb)
|
||||
{
|
||||
return gltf_cache->load(path, path, progress_cb);
|
||||
}
|
||||
|
||||
void scene::unload_gltf(const std::filesystem::path & path)
|
||||
{
|
||||
gltf_cache->remove(path);
|
||||
}
|
||||
|
||||
std::pair<entt::entity, components::node &> scene::add_gltf(const std::filesystem::path & path, uint32_t layer_mask)
|
||||
{
|
||||
return add_gltf(load_gltf(path), layer_mask);
|
||||
}
|
||||
|
||||
void scene::remove(entt::entity entity)
|
||||
{
|
||||
std::vector to_be_removed{entity};
|
||||
|
||||
while (not to_be_removed.empty())
|
||||
{
|
||||
entt::entity parent = to_be_removed.back();
|
||||
to_be_removed.pop_back();
|
||||
world.destroy(parent);
|
||||
|
||||
for (auto [e, node]: world.view<components::node>().each())
|
||||
{
|
||||
if (node.parent == parent)
|
||||
to_be_removed.push_back(e);
|
||||
}
|
||||
|
||||
for (auto [e, anim]: world.view<components::animation>().each())
|
||||
{
|
||||
if (std::ranges::any_of(anim.tracks,
|
||||
[&](const auto & track) { return std::visit(
|
||||
[&](const components::animation_track_base & track) {
|
||||
return track.target == parent;
|
||||
},
|
||||
track); }))
|
||||
{
|
||||
to_be_removed.push_back(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void scene::on_unfocused() {}
|
||||
void scene::on_focused() {}
|
||||
void scene::on_xr_event(const xr::event &) {}
|
||||
|
||||
bool scene::on_input_key_down(uint8_t key_code)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool scene::on_input_key_up(uint8_t key_code)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool scene::on_input_mouse_move(float x, float y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool scene::on_input_button_down(uint8_t button)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool scene::on_input_button_up(uint8_t button)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool scene::on_input_scroll(float h, float v)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||