Compare commits
959 Commits
temp-tools
...
temp-vr-dr
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1fcc5adc60 | ||
![]() |
5350015d51 | ||
![]() |
3483aa57b3 | ||
![]() |
44a220f721 | ||
![]() |
85c843b115 | ||
f4e27bc2c9 | |||
00cb31de65 | |||
e2630f388d | |||
3227b37141 | |||
317033a1be | |||
467b0aa227 | |||
edb828d0d7 | |||
88a872dd6e | |||
6b0c97466f | |||
39f005eae8 | |||
dcad1eb03c | |||
8b2810a32f | |||
199c37d7e4 | |||
45ae33a952 | |||
785301e5ac | |||
bb53d2b07a | |||
1aabb0bfcf | |||
85c3e12049 | |||
0394f2ab30 | |||
694f9cb18c | |||
972c05537d | |||
08717f4a2c | |||
4cdc5a12da | |||
95de738953 | |||
dcbce4b924 | |||
![]() |
fa7643bc7b | ||
![]() |
02aca1bfb7 | ||
cdeda1fa6c | |||
b4a325f535 | |||
17f299c5d1 | |||
ad417f73c0 | |||
![]() |
43d4ac5db6 | ||
0c4ee9e13d | |||
9fe592ab8f | |||
![]() |
834b0b8262 | ||
64b092974c | |||
![]() |
d20393c8bd | ||
592759e3d6 | |||
![]() |
6a46860220 | ||
52f83011c8 | |||
58229b191a | |||
8f1a55831c | |||
afff94f09f | |||
2d60a54649 | |||
47bf754de4 | |||
916e51a407 | |||
fa1d470692 | |||
e31a1c6fd3 | |||
f9cf815160 | |||
38d7e14dc8 | |||
![]() |
34506a1276 | ||
![]() |
5274c5cce6 | ||
![]() |
eee5ba5cc3 | ||
![]() |
f5c023dfd7 | ||
9620b8f6bb | |||
94dce826a9 | |||
91fa07dfb1 | |||
8b4f00269c | |||
cd02fe5d70 | |||
f69ea92599 | |||
9fbf522dd8 | |||
418fdee5dc | |||
37cef86f0d | |||
![]() |
f08662d3ed | ||
47335b4e61 | |||
a2fe386153 | |||
c0aada58c9 | |||
dd3cdf6f1e | |||
18540f41d7 | |||
2425401a59 | |||
![]() |
85a7cebd53 | ||
edcefb739a | |||
e82b7f1527 | |||
27aef8b551 | |||
7f8d620e20 | |||
5e5cf9ea9f | |||
![]() |
06e0ea0c16 | ||
![]() |
41ed61b273 | ||
![]() |
88b79cacb2 | ||
![]() |
0d70afed19 | ||
3232fc335d | |||
6de4123ebd | |||
f7d5941faa | |||
15e224dca3 | |||
a744fedc85 | |||
26d5fae284 | |||
![]() |
c7653fad67 | ||
dda0de4a3d | |||
256c412b31 | |||
5ba070ce53 | |||
454daf9b6b | |||
53ae209d25 | |||
369ffbd911 | |||
455a1e210b | |||
9198ff4306 | |||
630747ca66 | |||
820522d514 | |||
15b848ef60 | |||
8936479f76 | |||
e5a5d28c3e | |||
05226e1512 | |||
cb1b7e8a48 | |||
8fbe18dc8d | |||
ae7137cdf8 | |||
5f4e99b7a2 | |||
ab3de09591 | |||
5cf6d7e2b0 | |||
d8c6105366 | |||
38ff5064b3 | |||
f4b0900856 | |||
22f17551e5 | |||
![]() |
7a711e133c | ||
b5807be437 | |||
0c7a4c74d3 | |||
67e5422970 | |||
8949dd6cb6 | |||
a89ecd9617 | |||
cb6e3e82b0 | |||
eb2a078f4d | |||
b54528fa1e | |||
31da3936b4 | |||
a897c8e342 | |||
2074d850ee | |||
81dc76c19c | |||
14b2c41216 | |||
c060a835bb | |||
58a2b2dd7e | |||
9be956c326 | |||
53a0916636 | |||
65b6d4a34d | |||
eff91da4df | |||
abebb27644 | |||
ec131e2d53 | |||
7a47c0031f | |||
7f9b1fe73c | |||
cfaef2db30 | |||
![]() |
7922bd26a2 | ||
![]() |
9b6ce439bb | ||
066a7173c0 | |||
![]() |
11975d5d95 | ||
![]() |
03b09dbe32 | ||
f66b5edf98 | |||
2c4dfbb002 | |||
![]() |
f04a5ad1e4 | ||
aa0322524e | |||
80123efc5f | |||
49b2162309 | |||
895201808c | |||
21c039f6ef | |||
2741992f66 | |||
08a6321501 | |||
eb7fe7546c | |||
6786c336bd | |||
4cbcbacc6a | |||
4b37abd61f | |||
5fde4494f6 | |||
433eb3f35d | |||
3a47fbfac5 | |||
7c5838cfd6 | |||
765ed6ffb9 | |||
eb0902243e | |||
b5b0804c5a | |||
502c2c233d | |||
46c22f33b2 | |||
d1848b80f1 | |||
036312ecff | |||
760dbd1cbf | |||
135413e324 | |||
fc982c102b | |||
421280a3f7 | |||
2b99faed52 | |||
![]() |
ab1455e972 | ||
![]() |
b94af38c31 | ||
1ec1797d35 | |||
059d61ae9d | |||
![]() |
40db778de3 | ||
d8fb63661b | |||
ea3690e329 | |||
77d7cc9ba7 | |||
a2f357edc2 | |||
feed46c4ae | |||
c72f6b713f | |||
881675dff1 | |||
f7c13f2d76 | |||
81d4cf5f5a | |||
6bda1fbd2e | |||
![]() |
ffda674893 | ||
4c12764a7f | |||
bcda8cc89b | |||
0516d49d0c | |||
e34587922c | |||
92a3995c6d | |||
3566b81c8b | |||
f5f3003874 | |||
0b2cb96725 | |||
96843ae85c | |||
bc42092a7d | |||
8dd95abb2f | |||
![]() |
200c9f37d6 | ||
fb03a86b1b | |||
b0531227d4 | |||
03be31e817 | |||
4328b56980 | |||
8b1041d510 | |||
64e029ea92 | |||
9c0e7f7dd6 | |||
0d3493d6d9 | |||
604fdb6e85 | |||
136a7a7fe8 | |||
0272b7c814 | |||
f7adb78828 | |||
07499c04f6 | |||
86029b5071 | |||
4bb9fbd3a8 | |||
03f652b2c1 | |||
6d2f9b1dfa | |||
e51067505b | |||
7761657129 | |||
94b81d51a6 | |||
ce0582ee2b | |||
11da3b132a | |||
2ddfd51810 | |||
ca0b5529d0 | |||
43b7512a59 | |||
631d5026c7 | |||
![]() |
22966f4d35 | ||
![]() |
e8f66ff060 | ||
af4dcc6073 | |||
43ec8d7ae9 | |||
5359b7a033 | |||
19b72f50d7 | |||
![]() |
8d3f4a1df3 | ||
![]() |
9ac33e56a1 | ||
fe47c7bf84 | |||
34b3a9583a | |||
9d7a03ab11 | |||
28bd15cdf0 | |||
7f29fc7415 | |||
f69e57a53f | |||
e9c149d911 | |||
dde978d149 | |||
e74847e6bb | |||
3568d56bcc | |||
d65a4b5990 | |||
7f552be7d1 | |||
0dece50667 | |||
406e960327 | |||
77cc69d66f | |||
d87fb0356a | |||
363dd97ae8 | |||
5f405728bb | |||
b9c257019f | |||
ae7db53744 | |||
cee484a4c5 | |||
b9718299ea | |||
![]() |
b961b3f0c9 | ||
51be0a765e | |||
edb3b7a323 | |||
5662a5969b | |||
651d8bfd98 | |||
a85963bed8 | |||
db0782e946 | |||
286c921c25 | |||
58b554c7a4 | |||
6fa47f656e | |||
d2063f7bc3 | |||
369b574fd5 | |||
a345f56ce3 | |||
f1516ae637 | |||
0a2fd63383 | |||
1178046ed2 | |||
2b8bc1a22e | |||
daa7b56890 | |||
770b496729 | |||
453586be06 | |||
0ae52711b6 | |||
baff245b9d | |||
a7d9e2f57e | |||
a3c66680fd | |||
537209cb4b | |||
3b6c75dc31 | |||
b83a1b62c7 | |||
13f57237f2 | |||
3ee246f614 | |||
92f6e60f46 | |||
60d71ffbe9 | |||
801962e2b6 | |||
d438e71729 | |||
fd730fce0c | |||
d3ca0bf6f8 | |||
7ac0c87473 | |||
0528ef0b4d | |||
a38759f017 | |||
314891b1c5 | |||
![]() |
a542f50b51 | ||
a49838ccb0 | |||
fc5ba7e0bd | |||
bf637984d1 | |||
1c40227bfa | |||
3e45f01494 | |||
c4cf14d161 | |||
1f47916664 | |||
11814080a6 | |||
5e56cfa958 | |||
2cce65de96 | |||
233f78c017 | |||
ae19f68d45 | |||
79ce2054d4 | |||
d25386b8a7 | |||
963b761144 | |||
9270c15af8 | |||
ad18d331d7 | |||
6cb8bd0a1c | |||
523de7ae9b | |||
ba94aaedba | |||
9e9c6eac6a | |||
11b994e26e | |||
1d7be99ba4 | |||
81043397d7 | |||
62338abde4 | |||
1693a5efe9 | |||
250995d67b | |||
cf0f2f2d3d | |||
ac7fe46ec3 | |||
cb10bd379b | |||
4f363283eb | |||
829cbd88ff | |||
6a7fcf725e | |||
d24300da5f | |||
e51943bd73 | |||
410eddcbcc | |||
2e92791074 | |||
419f137c64 | |||
76dfbee423 | |||
![]() |
091cc94379 | ||
bfe580642f | |||
4fe0fafb87 | |||
552cc30f3a | |||
52fb8b1e80 | |||
53944e2f9f | |||
796a2b5fc7 | |||
![]() |
fc31be5ab0 | ||
![]() |
aff49f607a | ||
![]() |
57b77cd193 | ||
b63f0266a0 | |||
4cf8f35cc1 | |||
7d65827980 | |||
361d578f9d | |||
9e3ff9e059 | |||
ef0e06d764 | |||
84c11e8644 | |||
19aa873f70 | |||
![]() |
2d98ac33be | ||
34ad6da4a0 | |||
07f3ad06fc | |||
6e72d3e00e | |||
0a0e2dd8a2 | |||
![]() |
d58eb8d29d | ||
![]() |
a4310ba85f | ||
8c61837150 | |||
2de95e8149 | |||
02c5c091df | |||
2c1d23f209 | |||
![]() |
bd42740ef1 | ||
45ae9edbd5 | |||
![]() |
679a4c34fc | ||
![]() |
55362436d9 | ||
![]() |
c1d164070b | ||
![]() |
3a4034a741 | ||
e2b0647272 | |||
4b980e2f57 | |||
c2e8e249ac | |||
65aac86d5a | |||
23ea4b56ad | |||
d5c0a02f86 | |||
69ba3b98e4 | |||
48418ec125 | |||
0d3e055bda | |||
fb84ef58c4 | |||
7fe81fe5a3 | |||
5f140e61c2 | |||
1ae4311902 | |||
48b4d42bce | |||
4b2e6d4e22 | |||
2e6139dfc2 | |||
b58a6a3e72 | |||
687f1df5db | |||
7a82896fbc | |||
5c8b1a1266 | |||
c6c9e168e2 | |||
20c725ed62 | |||
098f60f1b8 | |||
5d4bd8f1bb | |||
bf8393c1c9 | |||
8a083ef3b7 | |||
0b4c0472a3 | |||
112f0db40d | |||
807b6c4848 | |||
![]() |
a6b7ee2a1e | ||
![]() |
bfa6cb3a7d | ||
158eb98c22 | |||
eee46769ce | |||
709f126e81 | |||
4ddc7e8d1b | |||
c722c5204f | |||
c1bd5bcbfa | |||
b69c33aeba | |||
f17e2f8dac | |||
2e15b72089 | |||
58db64a3b6 | |||
![]() |
a0be113d2e | ||
580acab173 | |||
![]() |
151fb129e7 | ||
![]() |
165c5a5259 | ||
11741ff682 | |||
![]() |
74fc1db25b | ||
526272bf7c | |||
366865dd02 | |||
![]() |
03ff2a8dd5 | ||
9e9fbb39d7 | |||
f8a70db556 | |||
d8cebcfebf | |||
![]() |
d90201aee2 | ||
![]() |
5ca302cb0c | ||
4a5e046c92 | |||
d99d15f48d | |||
![]() |
6a998833cd | ||
![]() |
fca4826c7f | ||
a36a44bb81 | |||
9742fa6668 | |||
35aa13734d | |||
8a7dedc9d2 | |||
1f1d302950 | |||
91f539b384 | |||
28c684f66b | |||
105ae3be99 | |||
e6e69a28ab | |||
dd3e3474ab | |||
965bd4c8c3 | |||
c4a62493de | |||
6b3c1192e1 | |||
b0b2546d4a | |||
c635663e4a | |||
d5f725a238 | |||
1fa61c8843 | |||
d5fa230736 | |||
fdf2d8728a | |||
af51988115 | |||
f3899c13cd | |||
125e0cfb25 | |||
c42b7f8434 | |||
8faaeef5fb | |||
d061154b93 | |||
4404a0dcd4 | |||
0b25566143 | |||
9cdd2df277 | |||
ff1b5af307 | |||
ee55ac19dc | |||
daff18dd28 | |||
846e5f1dc0 | |||
69aa5bba4f | |||
8a5a8282ce | |||
70d193203b | |||
914427afd5 | |||
9db772fe9a | |||
e66c3589a2 | |||
ef35dc68d6 | |||
65a3624877 | |||
761135a284 | |||
d2a4a03890 | |||
576963d7c1 | |||
872025c4e5 | |||
8fa50b522a | |||
bb165d6df1 | |||
986c283c07 | |||
65168825e0 | |||
1f57157601 | |||
![]() |
b0845fc133 | ||
![]() |
70cf8bd9c6 | ||
![]() |
3a2e459f58 | ||
e3c586e262 | |||
1c73b60484 | |||
b94df17ae5 | |||
8d4800990c | |||
18310ad509 | |||
3569fdb745 | |||
![]() |
330f062099 | ||
53a7ce1f8a | |||
f3848e8e1e | |||
325501247d | |||
439777f081 | |||
2048db06d3 | |||
83010c2f02 | |||
f1af8908b3 | |||
1499994557 | |||
f2df520698 | |||
![]() |
09872df1c7 | ||
![]() |
67d6399da6 | ||
![]() |
c29724912b | ||
![]() |
99560d9657 | ||
![]() |
b8a7b87873 | ||
7ad21c3876 | |||
f0b72a776e | |||
8a1552545a | |||
d663048696 | |||
03d8bfb144 | |||
7c48b6c84c | |||
3c4f6399d9 | |||
a7ac40888f | |||
676543d91f | |||
1544b9322c | |||
e60d35153f | |||
d3a8d25fb3 | |||
de203b26c2 | |||
![]() |
c9f6c1a054 | ||
![]() |
dd0fcb50b4 | ||
![]() |
c1e9cf00ac | ||
bb7b741d2f | |||
91d3b00395 | |||
53c8fd5447 | |||
![]() |
84d609f67b | ||
![]() |
86178548d5 | ||
![]() |
d711540a85 | ||
a6ae53ef49 | |||
8d8ebc73b6 | |||
dc2b562ace | |||
7a431d40e3 | |||
7695fd9cff | |||
526876a634 | |||
b39d7e484c | |||
![]() |
d3e1782abc | ||
![]() |
fde88ad9d2 | ||
91b4262728 | |||
956d38488a | |||
56ec8108e2 | |||
ee4fa41245 | |||
12ceea0434 | |||
f9232c080d | |||
6f1190cbf0 | |||
d3b42fc167 | |||
f4b963dbdd | |||
167f5a61e5 | |||
d4d16e7a03 | |||
2e91fc39ac | |||
e9d3e056d1 | |||
0829bd7b66 | |||
e927ce8acb | |||
91b8e57d65 | |||
31f922bff6 | |||
95fcdb0401 | |||
3b4054cb58 | |||
2893417d67 | |||
29ebb37419 | |||
23f1bc7414 | |||
![]() |
6e3158cb00 | ||
3f208ed927 | |||
b77c01924a | |||
817e2796cb | |||
![]() |
b216690505 | ||
![]() |
b98896ddd9 | ||
6510ab8676 | |||
32f591c0a3 | |||
fd48ef25a0 | |||
b1020ca169 | |||
7bf820fb96 | |||
977c48b88d | |||
dd84ff212a | |||
484794ce67 | |||
986ff461fb | |||
7e34846176 | |||
db45aaafab | |||
89c762dd99 | |||
25a0acd0a6 | |||
805cabdf17 | |||
![]() |
a05104d61f | ||
2b43ec56af | |||
![]() |
7fe1cc8d24 | ||
516afd0162 | |||
ef5d0a927e | |||
05d14c4560 | |||
52cf94eeb5 | |||
75d48c6efd | |||
ac8c795429 | |||
a42cae1600 | |||
f04424a15d | |||
96f5918407 | |||
fa27d81937 | |||
ff91f605f0 | |||
be5911571e | |||
45761e4c7c | |||
c1bcde0c0f | |||
8d6a5fb5d3 | |||
3f6e17ddaf | |||
7767e080a0 | |||
1715c396e4 | |||
8a7c2c4192 | |||
9526e236fc | |||
473259f98b | |||
6b7bc30c64 | |||
226c6f086a | |||
0a16519f5d | |||
9a0a952f72 | |||
867cd8218a | |||
b2a9627600 | |||
50d0a74833 | |||
a4bc6aca0e | |||
6546442f4f | |||
9cb1810551 | |||
8066784ac2 | |||
27adc4aa33 | |||
![]() |
70e84a2c20 | ||
![]() |
084a33ca94 | ||
4ca054617b | |||
90dae36213 | |||
d6ebd04bb3 | |||
118a0df7a7 | |||
08aad00a5d | |||
f49692f429 | |||
bb2abacb4b | |||
d19d0ff99e | |||
ad16af7a7e | |||
1357dd7d3c | |||
084d545202 | |||
28057d54de | |||
9e12d762a2 | |||
414875ce96 | |||
d7f687c833 | |||
![]() |
37f619aea3 | ||
![]() |
6904ab10f4 | ||
0735c12ca8 | |||
cd6b49f995 | |||
a3e2076bc4 | |||
f2a11550b9 | |||
b1c3038f18 | |||
e68c8ba24e | |||
7a6c50e79c | |||
313097c267 | |||
903b5e1082 | |||
e106765c96 | |||
e1fbab12dc | |||
8933a3bbd0 | |||
1f2f5f660b | |||
f702830a79 | |||
6fad70d551 | |||
df5f06cac2 | |||
741f80864e | |||
6c1419d1f4 | |||
a0f3ea7da3 | |||
a7a9c0e50d | |||
699193713f | |||
![]() |
784121d62a | ||
![]() |
68c39e2b41 | ||
7b93aebff9 | |||
18e619ac69 | |||
599626edd5 | |||
16307d1e2a | |||
97aa43c364 | |||
9e155eb1f0 | |||
03ac94f46a | |||
ea05edceaa | |||
609e16339f | |||
34a0b65ba6 | |||
5cb3d9df1e | |||
9ffb87c629 | |||
3c7814d7de | |||
d1349bd0c7 | |||
15cc4c4cb3 | |||
db8c93c02f | |||
3640a58b9b | |||
4125a330b9 | |||
e7325bedfb | |||
68ec4c26b9 | |||
5d75672720 | |||
![]() |
1468f77a29 | ||
![]() |
baf3887207 | ||
c27d70853d | |||
338cbe4ad6 | |||
31d762c3a8 | |||
66684bdff3 | |||
4a08b974f4 | |||
fdcfc263e9 | |||
2740bdfff9 | |||
eed19d9f45 | |||
ab71991a78 | |||
178bae9504 | |||
9ffce6da65 | |||
7ba096e1e7 | |||
9e8e479a52 | |||
88d8f3a765 | |||
e2bf240cbf | |||
2ee257e2c3 | |||
c06eb4ab94 | |||
c497a7efab | |||
b2e3f23bec | |||
acf26dee5f | |||
33987caf3e | |||
944458fe6c | |||
711960b3c2 | |||
669d50f803 | |||
d2788510fb | |||
66a69fa220 | |||
c252fe7a32 | |||
cc667854a9 | |||
![]() |
146ef0dd1e | ||
b8ed75ab6d | |||
0a3e73a91f | |||
466cc3fbe4 | |||
771ea2d73f | |||
4d6172044c | |||
2866c74208 | |||
c6a199e254 | |||
5277557755 | |||
82990ce2b5 | |||
eb0142e9af | |||
21668359b7 | |||
5b2705adf6 | |||
c441448359 | |||
3d187a2764 | |||
65b2cc2301 | |||
bad5c379c6 | |||
f990c23bcf | |||
055289a95f | |||
c122bcc182 | |||
![]() |
50ccbe6bb2 | ||
2d35fed6f8 | |||
a5b7cf9b5f | |||
09ea5dfd09 | |||
2062d649bf | |||
87c39f1123 | |||
65bc59a56d | |||
57c26453f8 | |||
c362ca3b8a | |||
1f65606911 | |||
e7356bb011 | |||
e4df8b005f | |||
26e6bb3fa3 | |||
71099a3d67 | |||
163996b681 | |||
b708917d94 | |||
df330ab2bb | |||
bc0a0a1005 | |||
ef750790d2 | |||
5439f682fd | |||
3cc51cf28c | |||
6b17b51baa | |||
3ff984d746 | |||
10b694877b | |||
a9635c6384 | |||
1278853849 | |||
4f321a3373 | |||
5892233319 | |||
983ca12d82 | |||
9fbfa218e0 | |||
fcc567b797 | |||
05a54beb88 | |||
cbc0ad07b3 | |||
2002b29ecd | |||
c2a762c8e6 | |||
![]() |
5891e86420 | ||
dcf520cdad | |||
016d5cf919 | |||
4749edccdd | |||
c6d073f6a4 | |||
510daea545 | |||
69b5a06823 | |||
9197462e07 | |||
6b3e709feb | |||
32d3bce1ea | |||
a6fe4d112f | |||
31b2c4c10a | |||
![]() |
2cedad990a | ||
bbbb5cad31 | |||
28fee762ae | |||
2698544db2 | |||
3c6260d42d | |||
7a4c99de5a | |||
809f81cc3a | |||
e1cb15c5d6 | |||
76aff66301 | |||
6b9c41719b | |||
67fc4f4bed | |||
1f79aa602e | |||
c64b72998c | |||
89946834a1 | |||
65d770ffa3 | |||
cf73569d89 | |||
cfea0d9eb8 | |||
c74626c54f | |||
6f61b6aa44 | |||
8eae674eee | |||
fc10a5cf9e | |||
1a5e1273c1 | |||
05129ffb3e | |||
26e05cf67a | |||
bbb3500c97 | |||
ea4b279c32 | |||
35045b6135 | |||
789c6e94fb | |||
741967079c | |||
7c8bf77e13 | |||
f8f3aca1d4 | |||
e40f3f5c48 | |||
be060c3990 | |||
3994084e6a | |||
e981d93fa6 | |||
6f002d1a92 | |||
f566212aa2 | |||
1044a3b657 | |||
8637ff5c96 | |||
dd6aff71a7 | |||
f021635bd5 | |||
71086995a5 | |||
97e3af9a05 | |||
b7a03eed8b | |||
b93e57dcdf | |||
4afc9d8e4d | |||
![]() |
109be29e42 | ||
648e8a1f1d | |||
![]() |
13442da69f | ||
5762137f35 | |||
daf8e73886 | |||
b31af8682c | |||
c9238e638f | |||
4e8c5f4bc8 | |||
d44aebd3fe | |||
![]() |
231dbd53bf | ||
e8cb477f8a | |||
0511de99bb | |||
8401ee24ff | |||
533e267e95 | |||
![]() |
f5e0ae655e | ||
![]() |
30d65c326a | ||
![]() |
0519bb584b | ||
![]() |
da25748be7 | ||
2ffcb80cb6 | |||
dee6fe1441 | |||
![]() |
d3e48fb096 | ||
4f3f68df30 | |||
![]() |
d544a0b41c | ||
d7d9320f09 | |||
![]() |
cf4799e299 | ||
![]() |
40a1c67165 | ||
782813e463 | |||
980726c1d4 | |||
56d52466ef | |||
f35ef57c8c | |||
6f0de2328c | |||
9bcab8050f | |||
eac11046a1 | |||
2110f4a76c | |||
37d5d10849 | |||
9ec8887599 | |||
bd227d1378 | |||
83d92f55b8 | |||
651e574153 | |||
5dd8c3f0cb | |||
d06671b3d9 | |||
![]() |
57d9f004aa | ||
b5a1a2d186 | |||
![]() |
62cde7a9ef | ||
b2c92d90c8 | |||
c187fc09b6 | |||
![]() |
e4fcf25fc5 | ||
1cd11c9d75 | |||
7ee5ea7751 | |||
c5eceb3582 | |||
19d90c8602 | |||
4b124143b1 | |||
c74ccf6a97 | |||
58996e3057 | |||
91e00bd703 | |||
ccfb98511b | |||
658aa00718 | |||
2a22b8af04 | |||
1f4e9754c0 | |||
7f5a21177a | |||
0f983e8540 | |||
5eb156e769 | |||
6f516fcc63 | |||
![]() |
215c919b33 | ||
![]() |
da44a02d00 | ||
![]() |
867007d9d7 | ||
![]() |
e9ea814233 | ||
![]() |
6b43c82cb5 | ||
![]() |
afbb62fecd | ||
![]() |
8a676e8fa9 | ||
![]() |
c52111e983 | ||
![]() |
d749e8a2c4 | ||
![]() |
8663aa80e6 | ||
![]() |
88b39444a0 | ||
![]() |
4cfc3caa09 | ||
![]() |
28428b3462 | ||
![]() |
24146563a0 | ||
![]() |
2ee9c60c20 | ||
![]() |
fb64675209 | ||
![]() |
76385139cf | ||
![]() |
b18f5a6a81 | ||
![]() |
9d29373b06 | ||
![]() |
f2f1e4dfed | ||
![]() |
0da0f29ade | ||
![]() |
a8519dbac2 | ||
![]() |
d15d07c4f6 | ||
![]() |
d356787a65 | ||
![]() |
a284fa3abb | ||
![]() |
4eeb7523e9 | ||
![]() |
f30fcd6c85 | ||
![]() |
47e8133520 | ||
![]() |
3fa7d59a04 | ||
![]() |
df8dc43946 | ||
![]() |
3b0a2fecfc | ||
![]() |
80af6d534d | ||
![]() |
71c7d61808 | ||
![]() |
637b803b97 | ||
![]() |
314eef0df8 | ||
![]() |
34fa0f8ac6 | ||
![]() |
16366724bd | ||
![]() |
fc8127d070 | ||
![]() |
3ac37fb552 | ||
![]() |
8e51a75772 | ||
![]() |
ba2dab402d | ||
![]() |
796994d222 | ||
![]() |
66e90e9179 | ||
![]() |
1404edbe3a | ||
![]() |
2f68a76409 | ||
![]() |
304d9a20fc | ||
![]() |
b169e327bf | ||
![]() |
7238bbecc4 | ||
![]() |
a49b4ca402 | ||
![]() |
eb0424c946 | ||
![]() |
5d6da57aa3 | ||
![]() |
e968bbc5d8 | ||
![]() |
b1b0e05c54 | ||
![]() |
e547026dfe | ||
![]() |
f816380af5 | ||
![]() |
5e642bfea1 | ||
![]() |
0d1a22f74f | ||
![]() |
20a1af936d | ||
![]() |
c9c1b90532 | ||
![]() |
4192281e14 | ||
![]() |
329deadc9e | ||
![]() |
53845c554d | ||
![]() |
35c9e3beed | ||
![]() |
60f66768cf | ||
![]() |
3e88974a80 | ||
![]() |
09e7d6cd26 | ||
![]() |
5d5ad5d6dd | ||
![]() |
e70894c360 | ||
![]() |
4c11886c4e | ||
![]() |
41e2f2e75f | ||
![]() |
864abbd425 | ||
![]() |
f333e7eb56 | ||
![]() |
a2ac2ec3c3 | ||
![]() |
06d52afcda | ||
![]() |
e65ba62c37 |
@@ -241,7 +241,7 @@ ForEachMacros:
|
||||
- SEQ_BEGIN
|
||||
- foreach
|
||||
|
||||
# Use once we bump the minimum verison to version 8.
|
||||
# Use once we bump the minimum version to version 8.
|
||||
# # Without this string literals that in-line 'STRINGIFY' behave strangely (a bug?).
|
||||
# StatementMacros:
|
||||
# - PyObject_VAR_HEAD
|
||||
|
@@ -234,6 +234,17 @@ option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
|
||||
option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
|
||||
mark_as_advanced(WITH_SYSTEM_BULLET)
|
||||
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
|
||||
option(WITH_OPENXR "Enable VR features through the OpenXR specification" ON)
|
||||
if(WITH_OPENXR)
|
||||
option(OPENXR_USE_BUNDLED_SRC "Compile using the bundled OpenXR SDK sources (otherwise it has to be compiled manually)" ON)
|
||||
if(NOT OPENXR_USE_BUNDLED_SRC)
|
||||
find_package(OpenXR-SDK)
|
||||
if(NOT OPENXR_SDK_FOUND)
|
||||
message(WARNING "OpenXR-SDK was not found, disabling WITH_OPENXR")
|
||||
set(WITH_OPENXR OFF)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Compositor
|
||||
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
|
||||
@@ -413,6 +424,8 @@ unset(PLATFORM_DEFAULT)
|
||||
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
|
||||
option(WITH_CYCLES_DEBUG "Build Cycles with extra debug capabilities" OFF)
|
||||
option(WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF)
|
||||
option(WITH_CYCLES_KERNEL_ASAN "Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow" OFF)
|
||||
mark_as_advanced(WITH_CYCLES_KERNEL_ASAN)
|
||||
mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER)
|
||||
mark_as_advanced(WITH_CYCLES_LOGGING)
|
||||
mark_as_advanced(WITH_CYCLES_DEBUG)
|
||||
@@ -471,7 +484,7 @@ endif()
|
||||
option(WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON)
|
||||
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
|
||||
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
|
||||
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
|
||||
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
|
||||
|
||||
mark_as_advanced(
|
||||
WITH_OPENGL
|
||||
@@ -822,12 +835,6 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}")
|
||||
if(WITH_CYCLES_OSL)
|
||||
# With OSL, Cycles disables rtti in some modules, wich then breaks at linking
|
||||
# when trying to use vptr sanitizer (included into 'undefined' general option).
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-sanitize=vptr")
|
||||
endif()
|
||||
if(MSVC)
|
||||
set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6")
|
||||
endif()
|
||||
@@ -852,7 +859,8 @@ if(WITH_X11)
|
||||
if(X11_Xinput_LIB)
|
||||
list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
|
||||
else()
|
||||
set(WITH_X11_XINPUT OFF)
|
||||
message(FATAL_ERROR "LibXi not found. Disable WITH_X11_XINPUT if you
|
||||
want to build without tablet support")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -863,7 +871,8 @@ if(WITH_X11)
|
||||
if(X11_Xxf86vmode_LIB)
|
||||
list(APPEND PLATFORM_LINKLIBS ${X11_Xxf86vmode_LIB})
|
||||
else()
|
||||
set(WITH_X11_XF86VMODE OFF)
|
||||
message(FATAL_ERROR "libXxf86vm not found. Disable WITH_X11_XF86VMODE if you
|
||||
want to build without")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -871,7 +880,8 @@ if(WITH_X11)
|
||||
if(X11_Xfixes_LIB)
|
||||
list(APPEND PLATFORM_LINKLIBS ${X11_Xfixes_LIB})
|
||||
else()
|
||||
set(WITH_X11_XFIXES OFF)
|
||||
message(FATAL_ERROR "libXfixes not found. Disable WITH_X11_XFIXES if you
|
||||
want to build without")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -881,7 +891,8 @@ if(WITH_X11)
|
||||
if(X11_Xrender_LIB)
|
||||
list(APPEND PLATFORM_LINKLIBS ${X11_Xrender_LIB})
|
||||
else()
|
||||
set(WITH_X11_ALPHA OFF)
|
||||
message(FATAL_ERROR "libXrender not found. Disable WITH_X11_ALPHA if you
|
||||
want to build without")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1760,6 +1771,7 @@ if(FIRST_RUN)
|
||||
info_cfg_option(WITH_CYCLES)
|
||||
info_cfg_option(WITH_FREESTYLE)
|
||||
info_cfg_option(WITH_OPENCOLORIO)
|
||||
info_cfg_option(WITH_OPENXR)
|
||||
info_cfg_option(WITH_OPENVDB)
|
||||
info_cfg_option(WITH_ALEMBIC)
|
||||
|
||||
|
25
GNUmakefile
25
GNUmakefile
@@ -37,14 +37,16 @@ Convenience Targets
|
||||
* bpy: Build as a python module which can be loaded from python directly.
|
||||
* deps: Build library dependencies (intended only for platform maintainers).
|
||||
|
||||
* developer: Enable faster builds, error checking and tests, recommended for developers.
|
||||
* config: Run cmake configuration tool to set build options.
|
||||
* ninja: Use ninja build tool for faster builds.
|
||||
|
||||
Note: passing the argument 'BUILD_DIR=path' when calling make will override the default build dir.
|
||||
Note: passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments.
|
||||
|
||||
|
||||
Project Files
|
||||
Generate poject files for development environments.
|
||||
Generate project files for development environments.
|
||||
|
||||
* project_qtcreator: QtCreator Project Files.
|
||||
* project_netbeans: NetBeans Project Files.
|
||||
@@ -221,6 +223,19 @@ ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
|
||||
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
|
||||
endif
|
||||
|
||||
ifneq "$(findstring developer, $(MAKECMDGOALS))" ""
|
||||
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_developer.cmake"
|
||||
endif
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# build tool
|
||||
|
||||
ifneq "$(findstring ninja, $(MAKECMDGOALS))" ""
|
||||
BUILD_COMMAND:=ninja
|
||||
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -G Ninja
|
||||
else
|
||||
BUILD_COMMAND:=make -s
|
||||
endif
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Blender binary path
|
||||
@@ -282,7 +297,7 @@ all: .FORCE
|
||||
|
||||
@echo
|
||||
@echo Building Blender ...
|
||||
$(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
|
||||
$(BUILD_COMMAND) -C "$(BUILD_DIR)" -j $(NPROCS) install
|
||||
@echo
|
||||
@echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
|
||||
@echo Blender successfully built, run from: $(BLENDER_BIN)
|
||||
@@ -294,6 +309,8 @@ lite: all
|
||||
cycles: all
|
||||
headless: all
|
||||
bpy: all
|
||||
developer: all
|
||||
ninja: all
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build dependencies
|
||||
@@ -312,7 +329,7 @@ deps: .FORCE
|
||||
|
||||
@echo
|
||||
@echo Building dependencies ...
|
||||
$(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
|
||||
$(BUILD_COMMAND) -C "$(DEPS_BUILD_DIR)" -j $(NPROCS) $(DEPS_TARGET)
|
||||
@echo
|
||||
@echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
|
||||
@echo
|
||||
@@ -548,7 +565,7 @@ help_features: .FORCE
|
||||
@$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR)"/CMakeLists.txt"
|
||||
|
||||
clean: .FORCE
|
||||
$(MAKE) -C "$(BUILD_DIR)" clean
|
||||
$(BUILD_COMMAND) -C "$(BUILD_DIR)" clean
|
||||
|
||||
.PHONY: all
|
||||
|
||||
|
@@ -70,7 +70,6 @@ ExternalProject_Add(external_opensubdiv
|
||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||
URL_HASH MD5=${OPENSUBDIV_Hash}
|
||||
PREFIX ${BUILD_DIR}/opensubdiv
|
||||
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/opensubdiv/src/external_opensubdiv < ${PATCH_DIR}/opensubdiv.diff
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opensubdiv -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${OPENSUBDIV_EXTRA_ARGS}
|
||||
INSTALL_DIR ${LIBDIR}/opensubdiv
|
||||
)
|
||||
|
@@ -16,20 +16,26 @@
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
if (UNIX)
|
||||
set(THEORA_CONFIGURE_ENV ${CONFIGURE_ENV} && export HAVE_PDFLATEX=no)
|
||||
else()
|
||||
set(THEORA_CONFIGURE_ENV ${CONFIGURE_ENV})
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(external_theora
|
||||
URL ${THEORA_URI}
|
||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||
URL_HASH SHA256=${THEORA_HASH}
|
||||
PREFIX ${BUILD_DIR}/theora
|
||||
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/theora
|
||||
CONFIGURE_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/theora
|
||||
--disable-shared
|
||||
--enable-static
|
||||
--with-pic
|
||||
--with-ogg=${LIBDIR}/ogg
|
||||
--with-vorbis=${LIBDIR}/vorbis
|
||||
--disable-examples
|
||||
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS}
|
||||
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make install
|
||||
BUILD_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS}
|
||||
INSTALL_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make install
|
||||
INSTALL_DIR ${LIBDIR}/theora
|
||||
)
|
||||
|
||||
|
@@ -105,8 +105,8 @@ set(CUEW_GIT_UID 1744972026de9cf27c8a7dc39cf39cd83d5f922f)
|
||||
set(CUEW_URI https://github.com/CudaWrangler/cuew/archive/${CUEW_GIT_UID}.zip)
|
||||
set(CUEW_HASH 86760d62978ebfd96cd93f5aa1abaf4a)
|
||||
|
||||
set(OPENSUBDIV_VERSION v3_3_3)
|
||||
set(OPENSUBDIV_Hash 29c79dc01ef616aab02670bed5544ddd)
|
||||
set(OPENSUBDIV_VERSION v3_4_0_RC2)
|
||||
set(OPENSUBDIV_Hash f6a10ba9efaa82fde86fe65aad346319)
|
||||
set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.tar.gz)
|
||||
|
||||
set(SDL_VERSION 2.0.8)
|
||||
@@ -143,11 +143,11 @@ set(OSL_VERSION 1.9.9)
|
||||
set(OSL_URI https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.tar.gz)
|
||||
set(OSL_HASH 44ad511e424965a10fce051a053b0605)
|
||||
|
||||
set(PYTHON_VERSION 3.7.0)
|
||||
set(PYTHON_VERSION 3.7.4)
|
||||
set(PYTHON_SHORT_VERSION 3.7)
|
||||
set(PYTHON_SHORT_VERSION_NO_DOTS 37)
|
||||
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
|
||||
set(PYTHON_HASH eb8c2a6b1447d50813c02714af4681f3)
|
||||
set(PYTHON_HASH d33e4aae66097051c2eca45ee3604803)
|
||||
|
||||
set(TBB_VERSION 2018_U5)
|
||||
set(TBB_URI https://github.com/01org/tbb/archive/${TBB_VERSION}.tar.gz)
|
||||
|
@@ -303,7 +303,7 @@ USE_CXX11=true
|
||||
|
||||
CLANG_FORMAT_VERSION_MIN="6.0"
|
||||
|
||||
PYTHON_VERSION="3.7.0"
|
||||
PYTHON_VERSION="3.7.4"
|
||||
PYTHON_VERSION_MIN="3.7"
|
||||
PYTHON_FORCE_BUILD=false
|
||||
PYTHON_FORCE_REBUILD=false
|
||||
@@ -358,7 +358,7 @@ OSL_FORCE_REBUILD=false
|
||||
OSL_SKIP=false
|
||||
|
||||
# OpenSubdiv needs to be compiled for now
|
||||
OSD_VERSION="3.3.3"
|
||||
OSD_VERSION="3.4.0_RC2"
|
||||
OSD_VERSION_MIN=$OSD_VERSION
|
||||
OSD_FORCE_BUILD=false
|
||||
OSD_FORCE_REBUILD=false
|
||||
|
@@ -1,13 +0,0 @@
|
||||
diff --git a/opensubdiv/far/topologyRefiner.cpp b/opensubdiv/far/topologyRefiner.cpp
|
||||
index 3754b36e..7fe42bcc 100644
|
||||
--- a/opensubdiv/far/topologyRefiner.cpp
|
||||
+++ b/opensubdiv/far/topologyRefiner.cpp
|
||||
@@ -263,7 +263,7 @@ namespace internal {
|
||||
bool IsEmpty() const { return *((int_type*)this) == 0; }
|
||||
|
||||
FeatureMask() { Clear(); }
|
||||
- FeatureMask(Options const & options, Sdc::SchemeType sType) { InitializeFeatures(options, sType); }
|
||||
+ FeatureMask(Options const & options, Sdc::SchemeType sType) { Clear(); InitializeFeatures(options, sType); }
|
||||
|
||||
// These are the two primary methods intended for use -- intialization via a set of Options
|
||||
// and reduction of the subsequent feature set (which presumes prior initialization with the
|
@@ -6,7 +6,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/../../cmake/config/blender_release.cmake")
|
||||
# There we can not use CPU bitness check since it is always 64bit. So instead
|
||||
# we check for a specific libraries.
|
||||
#
|
||||
# Other builders we are runnign in a bare virtual machine, and the libraries
|
||||
# Other builders we are running in a bare virtual machine, and the libraries
|
||||
# are installed to /opt/.
|
||||
# We assume that only 64bit builders exists in such configuration.
|
||||
if(EXISTS "/lib/x86_64-linux-gnu/libc-2.24.so")
|
||||
|
@@ -61,7 +61,8 @@ if 'cmake' in builder:
|
||||
|
||||
# Set build options.
|
||||
cmake_options = []
|
||||
cmake_extra_options = ['-DCMAKE_BUILD_TYPE:STRING=Release']
|
||||
cmake_extra_options = ['-DCMAKE_BUILD_TYPE:STRING=Release',
|
||||
'-DWITH_GTESTS=ON']
|
||||
|
||||
if builder.startswith('mac'):
|
||||
# Set up OSX architecture
|
||||
|
@@ -33,27 +33,44 @@ builder = sys.argv[1]
|
||||
blender_dir = '../blender.git'
|
||||
|
||||
if "cmake" in builder:
|
||||
# cmake
|
||||
|
||||
print("Automated tests are still DISABLED!")
|
||||
sys.exit(0)
|
||||
|
||||
build_dir = os.path.abspath(os.path.join('..', 'build', builder))
|
||||
chroot_name = None
|
||||
chroot_prefix = []
|
||||
install_dir = os.path.abspath(os.path.join('..', 'install', builder))
|
||||
# NOTE: For quick test only to see if the approach work.
|
||||
# n the future must be replaced with an actual blender version.
|
||||
blender_version = '2.80'
|
||||
blender_version_dir = os.path.join(install_dir, blender_version)
|
||||
command_prefix = []
|
||||
extra_ctest_args = []
|
||||
|
||||
"""
|
||||
if builder.endswith('x86_64_cmake'):
|
||||
chroot_name = 'buildbot_jessie_x86_64'
|
||||
elif builder.endswith('i686_cmake'):
|
||||
chroot_name = 'buildbot_jessie_i686'
|
||||
if chroot_name:
|
||||
chroot_prefix = ['schroot', '-c', chroot_name, '--']
|
||||
"""
|
||||
if builder.startswith('win'):
|
||||
extra_ctest_args += ['-C', 'Release']
|
||||
elif builder.startswith('linux'):
|
||||
tokens = builder.split("_")
|
||||
glibc = tokens[1]
|
||||
if glibc == 'glibc224':
|
||||
deb_name = "stretch"
|
||||
if builder.endswith('x86_64_cmake'):
|
||||
chroot_name = 'buildbot_' + deb_name + '_x86_64'
|
||||
elif builder.endswith('i686_cmake'):
|
||||
chroot_name = 'buildbot_' + deb_name + '_i686'
|
||||
command_prefix = ['schroot', '--preserve-environment', '-c', chroot_name, '--']
|
||||
elif glibc == 'glibc217':
|
||||
command_prefix = ['scl', 'enable', 'devtoolset-6', '--']
|
||||
|
||||
ctest_env = os.environ.copy()
|
||||
ctest_env['BLENDER_SYSTEM_SCRIPTS'] = os.path.join(blender_version_dir, 'scripts')
|
||||
ctest_env['BLENDER_SYSTEM_DATAFILES'] = os.path.join(blender_version_dir, 'datafiles')
|
||||
|
||||
os.chdir(build_dir)
|
||||
retcode = subprocess.call(chroot_prefix + ['ctest', '--output-on-failure'])
|
||||
sys.exit(retcode)
|
||||
retcode = subprocess.call(command_prefix + ['ctest', '--output-on-failure'] + extra_ctest_args,
|
||||
env=ctest_env)
|
||||
|
||||
# Always exit with a success, for until we know all the tests are passing
|
||||
# on all builders.
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("Unknown building system")
|
||||
sys.exit(1)
|
||||
|
67
build_files/cmake/Modules/FindOpenXR-SDK.cmake
Normal file
67
build_files/cmake/Modules/FindOpenXR-SDK.cmake
Normal file
@@ -0,0 +1,67 @@
|
||||
# - Find OpenXR-SDK library
|
||||
# Find the native OpenXR-SDK includes and library
|
||||
# This module defines
|
||||
# OPENXR_SDK_INCLUDE_DIRS, where to find OpenXR-SDK headers, Set when
|
||||
# OPENXR_SDK_INCLUDE_DIR is found.
|
||||
# OPENXR_SDK_LIBRARIES, libraries to link against to use OpenXR-SDK.
|
||||
# OPENXR_SDK_ROOT_DIR, the base directory to search for OpenXR-SDK.
|
||||
# This can also be an environment variable.
|
||||
# OPENXR_SDK_FOUND, if false, do not try to use OpenXR-SDK.
|
||||
#
|
||||
# also defined, but not for general use are
|
||||
# OPENXR_LOADER_LIBRARY, where to find the OpenXR-SDK library.
|
||||
|
||||
#=============================================================================
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENXR_SDK_ROOT_DIR was defined in the environment, use it.
|
||||
IF(NOT OPENXR_SDK_ROOT_DIR AND NOT $ENV{OPENXR_SDK_ROOT_DIR} STREQUAL "")
|
||||
SET(OPENXR_SDK_ROOT_DIR $ENV{OPENXR_SDK_ROOT_DIR})
|
||||
ENDIF()
|
||||
|
||||
SET(_openxr_sdk_SEARCH_DIRS
|
||||
${OPENXR_SDK_ROOT_DIR}
|
||||
/usr/local
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
)
|
||||
|
||||
FIND_PATH(OPENXR_SDK_INCLUDE_DIR
|
||||
NAMES
|
||||
openxr/openxr.h
|
||||
HINTS
|
||||
${_openxr_sdk_SEARCH_DIRS}
|
||||
PATH_SUFFIXES
|
||||
include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(OPENXR_LOADER_LIBRARY
|
||||
NAMES
|
||||
openxr_loader
|
||||
HINTS
|
||||
${_openxr_sdk_SEARCH_DIRS}
|
||||
PATH_SUFFIXES
|
||||
lib64 lib
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENXR_SDK_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENXR_SDK DEFAULT_MSG
|
||||
OPENXR_LOADER_LIBRARY OPENXR_SDK_INCLUDE_DIR)
|
||||
|
||||
IF(OPENXR_SDK_FOUND)
|
||||
SET(OPENXR_SDK_LIBRARIES ${OPENXR_LOADER_LIBRARY})
|
||||
SET(OPENXR_SDK_INCLUDE_DIRS ${OPENXR_SDK_INCLUDE_DIR})
|
||||
ENDIF(OPENXR_SDK_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
OPENXR_SDK_INCLUDE_DIR
|
||||
OPENXR_LOADER_LIBRARY
|
||||
)
|
@@ -6,7 +6,7 @@
|
||||
# LIBSNDFILE_LIBRARIES, libraries to link against to use SndFile.
|
||||
# LIBSNDFILE_ROOT_DIR, The base directory to search for SndFile.
|
||||
# This can also be an environment variable.
|
||||
# LIBSNDFILE_FOUND, If false, do not try to use SndFile.
|
||||
# SNDFILE_FOUND, If false, do not try to use SndFile.
|
||||
#
|
||||
# also defined, but not for general use are
|
||||
# LIBSNDFILE_LIBRARY, where to find the SndFile library.
|
||||
@@ -50,16 +50,16 @@ FIND_LIBRARY(LIBSNDFILE_LIBRARY
|
||||
lib64 lib
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set LIBSNDFILE_FOUND to TRUE if
|
||||
# handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SndFile DEFAULT_MSG
|
||||
LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
|
||||
|
||||
IF(LIBSNDFILE_FOUND)
|
||||
IF(SNDFILE_FOUND)
|
||||
SET(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBRARY})
|
||||
SET(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIR})
|
||||
ENDIF(LIBSNDFILE_FOUND)
|
||||
ENDIF(SNDFILE_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
LIBSNDFILE_INCLUDE_DIR
|
||||
|
@@ -50,6 +50,10 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
|
||||
INCLUDE_DIRECTORIES "${TEST_INC}")
|
||||
if(${DO_ADD_TEST})
|
||||
add_test(NAME ${NAME}_test COMMAND ${TESTS_OUTPUT_DIR}/${NAME}_test WORKING_DIRECTORY $<TARGET_FILE_DIR:blender>)
|
||||
|
||||
# Don't fail tests on leaks since these often happen in external libraries
|
||||
# that we can't fix.
|
||||
set_tests_properties(${NAME}_test PROPERTIES ENVIRONMENT LSAN_OPTIONS=exitcode=0)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
101
build_files/cmake/Modules/presentation.cmake
Normal file
101
build_files/cmake/Modules/presentation.cmake
Normal file
@@ -0,0 +1,101 @@
|
||||
set(PRESENTATION_BACKENDS xlib xcb wayland)
|
||||
set(PRESENTATION_BACKEND xlib CACHE STRING
|
||||
"Presentation backend chosen at configure time")
|
||||
set_property(CACHE PRESENTATION_BACKEND PROPERTY STRINGS
|
||||
${PRESENTATION_BACKENDS})
|
||||
|
||||
list(FIND PRESENTATION_BACKENDS ${PRESENTATION_BACKEND} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR "Presentation backend must be one of
|
||||
${PRESENTATION_BACKENDS}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Using presentation backend: ${PRESENTATION_BACKEND}")
|
||||
|
||||
|
||||
if( PRESENTATION_BACKEND MATCHES "xlib" )
|
||||
find_package(X11 REQUIRED)
|
||||
if ((NOT X11_Xxf86vm_LIB) OR (NOT X11_Xrandr_LIB))
|
||||
message(FATAL_ERROR "OpenXR xlib backend requires Xxf86vm and Xrandr")
|
||||
endif()
|
||||
|
||||
add_definitions( -DSUPPORT_X )
|
||||
add_definitions( -DOS_LINUX_XLIB )
|
||||
set( XLIB_LIBRARIES
|
||||
${X11_LIBRARIES}
|
||||
${X11_Xxf86vm_LIB}
|
||||
${X11_Xrandr_LIB} )
|
||||
|
||||
elseif( PRESENTATION_BACKEND MATCHES "xcb" )
|
||||
find_package(PkgConfig REQUIRED)
|
||||
# XCB + XCB GLX is limited to OpenGL 2.1
|
||||
# add_definitions( -DOS_LINUX_XCB )
|
||||
# XCB + Xlib GLX 1.3
|
||||
add_definitions( -DOS_LINUX_XCB_GLX )
|
||||
|
||||
pkg_search_module(X11 REQUIRED x11)
|
||||
pkg_search_module(XCB REQUIRED xcb)
|
||||
pkg_search_module(XCB_RANDR REQUIRED xcb-randr)
|
||||
pkg_search_module(XCB_KEYSYMS REQUIRED xcb-keysyms)
|
||||
pkg_search_module(XCB_GLX REQUIRED xcb-glx)
|
||||
pkg_search_module(XCB_DRI2 REQUIRED xcb-dri2)
|
||||
pkg_search_module(XCB_ICCCM REQUIRED xcb-icccm)
|
||||
|
||||
set( XCB_LIBRARIES
|
||||
${XCB_LIBRARIES}
|
||||
${XCB_KEYSYMS_LIBRARIES}
|
||||
${XCB_RANDR_LIBRARIES}
|
||||
${XCB_GLX_LIBRARIES}
|
||||
${XCB_DRI2_LIBRARIES}
|
||||
${X11_LIBRARIES} )
|
||||
|
||||
elseif( PRESENTATION_BACKEND MATCHES "wayland" )
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(WAYLAND_CLIENT REQUIRED wayland-client)
|
||||
pkg_search_module(WAYLAND_EGL REQUIRED wayland-egl)
|
||||
pkg_search_module(WAYLAND_SCANNER REQUIRED wayland-scanner)
|
||||
pkg_search_module(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.7)
|
||||
pkg_search_module(EGL REQUIRED egl)
|
||||
|
||||
add_definitions( -DOS_LINUX_WAYLAND )
|
||||
set( WAYLAND_LIBRARIES
|
||||
${EGL_LIBRARIES}
|
||||
${WAYLAND_CLIENT_LIBRARIES}
|
||||
${WAYLAND_EGL_LIBRARIES} )
|
||||
|
||||
# generate wayland protocols
|
||||
set(WAYLAND_PROTOCOLS_DIR ${CMAKE_SOURCE_DIR}/wayland-protocols/)
|
||||
file(MAKE_DIRECTORY ${WAYLAND_PROTOCOLS_DIR})
|
||||
|
||||
pkg_get_variable(WAYLAND_PROTOCOLS_DATADIR wayland-protocols pkgdatadir)
|
||||
pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
|
||||
|
||||
set(PROTOCOL xdg-shell-unstable-v6)
|
||||
set(PROTOCOL_XML
|
||||
${WAYLAND_PROTOCOLS_DATADIR}/unstable/xdg-shell/${PROTOCOL}.xml)
|
||||
|
||||
if( EXISTS ${PROTOCOL_XML} )
|
||||
execute_process(COMMAND
|
||||
${WAYLAND_SCANNER}
|
||||
code
|
||||
${PROTOCOL_XML}
|
||||
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.c)
|
||||
execute_process(COMMAND
|
||||
${WAYLAND_SCANNER}
|
||||
client-header
|
||||
${PROTOCOL_XML}
|
||||
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.h)
|
||||
|
||||
set( WAYLAND_PROTOCOL_SRC
|
||||
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.c
|
||||
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.h )
|
||||
|
||||
include_directories(${WAYLAND_PROTOCOLS_DIR})
|
||||
else()
|
||||
message(FATAL_ERROR
|
||||
"xdg-shell-unstable-v6.xml not found in "
|
||||
${WAYLAND_PROTOCOLS_DATADIR}
|
||||
"\nYour wayland-protocols package does not "
|
||||
"contain xdg-shell-unstable-v6.")
|
||||
endif()
|
||||
endif()
|
47
build_files/cmake/Modules/xr_platform_defines.cmake
Normal file
47
build_files/cmake/Modules/xr_platform_defines.cmake
Normal file
@@ -0,0 +1,47 @@
|
||||
# Copyright (c) 2017 The Khronos Group Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DXR_OS_WINDOWS)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_definitions(-DXR_OS_LINUX)
|
||||
endif()
|
||||
|
||||
# Determine the presentation backend for Linux systems.
|
||||
# Use an include because the code is pretty big.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
include(presentation)
|
||||
endif()
|
||||
|
||||
# Several files use these compile-time platform switches
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
add_definitions( -DXR_USE_PLATFORM_WIN32 )
|
||||
elseif( PRESENTATION_BACKEND MATCHES "xlib" )
|
||||
add_definitions( -DXR_USE_PLATFORM_XLIB )
|
||||
elseif( PRESENTATION_BACKEND MATCHES "xcb" )
|
||||
add_definitions( -DXR_USE_PLATFORM_XCB )
|
||||
elseif( PRESENTATION_BACKEND MATCHES "wayland" )
|
||||
add_definitions( -DXR_USE_PLATFORM_WAYLAND )
|
||||
endif()
|
||||
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_D3D)
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_D3D10)
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_D3D11)
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_D3D12)
|
||||
endif()
|
||||
|
@@ -130,7 +130,7 @@ def function_parm_wash_tokens(parm):
|
||||
)
|
||||
|
||||
"""
|
||||
Return tolens without trailing commands and 'const'
|
||||
Return tokens without trailing commands and 'const'
|
||||
"""
|
||||
|
||||
tokens = [t for t in parm.get_tokens()]
|
||||
|
@@ -238,7 +238,7 @@ def create_nb_project_main():
|
||||
|
||||
f.write(' </makeTool>\n')
|
||||
f.write(' </makefileType>\n')
|
||||
# finishe makefle info
|
||||
# finished makefile info
|
||||
|
||||
f.write(' \n')
|
||||
|
||||
|
19
build_files/cmake/config/blender_developer.cmake
Normal file
19
build_files/cmake/config/blender_developer.cmake
Normal file
@@ -0,0 +1,19 @@
|
||||
# Configuration for developers, with faster builds, error checking and tests.
|
||||
#
|
||||
# Example usage:
|
||||
# cmake -C../blender/build_files/cmake/config/blender_developer.cmake ../blender
|
||||
#
|
||||
|
||||
set(WITH_ASSERT_ABORT ON CACHE BOOL "" FORCE)
|
||||
set(WITH_BUILDINFO OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_COMPILER_ASAN ON CACHE BOOL "" FORCE)
|
||||
set(WITH_CYCLES_DEBUG ON CACHE BOOL "" FORCE)
|
||||
set(WITH_CYCLES_NATIVE_ONLY ON CACHE BOOL "" FORCE)
|
||||
set(WITH_GTESTS ON CACHE BOOL "" FORCE)
|
||||
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_PYTHON_SAFETY ON CACHE BOOL "" FORCE)
|
||||
set(WITH_DOC_MANPAGE OFF CACHE BOOL "" FORCE)
|
||||
|
||||
# This may have issues with C++ initialization order, needs to be tested
|
||||
# on all platforms to be sure this is safe to enable.
|
||||
# set(WITH_CXX_GUARDEDALLOC ON CACHE BOOL "" FORCE)
|
@@ -40,6 +40,7 @@ set(WITH_AUDASPACE ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENAL ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENCOLLADA ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENCOLORIO ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENXR ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENMP ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENVDB ON CACHE BOOL "" FORCE)
|
||||
|
@@ -45,6 +45,7 @@ set(WITH_AUDASPACE OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENCOLLADA OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENCOLORIO OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENXR OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENIMAGEIO OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENMP OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
|
||||
|
@@ -41,6 +41,7 @@ set(WITH_AUDASPACE ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENAL ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENCOLLADA ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENCOLORIO ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENXR ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENMP ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
|
||||
set(WITH_OPENVDB ON CACHE BOOL "" FORCE)
|
||||
|
@@ -468,6 +468,9 @@ function(setup_liblinks
|
||||
if(WITH_OPENSUBDIV)
|
||||
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
|
||||
endif()
|
||||
if(WITH_OPENXR)
|
||||
target_link_libraries(${target} ${OPENXR_SDK_LIBRARIES})
|
||||
endif()
|
||||
if(WITH_CYCLES_EMBREE)
|
||||
target_link_libraries(${target} ${EMBREE_LIBRARIES})
|
||||
endif()
|
||||
@@ -713,7 +716,7 @@ macro(remove_strict_flags)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# TODO
|
||||
remove_cc_flag(/w34189) # Restore warn C4189 (unused variable) back to w4
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
@@ -393,16 +393,13 @@ if(WITH_OPENMP)
|
||||
set(OpenMP_CXX_FLAGS "-Xclang -fopenmp -I'${LIBDIR}/openmp/include'")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L'${LIBDIR}/openmp/lib' -lomp")
|
||||
|
||||
# Copy libomp.dylib to allow executables like datatoc to work.
|
||||
if(CMAKE_MAKE_PROGRAM MATCHES "xcodebuild")
|
||||
set(OPENMP_DYLIB_AUX_PATH "${CMAKE_BINARY_DIR}/bin")
|
||||
else()
|
||||
set(OPENMP_DYLIB_AUX_PATH "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
# Copy libomp.dylib to allow executables like datatoc and tests to work.
|
||||
execute_process(
|
||||
COMMAND mkdir -p ${OPENMP_DYLIB_AUX_PATH}/Resources/lib
|
||||
COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${OPENMP_DYLIB_AUX_PATH}/Resources/lib/libomp.dylib)
|
||||
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/Resources/lib
|
||||
COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${CMAKE_BINARY_DIR}/Resources/lib/libomp.dylib)
|
||||
execute_process(
|
||||
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/bin/Resources/lib
|
||||
COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${CMAKE_BINARY_DIR}/bin/Resources/lib/libomp.dylib)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@@ -156,7 +156,7 @@ endif()
|
||||
# Codecs
|
||||
if(WITH_CODEC_SNDFILE)
|
||||
find_package_wrapper(SndFile)
|
||||
if(NOT LIBSNDFILE_FOUND)
|
||||
if(NOT SNDFILE_FOUND)
|
||||
set(WITH_CODEC_SNDFILE OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
@@ -144,6 +144,11 @@ set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
|
||||
|
||||
#JMC is available on msvc 15.8 (1915) and up
|
||||
if(MSVC_VERSION GREATER 1914 AND NOT MSVC_CLANG)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /JMC")
|
||||
endif()
|
||||
|
||||
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ")
|
||||
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib ")
|
||||
|
||||
@@ -166,8 +171,7 @@ if(NOT DEFINED LIBDIR)
|
||||
message(STATUS "64 bit compiler detected.")
|
||||
set(LIBDIR_BASE "win64")
|
||||
else()
|
||||
message(STATUS "32 bit compiler detected.")
|
||||
set(LIBDIR_BASE "windows")
|
||||
message(FATAL_ERROR "32 bit compiler detected, blender no longer provides pre-build libraries for 32 bit windows, please set the LIBDIR cmake variable to your own library folder")
|
||||
endif()
|
||||
# Can be 1910..1912
|
||||
if(MSVC_VERSION GREATER 1919)
|
||||
@@ -381,9 +385,6 @@ if(WITH_BOOST)
|
||||
if(CMAKE_CL_64)
|
||||
set(BOOST_POSTFIX "vc140-mt-s-x64-1_68.lib")
|
||||
set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x64-1_68.lib")
|
||||
else()
|
||||
set(BOOST_POSTFIX "vc140-mt-s-x32-1_68.lib")
|
||||
set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x32-1_68.lib")
|
||||
endif()
|
||||
set(BOOST_LIBRARIES
|
||||
optimized ${BOOST_LIBPATH}/libboost_date_time-${BOOST_POSTFIX}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Builds a debian package from SVN source.
|
||||
#
|
||||
# For paralelle builds use:
|
||||
# For parallel builds use:
|
||||
# DEB_BUILD_OPTIONS="parallel=5" sh build_files/package_spec/build_debian.sh
|
||||
|
||||
# this needs to run in the root dir.
|
||||
|
@@ -2,11 +2,7 @@ if "%BUILD_VS_YEAR%"=="2015" set BUILD_VS_LIBDIRPOST=vc14
|
||||
if "%BUILD_VS_YEAR%"=="2017" set BUILD_VS_LIBDIRPOST=vc14
|
||||
if "%BUILD_VS_YEAR%"=="2019" set BUILD_VS_LIBDIRPOST=vc14
|
||||
|
||||
if "%BUILD_ARCH%"=="x64" (
|
||||
set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
|
||||
) else if "%BUILD_ARCH%"=="x86" (
|
||||
set BUILD_VS_SVNDIR=windows_%BUILD_VS_LIBDIRPOST%
|
||||
)
|
||||
set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
|
||||
set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"
|
||||
|
||||
if NOT "%verbose%" == "" (
|
||||
|
@@ -1,14 +1,6 @@
|
||||
set BUILD_GENERATOR_POST=
|
||||
set BUILD_PLATFORM_SELECT=
|
||||
if "%BUILD_ARCH%"=="x64" (
|
||||
set MSBUILD_PLATFORM=x64
|
||||
) else if "%BUILD_ARCH%"=="x86" (
|
||||
set MSBUILD_PLATFORM=win32
|
||||
if "%WITH_CLANG%"=="1" (
|
||||
echo Clang not supported for X86
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
set MSBUILD_PLATFORM=x64
|
||||
|
||||
if "%WITH_CLANG%"=="1" (
|
||||
set CLANG_CMAKE_ARGS=-T"llvm"
|
||||
|
@@ -6,11 +6,13 @@ if "%BUILD_ARCH%"=="" (
|
||||
set WINDOWS_ARCH= Win64
|
||||
set BUILD_ARCH=x64
|
||||
) else (
|
||||
set WINDOWS_ARCH=
|
||||
set BUILD_ARCH=x86
|
||||
echo Error: 32 bit builds of blender are no longer supported.
|
||||
goto ERR
|
||||
)
|
||||
) else if "%BUILD_ARCH%"=="x64" (
|
||||
set WINDOWS_ARCH= Win64
|
||||
) else if "%BUILD_ARCH%"=="x86" (
|
||||
set WINDOWS_ARCH=
|
||||
)
|
||||
:EOF
|
||||
exit /b 0
|
||||
:ERR
|
||||
exit /b 1
|
@@ -2,10 +2,6 @@ if EXIST %BLENDER_DIR%\..\lib\win64_vc14\llvm\bin\clang-format.exe (
|
||||
set CF_PATH=..\lib\win64_vc14\llvm\bin
|
||||
goto detect_done
|
||||
)
|
||||
if EXIST %BLENDER_DIR%\..\lib\windows_vc14\llvm\bin\clang-format.exe (
|
||||
set CF_PATH=..\lib\windows_vc14\llvm\bin
|
||||
goto detect_done
|
||||
)
|
||||
|
||||
echo clang-format not found
|
||||
exit /b 1
|
||||
|
@@ -41,10 +41,13 @@ if NOT "%1" == "" (
|
||||
) else if "%1" == "release" (
|
||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake"
|
||||
set TARGET=Release
|
||||
) else if "%1" == "developer" (
|
||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_developer.cmake"
|
||||
) else if "%1" == "asan" (
|
||||
set WITH_ASAN=1
|
||||
) else if "%1" == "x86" (
|
||||
set BUILD_ARCH=x86
|
||||
) else if "%1" == "x86" (
|
||||
echo Error: 32 bit builds of blender are no longer supported.
|
||||
goto ERR
|
||||
) else if "%1" == "x64" (
|
||||
set BUILD_ARCH=x64
|
||||
) else if "%1" == "2017" (
|
||||
@@ -97,10 +100,12 @@ if NOT "%1" == "" (
|
||||
goto EOF
|
||||
) else (
|
||||
echo Command "%1" unknown, aborting!
|
||||
exit /b 1
|
||||
goto ERR
|
||||
)
|
||||
shift /1
|
||||
goto argv_loop
|
||||
)
|
||||
:EOF
|
||||
exit /b 0
|
||||
exit /b 0
|
||||
:ERR
|
||||
exit /b 1
|
@@ -7,7 +7,6 @@ set BUILD_VS_YEAR=
|
||||
set BUILD_VS_LIBDIRPOST=
|
||||
set BUILD_VS_LIBDIR=
|
||||
set BUILD_VS_SVNDIR=
|
||||
set BUILD_NGE=
|
||||
set KEY_NAME=
|
||||
set MSBUILD_PLATFORM=
|
||||
set MUST_CLEAN=
|
||||
|
@@ -1,4 +1,9 @@
|
||||
set BUILD_DIR=%BUILD_DIR%_%TARGET%%BUILD_NGE%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
|
||||
if NOT "%TARGET%" == "" (
|
||||
set BUILD_DIR=%BUILD_DIR%_%TARGET%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
|
||||
) else (
|
||||
set BUILD_DIR=%BUILD_DIR%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
|
||||
)
|
||||
|
||||
if NOT "%BUILD_DIR_OVERRRIDE%"=="" (
|
||||
set BUILD_DIR=%BUILD_DIR_OVERRRIDE%
|
||||
)
|
@@ -17,13 +17,12 @@ echo - format [path] ^(Format the source using clang-format, path is optional, r
|
||||
echo.
|
||||
echo Configuration options
|
||||
echo - verbose ^(enable diagnostic output during configuration^)
|
||||
echo - developer ^(enable faster builds, error checking and tests, recommended for developers^)
|
||||
echo - with_tests ^(enable building unit tests^)
|
||||
echo - nobuildinfo ^(disable buildinfo^)
|
||||
echo - debug ^(Build an unoptimized debuggable build^)
|
||||
echo - packagename [newname] ^(override default cpack package name^)
|
||||
echo - buildir [newdir] ^(override default build folder^)
|
||||
echo - x86 ^(override host auto-detect and build 32 bit code^)
|
||||
echo - x64 ^(override host auto-detect and build 64 bit code^)
|
||||
echo - 2017 ^(build with visual studio 2017^)
|
||||
echo - 2017pre ^(build with visual studio 2017 pre-release^)
|
||||
echo - 2017b ^(build with visual studio 2017 Build Tools^)
|
||||
|
@@ -38,7 +38,7 @@ PROJECT_NAME = Blender
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = "V2.79"
|
||||
PROJECT_NUMBER = "V2.81"
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
@@ -177,7 +177,7 @@ font:
|
||||
With the new truetype option in Blender, this is used for all font families
|
||||
|
||||
When a uiBlock is created, each uiButton that is defined gets the uiBlock properties.
|
||||
Changing Block properties in between will affact uiButtons defined thereafter.
|
||||
Changing Block properties in between will effect uiButtons defined thereafter.
|
||||
|
||||
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
Sphinx==1.7.6
|
||||
sphinx_rtd_theme==0.4.1
|
||||
Sphinx==1.8.5
|
||||
sphinx_rtd_theme==0.4.3
|
||||
|
@@ -1208,27 +1208,6 @@ offers a set of extensive examples, including advanced features.
|
||||
:arg x, y, z: Specify the x, y, and z coordinates of a translation vector.
|
||||
|
||||
|
||||
.. function:: glVertex (x,y,z,w,v):
|
||||
|
||||
B{glVertex2d, glVertex2f, glVertex2i, glVertex2s, glVertex3d, glVertex3f, glVertex3i,
|
||||
glVertex3s, glVertex4d, glVertex4f, glVertex4i, glVertex4s, glVertex2dv, glVertex2fv,
|
||||
glVertex2iv, glVertex2sv, glVertex3dv, glVertex3fv, glVertex3iv, glVertex3sv, glVertex4dv,
|
||||
glVertex4fv, glVertex4iv, glVertex4sv}
|
||||
|
||||
Specify a vertex
|
||||
|
||||
.. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glVertex.xml>`__
|
||||
|
||||
:type x, y, z, w: Depends on function prototype (z and w for '3' and '4' prototypes only)
|
||||
:arg x, y, z, w: Specify x, y, z, and w coordinates of a vertex. Not all parameters
|
||||
are present in all forms of the command.
|
||||
:type v: :class:`bgl.Buffer` object. Depends of function prototype (for 'v'
|
||||
prototypes only)
|
||||
:arg v: Specifies a pointer to an array of two, three, or four elements. The
|
||||
elements of a two-element array are x and y; of a three-element array,
|
||||
x, y, and z; and of a four-element array, x, y, z, and w.
|
||||
|
||||
|
||||
.. function:: glViewport(x,y,width,height):
|
||||
|
||||
Set the viewport
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -40,7 +40,7 @@ In most cases you can figure out what context an operator needs
|
||||
simply be seeing how it's used in Blender and thinking about what it does.
|
||||
|
||||
Unfortunately if you're still stuck - the only way to **really** know
|
||||
whats going on is to read the source code for the poll function and see what its checking.
|
||||
what's going on is to read the source code for the poll function and see what its checking.
|
||||
|
||||
For Python operators it's not so hard to find the source
|
||||
since it's included with Blender and the source file/line is included in the operator reference docs.
|
||||
@@ -125,7 +125,7 @@ While a script executes Blender waits for it to finish and is effectively locked
|
||||
while in this state Blender won't redraw or respond to user input.
|
||||
Normally this is not such a problem because scripts distributed with Blender
|
||||
tend not to run for an extended period of time,
|
||||
nevertheless scripts *can* take ages to execute and its nice to see whats going on in the view port.
|
||||
nevertheless scripts *can* take ages to execute and its nice to see what's going on in the view port.
|
||||
|
||||
Tools that lock Blender in a loop and redraw are highly discouraged
|
||||
since they conflict with Blenders ability to run multiple operators
|
||||
|
@@ -45,7 +45,7 @@ scene manipulation, automation, defining your own toolset and customization.
|
||||
|
||||
On startup Blender scans the ``scripts/startup/`` directory for Python modules and imports them.
|
||||
The exact location of this directory depends on your installation.
|
||||
See the :ref:`directory layout docs <blender_manual:getting-started_installing-config-directories>`.
|
||||
See the :ref:`directory layout docs <blender_manual:blender-directory-layout>`.
|
||||
|
||||
|
||||
Script Loading
|
||||
|
@@ -51,7 +51,7 @@ A quick list of helpful things to know before starting:
|
||||
| ``scripts/startup/bl_operators`` for operators.
|
||||
|
||||
Exact location depends on platform, see:
|
||||
:ref:`Configuration and Data Paths <blender_manual:getting-started_installing-config-directories>`.
|
||||
:ref:`directory layout docs <blender_manual:blender-directory-layout>`.
|
||||
|
||||
|
||||
Running Scripts
|
||||
|
@@ -239,7 +239,7 @@ Drop Into a Python Interpreter in Your Script
|
||||
=============================================
|
||||
|
||||
In the middle of a script you may want to inspect some variables,
|
||||
run some function and generally dig about to see whats going on.
|
||||
run some function and generally dig about to see what's going on.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@@ -156,7 +156,8 @@ def api_dump():
|
||||
for func_id, attr in funcs:
|
||||
# arg_str = inspect.formatargspec(*inspect.getargspec(py_func))
|
||||
|
||||
func_args_ids = tuple(inspect.getargspec(attr).args)
|
||||
sig = inspect.signature(attr)
|
||||
func_args_ids = [k for k, v in sig.parameters.items()]
|
||||
|
||||
dump_class[func_id] = (
|
||||
"func_py", # basic_type
|
||||
@@ -175,7 +176,7 @@ def api_dump():
|
||||
import pprint
|
||||
|
||||
filename = api_dunp_fname()
|
||||
filehandle = open(filename, 'w')
|
||||
filehandle = open(filename, 'w', encoding='utf-8')
|
||||
tot = filehandle.write(pprint.pformat(dump, width=1))
|
||||
filehandle.close()
|
||||
print("%s, %d bytes written" % (filename, tot))
|
||||
@@ -199,11 +200,11 @@ def compare_props(a, b, fuzz=0.75):
|
||||
|
||||
def api_changelog(api_from, api_to, api_out):
|
||||
|
||||
file_handle = open(api_from, 'r')
|
||||
file_handle = open(api_from, 'r', encoding='utf-8')
|
||||
dict_from = eval(file_handle.read())
|
||||
file_handle.close()
|
||||
|
||||
file_handle = open(api_to, 'r')
|
||||
file_handle = open(api_to, 'r', encoding='utf-8')
|
||||
dict_to = eval(file_handle.read())
|
||||
file_handle.close()
|
||||
|
||||
@@ -266,7 +267,7 @@ def api_changelog(api_from, api_to, api_out):
|
||||
|
||||
# also document function argument changes
|
||||
|
||||
fout = open(api_out, 'w')
|
||||
fout = open(api_out, 'w', encoding='utf-8')
|
||||
fw = fout.write
|
||||
# print(api_changes)
|
||||
|
||||
|
@@ -320,8 +320,6 @@ EXTRA_SOURCE_FILES = (
|
||||
"../../../release/scripts/templates_py/ui_previews_custom_icon.py",
|
||||
"../examples/bmesh.ops.1.py",
|
||||
"../examples/bpy.app.translations.py",
|
||||
"../static/favicon.ico",
|
||||
"../static/blender_logo.svg",
|
||||
)
|
||||
|
||||
|
||||
@@ -401,7 +399,6 @@ is_release = bpy.app.version_cycle in {"rc", "release"}
|
||||
|
||||
# converting bytes to strings, due to T30154
|
||||
BLENDER_REVISION = str(bpy.app.build_hash, 'utf_8')
|
||||
BLENDER_DATE = str(bpy.app.build_date, 'utf_8')
|
||||
|
||||
if is_release:
|
||||
# '2.62a'
|
||||
@@ -409,9 +406,13 @@ if is_release:
|
||||
else:
|
||||
# '2.62.1'
|
||||
BLENDER_VERSION_DOTS = ".".join(blender_version_strings)
|
||||
|
||||
if BLENDER_REVISION != "Unknown":
|
||||
# '2.62a SHA1' (release) or '2.62.1 SHA1' (non-release)
|
||||
BLENDER_VERSION_DOTS += " " + BLENDER_REVISION
|
||||
BLENDER_VERSION_HASH = BLENDER_REVISION
|
||||
else:
|
||||
# Fallback: Should not be used
|
||||
BLENDER_VERSION_HASH = "Hash Unknown"
|
||||
|
||||
if is_release:
|
||||
# '2_62a_release'
|
||||
@@ -1610,26 +1611,39 @@ def write_sphinx_conf_py(basepath):
|
||||
fw("import sys, os\n\n")
|
||||
fw("extensions = ['sphinx.ext.intersphinx']\n\n")
|
||||
fw("intersphinx_mapping = {'blender_manual': ('https://docs.blender.org/manual/en/dev/', None)}\n\n")
|
||||
fw("project = 'Blender'\n")
|
||||
fw("project = 'Blender %s Python API'\n" % BLENDER_VERSION_DOTS)
|
||||
fw("master_doc = 'index'\n")
|
||||
fw("copyright = u'Blender Foundation'\n")
|
||||
fw("version = '%s'\n" % BLENDER_VERSION_DOTS)
|
||||
fw("release = '%s'\n" % BLENDER_VERSION_DOTS)
|
||||
fw("version = '%s'\n" % BLENDER_VERSION_HASH)
|
||||
fw("release = '%s'\n" % BLENDER_VERSION_HASH)
|
||||
|
||||
# Quiet file not in table-of-contents warnings.
|
||||
fw("exclude_patterns = [\n")
|
||||
fw(" 'include__bmesh.rst',\n")
|
||||
fw("]\n\n")
|
||||
|
||||
fw("html_title = 'Blender %s Python API'\n" % BLENDER_VERSION_DOTS)
|
||||
fw("html_title = 'Blender Python API'\n")
|
||||
fw("html_theme = 'sphinx_rtd_theme'\n")
|
||||
fw("html_theme_options = {\n")
|
||||
fw(" 'canonical_url': 'https://docs.blender.org/api/current/',\n")
|
||||
# fw(" 'analytics_id': '',\n")
|
||||
# fw(" 'collapse_navigation': True,\n")
|
||||
fw(" 'sticky_navigation': False,\n")
|
||||
fw(" 'navigation_depth': 1,\n")
|
||||
# fw(" 'includehidden': True,\n")
|
||||
# fw(" 'titles_only': False\n")
|
||||
fw(" }\n\n")
|
||||
|
||||
# not helpful since the source is generated, adds to upload size.
|
||||
fw("html_copy_source = False\n")
|
||||
fw("html_show_sphinx = False\n")
|
||||
fw("html_use_opensearch = 'https://docs.blender.org/api/current'\n")
|
||||
fw("html_split_index = True\n")
|
||||
fw("html_extra_path = ['__/static/favicon.ico', '__/static/blender_logo.svg']\n")
|
||||
fw("html_favicon = '__/static/favicon.ico'\n")
|
||||
fw("html_logo = '__/static/blender_logo.svg'\n\n")
|
||||
fw("html_static_path = ['static']\n")
|
||||
fw("html_extra_path = ['static/favicon.ico', 'static/blender_logo.svg']\n")
|
||||
fw("html_favicon = 'static/favicon.ico'\n")
|
||||
fw("html_logo = 'static/blender_logo.svg'\n")
|
||||
fw("html_last_updated_fmt = '%m/%d/%Y'\n\n")
|
||||
|
||||
# needed for latex, pdf gen
|
||||
fw("latex_elements = {\n")
|
||||
@@ -1649,12 +1663,13 @@ class PatchedPythonDomain(PythonDomain):
|
||||
del node['refspecific']
|
||||
return super(PatchedPythonDomain, self).resolve_xref(
|
||||
env, fromdocname, builder, typ, target, node, contnode)
|
||||
|
||||
def setup(sphinx):
|
||||
sphinx.override_domain(PatchedPythonDomain)
|
||||
""")
|
||||
# end workaround
|
||||
|
||||
fw("def setup(app):\n")
|
||||
fw(" app.add_stylesheet('css/theme_overrides.css')\n")
|
||||
fw(" app.override_domain(PatchedPythonDomain)\n\n")
|
||||
|
||||
file.close()
|
||||
|
||||
|
||||
@@ -1673,14 +1688,14 @@ def write_rst_contents(basepath):
|
||||
file = open(filepath, "w", encoding="utf-8")
|
||||
fw = file.write
|
||||
|
||||
fw(title_string("Blender Python API Documentation", "%", double=True))
|
||||
fw(title_string("Blender %s Python API Documentation" % BLENDER_VERSION_DOTS, "%", double=True))
|
||||
fw("\n")
|
||||
fw("Welcome to the API reference for Blender %s, built %s.\n" %
|
||||
(BLENDER_VERSION_DOTS, BLENDER_DATE))
|
||||
fw("Welcome to the Python API documentation for `Blender <https://www.blender.org>`__, ")
|
||||
fw("the free and open source 3D creation suite.\n")
|
||||
fw("\n")
|
||||
|
||||
# fw("`A PDF version of this document is also available <%s>`_\n" % BLENDER_PDF_FILENAME)
|
||||
fw("This site can be downloaded for offline use: `Download the full Documentation (zipped HTML files) <%s>`_\n" %
|
||||
fw("This site can be used offline: `Download the full documentation (zipped HTML files) <%s>`__\n" %
|
||||
BLENDER_ZIP_FILENAME)
|
||||
fw("\n")
|
||||
|
||||
@@ -1912,6 +1927,12 @@ def copy_handwritten_extra(basepath):
|
||||
shutil.copy2(f_src, f_dst)
|
||||
|
||||
|
||||
def copy_theme_assets(basepath):
|
||||
shutil.copytree(os.path.join(SCRIPT_DIR, "static"),
|
||||
os.path.join(basepath, "static"),
|
||||
copy_function=shutil.copy)
|
||||
|
||||
|
||||
def rna2sphinx(basepath):
|
||||
|
||||
try:
|
||||
@@ -1946,6 +1967,9 @@ def rna2sphinx(basepath):
|
||||
# copy source files referenced
|
||||
copy_handwritten_extra(basepath)
|
||||
|
||||
# copy extra files needed for theme
|
||||
copy_theme_assets(basepath)
|
||||
|
||||
|
||||
def align_sphinx_in_to_sphinx_in_tmp(dir_src, dir_dst):
|
||||
'''
|
||||
|
11
doc/python_api/static/css/theme_overrides.css
Normal file
11
doc/python_api/static/css/theme_overrides.css
Normal file
@@ -0,0 +1,11 @@
|
||||
/* Prevent Long enum lists */
|
||||
.field-body {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: 245px;
|
||||
overflow-y: auto !important;
|
||||
}
|
||||
|
||||
/* Hide home icon in search area */
|
||||
.wy-side-nav-search > a:hover {background: none; opacity: 0.9}
|
||||
.wy-side-nav-search > a.icon::before {content: none}
|
5
extern/CMakeLists.txt
vendored
5
extern/CMakeLists.txt
vendored
@@ -105,3 +105,8 @@ if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
|
||||
set(AUDASPACE_CMAKE_CFG ${CMAKE_CURRENT_SOURCE_DIR}/audaspace/blender_config.cmake)
|
||||
add_subdirectory(audaspace)
|
||||
endif()
|
||||
|
||||
if(WITH_OPENXR AND OPENXR_USE_BUNDLED_SRC)
|
||||
add_subdirectory(jsoncpp)
|
||||
add_subdirectory(openxr)
|
||||
endif()
|
||||
|
20
extern/jsoncpp/CMakeLists.txt
vendored
Normal file
20
extern/jsoncpp/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# 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 2
|
||||
# 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, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# All rights reserved.
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
add_subdirectory(src)
|
98
extern/jsoncpp/include/json/allocator.h
vendored
Normal file
98
extern/jsoncpp/include/json/allocator.h
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
||||
#define CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
namespace Json {
|
||||
template<typename T>
|
||||
class SecureAllocator {
|
||||
public:
|
||||
// Type definitions
|
||||
using value_type = T;
|
||||
using pointer = T*;
|
||||
using const_pointer = const T*;
|
||||
using reference = T&;
|
||||
using const_reference = const T&;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
/**
|
||||
* Allocate memory for N items using the standard allocator.
|
||||
*/
|
||||
pointer allocate(size_type n) {
|
||||
// allocate using "global operator new"
|
||||
return static_cast<pointer>(::operator new(n * sizeof(T)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Release memory which was allocated for N items at pointer P.
|
||||
*
|
||||
* The memory block is filled with zeroes before being released.
|
||||
* The pointer argument is tagged as "volatile" to prevent the
|
||||
* compiler optimizing out this critical step.
|
||||
*/
|
||||
void deallocate(volatile pointer p, size_type n) {
|
||||
std::memset(p, 0, n * sizeof(T));
|
||||
// free using "global operator delete"
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an item in-place at pointer P.
|
||||
*/
|
||||
template<typename... Args>
|
||||
void construct(pointer p, Args&&... args) {
|
||||
// construct using "placement new" and "perfect forwarding"
|
||||
::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
size_type max_size() const {
|
||||
return size_t(-1) / sizeof(T);
|
||||
}
|
||||
|
||||
pointer address( reference x ) const {
|
||||
return std::addressof(x);
|
||||
}
|
||||
|
||||
const_pointer address( const_reference x ) const {
|
||||
return std::addressof(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an item in-place at pointer P.
|
||||
*/
|
||||
void destroy(pointer p) {
|
||||
// destroy using "explicit destructor"
|
||||
p->~T();
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
SecureAllocator() {}
|
||||
template<typename U> SecureAllocator(const SecureAllocator<U>&) {}
|
||||
template<typename U> struct rebind { using other = SecureAllocator<U>; };
|
||||
};
|
||||
|
||||
|
||||
template<typename T, typename U>
|
||||
bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} //namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
54
extern/jsoncpp/include/json/assertions.h
vendored
Normal file
54
extern/jsoncpp/include/json/assertions.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
||||
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
/** It should not be possible for a maliciously designed file to
|
||||
* cause an abort() or seg-fault, so these macros are used only
|
||||
* for pre-condition violations and internal logic errors.
|
||||
*/
|
||||
#if JSON_USE_EXCEPTION
|
||||
|
||||
// @todo <= add detail about condition in exception
|
||||
# define JSON_ASSERT(condition) \
|
||||
{if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
|
||||
|
||||
# define JSON_FAIL_MESSAGE(message) \
|
||||
{ \
|
||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||
Json::throwLogicError(oss.str()); \
|
||||
abort(); \
|
||||
}
|
||||
|
||||
#else // JSON_USE_EXCEPTION
|
||||
|
||||
# define JSON_ASSERT(condition) assert(condition)
|
||||
|
||||
// The call to assert() will show the failure message in debug builds. In
|
||||
// release builds we abort, for a core-dump or debugger.
|
||||
# define JSON_FAIL_MESSAGE(message) \
|
||||
{ \
|
||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||
assert(false && oss.str().c_str()); \
|
||||
abort(); \
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#define JSON_ASSERT_MESSAGE(condition, message) \
|
||||
if (!(condition)) { \
|
||||
JSON_FAIL_MESSAGE(message); \
|
||||
}
|
||||
|
||||
#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
25
extern/jsoncpp/include/json/autolink.h
vendored
Normal file
25
extern/jsoncpp/include/json/autolink.h
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_AUTOLINK_H_INCLUDED
|
||||
#define JSON_AUTOLINK_H_INCLUDED
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef JSON_IN_CPPTL
|
||||
#include <cpptl/cpptl_autolink.h>
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && \
|
||||
!defined(JSON_IN_CPPTL)
|
||||
#define CPPTL_AUTOLINK_NAME "json"
|
||||
#undef CPPTL_AUTOLINK_DLL
|
||||
#ifdef JSON_DLL
|
||||
#define CPPTL_AUTOLINK_DLL
|
||||
#endif
|
||||
#include "autolink.h"
|
||||
#endif
|
||||
|
||||
#endif // JSON_AUTOLINK_H_INCLUDED
|
184
extern/jsoncpp/include/json/config.h
vendored
Normal file
184
extern/jsoncpp/include/json/config.h
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_CONFIG_H_INCLUDED
|
||||
#define JSON_CONFIG_H_INCLUDED
|
||||
#include <stddef.h>
|
||||
#include <string> //typedef String
|
||||
#include <stdint.h> //typedef int64_t, uint64_t
|
||||
|
||||
/// If defined, indicates that json library is embedded in CppTL library.
|
||||
//# define JSON_IN_CPPTL 1
|
||||
|
||||
/// If defined, indicates that json may leverage CppTL library
|
||||
//# define JSON_USE_CPPTL 1
|
||||
/// If defined, indicates that cpptl vector based map should be used instead of
|
||||
/// std::map
|
||||
/// as Value container.
|
||||
//# define JSON_USE_CPPTL_SMALLMAP 1
|
||||
|
||||
// If non-zero, the library uses exceptions to report bad input instead of C
|
||||
// assertion macros. The default is to use exceptions.
|
||||
#ifndef JSON_USE_EXCEPTION
|
||||
#define JSON_USE_EXCEPTION 1
|
||||
#endif
|
||||
|
||||
/// If defined, indicates that the source file is amalgated
|
||||
/// to prevent private header inclusion.
|
||||
/// Remarks: it is automatically defined in the generated amalgated header.
|
||||
// #define JSON_IS_AMALGAMATION
|
||||
|
||||
#ifdef JSON_IN_CPPTL
|
||||
#include <cpptl/config.h>
|
||||
#ifndef JSON_USE_CPPTL
|
||||
#define JSON_USE_CPPTL 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef JSON_IN_CPPTL
|
||||
#define JSON_API CPPTL_API
|
||||
#elif defined(JSON_DLL_BUILD)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllexport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#elif defined(JSON_DLL)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllimport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#endif // ifdef JSON_IN_CPPTL
|
||||
#if !defined(JSON_API)
|
||||
#define JSON_API
|
||||
#endif
|
||||
|
||||
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
||||
// integer
|
||||
// Storages, and 64 bits integer support is disabled.
|
||||
// #define JSON_NO_INT64 1
|
||||
|
||||
#if defined(_MSC_VER) // MSVC
|
||||
# if _MSC_VER <= 1200 // MSVC 6
|
||||
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
||||
// (no conversion from unsigned __int64).
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
||||
// characters in the debug information)
|
||||
// All projects I've ever seen with VS6 were using this globally (not bothering
|
||||
// with pragma push/pop).
|
||||
# pragma warning(disable : 4786)
|
||||
# endif // MSVC 6
|
||||
|
||||
# if _MSC_VER >= 1500 // MSVC 2008
|
||||
/// Indicates that the following function is deprecated.
|
||||
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
# endif
|
||||
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
// In c++11 the override keyword allows you to explicity define that a function
|
||||
// is intended to override the base-class version. This makes the code more
|
||||
// managable and fixes a set of common hard-to-find bugs.
|
||||
#if __cplusplus >= 201103L
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT noexcept
|
||||
#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT throw()
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1900
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT noexcept
|
||||
#else
|
||||
# define JSONCPP_OVERRIDE
|
||||
# define JSONCPP_NOEXCEPT throw()
|
||||
#endif
|
||||
|
||||
#ifndef JSON_HAS_RVALUE_REFERENCES
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // MSVC >= 2010
|
||||
|
||||
#ifdef __clang__
|
||||
#if __has_feature(cxx_rvalue_references)
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // has_feature
|
||||
|
||||
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // GXX_EXPERIMENTAL
|
||||
|
||||
#endif // __clang__ || __GNUC__
|
||||
|
||||
#endif // not defined JSON_HAS_RVALUE_REFERENCES
|
||||
|
||||
#ifndef JSON_HAS_RVALUE_REFERENCES
|
||||
#define JSON_HAS_RVALUE_REFERENCES 0
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||
# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
# endif // GNUC version
|
||||
#endif // __clang__ || __GNUC__
|
||||
|
||||
#if !defined(JSONCPP_DEPRECATED)
|
||||
#define JSONCPP_DEPRECATED(message)
|
||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||
|
||||
#if __GNUC__ >= 6
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
# include "version.h"
|
||||
|
||||
# if JSONCPP_USING_SECURE_MEMORY
|
||||
# include "allocator.h" //typedef Allocator
|
||||
# endif
|
||||
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
typedef int Int;
|
||||
typedef unsigned int UInt;
|
||||
#if defined(JSON_NO_INT64)
|
||||
typedef int LargestInt;
|
||||
typedef unsigned int LargestUInt;
|
||||
#undef JSON_HAS_INT64
|
||||
#else // if defined(JSON_NO_INT64)
|
||||
// For Microsoft Visual use specific types as long long is not supported
|
||||
#if defined(_MSC_VER) // Microsoft Visual Studio
|
||||
typedef __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||
typedef int64_t Int64;
|
||||
typedef uint64_t UInt64;
|
||||
#endif // if defined(_MSC_VER)
|
||||
typedef Int64 LargestInt;
|
||||
typedef UInt64 LargestUInt;
|
||||
#define JSON_HAS_INT64
|
||||
#endif // if defined(JSON_NO_INT64)
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
|
||||
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#else
|
||||
#define JSONCPP_STRING std::string
|
||||
#define JSONCPP_OSTRINGSTREAM std::ostringstream
|
||||
#define JSONCPP_OSTREAM std::ostream
|
||||
#define JSONCPP_ISTRINGSTREAM std::istringstream
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#endif // if JSONCPP_USING_SECURE_MEMORY
|
||||
} // end namespace Json
|
||||
|
||||
#endif // JSON_CONFIG_H_INCLUDED
|
61
extern/jsoncpp/include/json/features.h
vendored
Normal file
61
extern/jsoncpp/include/json/features.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
#define CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
namespace Json {
|
||||
|
||||
/** \brief Configuration passed to reader and writer.
|
||||
* This configuration object can be used to force the Reader or Writer
|
||||
* to behave in a standard conforming way.
|
||||
*/
|
||||
class JSON_API Features {
|
||||
public:
|
||||
/** \brief A configuration that allows all features and assumes all strings
|
||||
* are UTF-8.
|
||||
* - C & C++ comments are allowed
|
||||
* - Root object can be any JSON value
|
||||
* - Assumes Value strings are encoded in UTF-8
|
||||
*/
|
||||
static Features all();
|
||||
|
||||
/** \brief A configuration that is strictly compatible with the JSON
|
||||
* specification.
|
||||
* - Comments are forbidden.
|
||||
* - Root object must be either an array or an object value.
|
||||
* - Assumes Value strings are encoded in UTF-8
|
||||
*/
|
||||
static Features strictMode();
|
||||
|
||||
/** \brief Initialize the configuration like JsonConfig::allFeatures;
|
||||
*/
|
||||
Features();
|
||||
|
||||
/// \c true if comments are allowed. Default: \c true.
|
||||
bool allowComments_;
|
||||
|
||||
/// \c true if root must be either an array or an object value. Default: \c
|
||||
/// false.
|
||||
bool strictRoot_;
|
||||
|
||||
/// \c true if dropped null placeholders are allowed. Default: \c false.
|
||||
bool allowDroppedNullPlaceholders_;
|
||||
|
||||
/// \c true if numeric object key are allowed. Default: \c false.
|
||||
bool allowNumericKeys_;
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
|
37
extern/jsoncpp/include/json/forwards.h
vendored
Normal file
37
extern/jsoncpp/include/json/forwards.h
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||
#define JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
// writer.h
|
||||
class FastWriter;
|
||||
class StyledWriter;
|
||||
|
||||
// reader.h
|
||||
class Reader;
|
||||
|
||||
// features.h
|
||||
class Features;
|
||||
|
||||
// value.h
|
||||
typedef unsigned int ArrayIndex;
|
||||
class StaticString;
|
||||
class Path;
|
||||
class PathArgument;
|
||||
class Value;
|
||||
class ValueIteratorBase;
|
||||
class ValueIterator;
|
||||
class ValueConstIterator;
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#endif // JSON_FORWARDS_H_INCLUDED
|
15
extern/jsoncpp/include/json/json.h
vendored
Normal file
15
extern/jsoncpp/include/json/json.h
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_JSON_H_INCLUDED
|
||||
#define JSON_JSON_H_INCLUDED
|
||||
|
||||
#include "autolink.h"
|
||||
#include "value.h"
|
||||
#include "reader.h"
|
||||
#include "writer.h"
|
||||
#include "features.h"
|
||||
|
||||
#endif // JSON_JSON_H_INCLUDED
|
408
extern/jsoncpp/include/json/reader.h
vendored
Normal file
408
extern/jsoncpp/include/json/reader.h
vendored
Normal file
@@ -0,0 +1,408 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef CPPTL_JSON_READER_H_INCLUDED
|
||||
#define CPPTL_JSON_READER_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "features.h"
|
||||
#include "value.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <deque>
|
||||
#include <iosfwd>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <istream>
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
namespace Json {
|
||||
|
||||
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
|
||||
*Value.
|
||||
*
|
||||
* \deprecated Use CharReader and CharReaderBuilder.
|
||||
*/
|
||||
class JSON_API Reader {
|
||||
public:
|
||||
typedef char Char;
|
||||
typedef const Char* Location;
|
||||
|
||||
/** \brief An error tagged with where in the JSON text it was encountered.
|
||||
*
|
||||
* The offsets give the [start, limit) range of bytes within the text. Note
|
||||
* that this is bytes, not codepoints.
|
||||
*
|
||||
*/
|
||||
struct StructuredError {
|
||||
ptrdiff_t offset_start;
|
||||
ptrdiff_t offset_limit;
|
||||
JSONCPP_STRING message;
|
||||
};
|
||||
|
||||
/** \brief Constructs a Reader allowing all features
|
||||
* for parsing.
|
||||
*/
|
||||
Reader();
|
||||
|
||||
/** \brief Constructs a Reader allowing the specified feature set
|
||||
* for parsing.
|
||||
*/
|
||||
Reader(const Features& features);
|
||||
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||
* document.
|
||||
* \param document UTF-8 encoded string containing the document to read.
|
||||
* \param root [out] Contains the root value of the document if it was
|
||||
* successfully parsed.
|
||||
* \param collectComments \c true to collect comment and allow writing them
|
||||
* back during
|
||||
* serialization, \c false to discard comments.
|
||||
* This parameter is ignored if
|
||||
* Features::allowComments_
|
||||
* is \c false.
|
||||
* \return \c true if the document was successfully parsed, \c false if an
|
||||
* error occurred.
|
||||
*/
|
||||
bool
|
||||
parse(const std::string& document, Value& root, bool collectComments = true);
|
||||
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||
document.
|
||||
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
|
||||
document to read.
|
||||
* \param endDoc Pointer on the end of the UTF-8 encoded string of the
|
||||
document to read.
|
||||
* Must be >= beginDoc.
|
||||
* \param root [out] Contains the root value of the document if it was
|
||||
* successfully parsed.
|
||||
* \param collectComments \c true to collect comment and allow writing them
|
||||
back during
|
||||
* serialization, \c false to discard comments.
|
||||
* This parameter is ignored if
|
||||
Features::allowComments_
|
||||
* is \c false.
|
||||
* \return \c true if the document was successfully parsed, \c false if an
|
||||
error occurred.
|
||||
*/
|
||||
bool parse(const char* beginDoc,
|
||||
const char* endDoc,
|
||||
Value& root,
|
||||
bool collectComments = true);
|
||||
|
||||
/// \brief Parse from input stream.
|
||||
/// \see Json::operator>>(std::istream&, Json::Value&).
|
||||
bool parse(JSONCPP_ISTREAM& is, Value& root, bool collectComments = true);
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed
|
||||
* document.
|
||||
* \return Formatted error message with the list of errors with their location
|
||||
* in
|
||||
* the parsed document. An empty string is returned if no error
|
||||
* occurred
|
||||
* during parsing.
|
||||
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
||||
*/
|
||||
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
|
||||
JSONCPP_STRING getFormatedErrorMessages() const;
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed
|
||||
* document.
|
||||
* \return Formatted error message with the list of errors with their location
|
||||
* in
|
||||
* the parsed document. An empty string is returned if no error
|
||||
* occurred
|
||||
* during parsing.
|
||||
*/
|
||||
JSONCPP_STRING getFormattedErrorMessages() const;
|
||||
|
||||
/** \brief Returns a vector of structured erros encounted while parsing.
|
||||
* \return A (possibly empty) vector of StructuredError objects. Currently
|
||||
* only one error can be returned, but the caller should tolerate
|
||||
* multiple
|
||||
* errors. This can occur if the parser recovers from a non-fatal
|
||||
* parse error and then encounters additional errors.
|
||||
*/
|
||||
std::vector<StructuredError> getStructuredErrors() const;
|
||||
|
||||
/** \brief Add a semantic error message.
|
||||
* \param value JSON Value location associated with the error
|
||||
* \param message The error message.
|
||||
* \return \c true if the error was successfully added, \c false if the
|
||||
* Value offset exceeds the document size.
|
||||
*/
|
||||
bool pushError(const Value& value, const JSONCPP_STRING& message);
|
||||
|
||||
/** \brief Add a semantic error message with extra context.
|
||||
* \param value JSON Value location associated with the error
|
||||
* \param message The error message.
|
||||
* \param extra Additional JSON Value location to contextualize the error
|
||||
* \return \c true if the error was successfully added, \c false if either
|
||||
* Value offset exceeds the document size.
|
||||
*/
|
||||
bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
|
||||
|
||||
/** \brief Return whether there are any errors.
|
||||
* \return \c true if there are no errors to report \c false if
|
||||
* errors have occurred.
|
||||
*/
|
||||
bool good() const;
|
||||
|
||||
private:
|
||||
enum TokenType {
|
||||
tokenEndOfStream = 0,
|
||||
tokenObjectBegin,
|
||||
tokenObjectEnd,
|
||||
tokenArrayBegin,
|
||||
tokenArrayEnd,
|
||||
tokenString,
|
||||
tokenNumber,
|
||||
tokenTrue,
|
||||
tokenFalse,
|
||||
tokenNull,
|
||||
tokenArraySeparator,
|
||||
tokenMemberSeparator,
|
||||
tokenComment,
|
||||
tokenError
|
||||
};
|
||||
|
||||
class Token {
|
||||
public:
|
||||
TokenType type_;
|
||||
Location start_;
|
||||
Location end_;
|
||||
};
|
||||
|
||||
class ErrorInfo {
|
||||
public:
|
||||
Token token_;
|
||||
JSONCPP_STRING message_;
|
||||
Location extra_;
|
||||
};
|
||||
|
||||
typedef std::deque<ErrorInfo> Errors;
|
||||
|
||||
bool readToken(Token& token);
|
||||
void skipSpaces();
|
||||
bool match(Location pattern, int patternLength);
|
||||
bool readComment();
|
||||
bool readCStyleComment();
|
||||
bool readCppStyleComment();
|
||||
bool readString();
|
||||
void readNumber();
|
||||
bool readValue();
|
||||
bool readObject(Token& token);
|
||||
bool readArray(Token& token);
|
||||
bool decodeNumber(Token& token);
|
||||
bool decodeNumber(Token& token, Value& decoded);
|
||||
bool decodeString(Token& token);
|
||||
bool decodeString(Token& token, JSONCPP_STRING& decoded);
|
||||
bool decodeDouble(Token& token);
|
||||
bool decodeDouble(Token& token, Value& decoded);
|
||||
bool decodeUnicodeCodePoint(Token& token,
|
||||
Location& current,
|
||||
Location end,
|
||||
unsigned int& unicode);
|
||||
bool decodeUnicodeEscapeSequence(Token& token,
|
||||
Location& current,
|
||||
Location end,
|
||||
unsigned int& unicode);
|
||||
bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
|
||||
bool recoverFromError(TokenType skipUntilToken);
|
||||
bool addErrorAndRecover(const JSONCPP_STRING& message,
|
||||
Token& token,
|
||||
TokenType skipUntilToken);
|
||||
void skipUntilSpace();
|
||||
Value& currentValue();
|
||||
Char getNextChar();
|
||||
void
|
||||
getLocationLineAndColumn(Location location, int& line, int& column) const;
|
||||
JSONCPP_STRING getLocationLineAndColumn(Location location) const;
|
||||
void addComment(Location begin, Location end, CommentPlacement placement);
|
||||
void skipCommentTokens(Token& token);
|
||||
|
||||
typedef std::stack<Value*> Nodes;
|
||||
Nodes nodes_;
|
||||
Errors errors_;
|
||||
JSONCPP_STRING document_;
|
||||
Location begin_;
|
||||
Location end_;
|
||||
Location current_;
|
||||
Location lastValueEnd_;
|
||||
Value* lastValue_;
|
||||
JSONCPP_STRING commentsBefore_;
|
||||
Features features_;
|
||||
bool collectComments_;
|
||||
}; // Reader
|
||||
|
||||
/** Interface for reading JSON from a char array.
|
||||
*/
|
||||
class JSON_API CharReader {
|
||||
public:
|
||||
virtual ~CharReader() {}
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||
document.
|
||||
* The document must be a UTF-8 encoded string containing the document to read.
|
||||
*
|
||||
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
|
||||
document to read.
|
||||
* \param endDoc Pointer on the end of the UTF-8 encoded string of the
|
||||
document to read.
|
||||
* Must be >= beginDoc.
|
||||
* \param root [out] Contains the root value of the document if it was
|
||||
* successfully parsed.
|
||||
* \param errs [out] Formatted error messages (if not NULL)
|
||||
* a user friendly string that lists errors in the parsed
|
||||
* document.
|
||||
* \return \c true if the document was successfully parsed, \c false if an
|
||||
error occurred.
|
||||
*/
|
||||
virtual bool parse(
|
||||
char const* beginDoc, char const* endDoc,
|
||||
Value* root, JSONCPP_STRING* errs) = 0;
|
||||
|
||||
class JSON_API Factory {
|
||||
public:
|
||||
virtual ~Factory() {}
|
||||
/** \brief Allocate a CharReader via operator new().
|
||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||
*/
|
||||
virtual CharReader* newCharReader() const = 0;
|
||||
}; // Factory
|
||||
}; // CharReader
|
||||
|
||||
/** \brief Build a CharReader implementation.
|
||||
|
||||
Usage:
|
||||
\code
|
||||
using namespace Json;
|
||||
CharReaderBuilder builder;
|
||||
builder["collectComments"] = false;
|
||||
Value value;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = parseFromStream(builder, std::cin, &value, &errs);
|
||||
\endcode
|
||||
*/
|
||||
class JSON_API CharReaderBuilder : public CharReader::Factory {
|
||||
public:
|
||||
// Note: We use a Json::Value so that we can add data-members to this class
|
||||
// without a major version bump.
|
||||
/** Configuration of this builder.
|
||||
These are case-sensitive.
|
||||
Available settings (case-sensitive):
|
||||
- `"collectComments": false or true`
|
||||
- true to collect comment and allow writing them
|
||||
back during serialization, false to discard comments.
|
||||
This parameter is ignored if allowComments is false.
|
||||
- `"allowComments": false or true`
|
||||
- true if comments are allowed.
|
||||
- `"strictRoot": false or true`
|
||||
- true if root must be either an array or an object value
|
||||
- `"allowDroppedNullPlaceholders": false or true`
|
||||
- true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
|
||||
- `"allowNumericKeys": false or true`
|
||||
- true if numeric object keys are allowed.
|
||||
- `"allowSingleQuotes": false or true`
|
||||
- true if '' are allowed for strings (both keys and values)
|
||||
- `"stackLimit": integer`
|
||||
- Exceeding stackLimit (recursive depth of `readValue()`) will
|
||||
cause an exception.
|
||||
- This is a security issue (seg-faults caused by deeply nested JSON),
|
||||
so the default is low.
|
||||
- `"failIfExtra": false or true`
|
||||
- If true, `parse()` returns false when extra non-whitespace trails
|
||||
the JSON value in the input string.
|
||||
- `"rejectDupKeys": false or true`
|
||||
- If true, `parse()` returns false when a key is duplicated within an object.
|
||||
- `"allowSpecialFloats": false or true`
|
||||
- If true, special float values (NaNs and infinities) are allowed
|
||||
and their values are lossfree restorable.
|
||||
|
||||
You can examine 'settings_` yourself
|
||||
to see the defaults. You can also write and read them just like any
|
||||
JSON Value.
|
||||
\sa setDefaults()
|
||||
*/
|
||||
Json::Value settings_;
|
||||
|
||||
CharReaderBuilder();
|
||||
~CharReaderBuilder() JSONCPP_OVERRIDE;
|
||||
|
||||
CharReader* newCharReader() const JSONCPP_OVERRIDE;
|
||||
|
||||
/** \return true if 'settings' are legal and consistent;
|
||||
* otherwise, indicate bad settings via 'invalid'.
|
||||
*/
|
||||
bool validate(Json::Value* invalid) const;
|
||||
|
||||
/** A simple way to update a specific setting.
|
||||
*/
|
||||
Value& operator[](JSONCPP_STRING key);
|
||||
|
||||
/** Called by ctor, but you can use this to reset settings_.
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
* \remark Defaults:
|
||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
||||
*/
|
||||
static void setDefaults(Json::Value* settings);
|
||||
/** Same as old Features::strictMode().
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
* \remark Defaults:
|
||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
||||
*/
|
||||
static void strictMode(Json::Value* settings);
|
||||
};
|
||||
|
||||
/** Consume entire stream and use its begin/end.
|
||||
* Someday we might have a real StreamReader, but for now this
|
||||
* is convenient.
|
||||
*/
|
||||
bool JSON_API parseFromStream(
|
||||
CharReader::Factory const&,
|
||||
JSONCPP_ISTREAM&,
|
||||
Value* root, std::string* errs);
|
||||
|
||||
/** \brief Read from 'sin' into 'root'.
|
||||
|
||||
Always keep comments from the input JSON.
|
||||
|
||||
This can be used to read a file into a particular sub-object.
|
||||
For example:
|
||||
\code
|
||||
Json::Value root;
|
||||
cin >> root["dir"]["file"];
|
||||
cout << root;
|
||||
\endcode
|
||||
Result:
|
||||
\verbatim
|
||||
{
|
||||
"dir": {
|
||||
"file": {
|
||||
// The input stream JSON would be nested here.
|
||||
}
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
\throw std::exception on parse error.
|
||||
\see Json::operator<<()
|
||||
*/
|
||||
JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#endif // CPPTL_JSON_READER_H_INCLUDED
|
888
extern/jsoncpp/include/json/value.h
vendored
Normal file
888
extern/jsoncpp/include/json/value.h
vendored
Normal file
@@ -0,0 +1,888 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef CPPTL_JSON_H_INCLUDED
|
||||
#define CPPTL_JSON_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <exception>
|
||||
|
||||
#ifndef JSON_USE_CPPTL_SMALLMAP
|
||||
#include <map>
|
||||
#else
|
||||
#include <cpptl/smallmap.h>
|
||||
#endif
|
||||
#ifdef JSON_USE_CPPTL
|
||||
#include <cpptl/forwards.h>
|
||||
#endif
|
||||
|
||||
//Conditional NORETURN attribute on the throw functions would:
|
||||
// a) suppress false positives from static code analysis
|
||||
// b) possibly improve optimization opportunities.
|
||||
#if !defined(JSONCPP_NORETURN)
|
||||
# if defined(_MSC_VER)
|
||||
# define JSONCPP_NORETURN __declspec(noreturn)
|
||||
# elif defined(__GNUC__)
|
||||
# define JSONCPP_NORETURN __attribute__ ((__noreturn__))
|
||||
# else
|
||||
# define JSONCPP_NORETURN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
/** \brief JSON (JavaScript Object Notation).
|
||||
*/
|
||||
namespace Json {
|
||||
|
||||
/** Base class for all exceptions we throw.
|
||||
*
|
||||
* We use nothing but these internally. Of course, STL can throw others.
|
||||
*/
|
||||
class JSON_API Exception : public std::exception {
|
||||
public:
|
||||
Exception(JSONCPP_STRING const& msg);
|
||||
~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
|
||||
char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
|
||||
protected:
|
||||
JSONCPP_STRING msg_;
|
||||
};
|
||||
|
||||
/** Exceptions which the user cannot easily avoid.
|
||||
*
|
||||
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
||||
*
|
||||
* \remark derived from Json::Exception
|
||||
*/
|
||||
class JSON_API RuntimeError : public Exception {
|
||||
public:
|
||||
RuntimeError(JSONCPP_STRING const& msg);
|
||||
};
|
||||
|
||||
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
||||
*
|
||||
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
||||
*
|
||||
* \remark derived from Json::Exception
|
||||
*/
|
||||
class JSON_API LogicError : public Exception {
|
||||
public:
|
||||
LogicError(JSONCPP_STRING const& msg);
|
||||
};
|
||||
|
||||
/// used internally
|
||||
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
|
||||
/// used internally
|
||||
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
|
||||
|
||||
/** \brief Type of the value held by a Value object.
|
||||
*/
|
||||
enum ValueType {
|
||||
nullValue = 0, ///< 'null' value
|
||||
intValue, ///< signed integer value
|
||||
uintValue, ///< unsigned integer value
|
||||
realValue, ///< double value
|
||||
stringValue, ///< UTF-8 string value
|
||||
booleanValue, ///< bool value
|
||||
arrayValue, ///< array value (ordered list)
|
||||
objectValue ///< object value (collection of name/value pairs).
|
||||
};
|
||||
|
||||
enum CommentPlacement {
|
||||
commentBefore = 0, ///< a comment placed on the line before a value
|
||||
commentAfterOnSameLine, ///< a comment just after a value on the same line
|
||||
commentAfter, ///< a comment on the line after a value (only make sense for
|
||||
/// root value)
|
||||
numberOfCommentPlacement
|
||||
};
|
||||
|
||||
//# ifdef JSON_USE_CPPTL
|
||||
// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
|
||||
// typedef CppTL::AnyEnumerator<const Value &> EnumValues;
|
||||
//# endif
|
||||
|
||||
/** \brief Lightweight wrapper to tag static string.
|
||||
*
|
||||
* Value constructor and objectValue member assignement takes advantage of the
|
||||
* StaticString and avoid the cost of string duplication when storing the
|
||||
* string or the member name.
|
||||
*
|
||||
* Example of usage:
|
||||
* \code
|
||||
* Json::Value aValue( StaticString("some text") );
|
||||
* Json::Value object;
|
||||
* static const StaticString code("code");
|
||||
* object[code] = 1234;
|
||||
* \endcode
|
||||
*/
|
||||
class JSON_API StaticString {
|
||||
public:
|
||||
explicit StaticString(const char* czstring) : c_str_(czstring) {}
|
||||
|
||||
operator const char*() const { return c_str_; }
|
||||
|
||||
const char* c_str() const { return c_str_; }
|
||||
|
||||
private:
|
||||
const char* c_str_;
|
||||
};
|
||||
|
||||
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
|
||||
*
|
||||
* This class is a discriminated union wrapper that can represents a:
|
||||
* - signed integer [range: Value::minInt - Value::maxInt]
|
||||
* - unsigned integer (range: 0 - Value::maxUInt)
|
||||
* - double
|
||||
* - UTF-8 string
|
||||
* - boolean
|
||||
* - 'null'
|
||||
* - an ordered list of Value
|
||||
* - collection of name/value pairs (javascript object)
|
||||
*
|
||||
* The type of the held value is represented by a #ValueType and
|
||||
* can be obtained using type().
|
||||
*
|
||||
* Values of an #objectValue or #arrayValue can be accessed using operator[]()
|
||||
* methods.
|
||||
* Non-const methods will automatically create the a #nullValue element
|
||||
* if it does not exist.
|
||||
* The sequence of an #arrayValue will be automatically resized and initialized
|
||||
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
|
||||
*
|
||||
* The get() methods can be used to obtain default value in the case the
|
||||
* required element does not exist.
|
||||
*
|
||||
* It is possible to iterate over the list of a #objectValue values using
|
||||
* the getMemberNames() method.
|
||||
*
|
||||
* \note #Value string-length fit in size_t, but keys must be < 2^30.
|
||||
* (The reason is an implementation detail.) A #CharReader will raise an
|
||||
* exception if a bound is exceeded to avoid security holes in your app,
|
||||
* but the Value API does *not* check bounds. That is the responsibility
|
||||
* of the caller.
|
||||
*/
|
||||
class JSON_API Value {
|
||||
friend class ValueIteratorBase;
|
||||
public:
|
||||
typedef std::vector<JSONCPP_STRING> Members;
|
||||
typedef ValueIterator iterator;
|
||||
typedef ValueConstIterator const_iterator;
|
||||
typedef Json::UInt UInt;
|
||||
typedef Json::Int Int;
|
||||
#if defined(JSON_HAS_INT64)
|
||||
typedef Json::UInt64 UInt64;
|
||||
typedef Json::Int64 Int64;
|
||||
#endif // defined(JSON_HAS_INT64)
|
||||
typedef Json::LargestInt LargestInt;
|
||||
typedef Json::LargestUInt LargestUInt;
|
||||
typedef Json::ArrayIndex ArrayIndex;
|
||||
|
||||
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
|
||||
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
|
||||
static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
|
||||
|
||||
/// Minimum signed integer value that can be stored in a Json::Value.
|
||||
static const LargestInt minLargestInt;
|
||||
/// Maximum signed integer value that can be stored in a Json::Value.
|
||||
static const LargestInt maxLargestInt;
|
||||
/// Maximum unsigned integer value that can be stored in a Json::Value.
|
||||
static const LargestUInt maxLargestUInt;
|
||||
|
||||
/// Minimum signed int value that can be stored in a Json::Value.
|
||||
static const Int minInt;
|
||||
/// Maximum signed int value that can be stored in a Json::Value.
|
||||
static const Int maxInt;
|
||||
/// Maximum unsigned int value that can be stored in a Json::Value.
|
||||
static const UInt maxUInt;
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
/// Minimum signed 64 bits int value that can be stored in a Json::Value.
|
||||
static const Int64 minInt64;
|
||||
/// Maximum signed 64 bits int value that can be stored in a Json::Value.
|
||||
static const Int64 maxInt64;
|
||||
/// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
|
||||
static const UInt64 maxUInt64;
|
||||
#endif // defined(JSON_HAS_INT64)
|
||||
|
||||
private:
|
||||
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||
class CZString {
|
||||
public:
|
||||
enum DuplicationPolicy {
|
||||
noDuplication = 0,
|
||||
duplicate,
|
||||
duplicateOnCopy
|
||||
};
|
||||
CZString(ArrayIndex index);
|
||||
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
||||
CZString(CZString const& other);
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
CZString(CZString&& other);
|
||||
#endif
|
||||
~CZString();
|
||||
CZString& operator=(const CZString& other);
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
CZString& operator=(CZString&& other);
|
||||
#endif
|
||||
|
||||
bool operator<(CZString const& other) const;
|
||||
bool operator==(CZString const& other) const;
|
||||
ArrayIndex index() const;
|
||||
//const char* c_str() const; ///< \deprecated
|
||||
char const* data() const;
|
||||
unsigned length() const;
|
||||
bool isStaticString() const;
|
||||
|
||||
private:
|
||||
void swap(CZString& other);
|
||||
|
||||
struct StringStorage {
|
||||
unsigned policy_: 2;
|
||||
unsigned length_: 30; // 1GB max
|
||||
};
|
||||
|
||||
char const* cstr_; // actually, a prefixed string, unless policy is noDup
|
||||
union {
|
||||
ArrayIndex index_;
|
||||
StringStorage storage_;
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
#ifndef JSON_USE_CPPTL_SMALLMAP
|
||||
typedef std::map<CZString, Value> ObjectValues;
|
||||
#else
|
||||
typedef CppTL::SmallMap<CZString, Value> ObjectValues;
|
||||
#endif // ifndef JSON_USE_CPPTL_SMALLMAP
|
||||
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||
|
||||
public:
|
||||
/** \brief Create a default Value of the given type.
|
||||
|
||||
This is a very useful constructor.
|
||||
To create an empty array, pass arrayValue.
|
||||
To create an empty object, pass objectValue.
|
||||
Another Value can then be set to this one by assignment.
|
||||
This is useful since clear() and resize() will not alter types.
|
||||
|
||||
Examples:
|
||||
\code
|
||||
Json::Value null_value; // null
|
||||
Json::Value arr_value(Json::arrayValue); // []
|
||||
Json::Value obj_value(Json::objectValue); // {}
|
||||
\endcode
|
||||
*/
|
||||
Value(ValueType type = nullValue);
|
||||
Value(Int value);
|
||||
Value(UInt value);
|
||||
#if defined(JSON_HAS_INT64)
|
||||
Value(Int64 value);
|
||||
Value(UInt64 value);
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
Value(double value);
|
||||
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
|
||||
Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
|
||||
/** \brief Constructs a value from a static string.
|
||||
|
||||
* Like other value string constructor but do not duplicate the string for
|
||||
* internal storage. The given string must remain alive after the call to this
|
||||
* constructor.
|
||||
* \note This works only for null-terminated strings. (We cannot change the
|
||||
* size of this class, so we have nowhere to store the length,
|
||||
* which might be computed later for various operations.)
|
||||
*
|
||||
* Example of usage:
|
||||
* \code
|
||||
* static StaticString foo("some text");
|
||||
* Json::Value aValue(foo);
|
||||
* \endcode
|
||||
*/
|
||||
Value(const StaticString& value);
|
||||
Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
|
||||
#ifdef JSON_USE_CPPTL
|
||||
Value(const CppTL::ConstString& value);
|
||||
#endif
|
||||
Value(bool value);
|
||||
/// Deep copy.
|
||||
Value(const Value& other);
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
/// Move constructor
|
||||
Value(Value&& other);
|
||||
#endif
|
||||
~Value();
|
||||
|
||||
/// Deep copy, then swap(other).
|
||||
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
|
||||
Value& operator=(const Value& other);
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
Value& operator=(Value&& other);
|
||||
#endif
|
||||
|
||||
/// Swap everything.
|
||||
void swap(Value& other);
|
||||
/// Swap values but leave comments and source offsets in place.
|
||||
void swapPayload(Value& other);
|
||||
|
||||
/// copy everything.
|
||||
void copy(const Value& other);
|
||||
/// copy values but leave comments and source offsets in place.
|
||||
void copyPayload(const Value& other);
|
||||
|
||||
ValueType type() const;
|
||||
|
||||
/// Compare payload only, not comments etc.
|
||||
bool operator<(const Value& other) const;
|
||||
bool operator<=(const Value& other) const;
|
||||
bool operator>=(const Value& other) const;
|
||||
bool operator>(const Value& other) const;
|
||||
bool operator==(const Value& other) const;
|
||||
bool operator!=(const Value& other) const;
|
||||
int compare(const Value& other) const;
|
||||
|
||||
const char* asCString() const; ///< Embedded zeroes could cause you trouble!
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
unsigned getCStringLength() const; //Allows you to understand the length of the CString
|
||||
#endif
|
||||
JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
|
||||
/** Get raw char* of string-value.
|
||||
* \return false if !string. (Seg-fault if str or end are NULL.)
|
||||
*/
|
||||
bool getString(
|
||||
char const** begin, char const** end) const;
|
||||
#ifdef JSON_USE_CPPTL
|
||||
CppTL::ConstString asConstString() const;
|
||||
#endif
|
||||
Int asInt() const;
|
||||
UInt asUInt() const;
|
||||
#if defined(JSON_HAS_INT64)
|
||||
Int64 asInt64() const;
|
||||
UInt64 asUInt64() const;
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
LargestInt asLargestInt() const;
|
||||
LargestUInt asLargestUInt() const;
|
||||
float asFloat() const;
|
||||
double asDouble() const;
|
||||
bool asBool() const;
|
||||
|
||||
bool isNull() const;
|
||||
bool isBool() const;
|
||||
bool isInt() const;
|
||||
bool isInt64() const;
|
||||
bool isUInt() const;
|
||||
bool isUInt64() const;
|
||||
bool isIntegral() const;
|
||||
bool isDouble() const;
|
||||
bool isNumeric() const;
|
||||
bool isString() const;
|
||||
bool isArray() const;
|
||||
bool isObject() const;
|
||||
|
||||
bool isConvertibleTo(ValueType other) const;
|
||||
|
||||
/// Number of values in array or object
|
||||
ArrayIndex size() const;
|
||||
|
||||
/// \brief Return true if empty array, empty object, or null;
|
||||
/// otherwise, false.
|
||||
bool empty() const;
|
||||
|
||||
/// Return isNull()
|
||||
bool operator!() const;
|
||||
|
||||
/// Remove all object members and array elements.
|
||||
/// \pre type() is arrayValue, objectValue, or nullValue
|
||||
/// \post type() is unchanged
|
||||
void clear();
|
||||
|
||||
/// Resize the array to size elements.
|
||||
/// New elements are initialized to null.
|
||||
/// May only be called on nullValue or arrayValue.
|
||||
/// \pre type() is arrayValue or nullValue
|
||||
/// \post type() is arrayValue
|
||||
void resize(ArrayIndex size);
|
||||
|
||||
/// Access an array element (zero based index ).
|
||||
/// If the array contains less than index element, then null value are
|
||||
/// inserted
|
||||
/// in the array so that its size is index+1.
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
Value& operator[](ArrayIndex index);
|
||||
|
||||
/// Access an array element (zero based index ).
|
||||
/// If the array contains less than index element, then null value are
|
||||
/// inserted
|
||||
/// in the array so that its size is index+1.
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
Value& operator[](int index);
|
||||
|
||||
/// Access an array element (zero based index )
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
const Value& operator[](ArrayIndex index) const;
|
||||
|
||||
/// Access an array element (zero based index )
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
const Value& operator[](int index) const;
|
||||
|
||||
/// If the array contains at least index+1 elements, returns the element
|
||||
/// value,
|
||||
/// otherwise returns defaultValue.
|
||||
Value get(ArrayIndex index, const Value& defaultValue) const;
|
||||
/// Return true if index < size().
|
||||
bool isValidIndex(ArrayIndex index) const;
|
||||
/// \brief Append value to array at the end.
|
||||
///
|
||||
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
|
||||
Value& append(const Value& value);
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
Value& append(Value&& value);
|
||||
#endif
|
||||
|
||||
/// Access an object value by name, create a null member if it does not exist.
|
||||
/// \note Because of our implementation, keys are limited to 2^30 -1 chars.
|
||||
/// Exceeding that will cause an exception.
|
||||
Value& operator[](const char* key);
|
||||
/// Access an object value by name, returns null if there is no member with
|
||||
/// that name.
|
||||
const Value& operator[](const char* key) const;
|
||||
/// Access an object value by name, create a null member if it does not exist.
|
||||
/// \param key may contain embedded nulls.
|
||||
Value& operator[](const JSONCPP_STRING& key);
|
||||
/// Access an object value by name, returns null if there is no member with
|
||||
/// that name.
|
||||
/// \param key may contain embedded nulls.
|
||||
const Value& operator[](const JSONCPP_STRING& key) const;
|
||||
/** \brief Access an object value by name, create a null member if it does not
|
||||
exist.
|
||||
|
||||
* If the object has no entry for that name, then the member name used to store
|
||||
* the new entry is not duplicated.
|
||||
* Example of use:
|
||||
* \code
|
||||
* Json::Value object;
|
||||
* static const StaticString code("code");
|
||||
* object[code] = 1234;
|
||||
* \endcode
|
||||
*/
|
||||
Value& operator[](const StaticString& key);
|
||||
#ifdef JSON_USE_CPPTL
|
||||
/// Access an object value by name, create a null member if it does not exist.
|
||||
Value& operator[](const CppTL::ConstString& key);
|
||||
/// Access an object value by name, returns null if there is no member with
|
||||
/// that name.
|
||||
const Value& operator[](const CppTL::ConstString& key) const;
|
||||
#endif
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
Value get(const char* key, const Value& defaultValue) const;
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
/// \note key may contain embedded nulls.
|
||||
Value get(const char* begin, const char* end, const Value& defaultValue) const;
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
/// \param key may contain embedded nulls.
|
||||
Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
|
||||
#ifdef JSON_USE_CPPTL
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
|
||||
#endif
|
||||
/// Most general and efficient version of isMember()const, get()const,
|
||||
/// and operator[]const
|
||||
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
||||
Value const* find(char const* begin, char const* end) const;
|
||||
/// Most general and efficient version of object-mutators.
|
||||
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
||||
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
|
||||
Value const* demand(char const* begin, char const* end);
|
||||
/// \brief Remove and return the named member.
|
||||
///
|
||||
/// Do nothing if it did not exist.
|
||||
/// \return the removed Value, or null.
|
||||
/// \pre type() is objectValue or nullValue
|
||||
/// \post type() is unchanged
|
||||
/// \deprecated
|
||||
Value removeMember(const char* key);
|
||||
/// Same as removeMember(const char*)
|
||||
/// \param key may contain embedded nulls.
|
||||
/// \deprecated
|
||||
Value removeMember(const JSONCPP_STRING& key);
|
||||
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
||||
/// but 'key' is null-terminated.
|
||||
bool removeMember(const char* key, Value* removed);
|
||||
/** \brief Remove the named map member.
|
||||
|
||||
Update 'removed' iff removed.
|
||||
\param key may contain embedded nulls.
|
||||
\return true iff removed (no exceptions)
|
||||
*/
|
||||
bool removeMember(JSONCPP_STRING const& key, Value* removed);
|
||||
/// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
|
||||
bool removeMember(const char* begin, const char* end, Value* removed);
|
||||
/** \brief Remove the indexed array element.
|
||||
|
||||
O(n) expensive operations.
|
||||
Update 'removed' iff removed.
|
||||
\return true iff removed (no exceptions)
|
||||
*/
|
||||
bool removeIndex(ArrayIndex i, Value* removed);
|
||||
|
||||
/// Return true if the object has a member named key.
|
||||
/// \note 'key' must be null-terminated.
|
||||
bool isMember(const char* key) const;
|
||||
/// Return true if the object has a member named key.
|
||||
/// \param key may contain embedded nulls.
|
||||
bool isMember(const JSONCPP_STRING& key) const;
|
||||
/// Same as isMember(JSONCPP_STRING const& key)const
|
||||
bool isMember(const char* begin, const char* end) const;
|
||||
#ifdef JSON_USE_CPPTL
|
||||
/// Return true if the object has a member named key.
|
||||
bool isMember(const CppTL::ConstString& key) const;
|
||||
#endif
|
||||
|
||||
/// \brief Return a list of the member names.
|
||||
///
|
||||
/// If null, return an empty list.
|
||||
/// \pre type() is objectValue or nullValue
|
||||
/// \post if type() was nullValue, it remains nullValue
|
||||
Members getMemberNames() const;
|
||||
|
||||
//# ifdef JSON_USE_CPPTL
|
||||
// EnumMemberNames enumMemberNames() const;
|
||||
// EnumValues enumValues() const;
|
||||
//# endif
|
||||
|
||||
/// \deprecated Always pass len.
|
||||
JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
|
||||
void setComment(const char* comment, CommentPlacement placement);
|
||||
/// Comments must be //... or /* ... */
|
||||
void setComment(const char* comment, size_t len, CommentPlacement placement);
|
||||
/// Comments must be //... or /* ... */
|
||||
void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
|
||||
bool hasComment(CommentPlacement placement) const;
|
||||
/// Include delimiters and embedded newlines.
|
||||
JSONCPP_STRING getComment(CommentPlacement placement) const;
|
||||
|
||||
JSONCPP_STRING toStyledString() const;
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
// Accessors for the [start, limit) range of bytes within the JSON text from
|
||||
// which this value was parsed, if any.
|
||||
void setOffsetStart(ptrdiff_t start);
|
||||
void setOffsetLimit(ptrdiff_t limit);
|
||||
ptrdiff_t getOffsetStart() const;
|
||||
ptrdiff_t getOffsetLimit() const;
|
||||
|
||||
private:
|
||||
void initBasic(ValueType type, bool allocated = false);
|
||||
|
||||
Value& resolveReference(const char* key);
|
||||
Value& resolveReference(const char* key, const char* end);
|
||||
|
||||
struct CommentInfo {
|
||||
CommentInfo();
|
||||
~CommentInfo();
|
||||
|
||||
void setComment(const char* text, size_t len);
|
||||
|
||||
char* comment_;
|
||||
};
|
||||
|
||||
// struct MemberNamesTransform
|
||||
//{
|
||||
// typedef const char *result_type;
|
||||
// const char *operator()( const CZString &name ) const
|
||||
// {
|
||||
// return name.c_str();
|
||||
// }
|
||||
//};
|
||||
|
||||
union ValueHolder {
|
||||
LargestInt int_;
|
||||
LargestUInt uint_;
|
||||
double real_;
|
||||
bool bool_;
|
||||
char* string_; // actually ptr to unsigned, followed by str, unless !allocated_
|
||||
ObjectValues* map_;
|
||||
} value_;
|
||||
ValueType type_ : 8;
|
||||
unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
|
||||
// If not allocated_, string_ must be null-terminated.
|
||||
CommentInfo* comments_;
|
||||
|
||||
// [start, limit) byte offsets in the source JSON text from which this Value
|
||||
// was extracted.
|
||||
ptrdiff_t start_;
|
||||
ptrdiff_t limit_;
|
||||
};
|
||||
|
||||
/** \brief Experimental and untested: represents an element of the "path" to
|
||||
* access a node.
|
||||
*/
|
||||
class JSON_API PathArgument {
|
||||
public:
|
||||
friend class Path;
|
||||
|
||||
PathArgument();
|
||||
PathArgument(ArrayIndex index);
|
||||
PathArgument(const char* key);
|
||||
PathArgument(const JSONCPP_STRING& key);
|
||||
|
||||
private:
|
||||
enum Kind {
|
||||
kindNone = 0,
|
||||
kindIndex,
|
||||
kindKey
|
||||
};
|
||||
JSONCPP_STRING key_;
|
||||
ArrayIndex index_;
|
||||
Kind kind_;
|
||||
};
|
||||
|
||||
/** \brief Experimental and untested: represents a "path" to access a node.
|
||||
*
|
||||
* Syntax:
|
||||
* - "." => root node
|
||||
* - ".[n]" => elements at index 'n' of root node (an array value)
|
||||
* - ".name" => member named 'name' of root node (an object value)
|
||||
* - ".name1.name2.name3"
|
||||
* - ".[0][1][2].name1[3]"
|
||||
* - ".%" => member name is provided as parameter
|
||||
* - ".[%]" => index is provied as parameter
|
||||
*/
|
||||
class JSON_API Path {
|
||||
public:
|
||||
Path(const JSONCPP_STRING& path,
|
||||
const PathArgument& a1 = PathArgument(),
|
||||
const PathArgument& a2 = PathArgument(),
|
||||
const PathArgument& a3 = PathArgument(),
|
||||
const PathArgument& a4 = PathArgument(),
|
||||
const PathArgument& a5 = PathArgument());
|
||||
|
||||
const Value& resolve(const Value& root) const;
|
||||
Value resolve(const Value& root, const Value& defaultValue) const;
|
||||
/// Creates the "path" to access the specified node and returns a reference on
|
||||
/// the node.
|
||||
Value& make(Value& root) const;
|
||||
|
||||
private:
|
||||
typedef std::vector<const PathArgument*> InArgs;
|
||||
typedef std::vector<PathArgument> Args;
|
||||
|
||||
void makePath(const JSONCPP_STRING& path, const InArgs& in);
|
||||
void addPathInArg(const JSONCPP_STRING& path,
|
||||
const InArgs& in,
|
||||
InArgs::const_iterator& itInArg,
|
||||
PathArgument::Kind kind);
|
||||
void invalidPath(const JSONCPP_STRING& path, int location);
|
||||
|
||||
Args args_;
|
||||
};
|
||||
|
||||
/** \brief base class for Value iterators.
|
||||
*
|
||||
*/
|
||||
class JSON_API ValueIteratorBase {
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef unsigned int size_t;
|
||||
typedef int difference_type;
|
||||
typedef ValueIteratorBase SelfType;
|
||||
|
||||
bool operator==(const SelfType& other) const { return isEqual(other); }
|
||||
|
||||
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
||||
|
||||
difference_type operator-(const SelfType& other) const {
|
||||
return other.computeDistance(*this);
|
||||
}
|
||||
|
||||
/// Return either the index or the member name of the referenced value as a
|
||||
/// Value.
|
||||
Value key() const;
|
||||
|
||||
/// Return the index of the referenced Value, or -1 if it is not an arrayValue.
|
||||
UInt index() const;
|
||||
|
||||
/// Return the member name of the referenced Value, or "" if it is not an
|
||||
/// objectValue.
|
||||
/// \note Avoid `c_str()` on result, as embedded zeroes are possible.
|
||||
JSONCPP_STRING name() const;
|
||||
|
||||
/// Return the member name of the referenced Value. "" if it is not an
|
||||
/// objectValue.
|
||||
/// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
|
||||
JSONCPP_DEPRECATED("Use `key = name();` instead.")
|
||||
char const* memberName() const;
|
||||
/// Return the member name of the referenced Value, or NULL if it is not an
|
||||
/// objectValue.
|
||||
/// \note Better version than memberName(). Allows embedded nulls.
|
||||
char const* memberName(char const** end) const;
|
||||
|
||||
protected:
|
||||
Value& deref() const;
|
||||
|
||||
void increment();
|
||||
|
||||
void decrement();
|
||||
|
||||
difference_type computeDistance(const SelfType& other) const;
|
||||
|
||||
bool isEqual(const SelfType& other) const;
|
||||
|
||||
void copy(const SelfType& other);
|
||||
|
||||
private:
|
||||
Value::ObjectValues::iterator current_;
|
||||
// Indicates that iterator is for a null value.
|
||||
bool isNull_;
|
||||
|
||||
public:
|
||||
// For some reason, BORLAND needs these at the end, rather
|
||||
// than earlier. No idea why.
|
||||
ValueIteratorBase();
|
||||
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
|
||||
};
|
||||
|
||||
/** \brief const iterator for object and array value.
|
||||
*
|
||||
*/
|
||||
class JSON_API ValueConstIterator : public ValueIteratorBase {
|
||||
friend class Value;
|
||||
|
||||
public:
|
||||
typedef const Value value_type;
|
||||
//typedef unsigned int size_t;
|
||||
//typedef int difference_type;
|
||||
typedef const Value& reference;
|
||||
typedef const Value* pointer;
|
||||
typedef ValueConstIterator SelfType;
|
||||
|
||||
ValueConstIterator();
|
||||
ValueConstIterator(ValueIterator const& other);
|
||||
|
||||
private:
|
||||
/*! \internal Use by Value to create an iterator.
|
||||
*/
|
||||
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
|
||||
public:
|
||||
SelfType& operator=(const ValueIteratorBase& other);
|
||||
|
||||
SelfType operator++(int) {
|
||||
SelfType temp(*this);
|
||||
++*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
SelfType operator--(int) {
|
||||
SelfType temp(*this);
|
||||
--*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
SelfType& operator--() {
|
||||
decrement();
|
||||
return *this;
|
||||
}
|
||||
|
||||
SelfType& operator++() {
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference operator*() const { return deref(); }
|
||||
|
||||
pointer operator->() const { return &deref(); }
|
||||
};
|
||||
|
||||
/** \brief Iterator for object and array value.
|
||||
*/
|
||||
class JSON_API ValueIterator : public ValueIteratorBase {
|
||||
friend class Value;
|
||||
|
||||
public:
|
||||
typedef Value value_type;
|
||||
typedef unsigned int size_t;
|
||||
typedef int difference_type;
|
||||
typedef Value& reference;
|
||||
typedef Value* pointer;
|
||||
typedef ValueIterator SelfType;
|
||||
|
||||
ValueIterator();
|
||||
explicit ValueIterator(const ValueConstIterator& other);
|
||||
ValueIterator(const ValueIterator& other);
|
||||
|
||||
private:
|
||||
/*! \internal Use by Value to create an iterator.
|
||||
*/
|
||||
explicit ValueIterator(const Value::ObjectValues::iterator& current);
|
||||
public:
|
||||
SelfType& operator=(const SelfType& other);
|
||||
|
||||
SelfType operator++(int) {
|
||||
SelfType temp(*this);
|
||||
++*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
SelfType operator--(int) {
|
||||
SelfType temp(*this);
|
||||
--*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
SelfType& operator--() {
|
||||
decrement();
|
||||
return *this;
|
||||
}
|
||||
|
||||
SelfType& operator++() {
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference operator*() const { return deref(); }
|
||||
|
||||
pointer operator->() const { return &deref(); }
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
|
||||
|
||||
namespace std {
|
||||
/// Specialize std::swap() for Json::Value.
|
||||
template<>
|
||||
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
||||
}
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#endif // CPPTL_JSON_H_INCLUDED
|
20
extern/jsoncpp/include/json/version.h
vendored
Normal file
20
extern/jsoncpp/include/json/version.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// DO NOT EDIT. This file (and "version") is generated by CMake.
|
||||
// Run CMake configure step to update it.
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
# define JSON_VERSION_H_INCLUDED
|
||||
|
||||
# define JSONCPP_VERSION_STRING "1.8.1"
|
||||
# define JSONCPP_VERSION_MAJOR 1
|
||||
# define JSONCPP_VERSION_MINOR 8
|
||||
# define JSONCPP_VERSION_PATCH 1
|
||||
# define JSONCPP_VERSION_QUALIFIER
|
||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY 0
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
335
extern/jsoncpp/include/json/writer.h
vendored
Normal file
335
extern/jsoncpp/include/json/writer.h
vendored
Normal file
@@ -0,0 +1,335 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_WRITER_H_INCLUDED
|
||||
#define JSON_WRITER_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "value.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
namespace Json {
|
||||
|
||||
class Value;
|
||||
|
||||
/**
|
||||
|
||||
Usage:
|
||||
\code
|
||||
using namespace Json;
|
||||
void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
|
||||
std::unique_ptr<StreamWriter> const writer(
|
||||
factory.newStreamWriter());
|
||||
writer->write(value, &std::cout);
|
||||
std::cout << std::endl; // add lf and flush
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
class JSON_API StreamWriter {
|
||||
protected:
|
||||
JSONCPP_OSTREAM* sout_; // not owned; will not delete
|
||||
public:
|
||||
StreamWriter();
|
||||
virtual ~StreamWriter();
|
||||
/** Write Value into document as configured in sub-class.
|
||||
Do not take ownership of sout, but maintain a reference during function.
|
||||
\pre sout != NULL
|
||||
\return zero on success (For now, we always return zero, so check the stream instead.)
|
||||
\throw std::exception possibly, depending on configuration
|
||||
*/
|
||||
virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
|
||||
|
||||
/** \brief A simple abstract factory.
|
||||
*/
|
||||
class JSON_API Factory {
|
||||
public:
|
||||
virtual ~Factory();
|
||||
/** \brief Allocate a CharReader via operator new().
|
||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||
*/
|
||||
virtual StreamWriter* newStreamWriter() const = 0;
|
||||
}; // Factory
|
||||
}; // StreamWriter
|
||||
|
||||
/** \brief Write into stringstream, then return string, for convenience.
|
||||
* A StreamWriter will be created from the factory, used, and then deleted.
|
||||
*/
|
||||
JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
|
||||
|
||||
|
||||
/** \brief Build a StreamWriter implementation.
|
||||
|
||||
Usage:
|
||||
\code
|
||||
using namespace Json;
|
||||
Value value = ...;
|
||||
StreamWriterBuilder builder;
|
||||
builder["commentStyle"] = "None";
|
||||
builder["indentation"] = " "; // or whatever you like
|
||||
std::unique_ptr<Json::StreamWriter> writer(
|
||||
builder.newStreamWriter());
|
||||
writer->write(value, &std::cout);
|
||||
std::cout << std::endl; // add lf and flush
|
||||
\endcode
|
||||
*/
|
||||
class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
|
||||
public:
|
||||
// Note: We use a Json::Value so that we can add data-members to this class
|
||||
// without a major version bump.
|
||||
/** Configuration of this builder.
|
||||
Available settings (case-sensitive):
|
||||
- "commentStyle": "None" or "All"
|
||||
- "indentation": "<anything>"
|
||||
- "enableYAMLCompatibility": false or true
|
||||
- slightly change the whitespace around colons
|
||||
- "dropNullPlaceholders": false or true
|
||||
- Drop the "null" string from the writer's output for nullValues.
|
||||
Strictly speaking, this is not valid JSON. But when the output is being
|
||||
fed to a browser's Javascript, it makes for smaller output and the
|
||||
browser can handle the output just fine.
|
||||
- "useSpecialFloats": false or true
|
||||
- If true, outputs non-finite floating point values in the following way:
|
||||
NaN values as "NaN", positive infinity as "Infinity", and negative infinity
|
||||
as "-Infinity".
|
||||
|
||||
You can examine 'settings_` yourself
|
||||
to see the defaults. You can also write and read them just like any
|
||||
JSON Value.
|
||||
\sa setDefaults()
|
||||
*/
|
||||
Json::Value settings_;
|
||||
|
||||
StreamWriterBuilder();
|
||||
~StreamWriterBuilder() JSONCPP_OVERRIDE;
|
||||
|
||||
/**
|
||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||
*/
|
||||
StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
|
||||
|
||||
/** \return true if 'settings' are legal and consistent;
|
||||
* otherwise, indicate bad settings via 'invalid'.
|
||||
*/
|
||||
bool validate(Json::Value* invalid) const;
|
||||
/** A simple way to update a specific setting.
|
||||
*/
|
||||
Value& operator[](JSONCPP_STRING key);
|
||||
|
||||
/** Called by ctor, but you can use this to reset settings_.
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
* \remark Defaults:
|
||||
* \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
|
||||
*/
|
||||
static void setDefaults(Json::Value* settings);
|
||||
};
|
||||
|
||||
/** \brief Abstract class for writers.
|
||||
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
||||
*/
|
||||
class JSON_API Writer {
|
||||
public:
|
||||
virtual ~Writer();
|
||||
|
||||
virtual JSONCPP_STRING write(const Value& root) = 0;
|
||||
};
|
||||
|
||||
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
|
||||
*without formatting (not human friendly).
|
||||
*
|
||||
* The JSON document is written in a single line. It is not intended for 'human'
|
||||
*consumption,
|
||||
* but may be usefull to support feature such as RPC where bandwith is limited.
|
||||
* \sa Reader, Value
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
class JSON_API FastWriter : public Writer {
|
||||
|
||||
public:
|
||||
FastWriter();
|
||||
~FastWriter() JSONCPP_OVERRIDE {}
|
||||
|
||||
void enableYAMLCompatibility();
|
||||
|
||||
/** \brief Drop the "null" string from the writer's output for nullValues.
|
||||
* Strictly speaking, this is not valid JSON. But when the output is being
|
||||
* fed to a browser's Javascript, it makes for smaller output and the
|
||||
* browser can handle the output just fine.
|
||||
*/
|
||||
void dropNullPlaceholders();
|
||||
|
||||
void omitEndingLineFeed();
|
||||
|
||||
public: // overridden from Writer
|
||||
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
|
||||
JSONCPP_STRING document_;
|
||||
bool yamlCompatiblityEnabled_;
|
||||
bool dropNullPlaceholders_;
|
||||
bool omitEndingLineFeed_;
|
||||
};
|
||||
|
||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
||||
*human friendly way.
|
||||
*
|
||||
* The rules for line break and indent are as follow:
|
||||
* - Object value:
|
||||
* - if empty then print {} without indent and line break
|
||||
* - if not empty the print '{', line break & indent, print one value per
|
||||
*line
|
||||
* and then unindent and line break and print '}'.
|
||||
* - Array value:
|
||||
* - if empty then print [] without indent and line break
|
||||
* - if the array contains no object value, empty array or some other value
|
||||
*types,
|
||||
* and all the values fit on one lines, then print the array on a single
|
||||
*line.
|
||||
* - otherwise, it the values do not fit on one line, or the array contains
|
||||
* object or non empty array, then print one value per line.
|
||||
*
|
||||
* If the Value have comments then they are outputed according to their
|
||||
*#CommentPlacement.
|
||||
*
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
class JSON_API StyledWriter : public Writer {
|
||||
public:
|
||||
StyledWriter();
|
||||
~StyledWriter() JSONCPP_OVERRIDE {}
|
||||
|
||||
public: // overridden from Writer
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||
* \param root Value to serialize.
|
||||
* \return String containing the JSON document that represents the root value.
|
||||
*/
|
||||
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
void writeArrayValue(const Value& value);
|
||||
bool isMultineArray(const Value& value);
|
||||
void pushValue(const JSONCPP_STRING& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(const JSONCPP_STRING& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(const Value& root);
|
||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||
bool hasCommentForValue(const Value& value);
|
||||
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
|
||||
|
||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
JSONCPP_STRING document_;
|
||||
JSONCPP_STRING indentString_;
|
||||
unsigned int rightMargin_;
|
||||
unsigned int indentSize_;
|
||||
bool addChildValues_;
|
||||
};
|
||||
|
||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
||||
human friendly way,
|
||||
to a stream rather than to a string.
|
||||
*
|
||||
* The rules for line break and indent are as follow:
|
||||
* - Object value:
|
||||
* - if empty then print {} without indent and line break
|
||||
* - if not empty the print '{', line break & indent, print one value per
|
||||
line
|
||||
* and then unindent and line break and print '}'.
|
||||
* - Array value:
|
||||
* - if empty then print [] without indent and line break
|
||||
* - if the array contains no object value, empty array or some other value
|
||||
types,
|
||||
* and all the values fit on one lines, then print the array on a single
|
||||
line.
|
||||
* - otherwise, it the values do not fit on one line, or the array contains
|
||||
* object or non empty array, then print one value per line.
|
||||
*
|
||||
* If the Value have comments then they are outputed according to their
|
||||
#CommentPlacement.
|
||||
*
|
||||
* \param indentation Each level will be indented by this amount extra.
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
class JSON_API StyledStreamWriter {
|
||||
public:
|
||||
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
|
||||
~StyledStreamWriter() {}
|
||||
|
||||
public:
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||
* \param out Stream to write to. (Can be ostringstream, e.g.)
|
||||
* \param root Value to serialize.
|
||||
* \note There is no point in deriving from Writer, since write() should not
|
||||
* return a value.
|
||||
*/
|
||||
void write(JSONCPP_OSTREAM& out, const Value& root);
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
void writeArrayValue(const Value& value);
|
||||
bool isMultineArray(const Value& value);
|
||||
void pushValue(const JSONCPP_STRING& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(const JSONCPP_STRING& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(const Value& root);
|
||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||
bool hasCommentForValue(const Value& value);
|
||||
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
|
||||
|
||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
JSONCPP_OSTREAM* document_;
|
||||
JSONCPP_STRING indentString_;
|
||||
unsigned int rightMargin_;
|
||||
JSONCPP_STRING indentation_;
|
||||
bool addChildValues_ : 1;
|
||||
bool indented_ : 1;
|
||||
};
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
JSONCPP_STRING JSON_API valueToString(Int value);
|
||||
JSONCPP_STRING JSON_API valueToString(UInt value);
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
JSONCPP_STRING JSON_API valueToString(LargestInt value);
|
||||
JSONCPP_STRING JSON_API valueToString(LargestUInt value);
|
||||
JSONCPP_STRING JSON_API valueToString(double value);
|
||||
JSONCPP_STRING JSON_API valueToString(bool value);
|
||||
JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
|
||||
|
||||
/// \brief Output using the StyledStreamWriter.
|
||||
/// \see Json::operator>>()
|
||||
JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#endif // JSON_WRITER_H_INCLUDED
|
80
extern/jsoncpp/src/CMakeLists.txt
vendored
Normal file
80
extern/jsoncpp/src/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
IF( CMAKE_COMPILER_IS_GNUCXX )
|
||||
#Get compiler version.
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GNUCXX_VERSION )
|
||||
|
||||
#-Werror=* was introduced -after- GCC 4.1.2
|
||||
IF( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
|
||||
ENDIF()
|
||||
ENDIF( CMAKE_COMPILER_IS_GNUCXX )
|
||||
|
||||
INCLUDE(CheckIncludeFileCXX)
|
||||
INCLUDE(CheckTypeSize)
|
||||
INCLUDE(CheckStructHasMember)
|
||||
INCLUDE(CheckCXXSymbolExists)
|
||||
|
||||
check_include_file_cxx(clocale HAVE_CLOCALE)
|
||||
check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
|
||||
|
||||
IF(CMAKE_VERSION VERSION_LESS 3.0.0)
|
||||
# The "LANGUAGE CXX" parameter is not supported in CMake versions below 3,
|
||||
# so the C compiler and header has to be used.
|
||||
check_include_file(locale.h HAVE_LOCALE_H)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES locale.h)
|
||||
check_type_size("struct lconv" LCONV_SIZE)
|
||||
UNSET(CMAKE_EXTRA_INCLUDE_FILES)
|
||||
check_struct_has_member("struct lconv" decimal_point locale.h HAVE_DECIMAL_POINT)
|
||||
ELSE()
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES clocale)
|
||||
check_type_size(lconv LCONV_SIZE LANGUAGE CXX)
|
||||
UNSET(CMAKE_EXTRA_INCLUDE_FILES)
|
||||
check_struct_has_member(lconv decimal_point clocale HAVE_DECIMAL_POINT LANGUAGE CXX)
|
||||
ENDIF()
|
||||
|
||||
IF(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALECONV))
|
||||
MESSAGE(WARNING "Locale functionality is not supported")
|
||||
ADD_DEFINITIONS(-DJSONCPP_NO_LOCALE_SUPPORT)
|
||||
ENDIF()
|
||||
|
||||
SET( JSONCPP_INCLUDE_DIR ../include )
|
||||
|
||||
SET( PUBLIC_HEADERS
|
||||
${JSONCPP_INCLUDE_DIR}/json/config.h
|
||||
${JSONCPP_INCLUDE_DIR}/json/forwards.h
|
||||
${JSONCPP_INCLUDE_DIR}/json/features.h
|
||||
${JSONCPP_INCLUDE_DIR}/json/value.h
|
||||
${JSONCPP_INCLUDE_DIR}/json/reader.h
|
||||
${JSONCPP_INCLUDE_DIR}/json/writer.h
|
||||
${JSONCPP_INCLUDE_DIR}/json/assertions.h
|
||||
${JSONCPP_INCLUDE_DIR}/json/version.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP( "Public API" FILES ${PUBLIC_HEADERS} )
|
||||
|
||||
SET(jsoncpp_sources
|
||||
json_tool.h
|
||||
json_reader.cpp
|
||||
json_valueiterator.inl
|
||||
json_value.cpp
|
||||
json_writer.cpp
|
||||
version.h.in
|
||||
)
|
||||
|
||||
# Install instructions for this target
|
||||
IF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
SET(INSTALL_EXPORT EXPORT jsoncpp)
|
||||
ELSE(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
SET(INSTALL_EXPORT)
|
||||
ENDIF()
|
||||
|
||||
set(SRC
|
||||
${PUBLIC_HEADERS}
|
||||
${jsoncpp_sources}
|
||||
)
|
||||
|
||||
set(INC
|
||||
../include
|
||||
)
|
||||
|
||||
blender_add_lib(jsoncpp_lib "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
2036
extern/jsoncpp/src/json_reader.cpp
vendored
Normal file
2036
extern/jsoncpp/src/json_reader.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
117
extern/jsoncpp/src/json_tool.h
vendored
Normal file
117
extern/jsoncpp/src/json_tool.h
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||
|
||||
|
||||
// Also support old flag NO_LOCALE_SUPPORT
|
||||
#ifdef NO_LOCALE_SUPPORT
|
||||
#define JSONCPP_NO_LOCALE_SUPPORT
|
||||
#endif
|
||||
|
||||
#ifndef JSONCPP_NO_LOCALE_SUPPORT
|
||||
#include <clocale>
|
||||
#endif
|
||||
|
||||
/* This header provides common string manipulation support, such as UTF-8,
|
||||
* portable conversion from/to string...
|
||||
*
|
||||
* It is an internal header that must not be exposed.
|
||||
*/
|
||||
|
||||
namespace Json {
|
||||
static char getDecimalPoint() {
|
||||
#ifdef JSONCPP_NO_LOCALE_SUPPORT
|
||||
return '\0';
|
||||
#else
|
||||
struct lconv* lc = localeconv();
|
||||
return lc ? *(lc->decimal_point) : '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Converts a unicode code-point to UTF-8.
|
||||
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
||||
JSONCPP_STRING result;
|
||||
|
||||
// based on description from http://en.wikipedia.org/wiki/UTF-8
|
||||
|
||||
if (cp <= 0x7f) {
|
||||
result.resize(1);
|
||||
result[0] = static_cast<char>(cp);
|
||||
} else if (cp <= 0x7FF) {
|
||||
result.resize(2);
|
||||
result[1] = static_cast<char>(0x80 | (0x3f & cp));
|
||||
result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
|
||||
} else if (cp <= 0xFFFF) {
|
||||
result.resize(3);
|
||||
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
||||
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
|
||||
result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
|
||||
} else if (cp <= 0x10FFFF) {
|
||||
result.resize(4);
|
||||
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
||||
result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
|
||||
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
|
||||
result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Returns true if ch is a control character (in range [1,31]).
|
||||
static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
|
||||
|
||||
enum {
|
||||
/// Constant that specify the size of the buffer that must be passed to
|
||||
/// uintToString.
|
||||
uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1
|
||||
};
|
||||
|
||||
// Defines a char buffer for use with uintToString().
|
||||
typedef char UIntToStringBuffer[uintToStringBufferSize];
|
||||
|
||||
/** Converts an unsigned integer to string.
|
||||
* @param value Unsigned interger to convert to string
|
||||
* @param current Input/Output string buffer.
|
||||
* Must have at least uintToStringBufferSize chars free.
|
||||
*/
|
||||
static inline void uintToString(LargestUInt value, char*& current) {
|
||||
*--current = 0;
|
||||
do {
|
||||
*--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
|
||||
value /= 10;
|
||||
} while (value != 0);
|
||||
}
|
||||
|
||||
/** Change ',' to '.' everywhere in buffer.
|
||||
*
|
||||
* We had a sophisticated way, but it did not work in WinCE.
|
||||
* @see https://github.com/open-source-parsers/jsoncpp/pull/9
|
||||
*/
|
||||
static inline void fixNumericLocale(char* begin, char* end) {
|
||||
while (begin < end) {
|
||||
if (*begin == ',') {
|
||||
*begin = '.';
|
||||
}
|
||||
++begin;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void fixNumericLocaleInput(char* begin, char* end) {
|
||||
char decimalPoint = getDecimalPoint();
|
||||
if (decimalPoint != '\0' && decimalPoint != '.') {
|
||||
while (begin < end) {
|
||||
if (*begin == '.') {
|
||||
*begin = decimalPoint;
|
||||
}
|
||||
++begin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Json {
|
||||
|
||||
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
1665
extern/jsoncpp/src/json_value.cpp
vendored
Normal file
1665
extern/jsoncpp/src/json_value.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
167
extern/jsoncpp/src/json_valueiterator.inl
vendored
Normal file
167
extern/jsoncpp/src/json_valueiterator.inl
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
// included by json_value.cpp
|
||||
|
||||
namespace Json {
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueIteratorBase
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
ValueIteratorBase::ValueIteratorBase()
|
||||
: current_(), isNull_(true) {
|
||||
}
|
||||
|
||||
ValueIteratorBase::ValueIteratorBase(
|
||||
const Value::ObjectValues::iterator& current)
|
||||
: current_(current), isNull_(false) {}
|
||||
|
||||
Value& ValueIteratorBase::deref() const {
|
||||
return current_->second;
|
||||
}
|
||||
|
||||
void ValueIteratorBase::increment() {
|
||||
++current_;
|
||||
}
|
||||
|
||||
void ValueIteratorBase::decrement() {
|
||||
--current_;
|
||||
}
|
||||
|
||||
ValueIteratorBase::difference_type
|
||||
ValueIteratorBase::computeDistance(const SelfType& other) const {
|
||||
#ifdef JSON_USE_CPPTL_SMALLMAP
|
||||
return other.current_ - current_;
|
||||
#else
|
||||
// Iterator for null value are initialized using the default
|
||||
// constructor, which initialize current_ to the default
|
||||
// std::map::iterator. As begin() and end() are two instance
|
||||
// of the default std::map::iterator, they can not be compared.
|
||||
// To allow this, we handle this comparison specifically.
|
||||
if (isNull_ && other.isNull_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Usage of std::distance is not portable (does not compile with Sun Studio 12
|
||||
// RogueWave STL,
|
||||
// which is the one used by default).
|
||||
// Using a portable hand-made version for non random iterator instead:
|
||||
// return difference_type( std::distance( current_, other.current_ ) );
|
||||
difference_type myDistance = 0;
|
||||
for (Value::ObjectValues::iterator it = current_; it != other.current_;
|
||||
++it) {
|
||||
++myDistance;
|
||||
}
|
||||
return myDistance;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ValueIteratorBase::isEqual(const SelfType& other) const {
|
||||
if (isNull_) {
|
||||
return other.isNull_;
|
||||
}
|
||||
return current_ == other.current_;
|
||||
}
|
||||
|
||||
void ValueIteratorBase::copy(const SelfType& other) {
|
||||
current_ = other.current_;
|
||||
isNull_ = other.isNull_;
|
||||
}
|
||||
|
||||
Value ValueIteratorBase::key() const {
|
||||
const Value::CZString czstring = (*current_).first;
|
||||
if (czstring.data()) {
|
||||
if (czstring.isStaticString())
|
||||
return Value(StaticString(czstring.data()));
|
||||
return Value(czstring.data(), czstring.data() + czstring.length());
|
||||
}
|
||||
return Value(czstring.index());
|
||||
}
|
||||
|
||||
UInt ValueIteratorBase::index() const {
|
||||
const Value::CZString czstring = (*current_).first;
|
||||
if (!czstring.data())
|
||||
return czstring.index();
|
||||
return Value::UInt(-1);
|
||||
}
|
||||
|
||||
JSONCPP_STRING ValueIteratorBase::name() const {
|
||||
char const* keey;
|
||||
char const* end;
|
||||
keey = memberName(&end);
|
||||
if (!keey) return JSONCPP_STRING();
|
||||
return JSONCPP_STRING(keey, end);
|
||||
}
|
||||
|
||||
char const* ValueIteratorBase::memberName() const {
|
||||
const char* cname = (*current_).first.data();
|
||||
return cname ? cname : "";
|
||||
}
|
||||
|
||||
char const* ValueIteratorBase::memberName(char const** end) const {
|
||||
const char* cname = (*current_).first.data();
|
||||
if (!cname) {
|
||||
*end = NULL;
|
||||
return NULL;
|
||||
}
|
||||
*end = cname + (*current_).first.length();
|
||||
return cname;
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueConstIterator
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
ValueConstIterator::ValueConstIterator() {}
|
||||
|
||||
ValueConstIterator::ValueConstIterator(
|
||||
const Value::ObjectValues::iterator& current)
|
||||
: ValueIteratorBase(current) {}
|
||||
|
||||
ValueConstIterator::ValueConstIterator(ValueIterator const& other)
|
||||
: ValueIteratorBase(other) {}
|
||||
|
||||
ValueConstIterator& ValueConstIterator::
|
||||
operator=(const ValueIteratorBase& other) {
|
||||
copy(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueIterator
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
ValueIterator::ValueIterator() {}
|
||||
|
||||
ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
|
||||
: ValueIteratorBase(current) {}
|
||||
|
||||
ValueIterator::ValueIterator(const ValueConstIterator& other)
|
||||
: ValueIteratorBase(other) {
|
||||
throwRuntimeError("ConstIterator to Iterator should never be allowed.");
|
||||
}
|
||||
|
||||
ValueIterator::ValueIterator(const ValueIterator& other)
|
||||
: ValueIteratorBase(other) {}
|
||||
|
||||
ValueIterator& ValueIterator::operator=(const SelfType& other) {
|
||||
copy(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace Json
|
1223
extern/jsoncpp/src/json_writer.cpp
vendored
Normal file
1223
extern/jsoncpp/src/json_writer.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
extern/jsoncpp/src/sconscript
vendored
Normal file
8
extern/jsoncpp/src/sconscript
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Import( 'env buildLibrary' )
|
||||
|
||||
buildLibrary( env, Split( """
|
||||
json_reader.cpp
|
||||
json_value.cpp
|
||||
json_writer.cpp
|
||||
""" ),
|
||||
'json' )
|
20
extern/jsoncpp/src/version.h.in
vendored
Normal file
20
extern/jsoncpp/src/version.h.in
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// DO NOT EDIT. This file (and "version") is generated by CMake.
|
||||
// Run CMake configure step to update it.
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
# define JSON_VERSION_H_INCLUDED
|
||||
|
||||
# define JSONCPP_VERSION_STRING "@JSONCPP_VERSION@"
|
||||
# define JSONCPP_VERSION_MAJOR @JSONCPP_VERSION_MAJOR@
|
||||
# define JSONCPP_VERSION_MINOR @JSONCPP_VERSION_MINOR@
|
||||
# define JSONCPP_VERSION_PATCH @JSONCPP_VERSION_PATCH@
|
||||
# define JSONCPP_VERSION_QUALIFIER
|
||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY @JSONCPP_USE_SECURE_MEMORY@
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
71
extern/openxr/CMakeLists.txt
vendored
Normal file
71
extern/openxr/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author:
|
||||
#
|
||||
|
||||
# Note: This is the top-level CMake file for the OpenXR project.
|
||||
# It should contain only definitions that are applicable to the
|
||||
# entire project and includes for the sub-directories.
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(OPENXR)
|
||||
|
||||
#find_package(PythonInterp 3)
|
||||
|
||||
# Enable IDE GUI folders. "Helper targets" that don't have interesting source code should set their FOLDER property to this
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake predefined targets")
|
||||
set(LOADER_FOLDER "Loader")
|
||||
set(HELPER_FOLDER "Helpers")
|
||||
set(CODEGEN_FOLDER "Generated")
|
||||
set(TESTS_FOLDER "Tests")
|
||||
set(API_LAYERS_FOLDER "Layers")
|
||||
set(SAMPLES_FOLDER "Samples")
|
||||
|
||||
option(BUILD_FORCE_GENERATION "Force re-generation of files even in the presence of pre-generated copies, replacing those copies." OFF)
|
||||
|
||||
if(BUILD_FORCE_GENERATION AND NOT PYTHON_EXECUTABLE)
|
||||
message(FATAL_ERROR "BUILD_FORCE_GENERATION requires Python")
|
||||
endif()
|
||||
|
||||
set(OPENXR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(src)
|
||||
|
||||
# uninstall target
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/cmake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE
|
||||
@ONLY)
|
||||
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
set_target_properties(uninstall PROPERTIES FOLDER ${HELPER_FOLDER})
|
||||
endif()
|
||||
|
||||
find_program(BASH_COMMAND NAMES bash)
|
||||
if(BASH_COMMAND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/specification/Makefile")
|
||||
option(BUILD_SPECIFICATION "Run './makeAllExts all' in the specification directory as part of the build - intended for one-step checking of spec changes" OFF)
|
||||
if(BUILD_SPECIFICATION)
|
||||
add_custom_target(spec-all ALL
|
||||
${BASH_COMMAND} ./makeAllExts all
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/specification"
|
||||
VERBATIM
|
||||
COMMENT "Running './makeAllExts all' in the specification directory"
|
||||
USES_TERMINAL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" DESTINATION share/doc/openxr)
|
202
extern/openxr/LICENSE
vendored
Normal file
202
extern/openxr/LICENSE
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
18
extern/openxr/include/CMakeLists.txt
vendored
Normal file
18
extern/openxr/include/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2017 The Khronos Group Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author:
|
||||
#
|
||||
|
||||
add_subdirectory(openxr)
|
94
extern/openxr/include/openxr/CMakeLists.txt
vendored
Normal file
94
extern/openxr/include/openxr/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
# Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author:
|
||||
#
|
||||
|
||||
# Copy the openxr_platform_defines.h file and place it in the binary (build) directory.
|
||||
configure_file(openxr_platform_defines.h ${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h COPYONLY)
|
||||
|
||||
# Generate OpenXR header files.
|
||||
|
||||
|
||||
set(HEADERS
|
||||
openxr.h
|
||||
openxr_platform.h
|
||||
openxr_reflection.h)
|
||||
set(HAVE_PREGENERATED TRUE)
|
||||
set(SOURCE_HEADERS)
|
||||
foreach(output ${HEADERS})
|
||||
list(APPEND SOURCE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${output})
|
||||
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${output})
|
||||
set(HAVE_PREGENERATED FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(XR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||
if(HAVE_PREGENERATED AND NOT BUILD_FORCE_GENERATION)
|
||||
add_custom_target(generate_openxr_header
|
||||
COMMENT "Using found pre-generated OpenXR headers.")
|
||||
|
||||
set(INSTALL_HEADERS ${SOURCE_HEADERS})
|
||||
else()
|
||||
|
||||
set(GENERATED_HEADERS)
|
||||
set(OUTPUT_STAMPS)
|
||||
# Copy the openxr_platform_defines.h file and place it in the binary (build) directory.
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openxr_platform_defines.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h
|
||||
COPYONLY)
|
||||
|
||||
# Generate the header files and place it in the binary (build) directory.
|
||||
foreach(output ${HEADERS})
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${output}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${XR_ROOT}/specification/scripts/genxr.py
|
||||
-registry ${XR_ROOT}/specification/registry/xr.xml
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR} ${output}
|
||||
DEPENDS
|
||||
${XR_ROOT}/specification/scripts/genxr.py
|
||||
${XR_ROOT}/specification/scripts/cgenerator.py
|
||||
${XR_ROOT}/specification/scripts/creflectiongenerator.py
|
||||
${XR_ROOT}/specification/scripts/generator.py
|
||||
${XR_ROOT}/specification/scripts/reg.py
|
||||
${XR_ROOT}/specification/registry/xr.xml
|
||||
COMMENT "Generating ${CMAKE_CURRENT_BINARY_DIR}/${output}"
|
||||
)
|
||||
list(APPEND GENERATED_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/${output}")
|
||||
endforeach()
|
||||
|
||||
set_source_files_properties(
|
||||
${GENERATED_HEADERS}
|
||||
PROPERTIES GENERATED TRUE
|
||||
)
|
||||
|
||||
set(INSTALL_HEADERS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/openxr.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/openxr_platform.h)
|
||||
|
||||
|
||||
# Define generate_openxr_header target to generate the OpenXR header files.
|
||||
# Other targets that need the OpenXR headers should use generate_openxr_header as a dependency.
|
||||
add_custom_target(generate_openxr_header
|
||||
SOURCES ${XR_ROOT}/specification/registry/xr.xml
|
||||
DEPENDS
|
||||
${GENERATED_HEADERS}
|
||||
${OUTPUT_STAMPS}
|
||||
)
|
||||
endif()
|
||||
set_target_properties(generate_openxr_header PROPERTIES FOLDER ${CODEGEN_FOLDER})
|
||||
|
||||
INSTALL(FILES ${INSTALL_HEADERS}
|
||||
DESTINATION include/openxr
|
||||
)
|
1538
extern/openxr/include/openxr/openxr.h
vendored
Normal file
1538
extern/openxr/include/openxr/openxr.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
383
extern/openxr/include/openxr/openxr_platform.h
vendored
Normal file
383
extern/openxr/include/openxr/openxr_platform.h
vendored
Normal file
@@ -0,0 +1,383 @@
|
||||
#ifndef OPENXR_PLATFORM_H_
|
||||
#define OPENXR_PLATFORM_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos OpenXR XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
#include "openxr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
|
||||
#define XR_KHR_android_thread_settings 1
|
||||
#define XR_KHR_android_thread_settings_SPEC_VERSION 5
|
||||
#define XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME "XR_KHR_android_thread_settings"
|
||||
|
||||
typedef enum XrAndroidThreadTypeKHR {
|
||||
XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR = 1,
|
||||
XR_ANDROID_THREAD_TYPE_APPLICATION_WORKER_KHR = 2,
|
||||
XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR = 3,
|
||||
XR_ANDROID_THREAD_TYPE_RENDERER_WORKER_KHR = 4,
|
||||
XR_ANDROID_THREAD_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} XrAndroidThreadTypeKHR;
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrSetAndroidApplicationThreadKHR)(XrSession session, XrAndroidThreadTypeKHR threadType, uint32_t threadId);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrSetAndroidApplicationThreadKHR(
|
||||
XrSession session,
|
||||
XrAndroidThreadTypeKHR threadType,
|
||||
uint32_t threadId);
|
||||
#endif
|
||||
#endif /* XR_USE_PLATFORM_ANDROID */
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
|
||||
#define XR_KHR_android_surface_swapchain 1
|
||||
#define XR_KHR_android_surface_swapchain_SPEC_VERSION 4
|
||||
#define XR_KHR_ANDROID_SURFACE_SWAPCHAIN_EXTENSION_NAME "XR_KHR_android_surface_swapchain"
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateSwapchainAndroidSurfaceKHR)(XrSession session, const XrSwapchainCreateInfo* info, XrSwapchain* swapchain, jobject* surface);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrCreateSwapchainAndroidSurfaceKHR(
|
||||
XrSession session,
|
||||
const XrSwapchainCreateInfo* info,
|
||||
XrSwapchain* swapchain,
|
||||
jobject* surface);
|
||||
#endif
|
||||
#endif /* XR_USE_PLATFORM_ANDROID */
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
|
||||
#define XR_KHR_android_create_instance 1
|
||||
#define XR_KHR_android_create_instance_SPEC_VERSION 3
|
||||
#define XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME "XR_KHR_android_create_instance"
|
||||
typedef struct XrInstanceCreateInfoAndroidKHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
void* XR_MAY_ALIAS applicationVM;
|
||||
void* XR_MAY_ALIAS applicationActivity;
|
||||
} XrInstanceCreateInfoAndroidKHR;
|
||||
|
||||
#endif /* XR_USE_PLATFORM_ANDROID */
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_VULKAN
|
||||
|
||||
#define XR_KHR_vulkan_swapchain_format_list 1
|
||||
#define XR_KHR_vulkan_swapchain_format_list_SPEC_VERSION 2
|
||||
#define XR_KHR_VULKAN_SWAPCHAIN_FORMAT_LIST_EXTENSION_NAME "XR_KHR_vulkan_swapchain_format_list"
|
||||
typedef struct XrVulkanSwapchainFormatListCreateInfoKHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
uint32_t viewFormatCount;
|
||||
const VkFormat* viewFormats;
|
||||
} XrVulkanSwapchainFormatListCreateInfoKHR;
|
||||
|
||||
#endif /* XR_USE_GRAPHICS_API_VULKAN */
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_OPENGL
|
||||
|
||||
#define XR_KHR_opengl_enable 1
|
||||
#define XR_KHR_opengl_enable_SPEC_VERSION 7
|
||||
#define XR_KHR_OPENGL_ENABLE_EXTENSION_NAME "XR_KHR_opengl_enable"
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
typedef struct XrGraphicsBindingOpenGLWin32KHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
HDC hDC;
|
||||
HGLRC hGLRC;
|
||||
} XrGraphicsBindingOpenGLWin32KHR;
|
||||
#endif // XR_USE_PLATFORM_WIN32
|
||||
|
||||
#ifdef XR_USE_PLATFORM_XLIB
|
||||
typedef struct XrGraphicsBindingOpenGLXlibKHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
Display* xDisplay;
|
||||
uint32_t visualid;
|
||||
GLXFBConfig glxFBConfig;
|
||||
GLXDrawable glxDrawable;
|
||||
GLXContext glxContext;
|
||||
} XrGraphicsBindingOpenGLXlibKHR;
|
||||
#endif // XR_USE_PLATFORM_XLIB
|
||||
|
||||
#ifdef XR_USE_PLATFORM_XCB
|
||||
typedef struct XrGraphicsBindingOpenGLXcbKHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
xcb_connection_t* connection;
|
||||
uint32_t screenNumber;
|
||||
xcb_glx_fbconfig_t fbconfigid;
|
||||
xcb_visualid_t visualid;
|
||||
xcb_glx_drawable_t glxDrawable;
|
||||
xcb_glx_context_t glxContext;
|
||||
} XrGraphicsBindingOpenGLXcbKHR;
|
||||
#endif // XR_USE_PLATFORM_XCB
|
||||
|
||||
#ifdef XR_USE_PLATFORM_WAYLAND
|
||||
typedef struct XrGraphicsBindingOpenGLWaylandKHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
struct wl_display* display;
|
||||
} XrGraphicsBindingOpenGLWaylandKHR;
|
||||
#endif // XR_USE_PLATFORM_WAYLAND
|
||||
|
||||
typedef struct XrSwapchainImageOpenGLKHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
uint32_t image;
|
||||
} XrSwapchainImageOpenGLKHR;
|
||||
|
||||
typedef struct XrGraphicsRequirementsOpenGLKHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
XrVersion minApiVersionSupported;
|
||||
XrVersion maxApiVersionSupported;
|
||||
} XrGraphicsRequirementsOpenGLKHR;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetOpenGLGraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsOpenGLKHR* graphicsRequirements);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetOpenGLGraphicsRequirementsKHR(
|
||||
XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
XrGraphicsRequirementsOpenGLKHR* graphicsRequirements);
|
||||
#endif
|
||||
#endif /* XR_USE_GRAPHICS_API_OPENGL */
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
||||
|
||||
#define XR_KHR_opengl_es_enable 1
|
||||
#define XR_KHR_opengl_es_enable_SPEC_VERSION 6
|
||||
#define XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME "XR_KHR_opengl_es_enable"
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
typedef struct XrGraphicsBindingOpenGLESAndroidKHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
EGLDisplay display;
|
||||
EGLConfig config;
|
||||
EGLContext context;
|
||||
} XrGraphicsBindingOpenGLESAndroidKHR;
|
||||
#endif // XR_USE_PLATFORM_ANDROID
|
||||
|
||||
typedef struct XrSwapchainImageOpenGLESKHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
uint32_t image;
|
||||
} XrSwapchainImageOpenGLESKHR;
|
||||
|
||||
typedef struct XrGraphicsRequirementsOpenGLESKHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
XrVersion minApiVersionSupported;
|
||||
XrVersion maxApiVersionSupported;
|
||||
} XrGraphicsRequirementsOpenGLESKHR;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetOpenGLESGraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsOpenGLESKHR* graphicsRequirements);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetOpenGLESGraphicsRequirementsKHR(
|
||||
XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
XrGraphicsRequirementsOpenGLESKHR* graphicsRequirements);
|
||||
#endif
|
||||
#endif /* XR_USE_GRAPHICS_API_OPENGL_ES */
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_VULKAN
|
||||
|
||||
#define XR_KHR_vulkan_enable 1
|
||||
#define XR_KHR_vulkan_enable_SPEC_VERSION 6
|
||||
#define XR_KHR_VULKAN_ENABLE_EXTENSION_NAME "XR_KHR_vulkan_enable"
|
||||
typedef struct XrGraphicsBindingVulkanKHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
VkInstance instance;
|
||||
VkPhysicalDevice physicalDevice;
|
||||
VkDevice device;
|
||||
uint32_t queueFamilyIndex;
|
||||
uint32_t queueIndex;
|
||||
} XrGraphicsBindingVulkanKHR;
|
||||
|
||||
typedef struct XrSwapchainImageVulkanKHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
VkImage image;
|
||||
} XrSwapchainImageVulkanKHR;
|
||||
|
||||
typedef struct XrGraphicsRequirementsVulkanKHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
XrVersion minApiVersionSupported;
|
||||
XrVersion maxApiVersionSupported;
|
||||
} XrGraphicsRequirementsVulkanKHR;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanInstanceExtensionsKHR)(XrInstance instance, XrSystemId systemId, uint32_t bufferCapacityInput, uint32_t* bufferCountOutput, char* buffer);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanDeviceExtensionsKHR)(XrInstance instance, XrSystemId systemId, uint32_t bufferCapacityInput, uint32_t* bufferCountOutput, char* buffer);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsDeviceKHR)(XrInstance instance, XrSystemId systemId, VkInstance vkInstance, VkPhysicalDevice* vkPhysicalDevice);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsVulkanKHR* graphicsRequirements);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanInstanceExtensionsKHR(
|
||||
XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
uint32_t bufferCapacityInput,
|
||||
uint32_t* bufferCountOutput,
|
||||
char* buffer);
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanDeviceExtensionsKHR(
|
||||
XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
uint32_t bufferCapacityInput,
|
||||
uint32_t* bufferCountOutput,
|
||||
char* buffer);
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanGraphicsDeviceKHR(
|
||||
XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
VkInstance vkInstance,
|
||||
VkPhysicalDevice* vkPhysicalDevice);
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanGraphicsRequirementsKHR(
|
||||
XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
XrGraphicsRequirementsVulkanKHR* graphicsRequirements);
|
||||
#endif
|
||||
#endif /* XR_USE_GRAPHICS_API_VULKAN */
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_D3D11
|
||||
|
||||
#define XR_KHR_D3D11_enable 1
|
||||
#define XR_KHR_D3D11_enable_SPEC_VERSION 4
|
||||
#define XR_KHR_D3D11_ENABLE_EXTENSION_NAME "XR_KHR_D3D11_enable"
|
||||
typedef struct XrGraphicsBindingD3D11KHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
ID3D11Device* device;
|
||||
} XrGraphicsBindingD3D11KHR;
|
||||
|
||||
typedef struct XrSwapchainImageD3D11KHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
ID3D11Texture2D* texture;
|
||||
} XrSwapchainImageD3D11KHR;
|
||||
|
||||
typedef struct XrGraphicsRequirementsD3D11KHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
LUID adapterLuid;
|
||||
D3D_FEATURE_LEVEL minFeatureLevel;
|
||||
} XrGraphicsRequirementsD3D11KHR;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetD3D11GraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsD3D11KHR* graphicsRequirements);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetD3D11GraphicsRequirementsKHR(
|
||||
XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
XrGraphicsRequirementsD3D11KHR* graphicsRequirements);
|
||||
#endif
|
||||
#endif /* XR_USE_GRAPHICS_API_D3D11 */
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_D3D12
|
||||
|
||||
#define XR_KHR_D3D12_enable 1
|
||||
#define XR_KHR_D3D12_enable_SPEC_VERSION 5
|
||||
#define XR_KHR_D3D12_ENABLE_EXTENSION_NAME "XR_KHR_D3D12_enable"
|
||||
typedef struct XrGraphicsBindingD3D12KHR {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
ID3D12Device* device;
|
||||
ID3D12CommandQueue* queue;
|
||||
} XrGraphicsBindingD3D12KHR;
|
||||
|
||||
typedef struct XrSwapchainImageD3D12KHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
ID3D12Resource* texture;
|
||||
} XrSwapchainImageD3D12KHR;
|
||||
|
||||
typedef struct XrGraphicsRequirementsD3D12KHR {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
LUID adapterLuid;
|
||||
D3D_FEATURE_LEVEL minFeatureLevel;
|
||||
} XrGraphicsRequirementsD3D12KHR;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetD3D12GraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsD3D12KHR* graphicsRequirements);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetD3D12GraphicsRequirementsKHR(
|
||||
XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
XrGraphicsRequirementsD3D12KHR* graphicsRequirements);
|
||||
#endif
|
||||
#endif /* XR_USE_GRAPHICS_API_D3D12 */
|
||||
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
|
||||
#define XR_KHR_win32_convert_performance_counter_time 1
|
||||
#define XR_KHR_win32_convert_performance_counter_time_SPEC_VERSION 1
|
||||
#define XR_KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME_EXTENSION_NAME "XR_KHR_win32_convert_performance_counter_time"
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrConvertWin32PerformanceCounterToTimeKHR)(XrInstance instance, const LARGE_INTEGER* performanceCounter, XrTime* time);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrConvertTimeToWin32PerformanceCounterKHR)(XrInstance instance, XrTime time, LARGE_INTEGER* performanceCounter);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrConvertWin32PerformanceCounterToTimeKHR(
|
||||
XrInstance instance,
|
||||
const LARGE_INTEGER* performanceCounter,
|
||||
XrTime* time);
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrConvertTimeToWin32PerformanceCounterKHR(
|
||||
XrInstance instance,
|
||||
XrTime time,
|
||||
LARGE_INTEGER* performanceCounter);
|
||||
#endif
|
||||
#endif /* XR_USE_PLATFORM_WIN32 */
|
||||
|
||||
#ifdef XR_USE_TIMESPEC
|
||||
|
||||
#define XR_KHR_convert_timespec_time 1
|
||||
#define XR_KHR_convert_timespec_time_SPEC_VERSION 1
|
||||
#define XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME "XR_KHR_convert_timespec_time"
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrConvertTimespecTimeToTimeKHR)(XrInstance instance, const struct timespec* timespecTime, XrTime* time);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrConvertTimeToTimespecTimeKHR)(XrInstance instance, XrTime time, struct timespec* timespecTime);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrConvertTimespecTimeToTimeKHR(
|
||||
XrInstance instance,
|
||||
const struct timespec* timespecTime,
|
||||
XrTime* time);
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrConvertTimeToTimespecTimeKHR(
|
||||
XrInstance instance,
|
||||
XrTime time,
|
||||
struct timespec* timespecTime);
|
||||
#endif
|
||||
#endif /* XR_USE_TIMESPEC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
124
extern/openxr/include/openxr/openxr_platform_defines.h
vendored
Normal file
124
extern/openxr/include/openxr/openxr_platform_defines.h
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
** Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OPENXR_PLATFORM_DEFINES_H_
|
||||
#define OPENXR_PLATFORM_DEFINES_H_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Platform-specific calling convention macros.
|
||||
*
|
||||
* Platforms should define these so that OpenXR clients call OpenXR functions
|
||||
* with the same calling conventions that the OpenXR implementation expects.
|
||||
*
|
||||
* XRAPI_ATTR - Placed before the return type in function declarations.
|
||||
* Useful for C++11 and GCC/Clang-style function attribute syntax.
|
||||
* XRAPI_CALL - Placed after the return type in function declarations.
|
||||
* Useful for MSVC-style calling convention syntax.
|
||||
* XRAPI_PTR - Placed between the '(' and '*' in function pointer types.
|
||||
*
|
||||
* Function declaration: XRAPI_ATTR void XRAPI_CALL xrFunction(void);
|
||||
* Function pointer type: typedef void (XRAPI_PTR *PFN_xrFunction)(void);
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
#ifdef XRAPI_DLL_EXPORT
|
||||
#define XRAPI_ATTR __declspec(dllexport)
|
||||
#else
|
||||
#define XRAPI_ATTR
|
||||
#endif
|
||||
// On Windows, functions use the stdcall convention
|
||||
#define XRAPI_CALL __stdcall
|
||||
#define XRAPI_PTR XRAPI_CALL
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
|
||||
#error "API not supported for the 'armeabi' NDK ABI"
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
|
||||
// On Android 32-bit ARM targets, functions use the "hardfloat"
|
||||
// calling convention, i.e. float parameters are passed in registers. This
|
||||
// is true even if the rest of the application passes floats on the stack,
|
||||
// as it does by default when compiling for the armeabi-v7a NDK ABI.
|
||||
#define XRAPI_ATTR __attribute__((pcs("aapcs-vfp")))
|
||||
#define XRAPI_CALL
|
||||
#define XRAPI_PTR XRAPI_ATTR
|
||||
#else
|
||||
// On other platforms, use the default calling convention
|
||||
#define XRAPI_ATTR
|
||||
#define XRAPI_CALL
|
||||
#define XRAPI_PTR
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if !defined(XR_NO_STDINT_H)
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif // !defined( XR_NO_STDINT_H )
|
||||
|
||||
// XR_PTR_SIZE (in bytes)
|
||||
#if (defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__))
|
||||
#define XR_PTR_SIZE 8
|
||||
#else
|
||||
#define XR_PTR_SIZE 4
|
||||
#endif
|
||||
|
||||
// Needed so we can use clang __has_feature portably.
|
||||
#if !defined(XR_COMPILER_HAS_FEATURE)
|
||||
#if defined(__clang__)
|
||||
#define XR_COMPILER_HAS_FEATURE(x) __has_feature(x)
|
||||
#else
|
||||
#define XR_COMPILER_HAS_FEATURE(x) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Identifies if the current compiler has C++11 support enabled.
|
||||
// Does not by itself identify if any given C++11 feature is present.
|
||||
#if !defined(XR_CPP11_ENABLED) && defined(__cplusplus)
|
||||
#if defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
#define XR_CPP11_ENABLED 1
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1600)
|
||||
#define XR_CPP11_ENABLED 1
|
||||
#elif (__cplusplus >= 201103L) // 201103 is the first C++11 version.
|
||||
#define XR_CPP11_ENABLED 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Identifies if the current compiler supports C++11 nullptr.
|
||||
#if !defined(XR_CPP_NULLPTR_SUPPORTED)
|
||||
#if defined(XR_CPP11_ENABLED) && \
|
||||
((defined(__clang__) && XR_COMPILER_HAS_FEATURE(cxx_nullptr)) || \
|
||||
(defined(__GNUC__) && (((__GNUC__ * 1000) + __GNUC_MINOR__) >= 4006)) || \
|
||||
(defined(_MSC_VER) && (_MSC_VER >= 1600)) || \
|
||||
(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403)))
|
||||
#define XR_CPP_NULLPTR_SUPPORTED 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
1004
extern/openxr/include/openxr/openxr_reflection.h
vendored
Normal file
1004
extern/openxr/include/openxr/openxr_reflection.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
194
extern/openxr/src/CMakeLists.txt
vendored
Normal file
194
extern/openxr/src/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
# Copyright (c) 2017 The Khronos Group Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author:
|
||||
#
|
||||
|
||||
# Entire project uses C++11
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# All options defined here
|
||||
option(BUILD_LOADER "Build loader" ON)
|
||||
option(BUILD_LOADER_WITH_EXCEPTION_HANDLING "Enable exception handling in the loader. Leave this on unless your standard library is built to not throw." ON)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
option(DYNAMIC_LOADER "Build the loader as a .dll library" OFF)
|
||||
else()
|
||||
option(DYNAMIC_LOADER "Build the loader as a .dll library" ON)
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/api_layers")
|
||||
option(BUILD_API_LAYERS "Build API layers" ON)
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
||||
option(BUILD_TESTS "Build tests" ON)
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conformance")
|
||||
option(BUILD_CONFORMANCE_TESTS "Build conformance tests" ON)
|
||||
endif()
|
||||
|
||||
# Several files use these compile-time OS switches
|
||||
if(WIN32)
|
||||
add_definitions(-DXR_OS_WINDOWS)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_definitions(-DXR_OS_LINUX)
|
||||
endif()
|
||||
|
||||
# Determine the presentation backend for Linux systems.
|
||||
# Use an include because the code is pretty big.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
include(presentation)
|
||||
endif()
|
||||
|
||||
# Several files use these compile-time platform switches
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
add_definitions( -DXR_USE_PLATFORM_WIN32 )
|
||||
elseif( PRESENTATION_BACKEND MATCHES "xlib" )
|
||||
add_definitions( -DXR_USE_PLATFORM_XLIB )
|
||||
elseif( PRESENTATION_BACKEND MATCHES "xcb" )
|
||||
add_definitions( -DXR_USE_PLATFORM_XCB )
|
||||
|
||||
# TODO remove once conformance supports XCB
|
||||
set(BUILD_CONFORMANCE_TESTS OFF)
|
||||
elseif( PRESENTATION_BACKEND MATCHES "wayland" )
|
||||
add_definitions( -DXR_USE_PLATFORM_WAYLAND )
|
||||
|
||||
# TODO remove once conformance supports Wayland
|
||||
set(BUILD_CONFORMANCE_TESTS OFF)
|
||||
endif()
|
||||
|
||||
# Enable graphics API available to the build.
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.7.0)
|
||||
# Find the Vulkan headers
|
||||
find_package(VulkanHeaders)
|
||||
if (VulkanHeaders_FOUND)
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_VULKAN)
|
||||
endif()
|
||||
# Find the Vulkan loader.
|
||||
find_package(Vulkan)
|
||||
# To use simply include ${Vulkan_LIBRARY} in your target_link_library or
|
||||
# wherever you normally link your library files to your target.
|
||||
endif()
|
||||
|
||||
find_package(OpenGL)
|
||||
if (OPENGL_FOUND)
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_D3D)
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_D3D11)
|
||||
add_definitions(-DXR_USE_GRAPHICS_API_D3D12)
|
||||
endif()
|
||||
|
||||
if(BUILD_LOADER_WITH_EXCEPTION_HANDLING)
|
||||
set(XRLOADER_ENABLE_EXCEPTION_HANDLING TRUE)
|
||||
endif()
|
||||
# Check for the existence of the secure_getenv or __secure_getenv commands
|
||||
include(CheckFunctionExists)
|
||||
CHECK_FUNCTION_EXISTS(secure_getenv HAVE_SECURE_GETENV)
|
||||
CHECK_FUNCTION_EXISTS(__secure_getenv HAVE___SECURE_GETENV)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/common_cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/common_cmake_config.h)
|
||||
|
||||
# Be able to find pre-generated files, if used.
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_definitions(-DXR_USE_TIMESPEC)
|
||||
|
||||
# Set up the OpenXR version variables, used by several targets in this project.
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
|
||||
|
||||
# Path separators ( : or ; ) are not handled well in CMake.
|
||||
# This seems like a reasonable approach.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(CODEGEN_PYTHON_PATH "${CMAKE_SOURCE_DIR}/specification/scripts;${CMAKE_SOURCE_DIR}/src/scripts;$ENV{PYTHONPATH}")
|
||||
else()
|
||||
set(CODEGEN_PYTHON_PATH "${CMAKE_SOURCE_DIR}/specification/scripts:${CMAKE_SOURCE_DIR}/src/scripts:$ENV{PYTHONPATH}")
|
||||
endif()
|
||||
|
||||
# General code generation macro used by several targets.
|
||||
macro(run_xr_xml_generate dependency output)
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${output}" AND NOT BUILD_FORCE_GENERATION)
|
||||
# pre-generated found
|
||||
message(STATUS "Found and will use pre-generated ${output} in source tree")
|
||||
list(APPEND GENERATED_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${output}")
|
||||
else()
|
||||
if(NOT PYTHON_EXECUTABLE)
|
||||
message(FATAL_ERROR "Python 3 not found, but pre-generated ${CMAKE_CURRENT_SOURCE_DIR}/${output} not found")
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${output}
|
||||
COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CODEGEN_PYTHON_PATH}"
|
||||
${PYTHON_EXECUTABLE}
|
||||
${CMAKE_SOURCE_DIR}/src/scripts/src_genxr.py
|
||||
-registry ${CMAKE_SOURCE_DIR}/specification/registry/xr.xml
|
||||
${output}
|
||||
DEPENDS
|
||||
"${CMAKE_SOURCE_DIR}/specification/registry/xr.xml"
|
||||
"${CMAKE_SOURCE_DIR}/specification/scripts/generator.py"
|
||||
"${CMAKE_SOURCE_DIR}/specification/scripts/reg.py"
|
||||
"${CMAKE_SOURCE_DIR}/src/scripts/${dependency}"
|
||||
"${CMAKE_SOURCE_DIR}/src/scripts/src_genxr.py"
|
||||
${ARGN}
|
||||
COMMENT "Generating ${output} using ${PYTHON_EXECUTABLE} on ${dependency}"
|
||||
)
|
||||
set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
|
||||
list(APPEND GENERATED_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${output}")
|
||||
list(APPEND GENERATED_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${output}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Layer JSON generation macro used by several targets.
|
||||
macro(gen_xr_layer_json filename layername libfile version desc genbad)
|
||||
add_custom_command(OUTPUT ${filename}
|
||||
COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CODEGEN_PYTHON_PATH}"
|
||||
${PYTHON_EXECUTABLE}
|
||||
${CMAKE_SOURCE_DIR}/src/scripts/generate_api_layer_manifest.py
|
||||
-f ${filename} -n ${layername} -l ${libfile} -a ${MAJOR}.${MINOR} -v ${version} ${genbad} -d ${desc}
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/src/scripts/generate_api_layer_manifest.py
|
||||
COMMENT "Generating API Layer JSON ${filename} using -f ${filename} -n ${layername} -l ${libfile} -a ${MAJOR}.${MINOR} -v ${version} ${genbad} -d ${desc}"
|
||||
)
|
||||
endmacro()
|
||||
|
||||
# Custom target for generated dispatch table sources, used by several targets.
|
||||
set(GENERATED_OUTPUT)
|
||||
run_xr_xml_generate(utility_source_generator.py xr_generated_dispatch_table.h)
|
||||
run_xr_xml_generate(utility_source_generator.py xr_generated_dispatch_table.c)
|
||||
run_xr_xml_generate(utility_source_generator.py xr_generated_utilities.h)
|
||||
run_xr_xml_generate(utility_source_generator.py xr_generated_utilities.c)
|
||||
add_custom_target(xr_global_generated_files DEPENDS
|
||||
${GENERATED_DEPENDS}
|
||||
)
|
||||
set_target_properties(xr_global_generated_files PROPERTIES FOLDER ${CODEGEN_FOLDER})
|
||||
|
||||
set(COMMON_GENERATED_OUTPUT ${GENERATED_OUTPUT})
|
||||
|
||||
if(BUILD_LOADER)
|
||||
add_subdirectory(loader)
|
||||
endif()
|
||||
|
||||
if(BUILD_API_LAYERS)
|
||||
add_subdirectory(api_layers)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
if(BUILD_CONFORMANCE_TESTS)
|
||||
add_subdirectory(conformance)
|
||||
endif()
|
||||
|
||||
|
||||
|
103
extern/openxr/src/api_layers/CMakeLists.txt
vendored
Normal file
103
extern/openxr/src/api_layers/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
# Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author:
|
||||
#
|
||||
|
||||
# Force all compilers to output to binary folder without additional output (like Windows adds "Debug" and "Release" folders)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
|
||||
|
||||
# Copy the api_layer_platform_defines.h file and place it in the binary (build) directory.
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/api_layer_platform_defines.h ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
|
||||
|
||||
# Basics for core_validation API Layer
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XrApiLayer_core_validation.json ${CMAKE_CURRENT_BINARY_DIR}/XrApiLayer_core_validation.json COPYONLY)
|
||||
|
||||
add_library(XrApiLayer_core_validation SHARED
|
||||
core_validation.cpp
|
||||
${OPENXR_ROOT_DIR}/src/common/hex_and_handles.cpp
|
||||
${OPENXR_ROOT_DIR}/src/common/hex_and_handles.h
|
||||
${OPENXR_ROOT_DIR}/src/xr_generated_dispatch_table.c
|
||||
${OPENXR_ROOT_DIR}/src/api_layers/xr_generated_core_validation.cpp
|
||||
${OPENXR_ROOT_DIR}/src/api_layers/xr_generated_core_validation.hpp
|
||||
# Included in this list to force generation
|
||||
${CMAKE_CURRENT_BINARY_DIR}/XrApiLayer_core_validation.json
|
||||
)
|
||||
set_target_properties(XrApiLayer_core_validation PROPERTIES FOLDER ${API_LAYERS_FOLDER})
|
||||
|
||||
add_dependencies(XrApiLayer_core_validation
|
||||
generate_openxr_header
|
||||
xr_global_generated_files
|
||||
)
|
||||
target_include_directories(XrApiLayer_core_validation
|
||||
PRIVATE ${OPENXR_ROOT_DIR}/src/common
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${CMAKE_BINARY_DIR}/include
|
||||
PRIVATE ${CMAKE_BINARY_DIR}/src
|
||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
if(VulkanHeaders_FOUND)
|
||||
target_include_directories(XrApiLayer_core_validation
|
||||
PRIVATE ${Vulkan_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Flag generated files
|
||||
set_source_files_properties(
|
||||
${CMAKE_BINARY_DIR}/src/xr_generated_dispatch_table.c
|
||||
PROPERTIES GENERATED TRUE
|
||||
)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
# Windows core_validation-specific information
|
||||
target_compile_definitions(XrApiLayer_core_validation PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
# Turn off transitional "changed behavior" warning message for Visual Studio versions prior to 2015.
|
||||
# The changed behavior is that constructor initializers are now fixed to clear the struct members.
|
||||
target_compile_options(XrApiLayer_core_validation PRIVATE "$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,19>>:/wd4351>")
|
||||
|
||||
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/XrApiLayer_core_validation.def DEF_FILE)
|
||||
add_custom_target(copy-core_validation-def-file ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEF_FILE} ${CMAKE_CURRENT_BINARY_DIR}/XrApiLayer_core_validation.def
|
||||
VERBATIM
|
||||
)
|
||||
set_target_properties(copy-core_validation-def-file PROPERTIES FOLDER ${HELPER_FOLDER})
|
||||
elseif(APPLE)
|
||||
# Apple core_validation-specific information
|
||||
target_compile_options(XrApiLayer_core_validation PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
|
||||
set_target_properties(XrApiLayer_core_validation PROPERTIES LINK_FLAGS "-Wl")
|
||||
|
||||
else()
|
||||
# Linux core_validation-specific information
|
||||
target_compile_options(XrApiLayer_core_validation PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
|
||||
set_target_properties(XrApiLayer_core_validation PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,--exclude-libs,ALL")
|
||||
endif()
|
||||
|
||||
# Install explicit layers on Linux
|
||||
set(TARGET_NAMES
|
||||
XrApiLayer_core_validation)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
foreach(TARGET_NAME ${TARGET_NAMES})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.json DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openxr/${MAJOR}/api_layers/explicit.d)
|
||||
install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endforeach()
|
||||
endif()
|
27
extern/openxr/src/api_layers/XrApiLayer_core_validation.def
vendored
Normal file
27
extern/openxr/src/api_layers/XrApiLayer_core_validation.def
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;
|
||||
; Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
; Copyright (c) 2017-2019 Valve Corporation
|
||||
; Copyright (c) 2017-2019 LunarG, Inc.
|
||||
;
|
||||
; Licensed under the Apache License, Version 2.0 (the "License");
|
||||
; you may not use this file except in compliance with the License.
|
||||
; You may obtain a copy of the License at
|
||||
;
|
||||
; http://www.apache.org/licenses/LICENSE-2.0
|
||||
;
|
||||
; Unless required by applicable law or agreed to in writing, software
|
||||
; distributed under the License is distributed on an "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
; See the License for the specific language governing permissions and
|
||||
; limitations under the License.
|
||||
;
|
||||
; Author: Mark Young <marky@lunarg.com>
|
||||
;
|
||||
;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
LIBRARY XrApiLayer_core_validation
|
||||
EXPORTS
|
||||
xrNegotiateLoaderApiLayerInterface
|
||||
|
10
extern/openxr/src/api_layers/XrApiLayer_core_validation.json
vendored
Normal file
10
extern/openxr/src/api_layers/XrApiLayer_core_validation.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"file_format_version": "1.0.0",
|
||||
"api_layer": {
|
||||
"name": "XR_APILAYER_LUNARG_core_validation",
|
||||
"library_path": "libXrApiLayer_core_validation.dll",
|
||||
"api_version": "1.0",
|
||||
"implementation_version": "1",
|
||||
"description": "API Layer to perform validation of api calls and parameters as they occur"
|
||||
}
|
||||
}
|
48
extern/openxr/src/api_layers/api_layer_platform_defines.h
vendored
Normal file
48
extern/openxr/src/api_layers/api_layer_platform_defines.h
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2018-2019 The Khronos Group Inc.
|
||||
// Copyright (c) 2018-2019 Valve Corporation
|
||||
// Copyright (c) 2018-2019 LunarG, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#ifndef API_LAYER_PLATFORM_DEFINES_H_
|
||||
#define API_LAYER_PLATFORM_DEFINES_H_ 1
|
||||
|
||||
#ifdef _WIN32
|
||||
#define XR_USE_PLATFORM_WIN32 1 // Win32 platform
|
||||
#endif // _WIN32
|
||||
#if defined(OS_LINUX_XLIB)
|
||||
#define XR_USE_PLATFORM_XLIB 1 // Xlib platform
|
||||
#endif // OS_LINUX_XLIB
|
||||
#if defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX)
|
||||
#define XR_USE_PLATFORM_XCB 1 // Xcb platform
|
||||
#endif // OS_LINUX_XCB || OS_LINUX_XCB_GLX
|
||||
#if defined(OS_LINUX_WAYLAND)
|
||||
#define XR_USE_PLATFORM_WAYLAND 1 // Wayland platform
|
||||
#endif // OS_LINUX_WAYLAND
|
||||
#if defined(XR_OS_APPLE_IOS)
|
||||
#define XR_USE_PLATFORM_IOS 1 // iOS platform
|
||||
#define XR_USE_GRAPHICS_API_OPENGL_ES 1 // OpenGLES exists
|
||||
#define XR_USE_GRAPHICS_API_METAL 1 // Metal exists
|
||||
#endif // XR_OS_APPLE_IOS
|
||||
#if defined(XR_OS_APPLE_MACOS)
|
||||
#define XR_USE_PLATFORM_MACOS 1 // MacOS platform
|
||||
#define XR_USE_GRAPHICS_API_OPENGL 1 // OpenGL exists
|
||||
#define XR_USE_GRAPHICS_API_METAL 1 // Metal exists
|
||||
#endif // XR_OS_APPLE_MACOS
|
||||
|
||||
#include "xr_dependencies.h" // IWYU pragma: export
|
||||
|
||||
#endif // API_LAYER_PLATFORM_DEFINES_H_
|
932
extern/openxr/src/api_layers/core_validation.cpp
vendored
Normal file
932
extern/openxr/src/api_layers/core_validation.cpp
vendored
Normal file
@@ -0,0 +1,932 @@
|
||||
// Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2019 Valve Corporation
|
||||
// Copyright (c) 2017-2019 LunarG, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#include "api_layer_platform_defines.h"
|
||||
#include "extra_algorithms.h"
|
||||
#include "hex_and_handles.h"
|
||||
#include "loader_interfaces.h"
|
||||
#include "platform_utils.hpp"
|
||||
#include "validation_utils.h"
|
||||
#include "xr_generated_core_validation.hpp"
|
||||
#include "xr_generated_dispatch_table.h"
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define LAYER_EXPORT __attribute__((visibility("default")))
|
||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
||||
#define LAYER_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LAYER_EXPORT
|
||||
#endif
|
||||
|
||||
// Log recording information
|
||||
enum CoreValidationRecordType {
|
||||
RECORD_NONE = 0,
|
||||
RECORD_TEXT_COUT,
|
||||
RECORD_TEXT_FILE,
|
||||
RECORD_HTML_FILE,
|
||||
};
|
||||
|
||||
struct CoreValidationRecordInfo {
|
||||
bool initialized;
|
||||
CoreValidationRecordType type;
|
||||
std::string file_name;
|
||||
};
|
||||
|
||||
static CoreValidationRecordInfo g_record_info = {};
|
||||
static std::mutex g_record_mutex = {};
|
||||
|
||||
// HTML utilities
|
||||
bool CoreValidationWriteHtmlHeader() {
|
||||
try {
|
||||
std::unique_lock<std::mutex> mlock(g_record_mutex);
|
||||
std::ofstream html_file;
|
||||
html_file.open(g_record_info.file_name, std::ios::out);
|
||||
html_file
|
||||
<< "<!doctype html>\n"
|
||||
"<html>\n"
|
||||
" <head>\n"
|
||||
" <title>OpenXR Core Validation</title>\n"
|
||||
" <style type='text/css'>\n"
|
||||
" html {\n"
|
||||
" background-color: #0b1e48;\n"
|
||||
" background-image: url('https://vulkan.lunarg.com/img/bg-starfield.jpg');\n"
|
||||
" background-position: center;\n"
|
||||
" -webkit-background-size: cover;\n"
|
||||
" -moz-background-size: cover;\n"
|
||||
" -o-background-size: cover;\n"
|
||||
" background-size: cover;\n"
|
||||
" background-attachment: fixed;\n"
|
||||
" background-repeat: no-repeat;\n"
|
||||
" height: 100%;\n"
|
||||
" }\n"
|
||||
" #header {\n"
|
||||
" z-index: -1;\n"
|
||||
" }\n"
|
||||
" #header>img {\n"
|
||||
" position: absolute;\n"
|
||||
" width: 160px;\n"
|
||||
" margin-left: -280px;\n"
|
||||
" top: -10px;\n"
|
||||
" left: 50%;\n"
|
||||
" }\n"
|
||||
" #header>h1 {\n"
|
||||
" font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;\n"
|
||||
" font-size: 48px;\n"
|
||||
" font-weight: 200;\n"
|
||||
" text-shadow: 4px 4px 5px #000;\n"
|
||||
" color: #eee;\n"
|
||||
" position: absolute;\n"
|
||||
" width: 600px;\n"
|
||||
" margin-left: -80px;\n"
|
||||
" top: 8px;\n"
|
||||
" left: 50%;\n"
|
||||
" }\n"
|
||||
" body {\n"
|
||||
" font-family: Consolas, monaco, monospace;\n"
|
||||
" font-size: 14px;\n"
|
||||
" line-height: 20px;\n"
|
||||
" color: #eee;\n"
|
||||
" height: 100%;\n"
|
||||
" margin: 0;\n"
|
||||
" overflow: hidden;\n"
|
||||
" }\n"
|
||||
" #wrapper {\n"
|
||||
" background-color: rgba(0, 0, 0, 0.7);\n"
|
||||
" border: 1px solid #446;\n"
|
||||
" box-shadow: 0px 0px 10px #000;\n"
|
||||
" padding: 8px 12px;\n"
|
||||
" display: inline-block;\n"
|
||||
" position: absolute;\n"
|
||||
" top: 80px;\n"
|
||||
" bottom: 25px;\n"
|
||||
" left: 50px;\n"
|
||||
" right: 50px;\n"
|
||||
" overflow: auto;\n"
|
||||
" }\n"
|
||||
" details>*:not(summary) {\n"
|
||||
" margin-left: 22px;\n"
|
||||
" }\n"
|
||||
" summary:only-child {\n"
|
||||
" display: block;\n"
|
||||
" padding-left: 15px;\n"
|
||||
" }\n"
|
||||
" details>summary:only-child::-webkit-details-marker {\n"
|
||||
" display: none;\n"
|
||||
" padding-left: 15px;\n"
|
||||
" }\n"
|
||||
" .headervar, .generalheadertype, .warningheadertype, .errorheadertype, .debugheadertype, .headerval {\n"
|
||||
" display: inline;\n"
|
||||
" margin: 0 9px;\n"
|
||||
" }\n"
|
||||
" .var, .type, .val {\n"
|
||||
" display: inline;\n"
|
||||
" margin: 0 6px;\n"
|
||||
" }\n"
|
||||
" .warningheadertype, .type {\n"
|
||||
" color: #dce22f;\n"
|
||||
" }\n"
|
||||
" .errorheadertype, .type {\n"
|
||||
" color: #ff1616;\n"
|
||||
" }\n"
|
||||
" .debugheadertype, .type {\n"
|
||||
" color: #888;\n"
|
||||
" }\n"
|
||||
" .generalheadertype, .type {\n"
|
||||
" color: #acf;\n"
|
||||
" }\n"
|
||||
" .headerval, .val {\n"
|
||||
" color: #afa;\n"
|
||||
" text-align: right;\n"
|
||||
" }\n"
|
||||
" .thd {\n"
|
||||
" color: #888;\n"
|
||||
" }\n"
|
||||
" </style>\n"
|
||||
" </head>\n"
|
||||
" <body>\n"
|
||||
" <div id='header'>\n"
|
||||
" <img src='https://lunarg.com/wp-content/uploads/2016/02/LunarG-wReg-150.png' />\n"
|
||||
" <h1>OpenXR Core Validation</h1>\n"
|
||||
" </div>\n"
|
||||
" <div id='wrapper'>\n";
|
||||
return true;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CoreValidationWriteHtmlFooter() {
|
||||
try {
|
||||
std::unique_lock<std::mutex> mlock(g_record_mutex);
|
||||
std::ofstream html_file;
|
||||
html_file.open(g_record_info.file_name, std::ios::out | std::ios::app);
|
||||
html_file << " </div>\n"
|
||||
" </body>\n"
|
||||
"</html>";
|
||||
|
||||
// Writing the footer means we're done.
|
||||
if (g_record_info.initialized) {
|
||||
g_record_info.initialized = false;
|
||||
g_record_info.type = RECORD_NONE;
|
||||
}
|
||||
return true;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to record all the core validation information
|
||||
void CoreValidLogMessage(GenValidUsageXrInstanceInfo *instance_info, const std::string &message_id,
|
||||
GenValidUsageDebugSeverity message_severity, const std::string &command_name,
|
||||
std::vector<GenValidUsageXrObjectInfo> objects_info, const std::string &message) {
|
||||
if (g_record_info.initialized) {
|
||||
std::unique_lock<std::mutex> mlock(g_record_mutex);
|
||||
|
||||
// Debug Utils items (in case we need them)
|
||||
XrDebugUtilsMessageSeverityFlagsEXT debug_utils_severity = 0;
|
||||
std::vector<XrDebugUtilsObjectNameInfoEXT> debug_utils_objects;
|
||||
std::vector<XrDebugUtilsLabelEXT> session_labels;
|
||||
|
||||
std::string severity_string;
|
||||
switch (message_severity) {
|
||||
case VALID_USAGE_DEBUG_SEVERITY_DEBUG:
|
||||
severity_string = "VALID_DEBUG";
|
||||
debug_utils_severity = XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
|
||||
break;
|
||||
case VALID_USAGE_DEBUG_SEVERITY_INFO:
|
||||
severity_string = "VALID_INFO";
|
||||
debug_utils_severity = XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
|
||||
break;
|
||||
case VALID_USAGE_DEBUG_SEVERITY_WARNING:
|
||||
severity_string = "VALID_WARNING";
|
||||
debug_utils_severity = XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
|
||||
break;
|
||||
case VALID_USAGE_DEBUG_SEVERITY_ERROR:
|
||||
severity_string = "VALID_ERROR";
|
||||
debug_utils_severity = XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||
break;
|
||||
default:
|
||||
severity_string = "VALID_UNKNOWN";
|
||||
break;
|
||||
}
|
||||
|
||||
// If we have instance information, see if we need to log this information out to a debug messenger
|
||||
// callback.
|
||||
if (nullptr != instance_info) {
|
||||
if (!objects_info.empty()) {
|
||||
for (auto &obj : objects_info) {
|
||||
XrDebugUtilsObjectNameInfoEXT obj_name_info = {};
|
||||
obj_name_info.next = nullptr;
|
||||
obj_name_info.objectType = obj.type;
|
||||
obj_name_info.objectHandle = obj.handle;
|
||||
// If there's a session in the list, see if it has labels
|
||||
if (XR_OBJECT_TYPE_SESSION == obj.type) {
|
||||
XrSession session = TreatIntegerAsHandle<XrSession>(obj.handle);
|
||||
auto session_label_iterator = g_xr_session_labels.find(session);
|
||||
if (session_label_iterator != g_xr_session_labels.end()) {
|
||||
auto rev_iter = session_label_iterator->second->rbegin();
|
||||
for (; rev_iter != session_label_iterator->second->rend(); ++rev_iter) {
|
||||
session_labels.push_back((*rev_iter)->debug_utils_label);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Loop through all object names and see if any match
|
||||
for (auto &object_name : instance_info->object_names) {
|
||||
if (object_name->objectType == obj.type && object_name->objectHandle == obj.handle) {
|
||||
obj_name_info.objectName = object_name->objectName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
debug_utils_objects.push_back(obj_name_info);
|
||||
}
|
||||
}
|
||||
if (!instance_info->debug_messengers.empty()) {
|
||||
// Setup our callback data once
|
||||
XrDebugUtilsMessengerCallbackDataEXT callback_data = {};
|
||||
callback_data.type = XR_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT;
|
||||
callback_data.messageId = message_id.c_str();
|
||||
callback_data.functionName = command_name.c_str();
|
||||
callback_data.message = message.c_str();
|
||||
callback_data.objectCount = static_cast<uint8_t>(debug_utils_objects.size());
|
||||
if (debug_utils_objects.empty()) {
|
||||
callback_data.objects = nullptr;
|
||||
} else {
|
||||
callback_data.objects = debug_utils_objects.data();
|
||||
}
|
||||
callback_data.sessionLabelCount = static_cast<uint8_t>(session_labels.size());
|
||||
if (session_labels.empty()) {
|
||||
callback_data.sessionLabels = nullptr;
|
||||
} else {
|
||||
callback_data.sessionLabels = session_labels.data();
|
||||
}
|
||||
|
||||
// Loop through all active messengers and give each a chance to output information
|
||||
for (auto &debug_messenger : instance_info->debug_messengers) {
|
||||
CoreValidationMessengerInfo *validation_messenger_info = debug_messenger.get();
|
||||
XrDebugUtilsMessengerCreateInfoEXT *messenger_create_info = validation_messenger_info->create_info;
|
||||
// If a callback exists, and the message is of a type this callback cares about, call it.
|
||||
if (nullptr != messenger_create_info->userCallback &&
|
||||
0 != (messenger_create_info->messageSeverities & debug_utils_severity) &&
|
||||
0 != (messenger_create_info->messageTypes & XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT)) {
|
||||
XrBool32 ret_val = messenger_create_info->userCallback(debug_utils_severity,
|
||||
XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT,
|
||||
&callback_data, messenger_create_info->userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (g_record_info.type) {
|
||||
case RECORD_TEXT_COUT: {
|
||||
std::cout << "[" << severity_string << " | " << message_id << " | " << command_name << "]: " << message
|
||||
<< std::endl;
|
||||
if (!objects_info.empty()) {
|
||||
std::cout << " Objects:" << std::endl;
|
||||
uint32_t count = 0;
|
||||
for (auto object_info : objects_info) {
|
||||
std::string object_type = GenValidUsageXrObjectTypeToString(object_info.type);
|
||||
std::ostringstream oss_object_handle;
|
||||
std::cout << " [" << std::to_string(count++) << "] - " << object_type << " ("
|
||||
<< Uint64ToHexString(object_info.handle) << ")";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
if (!session_labels.empty()) {
|
||||
std::cout << " Session Labels:" << std::endl;
|
||||
uint32_t count = 0;
|
||||
for (auto session_label : session_labels) {
|
||||
std::cout << " [" << std::to_string(count++) << "] - " << session_label.labelName << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::flush;
|
||||
break;
|
||||
}
|
||||
case RECORD_TEXT_FILE: {
|
||||
std::ofstream text_file;
|
||||
text_file.open(g_record_info.file_name, std::ios::out | std::ios::app);
|
||||
text_file << "[" << severity_string << " | " << message_id << " | " << command_name << "]: " << message
|
||||
<< std::endl;
|
||||
if (!objects_info.empty()) {
|
||||
text_file << " Objects:" << std::endl;
|
||||
uint32_t count = 0;
|
||||
for (auto object_info : objects_info) {
|
||||
std::string object_type = GenValidUsageXrObjectTypeToString(object_info.type);
|
||||
text_file << " [" << std::to_string(count++) << "] - " << object_type << " ("
|
||||
<< Uint64ToHexString(object_info.handle) << ")";
|
||||
text_file << std::endl;
|
||||
}
|
||||
}
|
||||
if (!session_labels.empty()) {
|
||||
text_file << " Session Labels:" << std::endl;
|
||||
uint32_t count = 0;
|
||||
for (auto session_label : session_labels) {
|
||||
text_file << " [" << std::to_string(count++) << "] - " << session_label.labelName << std::endl;
|
||||
}
|
||||
}
|
||||
text_file << std::flush;
|
||||
text_file.close();
|
||||
break;
|
||||
}
|
||||
case RECORD_HTML_FILE: {
|
||||
std::ofstream text_file;
|
||||
text_file.open(g_record_info.file_name, std::ios::out | std::ios::app);
|
||||
text_file << "<details class='data'>\n";
|
||||
std::string header_type = "generalheadertype";
|
||||
switch (message_severity) {
|
||||
case VALID_USAGE_DEBUG_SEVERITY_DEBUG:
|
||||
header_type = "debugheadertype";
|
||||
severity_string = "Debug Message";
|
||||
break;
|
||||
case VALID_USAGE_DEBUG_SEVERITY_INFO:
|
||||
severity_string = "Info Message";
|
||||
break;
|
||||
case VALID_USAGE_DEBUG_SEVERITY_WARNING:
|
||||
header_type = "warningheadertype";
|
||||
severity_string = "Warning Message";
|
||||
break;
|
||||
case VALID_USAGE_DEBUG_SEVERITY_ERROR:
|
||||
header_type = "errorheadertype";
|
||||
severity_string = "Error Message";
|
||||
break;
|
||||
default:
|
||||
severity_string = "Unknown Message";
|
||||
break;
|
||||
}
|
||||
text_file << " <summary>\n"
|
||||
<< " <div class='" << header_type << "'>" << severity_string << "</div>\n"
|
||||
<< " <div class='headerval'>" << command_name << "</div>\n"
|
||||
<< " <div class='headervar'>" << message_id << "</div>\n"
|
||||
<< " </summary>\n";
|
||||
text_file << " <div class='data'>\n";
|
||||
text_file << " <div class='val'>" << message << "</div>\n";
|
||||
if (!objects_info.empty()) {
|
||||
text_file << " <details class='data'>\n";
|
||||
text_file << " <summary>\n";
|
||||
text_file << " <div class='type'>Relevant OpenXR Objects</div>\n";
|
||||
text_file << " </summary>\n";
|
||||
uint32_t count = 0;
|
||||
for (auto object_info : objects_info) {
|
||||
std::string object_type = GenValidUsageXrObjectTypeToString(object_info.type);
|
||||
text_file << " <div class='data'>\n";
|
||||
text_file << " <div class='var'>[" << count++ << "]</div>\n";
|
||||
text_file << " <div class='type'>" << object_type << "</div>\n";
|
||||
text_file << " <div class='val'>" << Uint64ToHexString(object_info.handle) << "</div>\n";
|
||||
text_file << " </div>\n";
|
||||
}
|
||||
text_file << " </details>\n";
|
||||
text_file << std::flush;
|
||||
}
|
||||
if (!session_labels.empty()) {
|
||||
text_file << " <details class='data'>\n";
|
||||
text_file << " <summary>\n";
|
||||
text_file << " <div class='type'>Relevant Session Labels</div>\n";
|
||||
text_file << " </summary>\n";
|
||||
uint32_t count = 0;
|
||||
for (auto session_label : session_labels) {
|
||||
text_file << " <div class='data'>\n";
|
||||
text_file << " <div class='var'>[" << count++ << "]</div>\n";
|
||||
text_file << " <div class='type'>" << session_label.labelName << "</div>\n";
|
||||
text_file << " </div>\n";
|
||||
}
|
||||
text_file << " </details>\n";
|
||||
}
|
||||
text_file << " </div>\n";
|
||||
text_file << "</details>\n";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reportInternalError(std::string const &message) {
|
||||
std::cerr << "INTERNAL VALIDATION LAYER ERROR: " << message << std::endl;
|
||||
throw std::runtime_error("Internal validation layer error: " + message);
|
||||
}
|
||||
|
||||
void InvalidStructureType(GenValidUsageXrInstanceInfo *instance_info, const std::string &command_name,
|
||||
std::vector<GenValidUsageXrObjectInfo> &objects_info, const char *structure_name, XrStructureType type,
|
||||
const char *vuid, XrStructureType expected, const char *expected_name) {
|
||||
std::ostringstream oss_type;
|
||||
oss_type << structure_name << " has an invalid XrStructureType ";
|
||||
oss_type << Uint32ToHexString(static_cast<uint32_t>(type));
|
||||
if (expected != 0) {
|
||||
oss_type << ", expected " << Uint32ToHexString(static_cast<uint32_t>(type));
|
||||
oss_type << " (" << expected_name << ")";
|
||||
}
|
||||
if (vuid != nullptr) {
|
||||
CoreValidLogMessage(instance_info, vuid, VALID_USAGE_DEBUG_SEVERITY_ERROR, command_name, objects_info, oss_type.str());
|
||||
} else {
|
||||
CoreValidLogMessage(instance_info, "VUID-" + std::string(structure_name) + "-type-type", VALID_USAGE_DEBUG_SEVERITY_ERROR,
|
||||
command_name, objects_info, oss_type.str());
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Can't validate the following VUIDs since the command never enters a layer:
|
||||
// Command: xrEnumerateApiLayerProperties
|
||||
// VUIDs: "VUID-xrEnumerateApiLayerProperties-propertyCountOutput-parameter"
|
||||
// "VUID-xrEnumerateApiLayerProperties-properties-parameter"
|
||||
// Command: xrEnumerateInstanceExtensionProperties
|
||||
// VUIDs: "VUID-xrEnumerateInstanceExtensionProperties-layerName-parameter"
|
||||
// "VUID-xrEnumerateInstanceExtensionProperties-propertyCountOutput-parameter"
|
||||
// "VUID-xrEnumerateInstanceExtensionProperties-properties-parameter"
|
||||
|
||||
XrResult CoreValidationXrCreateInstance(const XrInstanceCreateInfo * /*info*/, XrInstance * /*instance*/) {
|
||||
// Shouldn't be called, coreValidationXrCreateApiLayerInstance should called instead
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
GenValidUsageXrInstanceInfo::GenValidUsageXrInstanceInfo(XrInstance inst, PFN_xrGetInstanceProcAddr next_get_instance_proc_addr)
|
||||
: instance(inst), dispatch_table(new XrGeneratedDispatchTable()) {
|
||||
/// @todo smart pointer here!
|
||||
|
||||
// Create the dispatch table to the next levels
|
||||
GeneratedXrPopulateDispatchTable(dispatch_table, instance, next_get_instance_proc_addr);
|
||||
}
|
||||
|
||||
GenValidUsageXrInstanceInfo::~GenValidUsageXrInstanceInfo() { delete dispatch_table; }
|
||||
|
||||
// See if there is a debug utils create structure in the "next" chain
|
||||
|
||||
XrResult CoreValidationXrCreateApiLayerInstance(const XrInstanceCreateInfo *info, const struct XrApiLayerCreateInfo *apiLayerInfo,
|
||||
XrInstance *instance) {
|
||||
try {
|
||||
XrApiLayerCreateInfo new_api_layer_info = {};
|
||||
XrResult validation_result = XR_SUCCESS;
|
||||
bool user_defined_output = false;
|
||||
bool first_time = !g_record_info.initialized;
|
||||
|
||||
if (!g_record_info.initialized) {
|
||||
g_record_info.initialized = true;
|
||||
g_record_info.type = RECORD_NONE;
|
||||
}
|
||||
|
||||
char *export_type = PlatformUtilsGetEnv("XR_CORE_VALIDATION_EXPORT_TYPE");
|
||||
char *file_name = PlatformUtilsGetEnv("XR_CORE_VALIDATION_FILE_NAME");
|
||||
if (nullptr != file_name) {
|
||||
g_record_info.file_name = file_name;
|
||||
PlatformUtilsFreeEnv(file_name);
|
||||
}
|
||||
|
||||
if (nullptr != export_type) {
|
||||
std::string string_export_type = export_type;
|
||||
PlatformUtilsFreeEnv(export_type);
|
||||
std::transform(string_export_type.begin(), string_export_type.end(), string_export_type.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
|
||||
std::cerr << "Core Validation output type: " << string_export_type << ", first time = " << std::to_string(first_time)
|
||||
<< std::endl;
|
||||
if (string_export_type == "text") {
|
||||
if (!g_record_info.file_name.empty()) {
|
||||
g_record_info.type = RECORD_TEXT_FILE;
|
||||
} else {
|
||||
g_record_info.type = RECORD_TEXT_COUT;
|
||||
}
|
||||
user_defined_output = true;
|
||||
} else if (string_export_type == "html" && first_time) {
|
||||
g_record_info.type = RECORD_HTML_FILE;
|
||||
if (!CoreValidationWriteHtmlHeader()) {
|
||||
return XR_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Call the generated pre valid usage check.
|
||||
validation_result = GenValidUsageInputsXrCreateInstance(info, instance);
|
||||
|
||||
// Copy the contents of the layer info struct, but then move the next info up by
|
||||
// one slot so that the next layer gets information.
|
||||
memcpy(&new_api_layer_info, apiLayerInfo, sizeof(XrApiLayerCreateInfo));
|
||||
new_api_layer_info.nextInfo = apiLayerInfo->nextInfo->next;
|
||||
|
||||
// Get the function pointers we need
|
||||
PFN_xrGetInstanceProcAddr next_get_instance_proc_addr = apiLayerInfo->nextInfo->nextGetInstanceProcAddr;
|
||||
PFN_xrCreateApiLayerInstance next_create_api_layer_instance = apiLayerInfo->nextInfo->nextCreateApiLayerInstance;
|
||||
|
||||
// Create the instance using the layer create instance command for the next layer
|
||||
XrInstance returned_instance = *instance;
|
||||
XrResult next_result = next_create_api_layer_instance(info, &new_api_layer_info, &returned_instance);
|
||||
*instance = returned_instance;
|
||||
|
||||
// Create the instance information
|
||||
std::unique_ptr<GenValidUsageXrInstanceInfo> instance_info(
|
||||
new GenValidUsageXrInstanceInfo(returned_instance, next_get_instance_proc_addr));
|
||||
|
||||
// Save the enabled extensions.
|
||||
for (uint32_t extension = 0; extension < info->enabledExtensionCount; ++extension) {
|
||||
instance_info->enabled_extensions.emplace_back(info->enabledExtensionNames[extension]);
|
||||
}
|
||||
|
||||
g_instance_info.insert(returned_instance, std::move(instance_info));
|
||||
|
||||
// See if a debug utils messenger is supposed to be created as part of the instance
|
||||
// NOTE: We have to wait until after the instance info is added to the map for this
|
||||
// to work properly.
|
||||
const auto *next_header = reinterpret_cast<const XrBaseInStructure *>(info->next);
|
||||
const XrDebugUtilsMessengerCreateInfoEXT *dbg_utils_create_info = nullptr;
|
||||
while (next_header != nullptr) {
|
||||
if (next_header->type == XR_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT) {
|
||||
dbg_utils_create_info = reinterpret_cast<const XrDebugUtilsMessengerCreateInfoEXT *>(next_header);
|
||||
// Create the debug messenger. We don't have to keep track of it because it will be tracked as part
|
||||
// of the instance info from here on out.
|
||||
XrDebugUtilsMessengerEXT messenger;
|
||||
validation_result = CoreValidationXrCreateDebugUtilsMessengerEXT(*instance, dbg_utils_create_info, &messenger);
|
||||
// If we created a debug messenger, turn off the text output unless a user indicates they wanted it
|
||||
if (XR_SUCCESS == validation_result && !user_defined_output) {
|
||||
g_record_info.type = RECORD_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
next_header = reinterpret_cast<const XrBaseInStructure *>(next_header->next);
|
||||
}
|
||||
|
||||
if (XR_SUCCESS == validation_result) {
|
||||
return next_result;
|
||||
}
|
||||
return validation_result;
|
||||
|
||||
} catch (std::bad_alloc &) {
|
||||
return XR_ERROR_OUT_OF_MEMORY;
|
||||
} catch (...) {
|
||||
return XR_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
void EraseAllInstanceTableMapElements(GenValidUsageXrInstanceInfo *search_value) {
|
||||
typedef typename InstanceHandleInfo::value_t value_t;
|
||||
auto map_with_lock = g_instance_info.lockMap();
|
||||
auto &map = map_with_lock.second;
|
||||
|
||||
map_erase_if(map, [=](value_t const &data) { return data.second.get() == search_value; });
|
||||
}
|
||||
|
||||
XrResult CoreValidationXrDestroyInstance(XrInstance instance) {
|
||||
GenValidUsageInputsXrDestroyInstance(instance);
|
||||
if (XR_NULL_HANDLE != instance) {
|
||||
auto info_with_lock = g_instance_info.getWithLock(instance);
|
||||
GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second;
|
||||
if (nullptr != gen_instance_info) {
|
||||
gen_instance_info->object_names.clear();
|
||||
gen_instance_info->debug_messengers.clear();
|
||||
}
|
||||
}
|
||||
XrResult result = GenValidUsageNextXrDestroyInstance(instance);
|
||||
if (!g_instance_info.empty() && g_record_info.type == RECORD_HTML_FILE) {
|
||||
CoreValidationWriteHtmlFooter();
|
||||
}
|
||||
return result;
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
XrResult CoreValidationXrCreateSession(XrInstance instance, const XrSessionCreateInfo *createInfo, XrSession *session) {
|
||||
try {
|
||||
XrResult test_result = GenValidUsageInputsXrCreateSession(instance, createInfo, session);
|
||||
if (XR_SUCCESS != test_result) {
|
||||
return test_result;
|
||||
}
|
||||
|
||||
GenValidUsageXrInstanceInfo *gen_instance_info = g_instance_info.get(instance);
|
||||
|
||||
// Check the next chain for a graphics binding structure, we need at least one.
|
||||
uint32_t num_graphics_bindings_found = 0;
|
||||
const auto *cur_ptr = reinterpret_cast<const XrBaseInStructure *>(createInfo->next);
|
||||
while (nullptr != cur_ptr) {
|
||||
switch (cur_ptr->type) {
|
||||
default:
|
||||
continue;
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
case XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR:
|
||||
num_graphics_bindings_found++;
|
||||
break;
|
||||
#endif
|
||||
#ifdef XR_USE_PLATFORM_XLIB
|
||||
case XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR:
|
||||
num_graphics_bindings_found++;
|
||||
break;
|
||||
#endif
|
||||
#ifdef XR_USE_PLATFORM_XCB
|
||||
case XR_TYPE_GRAPHICS_BINDING_OPENGL_XCB_KHR:
|
||||
num_graphics_bindings_found++;
|
||||
break;
|
||||
#endif
|
||||
#ifdef XR_USE_PLATFORM_WAYLAND
|
||||
case XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR:
|
||||
num_graphics_bindings_found++;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
cur_ptr = reinterpret_cast<const XrBaseInStructure *>(cur_ptr->next);
|
||||
}
|
||||
auto const &enabled_extensions = gen_instance_info->enabled_extensions;
|
||||
#ifdef XR_KHR_headless
|
||||
bool has_headless = (enabled_extensions.end() !=
|
||||
std::find(enabled_extensions.begin(), enabled_extensions.end(), XR_KHR_HEADLESS_EXTENSION_NAME));
|
||||
#else
|
||||
bool has_headless = false;
|
||||
#endif // XR_KHR_headless
|
||||
bool got_right_graphics_binding_count = (num_graphics_bindings_found == 1);
|
||||
if (!got_right_graphics_binding_count && has_headless) {
|
||||
// This permits 0 as well.
|
||||
got_right_graphics_binding_count = (num_graphics_bindings_found == 0);
|
||||
}
|
||||
if (!got_right_graphics_binding_count) {
|
||||
std::vector<GenValidUsageXrObjectInfo> objects_info;
|
||||
objects_info.emplace_back(instance, XR_OBJECT_TYPE_INSTANCE);
|
||||
std::ostringstream error_stream;
|
||||
error_stream << "Invalid number of graphics binding structures provided. ";
|
||||
error_stream << "Expected ";
|
||||
if (has_headless) {
|
||||
error_stream << "0 or 1";
|
||||
} else {
|
||||
error_stream << "1";
|
||||
}
|
||||
error_stream << ", but received ";
|
||||
error_stream << num_graphics_bindings_found;
|
||||
error_stream << ".";
|
||||
// TODO: This needs to be updated with the actual VUID once we generate it.
|
||||
CoreValidLogMessage(gen_instance_info, "VUID-xrCreateSession-next-parameter", VALID_USAGE_DEBUG_SEVERITY_ERROR,
|
||||
"xrCreateSession", objects_info, error_stream.str());
|
||||
return XR_ERROR_GRAPHICS_DEVICE_INVALID;
|
||||
}
|
||||
return GenValidUsageNextXrCreateSession(instance, createInfo, session);
|
||||
} catch (...) {
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- XR_EXT_debug_utils extension commands
|
||||
XrResult CoreValidationXrSetDebugUtilsObjectNameEXT(XrInstance instance, const XrDebugUtilsObjectNameInfoEXT *nameInfo) {
|
||||
try {
|
||||
XrResult result = GenValidUsageInputsXrSetDebugUtilsObjectNameEXT(instance, nameInfo);
|
||||
if (!XR_UNQUALIFIED_SUCCESS(result)) {
|
||||
return result;
|
||||
}
|
||||
result = GenValidUsageNextXrSetDebugUtilsObjectNameEXT(instance, nameInfo);
|
||||
if (!XR_UNQUALIFIED_SUCCESS(result)) {
|
||||
return result;
|
||||
}
|
||||
auto info_with_lock = g_instance_info.getWithLock(instance);
|
||||
GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second;
|
||||
if (nullptr != gen_instance_info) {
|
||||
// Create a copy of the base object name info (no next items)
|
||||
auto len = strlen(nameInfo->objectName);
|
||||
char *name_string = new char[len + 1];
|
||||
strncpy(name_string, nameInfo->objectName, len);
|
||||
bool found = false;
|
||||
for (auto &object_name : gen_instance_info->object_names) {
|
||||
if (object_name->objectHandle == nameInfo->objectHandle && object_name->objectType == nameInfo->objectType) {
|
||||
delete[] object_name->objectName;
|
||||
object_name->objectName = name_string;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
UniqueXrDebugUtilsObjectNameInfoEXT new_object_name(new XrDebugUtilsObjectNameInfoEXT(*nameInfo));
|
||||
new_object_name->next = nullptr;
|
||||
new_object_name->objectName = name_string;
|
||||
gen_instance_info->object_names.push_back(std::move(new_object_name));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (...) {
|
||||
return XR_ERROR_VALIDATION_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
XrResult CoreValidationXrCreateDebugUtilsMessengerEXT(XrInstance instance, const XrDebugUtilsMessengerCreateInfoEXT *createInfo,
|
||||
XrDebugUtilsMessengerEXT *messenger) {
|
||||
try {
|
||||
XrResult result = GenValidUsageInputsXrCreateDebugUtilsMessengerEXT(instance, createInfo, messenger);
|
||||
if (!XR_UNQUALIFIED_SUCCESS(result)) {
|
||||
return result;
|
||||
}
|
||||
result = GenValidUsageNextXrCreateDebugUtilsMessengerEXT(instance, createInfo, messenger);
|
||||
if (!XR_UNQUALIFIED_SUCCESS(result)) {
|
||||
return result;
|
||||
}
|
||||
auto info_with_lock = g_instance_info.getWithLock(instance);
|
||||
GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second;
|
||||
if (nullptr != gen_instance_info) {
|
||||
auto *new_create_info = new XrDebugUtilsMessengerCreateInfoEXT(*createInfo);
|
||||
new_create_info->next = nullptr;
|
||||
UniqueCoreValidationMessengerInfo new_messenger_info(new CoreValidationMessengerInfo);
|
||||
new_messenger_info->messenger = *messenger;
|
||||
new_messenger_info->create_info = new_create_info;
|
||||
gen_instance_info->debug_messengers.push_back(std::move(new_messenger_info));
|
||||
}
|
||||
return result;
|
||||
} catch (...) {
|
||||
return XR_ERROR_VALIDATION_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
XrResult CoreValidationXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT messenger) {
|
||||
try {
|
||||
XrResult result = GenValidUsageInputsXrDestroyDebugUtilsMessengerEXT(messenger);
|
||||
if (!XR_UNQUALIFIED_SUCCESS(result)) {
|
||||
return result;
|
||||
}
|
||||
result = GenValidUsageNextXrDestroyDebugUtilsMessengerEXT(messenger);
|
||||
if (!XR_UNQUALIFIED_SUCCESS(result)) {
|
||||
return result;
|
||||
}
|
||||
if (XR_NULL_HANDLE == messenger) {
|
||||
return XR_ERROR_HANDLE_INVALID;
|
||||
}
|
||||
auto info_with_lock = g_debugutilsmessengerext_info.getWithLock(messenger);
|
||||
GenValidUsageXrHandleInfo *gen_handle_info = info_with_lock.second;
|
||||
if (nullptr != gen_handle_info) {
|
||||
auto &debug_messengers = gen_handle_info->instance_info->debug_messengers;
|
||||
vector_remove_if_and_erase(debug_messengers,
|
||||
[=](UniqueCoreValidationMessengerInfo const &msg) { return msg->messenger == messenger; });
|
||||
}
|
||||
return result;
|
||||
} catch (...) {
|
||||
return XR_ERROR_VALIDATION_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// We always want to remove the old individual label before we do anything else.
|
||||
// So, do that in it's own method
|
||||
void CoreValidationRemoveIndividualLabel(std::vector<GenValidUsageXrInternalSessionLabel *> *label_vec) {
|
||||
if (!label_vec->empty()) {
|
||||
GenValidUsageXrInternalSessionLabel *cur_label = label_vec->back();
|
||||
if (cur_label->is_individual_label) {
|
||||
label_vec->pop_back();
|
||||
delete cur_label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CoreValidationBeginLabelRegion(XrSession session, const XrDebugUtilsLabelEXT *label_info) {
|
||||
std::vector<GenValidUsageXrInternalSessionLabel *> *vec_ptr = nullptr;
|
||||
auto session_label_iterator = g_xr_session_labels.find(session);
|
||||
if (session_label_iterator == g_xr_session_labels.end()) {
|
||||
vec_ptr = new std::vector<GenValidUsageXrInternalSessionLabel *>;
|
||||
g_xr_session_labels[session] = vec_ptr;
|
||||
} else {
|
||||
vec_ptr = session_label_iterator->second;
|
||||
}
|
||||
|
||||
// Individual labels do not stay around in the transition into a new label region
|
||||
CoreValidationRemoveIndividualLabel(vec_ptr);
|
||||
|
||||
// Start the new label region
|
||||
auto *new_session_label = new GenValidUsageXrInternalSessionLabel;
|
||||
new_session_label->label_name = label_info->labelName;
|
||||
new_session_label->debug_utils_label = *label_info;
|
||||
new_session_label->debug_utils_label.labelName = new_session_label->label_name.c_str();
|
||||
new_session_label->is_individual_label = false;
|
||||
vec_ptr->push_back(new_session_label);
|
||||
}
|
||||
|
||||
void CoreValidationEndLabelRegion(XrSession session) {
|
||||
auto session_label_iterator = g_xr_session_labels.find(session);
|
||||
if (session_label_iterator == g_xr_session_labels.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<GenValidUsageXrInternalSessionLabel *> *vec_ptr = session_label_iterator->second;
|
||||
|
||||
// Individual labels do not stay around in the transition out of label region
|
||||
CoreValidationRemoveIndividualLabel(vec_ptr);
|
||||
|
||||
// Remove the last label region
|
||||
if (!vec_ptr->empty()) {
|
||||
GenValidUsageXrInternalSessionLabel *cur_label = vec_ptr->back();
|
||||
vec_ptr->pop_back();
|
||||
delete cur_label;
|
||||
}
|
||||
}
|
||||
|
||||
void CoreValidationInsertLabel(XrSession session, const XrDebugUtilsLabelEXT *label_info) {
|
||||
std::vector<GenValidUsageXrInternalSessionLabel *> *vec_ptr = nullptr;
|
||||
auto session_label_iterator = g_xr_session_labels.find(session);
|
||||
if (session_label_iterator == g_xr_session_labels.end()) {
|
||||
vec_ptr = new std::vector<GenValidUsageXrInternalSessionLabel *>;
|
||||
g_xr_session_labels[session] = vec_ptr;
|
||||
} else {
|
||||
vec_ptr = session_label_iterator->second;
|
||||
}
|
||||
|
||||
// Remove any individual layer that might already be there
|
||||
CoreValidationRemoveIndividualLabel(vec_ptr);
|
||||
|
||||
// Insert a new individual label
|
||||
auto *new_session_label = new GenValidUsageXrInternalSessionLabel;
|
||||
new_session_label->label_name = label_info->labelName;
|
||||
new_session_label->debug_utils_label = *label_info;
|
||||
new_session_label->debug_utils_label.labelName = new_session_label->label_name.c_str();
|
||||
new_session_label->is_individual_label = true;
|
||||
vec_ptr->push_back(new_session_label);
|
||||
}
|
||||
|
||||
// Called during xrDestroySession. We need to delete all session related labels.
|
||||
void CoreValidationDeleteSessionLabels(XrSession session) {
|
||||
std::vector<GenValidUsageXrInternalSessionLabel *> *vec_ptr = nullptr;
|
||||
auto session_label_iterator = g_xr_session_labels.find(session);
|
||||
if (session_label_iterator == g_xr_session_labels.end()) {
|
||||
return;
|
||||
}
|
||||
vec_ptr = session_label_iterator->second;
|
||||
while (!vec_ptr->empty()) {
|
||||
delete vec_ptr->back();
|
||||
vec_ptr->pop_back();
|
||||
}
|
||||
delete vec_ptr;
|
||||
g_xr_session_labels.erase(session);
|
||||
}
|
||||
|
||||
XrResult CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session, const XrDebugUtilsLabelEXT *labelInfo) {
|
||||
XrResult test_result = GenValidUsageInputsXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo);
|
||||
if (XR_SUCCESS != test_result) {
|
||||
return test_result;
|
||||
}
|
||||
CoreValidationBeginLabelRegion(session, labelInfo);
|
||||
return GenValidUsageNextXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo);
|
||||
}
|
||||
|
||||
XrResult CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(XrSession session) {
|
||||
XrResult test_result = GenValidUsageInputsXrSessionEndDebugUtilsLabelRegionEXT(session);
|
||||
if (XR_SUCCESS != test_result) {
|
||||
return test_result;
|
||||
}
|
||||
CoreValidationEndLabelRegion(session);
|
||||
return GenValidUsageNextXrSessionEndDebugUtilsLabelRegionEXT(session);
|
||||
}
|
||||
|
||||
XrResult CoreValidationXrSessionInsertDebugUtilsLabelEXT(XrSession session, const XrDebugUtilsLabelEXT *labelInfo) {
|
||||
XrResult test_result = GenValidUsageInputsXrSessionInsertDebugUtilsLabelEXT(session, labelInfo);
|
||||
if (XR_SUCCESS != test_result) {
|
||||
return test_result;
|
||||
}
|
||||
CoreValidationInsertLabel(session, labelInfo);
|
||||
return GenValidUsageNextXrSessionInsertDebugUtilsLabelEXT(session, labelInfo);
|
||||
}
|
||||
|
||||
// ############################################################
|
||||
// NOTE: Add new validation checking above this comment block
|
||||
// ############################################################
|
||||
|
||||
extern "C" {
|
||||
|
||||
// Function used to negotiate an interface betewen the loader and an API layer. Each library exposing one or
|
||||
// more API layers needs to expose at least this function.
|
||||
LAYER_EXPORT XrResult xrNegotiateLoaderApiLayerInterface(const XrNegotiateLoaderInfo *loaderInfo, const char * /*apiLayerName*/,
|
||||
XrNegotiateApiLayerRequest *apiLayerRequest) {
|
||||
if (nullptr == loaderInfo || nullptr == apiLayerRequest || loaderInfo->structType != XR_LOADER_INTERFACE_STRUCT_LOADER_INFO ||
|
||||
loaderInfo->structVersion != XR_LOADER_INFO_STRUCT_VERSION || loaderInfo->structSize != sizeof(XrNegotiateLoaderInfo) ||
|
||||
apiLayerRequest->structType != XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST ||
|
||||
apiLayerRequest->structVersion != XR_API_LAYER_INFO_STRUCT_VERSION ||
|
||||
apiLayerRequest->structSize != sizeof(XrNegotiateApiLayerRequest) ||
|
||||
loaderInfo->minInterfaceVersion > XR_CURRENT_LOADER_API_LAYER_VERSION ||
|
||||
loaderInfo->maxInterfaceVersion < XR_CURRENT_LOADER_API_LAYER_VERSION ||
|
||||
loaderInfo->maxInterfaceVersion > XR_CURRENT_LOADER_API_LAYER_VERSION ||
|
||||
loaderInfo->maxApiVersion < XR_CORE_VALIDATION_API_VERSION || loaderInfo->minApiVersion > XR_CORE_VALIDATION_API_VERSION) {
|
||||
return XR_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
apiLayerRequest->layerInterfaceVersion = XR_CURRENT_LOADER_API_LAYER_VERSION;
|
||||
apiLayerRequest->layerApiVersion = XR_CORE_VALIDATION_API_VERSION;
|
||||
apiLayerRequest->getInstanceProcAddr = reinterpret_cast<PFN_xrGetInstanceProcAddr>(GenValidUsageXrGetInstanceProcAddr);
|
||||
apiLayerRequest->createApiLayerInstance =
|
||||
reinterpret_cast<PFN_xrCreateApiLayerInstance>(CoreValidationXrCreateApiLayerInstance);
|
||||
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
} // extern "C"
|
324
extern/openxr/src/api_layers/validation_utils.h
vendored
Normal file
324
extern/openxr/src/api_layers/validation_utils.h
vendored
Normal file
@@ -0,0 +1,324 @@
|
||||
// Copyright (c) 2018-2019 The Khronos Group Inc.
|
||||
// Copyright (c) 2018-2019 Valve Corporation
|
||||
// Copyright (c) 2018-2019 LunarG, Inc.
|
||||
// Copyright (c) 2019, Collabora, Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
// Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#ifndef VALIDATION_UTILS_H_
|
||||
#define VALIDATION_UTILS_H_ 1
|
||||
|
||||
#include "api_layer_platform_defines.h"
|
||||
#include "hex_and_handles.h"
|
||||
#include "extra_algorithms.h"
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
/// Prints a message to stderr then throws an exception.
|
||||
///
|
||||
/// The printing of the message is because the exception will probably be caught and silently turned into a validation error.
|
||||
[[noreturn]] void reportInternalError(std::string const &message);
|
||||
|
||||
// Structure used for storing the instance information we need for validating
|
||||
// various aspects of the OpenXR API.
|
||||
|
||||
// Debug Utils items
|
||||
struct CoreValidationMessengerInfo {
|
||||
XrDebugUtilsMessengerEXT messenger;
|
||||
XrDebugUtilsMessengerCreateInfoEXT *create_info;
|
||||
};
|
||||
|
||||
struct XrGeneratedDispatchTable;
|
||||
|
||||
struct CoreValidationMessengerInfoDeleter {
|
||||
void operator()(CoreValidationMessengerInfo *ptr) const {
|
||||
delete ptr->create_info;
|
||||
delete ptr;
|
||||
}
|
||||
};
|
||||
|
||||
struct XrDebugUtilsObjectNameInfoEXTDeleter {
|
||||
void operator()(XrDebugUtilsObjectNameInfoEXT *ptr) const {
|
||||
delete ptr->objectName;
|
||||
delete ptr;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::unique_ptr<XrDebugUtilsObjectNameInfoEXT, XrDebugUtilsObjectNameInfoEXTDeleter> UniqueXrDebugUtilsObjectNameInfoEXT;
|
||||
|
||||
typedef std::unique_ptr<CoreValidationMessengerInfo, CoreValidationMessengerInfoDeleter> UniqueCoreValidationMessengerInfo;
|
||||
|
||||
// Define the instance struct used for passing information around.
|
||||
// This information includes things like the dispatch table as well as the
|
||||
// enabled extensions.
|
||||
struct GenValidUsageXrInstanceInfo {
|
||||
GenValidUsageXrInstanceInfo(XrInstance inst, PFN_xrGetInstanceProcAddr next_get_instance_proc_addr);
|
||||
~GenValidUsageXrInstanceInfo();
|
||||
const XrInstance instance;
|
||||
XrGeneratedDispatchTable *dispatch_table;
|
||||
std::vector<std::string> enabled_extensions;
|
||||
std::vector<UniqueCoreValidationMessengerInfo> debug_messengers;
|
||||
std::vector<UniqueXrDebugUtilsObjectNameInfoEXT> object_names;
|
||||
};
|
||||
|
||||
// Structure used for storing information for other handles
|
||||
struct GenValidUsageXrHandleInfo {
|
||||
GenValidUsageXrInstanceInfo *instance_info;
|
||||
XrObjectType direct_parent_type;
|
||||
uint64_t direct_parent_handle;
|
||||
};
|
||||
|
||||
// Structure used for storing session label information
|
||||
struct GenValidUsageXrInternalSessionLabel {
|
||||
XrDebugUtilsLabelEXT debug_utils_label;
|
||||
std::string label_name;
|
||||
bool is_individual_label;
|
||||
};
|
||||
|
||||
// Enum used for indicating handle validation status.
|
||||
enum ValidateXrHandleResult {
|
||||
VALIDATE_XR_HANDLE_NULL,
|
||||
VALIDATE_XR_HANDLE_INVALID,
|
||||
VALIDATE_XR_HANDLE_SUCCESS,
|
||||
};
|
||||
|
||||
// Unordered Map associating pointer to a vector of session label information to a session's handle
|
||||
extern std::unordered_map<XrSession, std::vector<GenValidUsageXrInternalSessionLabel *> *> g_xr_session_labels;
|
||||
|
||||
// This function is used to delete session labels when a session is destroyed
|
||||
extern void CoreValidationDeleteSessionLabels(XrSession session);
|
||||
|
||||
// Object information used for logging.
|
||||
struct GenValidUsageXrObjectInfo {
|
||||
uint64_t handle;
|
||||
XrObjectType type;
|
||||
GenValidUsageXrObjectInfo() = default;
|
||||
template <typename T>
|
||||
GenValidUsageXrObjectInfo(T h, XrObjectType t) : handle(MakeHandleGeneric(h)), type(t) {}
|
||||
};
|
||||
|
||||
// Debug message severity levels for logging.
|
||||
enum GenValidUsageDebugSeverity {
|
||||
VALID_USAGE_DEBUG_SEVERITY_DEBUG = 0,
|
||||
VALID_USAGE_DEBUG_SEVERITY_INFO = 7,
|
||||
VALID_USAGE_DEBUG_SEVERITY_WARNING = 14,
|
||||
VALID_USAGE_DEBUG_SEVERITY_ERROR = 21,
|
||||
};
|
||||
|
||||
// in core_validation.cpp
|
||||
void EraseAllInstanceTableMapElements(GenValidUsageXrInstanceInfo *search_value);
|
||||
|
||||
typedef std::unique_lock<std::mutex> UniqueLock;
|
||||
template <typename HandleType, typename InfoType>
|
||||
class HandleInfoBase {
|
||||
public:
|
||||
typedef InfoType info_t;
|
||||
typedef HandleType handle_t;
|
||||
typedef std::unordered_map<HandleType, std::unique_ptr<InfoType>> map_t;
|
||||
typedef typename map_t::value_type value_t;
|
||||
|
||||
/// Validate a handle.
|
||||
///
|
||||
/// Returns an enum indicating null, invalid (not found), or success.
|
||||
ValidateXrHandleResult verifyHandle(HandleType const *handle_to_check);
|
||||
|
||||
/// Lookup a handle.
|
||||
/// Throws if not found.
|
||||
InfoType *get(HandleType handle);
|
||||
|
||||
/// Lookup a handle, returning a pointer (if found) as well as a lock for this object's dispatch mutex.
|
||||
std::pair<UniqueLock, InfoType *> getWithLock(HandleType handle);
|
||||
|
||||
bool empty() const { return info_map_.empty(); }
|
||||
|
||||
/// Insert an info for the supplied handle.
|
||||
/// Throws if it's already there.
|
||||
void insert(HandleType handle, std::unique_ptr<InfoType> &&info);
|
||||
|
||||
/// Remove the info associated with the supplied handle.
|
||||
/// Throws if not found.
|
||||
void erase(HandleType handle);
|
||||
|
||||
/// Get a constant reference to the whole map as well as a lock for this object's dispatch mutex.
|
||||
std::pair<UniqueLock, map_t const &> lockMapConst();
|
||||
|
||||
/// Get a reference to the whole map as well as a lock for this object's dispatch mutex.
|
||||
std::pair<UniqueLock, map_t &> lockMap();
|
||||
|
||||
protected:
|
||||
map_t info_map_;
|
||||
std::mutex dispatch_mutex_;
|
||||
};
|
||||
|
||||
/// Subclass used exclusively for instances.
|
||||
class InstanceHandleInfo : public HandleInfoBase<XrInstance, GenValidUsageXrInstanceInfo> {
|
||||
public:
|
||||
typedef HandleInfoBase<XrInstance, GenValidUsageXrInstanceInfo> base_t;
|
||||
typedef typename base_t::info_t info_t;
|
||||
typedef typename base_t::handle_t handle_t;
|
||||
};
|
||||
|
||||
/// Generic handle info for everything-except-instance handles.
|
||||
template <typename HandleType>
|
||||
class HandleInfo : public HandleInfoBase<HandleType, GenValidUsageXrHandleInfo> {
|
||||
public:
|
||||
typedef HandleInfoBase<HandleType, GenValidUsageXrHandleInfo> base_t;
|
||||
typedef typename base_t::info_t info_t;
|
||||
typedef typename base_t::handle_t handle_t;
|
||||
|
||||
/// Lookup a handle and its instance info
|
||||
/// Throws if not found.
|
||||
std::pair<GenValidUsageXrHandleInfo *, GenValidUsageXrInstanceInfo *> getWithInstanceInfo(HandleType handle);
|
||||
|
||||
/// Removes handles associated with an instance.
|
||||
void removeHandlesForInstance(GenValidUsageXrInstanceInfo *search_value);
|
||||
};
|
||||
|
||||
/// Function to record all the core validation information
|
||||
void CoreValidLogMessage(GenValidUsageXrInstanceInfo *instance_info, const std::string &message_id,
|
||||
GenValidUsageDebugSeverity message_severity, const std::string &command_name,
|
||||
std::vector<GenValidUsageXrObjectInfo> objects_info, const std::string &message);
|
||||
|
||||
void InvalidStructureType(GenValidUsageXrInstanceInfo *instance_info, const std::string &command_name,
|
||||
std::vector<GenValidUsageXrObjectInfo> &objects_info, const char *structure_name, XrStructureType type,
|
||||
const char *vuid = nullptr, XrStructureType expected = XrStructureType(0),
|
||||
const char *expected_name = "");
|
||||
|
||||
// -- Only implementations of templates follow --//
|
||||
|
||||
template <typename HT, typename IT>
|
||||
inline std::pair<UniqueLock, typename HandleInfoBase<HT, IT>::map_t const &> HandleInfoBase<HT, IT>::lockMapConst() {
|
||||
return {UniqueLock(dispatch_mutex_), info_map_};
|
||||
}
|
||||
|
||||
template <typename HT, typename IT>
|
||||
inline std::pair<UniqueLock, typename HandleInfoBase<HT, IT>::map_t &> HandleInfoBase<HT, IT>::lockMap() {
|
||||
return {UniqueLock(dispatch_mutex_), info_map_};
|
||||
}
|
||||
|
||||
template <typename HandleType, typename InfoType>
|
||||
inline ValidateXrHandleResult HandleInfoBase<HandleType, InfoType>::verifyHandle(HandleType const *handle_to_check) {
|
||||
try {
|
||||
if (nullptr == handle_to_check) {
|
||||
return VALIDATE_XR_HANDLE_INVALID;
|
||||
}
|
||||
// XR_NULL_HANDLE is valid in some cases, so we want to return that we found that value
|
||||
// and let the calling function decide what to do with it.
|
||||
if (*handle_to_check == XR_NULL_HANDLE) {
|
||||
return VALIDATE_XR_HANDLE_NULL;
|
||||
}
|
||||
|
||||
// Try to find the handle in the appropriate map
|
||||
UniqueLock lock(dispatch_mutex_);
|
||||
auto entry_returned = info_map_.find(*handle_to_check);
|
||||
// If it is not a valid handle, it should return the end of the map.
|
||||
if (info_map_.end() == entry_returned) {
|
||||
return VALIDATE_XR_HANDLE_INVALID;
|
||||
}
|
||||
return VALIDATE_XR_HANDLE_SUCCESS;
|
||||
} catch (...) {
|
||||
return VALIDATE_XR_HANDLE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename HandleType, typename InfoType>
|
||||
inline InfoType *HandleInfoBase<HandleType, InfoType>::get(HandleType handle) {
|
||||
if (handle == XR_NULL_HANDLE) {
|
||||
reportInternalError("Null handle passed to HandleInfoBase::get()");
|
||||
}
|
||||
// Try to find the handle in the appropriate map
|
||||
UniqueLock lock(dispatch_mutex_);
|
||||
auto entry_returned = info_map_.find(handle);
|
||||
if (entry_returned == info_map_.end()) {
|
||||
reportInternalError("Handle passed to HandleInfoBase::insert() not inserted");
|
||||
}
|
||||
return entry_returned->second.get();
|
||||
}
|
||||
|
||||
template <typename HandleType, typename InfoType>
|
||||
inline std::pair<UniqueLock, InfoType *> HandleInfoBase<HandleType, InfoType>::getWithLock(HandleType handle) {
|
||||
if (handle == XR_NULL_HANDLE) {
|
||||
reportInternalError("Null handle passed to HandleInfoBase::getWithLock()");
|
||||
}
|
||||
// Try to find the handle in the appropriate map
|
||||
UniqueLock lock(dispatch_mutex_);
|
||||
auto it = info_map_.find(handle);
|
||||
// If it is not a valid handle, it should return the end of the map.
|
||||
if (info_map_.end() == it) {
|
||||
return {std::move(lock), nullptr};
|
||||
}
|
||||
return {std::move(lock), it->second.get()};
|
||||
}
|
||||
|
||||
template <typename HandleType, typename InfoType>
|
||||
inline void HandleInfoBase<HandleType, InfoType>::insert(HandleType handle, std::unique_ptr<InfoType> &&info) {
|
||||
if (handle == XR_NULL_HANDLE) {
|
||||
reportInternalError("Null handle passed to HandleInfoBase::insert()");
|
||||
}
|
||||
UniqueLock lock(dispatch_mutex_);
|
||||
auto entry_returned = info_map_.find(handle);
|
||||
if (entry_returned != info_map_.end()) {
|
||||
reportInternalError("Handle passed to HandleInfoBase::insert() already inserted");
|
||||
}
|
||||
info_map_[handle] = std::move(info);
|
||||
}
|
||||
|
||||
template <typename HandleType, typename InfoType>
|
||||
inline void HandleInfoBase<HandleType, InfoType>::erase(HandleType handle) {
|
||||
if (handle == XR_NULL_HANDLE) {
|
||||
reportInternalError("Null handle passed to HandleInfoBase::erase()");
|
||||
}
|
||||
UniqueLock lock(dispatch_mutex_);
|
||||
auto entry_returned = info_map_.find(handle);
|
||||
if (entry_returned == info_map_.end()) {
|
||||
reportInternalError("Handle passed to HandleInfoBase::insert() not inserted");
|
||||
}
|
||||
info_map_.erase(handle);
|
||||
}
|
||||
|
||||
template <typename HandleType>
|
||||
inline std::pair<GenValidUsageXrHandleInfo *, GenValidUsageXrInstanceInfo *> HandleInfo<HandleType>::getWithInstanceInfo(
|
||||
HandleType handle) {
|
||||
if (handle == XR_NULL_HANDLE) {
|
||||
reportInternalError("Null handle passed to HandleInfoBase::getWithInstanceInfo()");
|
||||
}
|
||||
// Try to find the handle in the appropriate map
|
||||
UniqueLock lock(this->dispatch_mutex_);
|
||||
auto entry_returned = this->info_map_.find(handle);
|
||||
if (entry_returned == this->info_map_.end()) {
|
||||
reportInternalError("Handle passed to HandleInfoBase::getWithInstanceInfo() not inserted");
|
||||
}
|
||||
GenValidUsageXrHandleInfo *info = entry_returned->second.get();
|
||||
GenValidUsageXrInstanceInfo *instance_info = info->instance_info;
|
||||
return {info, instance_info};
|
||||
}
|
||||
|
||||
template <typename HandleType>
|
||||
inline void HandleInfo<HandleType>::removeHandlesForInstance(GenValidUsageXrInstanceInfo *search_value) {
|
||||
typedef typename base_t::value_t value_t;
|
||||
UniqueLock lock(this->dispatch_mutex_);
|
||||
map_erase_if(this->info_map_, [=](value_t const &data) { return data.second && data.second->instance_info == search_value; });
|
||||
}
|
||||
|
||||
#endif // VALIDATION_UTILS_H_
|
15407
extern/openxr/src/api_layers/xr_generated_core_validation.cpp
vendored
Normal file
15407
extern/openxr/src/api_layers/xr_generated_core_validation.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
156
extern/openxr/src/api_layers/xr_generated_core_validation.hpp
vendored
Normal file
156
extern/openxr/src/api_layers/xr_generated_core_validation.hpp
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
// *********** THIS FILE IS GENERATED - DO NOT EDIT ***********
|
||||
// See validation_layer_generator.py for modifications
|
||||
// ************************************************************
|
||||
|
||||
// Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2019 Valve Corporation
|
||||
// Copyright (c) 2017-2019 LunarG, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "xr_generated_dispatch_table.h"
|
||||
#include "validation_utils.h"
|
||||
#include "api_layer_platform_defines.h"
|
||||
#include "xr_dependencies.h"
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
// Unordered Map associating pointer to a vector of session label information to a session's handle
|
||||
extern std::unordered_map<XrSession, std::vector<GenValidUsageXrInternalSessionLabel*>*> g_xr_session_labels;
|
||||
|
||||
|
||||
// ---- Core 1.0 commands
|
||||
XrResult GenValidUsageXrGetInstanceProcAddr(
|
||||
XrInstance instance,
|
||||
const char* name,
|
||||
PFN_xrVoidFunction* function);
|
||||
XrResult CoreValidationXrCreateInstance(
|
||||
const XrInstanceCreateInfo* createInfo,
|
||||
XrInstance* instance);
|
||||
XrResult GenValidUsageInputsXrCreateInstance(const XrInstanceCreateInfo* createInfo, XrInstance* instance);
|
||||
XrResult GenValidUsageNextXrCreateInstance(
|
||||
const XrInstanceCreateInfo* createInfo,
|
||||
XrInstance* instance);
|
||||
XrResult CoreValidationXrDestroyInstance(
|
||||
XrInstance instance);
|
||||
XrResult GenValidUsageInputsXrDestroyInstance(XrInstance instance);
|
||||
XrResult GenValidUsageNextXrDestroyInstance(
|
||||
XrInstance instance);
|
||||
XrResult CoreValidationXrCreateSession(
|
||||
XrInstance instance,
|
||||
const XrSessionCreateInfo* createInfo,
|
||||
XrSession* session);
|
||||
XrResult GenValidUsageInputsXrCreateSession(XrInstance instance, const XrSessionCreateInfo* createInfo, XrSession* session);
|
||||
XrResult GenValidUsageNextXrCreateSession(
|
||||
XrInstance instance,
|
||||
const XrSessionCreateInfo* createInfo,
|
||||
XrSession* session);
|
||||
|
||||
// ---- XR_KHR_android_thread_settings extension commands
|
||||
|
||||
// ---- XR_KHR_android_surface_swapchain extension commands
|
||||
|
||||
// ---- XR_KHR_opengl_enable extension commands
|
||||
|
||||
// ---- XR_KHR_opengl_es_enable extension commands
|
||||
|
||||
// ---- XR_KHR_vulkan_enable extension commands
|
||||
|
||||
// ---- XR_KHR_D3D11_enable extension commands
|
||||
|
||||
// ---- XR_KHR_D3D12_enable extension commands
|
||||
|
||||
// ---- XR_KHR_visibility_mask extension commands
|
||||
|
||||
// ---- XR_KHR_win32_convert_performance_counter_time extension commands
|
||||
|
||||
// ---- XR_KHR_convert_timespec_time extension commands
|
||||
|
||||
// ---- XR_EXT_performance_settings extension commands
|
||||
|
||||
// ---- XR_EXT_thermal_query extension commands
|
||||
|
||||
// ---- XR_EXT_debug_utils extension commands
|
||||
XrResult CoreValidationXrSetDebugUtilsObjectNameEXT(
|
||||
XrInstance instance,
|
||||
const XrDebugUtilsObjectNameInfoEXT* nameInfo);
|
||||
XrResult GenValidUsageInputsXrSetDebugUtilsObjectNameEXT(XrInstance instance, const XrDebugUtilsObjectNameInfoEXT* nameInfo);
|
||||
XrResult GenValidUsageNextXrSetDebugUtilsObjectNameEXT(
|
||||
XrInstance instance,
|
||||
const XrDebugUtilsObjectNameInfoEXT* nameInfo);
|
||||
XrResult CoreValidationXrCreateDebugUtilsMessengerEXT(
|
||||
XrInstance instance,
|
||||
const XrDebugUtilsMessengerCreateInfoEXT* createInfo,
|
||||
XrDebugUtilsMessengerEXT* messenger);
|
||||
XrResult GenValidUsageInputsXrCreateDebugUtilsMessengerEXT(XrInstance instance, const XrDebugUtilsMessengerCreateInfoEXT* createInfo, XrDebugUtilsMessengerEXT* messenger);
|
||||
XrResult GenValidUsageNextXrCreateDebugUtilsMessengerEXT(
|
||||
XrInstance instance,
|
||||
const XrDebugUtilsMessengerCreateInfoEXT* createInfo,
|
||||
XrDebugUtilsMessengerEXT* messenger);
|
||||
XrResult CoreValidationXrDestroyDebugUtilsMessengerEXT(
|
||||
XrDebugUtilsMessengerEXT messenger);
|
||||
XrResult GenValidUsageInputsXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT messenger);
|
||||
XrResult GenValidUsageNextXrDestroyDebugUtilsMessengerEXT(
|
||||
XrDebugUtilsMessengerEXT messenger);
|
||||
XrResult CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(
|
||||
XrSession session,
|
||||
const XrDebugUtilsLabelEXT* labelInfo);
|
||||
XrResult GenValidUsageInputsXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session, const XrDebugUtilsLabelEXT* labelInfo);
|
||||
XrResult GenValidUsageNextXrSessionBeginDebugUtilsLabelRegionEXT(
|
||||
XrSession session,
|
||||
const XrDebugUtilsLabelEXT* labelInfo);
|
||||
XrResult CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(
|
||||
XrSession session);
|
||||
XrResult GenValidUsageInputsXrSessionEndDebugUtilsLabelRegionEXT(XrSession session);
|
||||
XrResult GenValidUsageNextXrSessionEndDebugUtilsLabelRegionEXT(
|
||||
XrSession session);
|
||||
XrResult CoreValidationXrSessionInsertDebugUtilsLabelEXT(
|
||||
XrSession session,
|
||||
const XrDebugUtilsLabelEXT* labelInfo);
|
||||
XrResult GenValidUsageInputsXrSessionInsertDebugUtilsLabelEXT(XrSession session, const XrDebugUtilsLabelEXT* labelInfo);
|
||||
XrResult GenValidUsageNextXrSessionInsertDebugUtilsLabelEXT(
|
||||
XrSession session,
|
||||
const XrDebugUtilsLabelEXT* labelInfo);
|
||||
|
||||
// Current API version of the Core Validation API Layer
|
||||
#define XR_CORE_VALIDATION_API_VERSION XR_CURRENT_API_VERSION
|
||||
|
||||
// Externs for Core Validation
|
||||
extern InstanceHandleInfo g_instance_info;
|
||||
extern HandleInfo<XrSession> g_session_info;
|
||||
extern HandleInfo<XrSpace> g_space_info;
|
||||
extern HandleInfo<XrAction> g_action_info;
|
||||
extern HandleInfo<XrSwapchain> g_swapchain_info;
|
||||
extern HandleInfo<XrActionSet> g_actionset_info;
|
||||
extern HandleInfo<XrDebugUtilsMessengerEXT> g_debugutilsmessengerext_info;void GenValidUsageCleanUpMaps(GenValidUsageXrInstanceInfo *instance_info);
|
||||
|
||||
|
||||
// Function to convert XrObjectType to string
|
||||
std::string GenValidUsageXrObjectTypeToString(const XrObjectType& type);
|
||||
|
||||
// Function to record all the core validation information
|
||||
extern void CoreValidLogMessage(GenValidUsageXrInstanceInfo *instance_info, const std::string &message_id,
|
||||
GenValidUsageDebugSeverity message_severity, const std::string &command_name,
|
||||
std::vector<GenValidUsageXrObjectInfo> objects_info, const std::string &message);
|
||||
|
86
extern/openxr/src/cmake/FindVulkanHeaders.cmake
vendored
Normal file
86
extern/openxr/src/cmake/FindVulkanHeaders.cmake
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
# ~~~
|
||||
# Copyright (c) 2018-2019 Valve Corporation
|
||||
# Copyright (c) 2018-2019 LunarG, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ~~~
|
||||
|
||||
#.rst:
|
||||
# FindVulkanHeaders
|
||||
# -----------------
|
||||
#
|
||||
# Try to find Vulkan Headers and Registry.
|
||||
#
|
||||
# This module is intended to be used by projects that build Vulkan
|
||||
# "system" components such as the loader and layers.
|
||||
# Vulkan applications should instead use the FindVulkan (or similar)
|
||||
# find module that locates the headers and the loader library.
|
||||
#
|
||||
# When using this find module to locate the headers and registry
|
||||
# in a Vulkan-Headers repository, the Vulkan-Headers repository
|
||||
# should be built with 'install' target and the following environment
|
||||
# or CMake variable set to the location of the install directory.
|
||||
#
|
||||
# VULKAN_HEADERS_INSTALL_DIR
|
||||
#
|
||||
# IMPORTED Targets
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines no IMPORTED targets
|
||||
#
|
||||
# Result Variables
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines the following variables::
|
||||
#
|
||||
# VulkanHeaders_FOUND - True if VulkanHeaders was found
|
||||
# VulkanHeaders_INCLUDE_DIRS - include directories for VulkanHeaders
|
||||
#
|
||||
# VulkanRegistry_FOUND - True if VulkanRegistry was found
|
||||
# VulkanRegistry_DIRS - directories for VulkanRegistry
|
||||
#
|
||||
# The module will also define two cache variables::
|
||||
#
|
||||
# VulkanHeaders_INCLUDE_DIR - the VulkanHeaders include directory
|
||||
# VulkanRegistry_DIR - the VulkanRegistry directory
|
||||
#
|
||||
|
||||
# Use HINTS instead of PATH to search these locations before
|
||||
# searching system environment variables like $PATH that may
|
||||
# contain SDK directories.
|
||||
find_path(VulkanHeaders_INCLUDE_DIR
|
||||
NAMES vulkan/vulkan.h
|
||||
HINTS
|
||||
${VULKAN_HEADERS_INSTALL_DIR}/include
|
||||
"$ENV{VULKAN_HEADERS_INSTALL_DIR}/include"
|
||||
"$ENV{VULKAN_SDK}/include")
|
||||
|
||||
if(VulkanHeaders_INCLUDE_DIR)
|
||||
get_filename_component(VULKAN_REGISTRY_PATH_HINT ${VulkanHeaders_INCLUDE_DIR} DIRECTORY)
|
||||
find_path(VulkanRegistry_DIR
|
||||
NAMES vk.xml
|
||||
HINTS "${VULKAN_REGISTRY_PATH_HINT}/share/vulkan/registry")
|
||||
endif()
|
||||
|
||||
set(VulkanHeaders_INCLUDE_DIRS ${VulkanHeaders_INCLUDE_DIR})
|
||||
set(VulkanRegistry_DIRS ${VulkanRegistry_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(VulkanHeaders
|
||||
DEFAULT_MSG
|
||||
VulkanHeaders_INCLUDE_DIR)
|
||||
find_package_handle_standard_args(VulkanRegistry
|
||||
DEFAULT_MSG
|
||||
VulkanRegistry_DIR)
|
||||
|
||||
mark_as_advanced(VulkanHeaders_INCLUDE_DIR VulkanRegistry_DIR)
|
21
extern/openxr/src/cmake/cmake_uninstall.cmake.in
vendored
Normal file
21
extern/openxr/src/cmake/cmake_uninstall.cmake.in
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
exec_program(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
if(NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
101
extern/openxr/src/cmake/presentation.cmake
vendored
Normal file
101
extern/openxr/src/cmake/presentation.cmake
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
set(PRESENTATION_BACKENDS xlib xcb wayland)
|
||||
set(PRESENTATION_BACKEND xlib CACHE STRING
|
||||
"Presentation backend chosen at configure time")
|
||||
set_property(CACHE PRESENTATION_BACKEND PROPERTY STRINGS
|
||||
${PRESENTATION_BACKENDS})
|
||||
|
||||
list(FIND PRESENTATION_BACKENDS ${PRESENTATION_BACKEND} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR "Presentation backend must be one of
|
||||
${PRESENTATION_BACKENDS}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Using presentation backend: ${PRESENTATION_BACKEND}")
|
||||
|
||||
|
||||
if( PRESENTATION_BACKEND MATCHES "xlib" )
|
||||
find_package(X11 REQUIRED)
|
||||
if ((NOT X11_Xxf86vm_LIB) OR (NOT X11_Xrandr_LIB))
|
||||
message(FATAL_ERROR "OpenXR xlib backend requires Xxf86vm and Xrandr")
|
||||
endif()
|
||||
|
||||
add_definitions( -DSUPPORT_X )
|
||||
add_definitions( -DOS_LINUX_XLIB )
|
||||
set( XLIB_LIBRARIES
|
||||
${X11_LIBRARIES}
|
||||
${X11_Xxf86vm_LIB}
|
||||
${X11_Xrandr_LIB} )
|
||||
|
||||
elseif( PRESENTATION_BACKEND MATCHES "xcb" )
|
||||
find_package(PkgConfig REQUIRED)
|
||||
# XCB + XCB GLX is limited to OpenGL 2.1
|
||||
# add_definitions( -DOS_LINUX_XCB )
|
||||
# XCB + Xlib GLX 1.3
|
||||
add_definitions( -DOS_LINUX_XCB_GLX )
|
||||
|
||||
pkg_search_module(X11 REQUIRED x11)
|
||||
pkg_search_module(XCB REQUIRED xcb)
|
||||
pkg_search_module(XCB_RANDR REQUIRED xcb-randr)
|
||||
pkg_search_module(XCB_KEYSYMS REQUIRED xcb-keysyms)
|
||||
pkg_search_module(XCB_GLX REQUIRED xcb-glx)
|
||||
pkg_search_module(XCB_DRI2 REQUIRED xcb-dri2)
|
||||
pkg_search_module(XCB_ICCCM REQUIRED xcb-icccm)
|
||||
|
||||
set( XCB_LIBRARIES
|
||||
${XCB_LIBRARIES}
|
||||
${XCB_KEYSYMS_LIBRARIES}
|
||||
${XCB_RANDR_LIBRARIES}
|
||||
${XCB_GLX_LIBRARIES}
|
||||
${XCB_DRI2_LIBRARIES}
|
||||
${X11_LIBRARIES} )
|
||||
|
||||
elseif( PRESENTATION_BACKEND MATCHES "wayland" )
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(WAYLAND_CLIENT REQUIRED wayland-client)
|
||||
pkg_search_module(WAYLAND_EGL REQUIRED wayland-egl)
|
||||
pkg_search_module(WAYLAND_SCANNER REQUIRED wayland-scanner)
|
||||
pkg_search_module(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.7)
|
||||
pkg_search_module(EGL REQUIRED egl)
|
||||
|
||||
add_definitions( -DOS_LINUX_WAYLAND )
|
||||
set( WAYLAND_LIBRARIES
|
||||
${EGL_LIBRARIES}
|
||||
${WAYLAND_CLIENT_LIBRARIES}
|
||||
${WAYLAND_EGL_LIBRARIES} )
|
||||
|
||||
# generate wayland protocols
|
||||
set(WAYLAND_PROTOCOLS_DIR ${CMAKE_SOURCE_DIR}/wayland-protocols/)
|
||||
file(MAKE_DIRECTORY ${WAYLAND_PROTOCOLS_DIR})
|
||||
|
||||
pkg_get_variable(WAYLAND_PROTOCOLS_DATADIR wayland-protocols pkgdatadir)
|
||||
pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
|
||||
|
||||
set(PROTOCOL xdg-shell-unstable-v6)
|
||||
set(PROTOCOL_XML
|
||||
${WAYLAND_PROTOCOLS_DATADIR}/unstable/xdg-shell/${PROTOCOL}.xml)
|
||||
|
||||
if( EXISTS ${PROTOCOL_XML} )
|
||||
execute_process(COMMAND
|
||||
${WAYLAND_SCANNER}
|
||||
code
|
||||
${PROTOCOL_XML}
|
||||
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.c)
|
||||
execute_process(COMMAND
|
||||
${WAYLAND_SCANNER}
|
||||
client-header
|
||||
${PROTOCOL_XML}
|
||||
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.h)
|
||||
|
||||
set( WAYLAND_PROTOCOL_SRC
|
||||
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.c
|
||||
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.h )
|
||||
|
||||
include_directories(${WAYLAND_PROTOCOLS_DIR})
|
||||
else()
|
||||
message(FATAL_ERROR
|
||||
"xdg-shell-unstable-v6.xml not found in "
|
||||
${WAYLAND_PROTOCOLS_DATADIR}
|
||||
"\nYour wayland-protocols package does not "
|
||||
"contain xdg-shell-unstable-v6.")
|
||||
endif()
|
||||
endif()
|
57
extern/openxr/src/common/extra_algorithms.h
vendored
Normal file
57
extern/openxr/src/common/extra_algorithms.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2019 Valve Corporation
|
||||
// Copyright (c) 2017-2019 LunarG, Inc.
|
||||
// Copyright (c) 2019 Collabora, Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
//
|
||||
|
||||
/*!
|
||||
* @file
|
||||
*
|
||||
* Additional functions along the lines of the standard library algorithms.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
/// Like std::remove_if, except it works on associative containers and it actually removes this.
|
||||
///
|
||||
/// The iterator stuff in here is subtle - .erase() invalidates only that iterator, but it returns a non-invalidated iterator to the
|
||||
/// next valid element which we can use instead of incrementing.
|
||||
template <typename T, typename Pred>
|
||||
static inline void map_erase_if(T &container, Pred &&predicate) {
|
||||
for (auto it = container.begin(); it != container.end();) {
|
||||
if (predicate(*it)) {
|
||||
it = container.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Moves all elements matching the predicate to the end of the vector then erases them.
|
||||
*
|
||||
* Combines the two parts of the erase-remove idiom to simplify things and avoid accidentally using the wrong erase overload.
|
||||
*/
|
||||
template <typename T, typename Alloc, typename Pred>
|
||||
static inline void vector_remove_if_and_erase(std::vector<T, Alloc> &vec, Pred &&predicate) {
|
||||
auto b = vec.begin();
|
||||
auto e = vec.end();
|
||||
vec.erase(std::remove_if(b, e, std::forward<Pred>(predicate)), e);
|
||||
}
|
330
extern/openxr/src/common/filesystem_utils.cpp
vendored
Normal file
330
extern/openxr/src/common/filesystem_utils.cpp
vendored
Normal file
@@ -0,0 +1,330 @@
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
// Copyright (c) 2017 Valve Corporation
|
||||
// Copyright (c) 2017 LunarG, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Authors: Mark Young <marky@lunarg.com>
|
||||
// Nat Brown <natb@valvesoftware.com>
|
||||
//
|
||||
|
||||
#include "filesystem_utils.hpp"
|
||||
|
||||
#include "platform_utils.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "xr_dependencies.h"
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#if defined DISABLE_STD_FILESYSTEM
|
||||
#define USE_EXPERIMENTAL_FS 0
|
||||
#define USE_FINAL_FS 0
|
||||
|
||||
#else
|
||||
// If the C++ macro is set to the version containing C++17, it must support
|
||||
// the final C++17 package
|
||||
#if __cplusplus >= 201703L
|
||||
#define USE_EXPERIMENTAL_FS 0
|
||||
#define USE_FINAL_FS 1
|
||||
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1900
|
||||
|
||||
#if defined(_HAS_CXX17) && _HAS_CXX17
|
||||
// When MSC supports c++17 use <filesystem> package.
|
||||
#define USE_EXPERIMENTAL_FS 0
|
||||
#define USE_FINAL_FS 1
|
||||
#endif // !_HAS_CXX17
|
||||
|
||||
// Right now, GCC still only supports the experimental filesystem items starting in GCC 6
|
||||
#elif (__GNUC__ >= 6)
|
||||
#define USE_EXPERIMENTAL_FS 1
|
||||
#define USE_FINAL_FS 0
|
||||
|
||||
// If Clang, check for feature support
|
||||
#elif defined(__clang__) && (__cpp_lib_filesystem || __cpp_lib_experimental_filesystem)
|
||||
#if __cpp_lib_filesystem
|
||||
#define USE_EXPERIMENTAL_FS 0
|
||||
#define USE_FINAL_FS 1
|
||||
#else
|
||||
#define USE_EXPERIMENTAL_FS 1
|
||||
#define USE_FINAL_FS 0
|
||||
#endif
|
||||
|
||||
// If all above fails, fall back to standard C++ and OS-specific items
|
||||
#else
|
||||
#define USE_EXPERIMENTAL_FS 0
|
||||
#define USE_FINAL_FS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_FINAL_FS == 1
|
||||
#include <filesystem>
|
||||
#define FS_PREFIX std::filesystem
|
||||
#elif USE_EXPERIMENTAL_FS == 1
|
||||
#include <experimental/filesystem>
|
||||
#define FS_PREFIX std::experimental::filesystem
|
||||
#elif defined(XR_USE_PLATFORM_WIN32)
|
||||
// Windows fallback includes
|
||||
#include <stdint.h>
|
||||
#include <direct.h>
|
||||
#else
|
||||
// Linux/Apple fallback includes
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#if defined(XR_USE_PLATFORM_WIN32)
|
||||
#define PATH_SEPARATOR ';'
|
||||
#define DIRECTORY_SYMBOL '\\'
|
||||
#else
|
||||
#define PATH_SEPARATOR ':'
|
||||
#define DIRECTORY_SYMBOL '/'
|
||||
#endif
|
||||
|
||||
#if (USE_FINAL_FS == 1) || (USE_EXPERIMENTAL_FS == 1)
|
||||
// We can use one of the C++ filesystem packages
|
||||
|
||||
bool FileSysUtilsIsRegularFile(const std::string& path) { return FS_PREFIX::is_regular_file(path); }
|
||||
|
||||
bool FileSysUtilsIsDirectory(const std::string& path) { return FS_PREFIX::is_directory(path); }
|
||||
|
||||
bool FileSysUtilsPathExists(const std::string& path) { return FS_PREFIX::exists(path); }
|
||||
|
||||
bool FileSysUtilsIsAbsolutePath(const std::string& path) {
|
||||
FS_PREFIX::path file_path(path);
|
||||
return file_path.is_absolute();
|
||||
}
|
||||
|
||||
bool FileSysUtilsGetCurrentPath(std::string& path) {
|
||||
FS_PREFIX::path cur_path = FS_PREFIX::current_path();
|
||||
path = cur_path.string();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsGetParentPath(const std::string& file_path, std::string& parent_path) {
|
||||
FS_PREFIX::path path_var(file_path);
|
||||
parent_path = path_var.parent_path().string();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsGetAbsolutePath(const std::string& path, std::string& absolute) {
|
||||
absolute = FS_PREFIX::absolute(path).string();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsCombinePaths(const std::string& parent, const std::string& child, std::string& combined) {
|
||||
FS_PREFIX::path parent_path(parent);
|
||||
FS_PREFIX::path child_path(child);
|
||||
FS_PREFIX::path full_path = parent_path / child_path;
|
||||
combined = full_path.string();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsParsePathList(std::string& path_list, std::vector<std::string>& paths) {
|
||||
std::string::size_type start = 0;
|
||||
std::string::size_type location = path_list.find(PATH_SEPARATOR);
|
||||
while (location != std::string::npos) {
|
||||
paths.push_back(path_list.substr(start, location));
|
||||
start = location + 1;
|
||||
location = path_list.find(PATH_SEPARATOR, start);
|
||||
}
|
||||
paths.push_back(path_list.substr(start, location));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsFindFilesInPath(const std::string& path, std::vector<std::string>& files) {
|
||||
for (auto& dir_iter : FS_PREFIX::directory_iterator(path)) {
|
||||
files.push_back(dir_iter.path().filename().string());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#elif defined(XR_OS_WINDOWS)
|
||||
|
||||
// For pre C++17 compiler that doesn't support experimental filesystem
|
||||
#include <shlwapi.h>
|
||||
|
||||
bool FileSysUtilsIsRegularFile(const std::string& path) { return (1 != PathIsDirectoryW(utf8_to_wide(path).c_str())); }
|
||||
|
||||
bool FileSysUtilsIsDirectory(const std::string& path) { return (1 == PathIsDirectoryW(utf8_to_wide(path).c_str())); }
|
||||
|
||||
bool FileSysUtilsPathExists(const std::string& path) { return (1 == PathFileExistsW(utf8_to_wide(path).c_str())); }
|
||||
|
||||
bool FileSysUtilsIsAbsolutePath(const std::string& path) {
|
||||
if ((path[0] == '\\') || (path[1] == ':' && (path[2] == '\\' || path[2] == '/'))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSysUtilsGetCurrentPath(std::string& path) {
|
||||
wchar_t tmp_path[MAX_PATH];
|
||||
if (nullptr != _wgetcwd(tmp_path, MAX_PATH - 1)) {
|
||||
path = wide_to_utf8(tmp_path);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSysUtilsGetParentPath(const std::string& file_path, std::string& parent_path) {
|
||||
std::string full_path;
|
||||
if (FileSysUtilsGetAbsolutePath(file_path, full_path)) {
|
||||
std::string::size_type lastSeperator = full_path.find_last_of(DIRECTORY_SYMBOL);
|
||||
parent_path = (lastSeperator == 0) ? full_path : full_path.substr(0, lastSeperator);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSysUtilsGetAbsolutePath(const std::string& path, std::string& absolute) {
|
||||
wchar_t tmp_path[MAX_PATH];
|
||||
if (0 != GetFullPathNameW(utf8_to_wide(path).c_str(), MAX_PATH, tmp_path, NULL)) {
|
||||
absolute = wide_to_utf8(tmp_path);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSysUtilsCombinePaths(const std::string& parent, const std::string& child, std::string& combined) {
|
||||
std::string::size_type parent_len = parent.length();
|
||||
if (0 == parent_len || "." == parent || ".\\" == parent || "./" == parent) {
|
||||
combined = child;
|
||||
return true;
|
||||
}
|
||||
char last_char = parent[parent_len - 1];
|
||||
if (last_char == DIRECTORY_SYMBOL) {
|
||||
parent_len--;
|
||||
}
|
||||
combined = parent.substr(0, parent_len) + DIRECTORY_SYMBOL + child;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsParsePathList(std::string& path_list, std::vector<std::string>& paths) {
|
||||
std::string::size_type start = 0;
|
||||
std::string::size_type location = path_list.find(PATH_SEPARATOR);
|
||||
while (location != std::string::npos) {
|
||||
paths.push_back(path_list.substr(start, location));
|
||||
start = location + 1;
|
||||
location = path_list.find(PATH_SEPARATOR, start);
|
||||
}
|
||||
paths.push_back(path_list.substr(start, location));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsFindFilesInPath(const std::string& path, std::vector<std::string>& files) {
|
||||
WIN32_FIND_DATAW file_data;
|
||||
HANDLE file_handle = FindFirstFileW(utf8_to_wide(path).c_str(), &file_data);
|
||||
if (file_handle != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
if (!(file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
files.push_back(wide_to_utf8(file_data.cFileName));
|
||||
}
|
||||
} while (FindNextFileW(file_handle, &file_data));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#else // XR_OS_LINUX/XR_OS_APPLE fallback
|
||||
|
||||
// simple POSIX-compatible implementation of the <filesystem> pieces used by OpenXR
|
||||
|
||||
bool FileSysUtilsIsRegularFile(const std::string& path) {
|
||||
struct stat path_stat;
|
||||
stat(path.c_str(), &path_stat);
|
||||
return S_ISREG(path_stat.st_mode);
|
||||
}
|
||||
|
||||
bool FileSysUtilsIsDirectory(const std::string& path) {
|
||||
struct stat path_stat;
|
||||
stat(path.c_str(), &path_stat);
|
||||
return S_ISDIR(path_stat.st_mode);
|
||||
}
|
||||
|
||||
bool FileSysUtilsPathExists(const std::string& path) { return (access(path.c_str(), F_OK) != -1); }
|
||||
|
||||
bool FileSysUtilsIsAbsolutePath(const std::string& path) { return (path[0] == DIRECTORY_SYMBOL); }
|
||||
|
||||
bool FileSysUtilsGetCurrentPath(std::string& path) {
|
||||
char tmp_path[PATH_MAX];
|
||||
if (nullptr != getcwd(tmp_path, PATH_MAX - 1)) {
|
||||
path = tmp_path;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSysUtilsGetParentPath(const std::string& file_path, std::string& parent_path) {
|
||||
std::string full_path;
|
||||
if (FileSysUtilsGetAbsolutePath(file_path, full_path)) {
|
||||
std::string::size_type lastSeperator = full_path.find_last_of(DIRECTORY_SYMBOL);
|
||||
parent_path = (lastSeperator == 0) ? full_path : full_path.substr(0, lastSeperator);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSysUtilsGetAbsolutePath(const std::string& path, std::string& absolute) {
|
||||
char buf[PATH_MAX];
|
||||
if (nullptr != realpath(path.c_str(), buf)) {
|
||||
absolute = buf;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSysUtilsCombinePaths(const std::string& parent, const std::string& child, std::string& combined) {
|
||||
std::string::size_type parent_len = parent.length();
|
||||
if (0 == parent_len || "." == parent || "./" == parent) {
|
||||
combined = child;
|
||||
return true;
|
||||
}
|
||||
char last_char = parent[parent_len - 1];
|
||||
if (last_char == DIRECTORY_SYMBOL) {
|
||||
parent_len--;
|
||||
}
|
||||
combined = parent.substr(0, parent_len) + DIRECTORY_SYMBOL + child;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsParsePathList(std::string& path_list, std::vector<std::string>& paths) {
|
||||
std::string::size_type start = 0;
|
||||
std::string::size_type location = path_list.find(PATH_SEPARATOR);
|
||||
while (location != std::string::npos) {
|
||||
paths.push_back(path_list.substr(start, location));
|
||||
start = location + 1;
|
||||
location = path_list.find(PATH_SEPARATOR, start);
|
||||
}
|
||||
paths.push_back(path_list.substr(start, location));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSysUtilsFindFilesInPath(const std::string& path, std::vector<std::string>& files) {
|
||||
DIR* dir = opendir(path.c_str());
|
||||
if (dir == nullptr) {
|
||||
return false;
|
||||
}
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
files.emplace_back(entry->d_name);
|
||||
}
|
||||
closedir(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
53
extern/openxr/src/common/filesystem_utils.hpp
vendored
Normal file
53
extern/openxr/src/common/filesystem_utils.hpp
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
// Copyright (c) 2017 Valve Corporation
|
||||
// Copyright (c) 2017 LunarG, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Determine if the path indicates a regular file (not a directory or symbolic link)
|
||||
bool FileSysUtilsIsRegularFile(const std::string& path);
|
||||
|
||||
// Determine if the path indicates a directory
|
||||
bool FileSysUtilsIsDirectory(const std::string& path);
|
||||
|
||||
// Determine if the provided path exists on the filesystem
|
||||
bool FileSysUtilsPathExists(const std::string& path);
|
||||
|
||||
// Get the current directory of the executable
|
||||
bool FileSysUtilsGetCurrentPath(std::string& path);
|
||||
|
||||
// Get the parent path of a file
|
||||
bool FileSysUtilsGetParentPath(const std::string& file_path, std::string& parent_path);
|
||||
|
||||
// Determine if the provided path is an absolute path
|
||||
bool FileSysUtilsIsAbsolutePath(const std::string& path);
|
||||
|
||||
// Get the absolute path for a provided file
|
||||
bool FileSysUtilsGetAbsolutePath(const std::string& path, std::string& absolute);
|
||||
|
||||
// Combine a parent and child directory
|
||||
bool FileSysUtilsCombinePaths(const std::string& parent, const std::string& child, std::string& combined);
|
||||
|
||||
// Parse out individual paths in a path list
|
||||
bool FileSysUtilsParsePathList(std::string& path_list, std::vector<std::string>& paths);
|
||||
|
||||
// Record all the filenames for files found in the provided path.
|
||||
bool FileSysUtilsFindFilesInPath(const std::string& path, std::vector<std::string>& files);
|
44
extern/openxr/src/common/hex_and_handles.cpp
vendored
Normal file
44
extern/openxr/src/common/hex_and_handles.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2019 Valve Corporation
|
||||
// Copyright (c) 2017-2019 LunarG, Inc.
|
||||
// Copyright (c) 2019 Collabora, Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
//
|
||||
|
||||
/*!
|
||||
* @file
|
||||
*
|
||||
* Implementations of the include-requiring hex conversion functions.
|
||||
*/
|
||||
|
||||
#include "hex_and_handles.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
std::string Uint64ToHexString(uint64_t val) {
|
||||
std::ostringstream oss;
|
||||
oss << "0x";
|
||||
oss << std::hex << std::setw(16) << std::setfill('0') << val;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::string Uint32ToHexString(uint32_t val) {
|
||||
std::ostringstream oss;
|
||||
oss << "0x";
|
||||
oss << std::hex << std::setw(8) << std::setfill('0') << val;
|
||||
return oss.str();
|
||||
}
|
108
extern/openxr/src/common/hex_and_handles.h
vendored
Normal file
108
extern/openxr/src/common/hex_and_handles.h
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
// Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2019 Valve Corporation
|
||||
// Copyright (c) 2017-2019 LunarG, Inc.
|
||||
// Copyright (c) 2019 Collabora, Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
//
|
||||
|
||||
/*!
|
||||
* @file
|
||||
*
|
||||
* Some utilities, primarily for working with OpenXR handles in a generic way.
|
||||
*
|
||||
* Most are trivial and inlined by default, but a few involve some non-trivial standard headers:
|
||||
* the various `...ToHexString`functions.
|
||||
* If you want those, make sure your build includes the corresponding hex_and_handles.cpp file.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
#if XR_PTR_SIZE == 8
|
||||
/// Convert a handle into a same-sized integer.
|
||||
template <typename T>
|
||||
static inline uint64_t MakeHandleGeneric(T handle) {
|
||||
return reinterpret_cast<uint64_t>(handle);
|
||||
}
|
||||
|
||||
/// Treat an integer as a handle
|
||||
template <typename T>
|
||||
static inline T& TreatIntegerAsHandle(uint64_t& handle) {
|
||||
return reinterpret_cast<T&>(handle);
|
||||
}
|
||||
|
||||
/// @overload
|
||||
template <typename T>
|
||||
static inline T const& TreatIntegerAsHandle(uint64_t const& handle) {
|
||||
return reinterpret_cast<T const&>(handle);
|
||||
}
|
||||
|
||||
/// Does a correctly-sized integer represent a null handle?
|
||||
static inline bool IsIntegerNullHandle(uint64_t handle) { return XR_NULL_HANDLE == reinterpret_cast<void*>(handle); }
|
||||
|
||||
#else
|
||||
|
||||
/// Convert a handle into a same-sized integer: no-op on 32-bit systems
|
||||
static inline uint64_t MakeHandleGeneric(uint64_t handle) { return handle; }
|
||||
|
||||
/// Treat an integer as a handle: no-op on 32-bit systems
|
||||
template <typename T>
|
||||
static inline T& TreatIntegerAsHandle(uint64_t& handle) {
|
||||
return handle;
|
||||
}
|
||||
|
||||
/// @overload
|
||||
template <typename T>
|
||||
static inline T const& TreatIntegerAsHandle(uint64_t const& handle) {
|
||||
return handle;
|
||||
}
|
||||
|
||||
/// Does a correctly-sized integer represent a null handle?
|
||||
static inline bool IsIntegerNullHandle(uint64_t handle) { return XR_NULL_HANDLE == handle; }
|
||||
|
||||
#endif
|
||||
|
||||
/// Turns a uint64_t into a string formatted as hex.
|
||||
///
|
||||
/// The core of the HandleToHexString implementation is in here.
|
||||
std::string Uint64ToHexString(uint64_t val);
|
||||
|
||||
/// Turns a uint32_t into a string formatted as hex.
|
||||
std::string Uint32ToHexString(uint32_t val);
|
||||
|
||||
/// Turns an OpenXR handle into a string formatted as hex.
|
||||
template <typename T>
|
||||
static inline std::string HandleToHexString(T handle) {
|
||||
return Uint64ToHexString(MakeHandleGeneric(handle));
|
||||
}
|
||||
|
||||
#if XR_PTR_SIZE == 8
|
||||
/// Turns a pointer-sized integer into a string formatted as hex.
|
||||
static inline std::string UintptrToHexString(uintptr_t val) { return Uint64ToHexString(val); }
|
||||
#else
|
||||
/// Turns a pointer-sized integer into a string formatted as hex.
|
||||
static inline std::string UintptrToHexString(uintptr_t val) { return Uint32ToHexString(val); }
|
||||
#endif
|
||||
|
||||
/// Convert a pointer to a string formatted as hex.
|
||||
template <typename T>
|
||||
static inline std::string PointerToHexString(T const* ptr) {
|
||||
return UintptrToHexString(reinterpret_cast<uintptr_t>(ptr));
|
||||
}
|
122
extern/openxr/src/common/loader_interfaces.h
vendored
Normal file
122
extern/openxr/src/common/loader_interfaces.h
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
// Copyright (c) 2017 Valve Corporation
|
||||
// Copyright (c) 2017 LunarG, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Forward declare.
|
||||
typedef struct XrApiLayerCreateInfo XrApiLayerCreateInfo;
|
||||
|
||||
// Function pointer prototype for the xrCreateApiLayerInstance function used in place of xrCreateInstance.
|
||||
// This function allows us to pass special API layer information to each layer during the process of creating an Instance.
|
||||
typedef XrResult(XRAPI_PTR *PFN_xrCreateApiLayerInstance)(const XrInstanceCreateInfo *info,
|
||||
const XrApiLayerCreateInfo *apiLayerInfo, XrInstance *instance);
|
||||
|
||||
// Loader/API Layer Interface versions
|
||||
// 1 - First version, introduces negotiation structure and functions
|
||||
#define XR_CURRENT_LOADER_API_LAYER_VERSION 1
|
||||
|
||||
// Loader/Runtime Interface versions
|
||||
// 1 - First version, introduces negotiation structure and functions
|
||||
#define XR_CURRENT_LOADER_RUNTIME_VERSION 1
|
||||
|
||||
// Version negotiation values
|
||||
typedef enum XrLoaderInterfaceStructs {
|
||||
XR_LOADER_INTERFACE_STRUCT_UNINTIALIZED = 0,
|
||||
XR_LOADER_INTERFACE_STRUCT_LOADER_INFO,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST,
|
||||
XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO,
|
||||
} XrLoaderInterfaceStructs;
|
||||
|
||||
#define XR_LOADER_INFO_STRUCT_VERSION 1
|
||||
typedef struct XrNegotiateLoaderInfo {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_LOADER_INFO
|
||||
uint32_t structVersion; // XR_LOADER_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrNegotiateLoaderInfo)
|
||||
uint32_t minInterfaceVersion;
|
||||
uint32_t maxInterfaceVersion;
|
||||
XrVersion minApiVersion;
|
||||
XrVersion maxApiVersion;
|
||||
} XrNegotiateLoaderInfo;
|
||||
|
||||
#define XR_API_LAYER_INFO_STRUCT_VERSION 1
|
||||
typedef struct XrNegotiateApiLayerRequest {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST
|
||||
uint32_t structVersion; // XR_API_LAYER_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrNegotiateApiLayerRequest)
|
||||
uint32_t layerInterfaceVersion; // CURRENT_LOADER_API_LAYER_VERSION
|
||||
XrVersion layerApiVersion;
|
||||
PFN_xrGetInstanceProcAddr getInstanceProcAddr;
|
||||
PFN_xrCreateApiLayerInstance createApiLayerInstance;
|
||||
} XrNegotiateApiLayerRequest;
|
||||
|
||||
#define XR_RUNTIME_INFO_STRUCT_VERSION 1
|
||||
typedef struct XrNegotiateRuntimeRequest {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST
|
||||
uint32_t structVersion; // XR_RUNTIME_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrNegotiateRuntimeRequest)
|
||||
uint32_t runtimeInterfaceVersion; // CURRENT_LOADER_RUNTIME_VERSION
|
||||
XrVersion runtimeApiVersion;
|
||||
PFN_xrGetInstanceProcAddr getInstanceProcAddr;
|
||||
} XrNegotiateRuntimeRequest;
|
||||
|
||||
// Function used to negotiate an interface betewen the loader and an API layer. Each library exposing one or
|
||||
// more API layers needs to expose at least this function.
|
||||
typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderApiLayerInterface)(const XrNegotiateLoaderInfo *loaderInfo,
|
||||
const char *apiLayerName,
|
||||
XrNegotiateApiLayerRequest *apiLayerRequest);
|
||||
|
||||
// Function used to negotiate an interface betewen the loader and a runtime. Each runtime should expose
|
||||
// at least this function.
|
||||
typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderRuntimeInterface)(const XrNegotiateLoaderInfo *loaderInfo,
|
||||
XrNegotiateRuntimeRequest *runtimeRequest);
|
||||
|
||||
// Forward declare.
|
||||
typedef struct XrApiLayerNextInfo XrApiLayerNextInfo;
|
||||
|
||||
#define XR_API_LAYER_NEXT_INFO_STRUCT_VERSION 1
|
||||
struct XrApiLayerNextInfo {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO
|
||||
uint32_t structVersion; // XR_API_LAYER_NEXT_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrApiLayerNextInfo)
|
||||
char layerName[XR_MAX_API_LAYER_NAME_SIZE]; // Name of API layer which should receive this info
|
||||
PFN_xrGetInstanceProcAddr nextGetInstanceProcAddr; // Pointer to next API layer's xrGetInstanceProcAddr
|
||||
PFN_xrCreateApiLayerInstance nextCreateApiLayerInstance; // Pointer to next API layer's xrCreateApiLayerInstance
|
||||
XrApiLayerNextInfo *next; // Pointer to the next API layer info in the sequence
|
||||
};
|
||||
|
||||
#define XR_API_LAYER_MAX_SETTINGS_PATH_SIZE 512
|
||||
#define XR_API_LAYER_CREATE_INFO_STRUCT_VERSION 1
|
||||
typedef struct XrApiLayerCreateInfo {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO
|
||||
uint32_t structVersion; // XR_API_LAYER_CREATE_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrApiLayerCreateInfo)
|
||||
void *loaderInstance; // Pointer to the LoaderInstance class
|
||||
char settings_file_location[XR_API_LAYER_MAX_SETTINGS_PATH_SIZE]; // Location to the found settings file (or empty '\0')
|
||||
XrApiLayerNextInfo *nextInfo; // Pointer to the next API layer's Info
|
||||
} XrApiLayerCreateInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
221
extern/openxr/src/common/platform_utils.hpp
vendored
Normal file
221
extern/openxr/src/common/platform_utils.hpp
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
// Copyright (c) 2017 Valve Corporation
|
||||
// Copyright (c) 2017 LunarG, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "xr_dependencies.h"
|
||||
#include <string>
|
||||
|
||||
#if defined(XR_OS_LINUX)
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
// This is a CMake generated file with #defines for any functions/includes
|
||||
// that it found present. This is currently necessary to properly determine
|
||||
// if secure_getenv or __secure_getenv are present
|
||||
#if !defined(OPENXR_NON_CMAKE_BUILD)
|
||||
#include "common_cmake_config.h"
|
||||
#endif // !defined(OPENXR_NON_CMAKE_BUILD)
|
||||
|
||||
// Environment variables
|
||||
#if defined(XR_OS_LINUX)
|
||||
|
||||
static inline char* PlatformUtilsGetEnv(const char* name) { return getenv(name); }
|
||||
|
||||
static inline char* PlatformUtilsGetSecureEnv(const char* name) {
|
||||
#ifdef HAVE_SECURE_GETENV
|
||||
return secure_getenv(name);
|
||||
#elif defined(HAVE___SECURE_GETENV)
|
||||
return __secure_getenv(name);
|
||||
#else
|
||||
#pragma message( \
|
||||
"Warning: Falling back to non-secure getenv for environmental" \
|
||||
"lookups! Consider updating to a different libc.")
|
||||
|
||||
return PlatformUtilsGetEnv(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void PlatformUtilsFreeEnv(const char* val) {
|
||||
// No freeing of memory necessary for Linux, but we should at least touch
|
||||
// the val and inst pointers to get rid of compiler warnings.
|
||||
(void)val;
|
||||
}
|
||||
|
||||
#elif defined(XR_OS_APPLE)
|
||||
|
||||
static inline char *PlatformUtilsGetEnv(const char *name) { return getenv(name); }
|
||||
|
||||
static inline char *PlatformUtilsGetSecureEnv(const char *name) {
|
||||
#ifdef HAVE_SECURE_GETENV
|
||||
return secure_getenv(name);
|
||||
#elif defined(HAVE___SECURE_GETENV)
|
||||
return __secure_getenv(name);
|
||||
#else
|
||||
#pragma message( \
|
||||
"Warning: Falling back to non-secure getenv for environmental" \
|
||||
"lookups! Consider updating to a different libc.")
|
||||
|
||||
return PlatformUtilsGetEnv(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void PlatformUtilsFreeEnv(char *val) {
|
||||
// No freeing of memory necessary for Linux, but we should at least touch
|
||||
// the val and inst pointers to get rid of compiler warnings.
|
||||
(void)val;
|
||||
}
|
||||
|
||||
// Prefix for the Apple global runtime JSON file name
|
||||
static const std::string rt_dir_prefix = "/usr/local/share/openxr/";
|
||||
static const std::string rt_filename = "/active_runtime.json";
|
||||
|
||||
static inline bool PlatformGetGlobalRuntimeFileName(uint16_t major_version, std::string &file_name) {
|
||||
file_name = rt_dir_prefix;
|
||||
file_name += std::to_string(major_version);
|
||||
file_name += rt_filename;
|
||||
return true;
|
||||
}
|
||||
|
||||
#elif defined(XR_OS_WINDOWS)
|
||||
|
||||
#if defined(_DEBUG)
|
||||
inline void LogError(const std::string& error) { OutputDebugStringA(error.c_str()); }
|
||||
#else
|
||||
#define LogError(x)
|
||||
#endif
|
||||
|
||||
inline std::wstring utf8_to_wide(const std::string& utf8Text) {
|
||||
if (utf8Text.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::wstring wideText;
|
||||
const int wideLength = ::MultiByteToWideChar(CP_UTF8, 0, utf8Text.data(), (int)utf8Text.size(), nullptr, 0);
|
||||
if (wideLength == 0) {
|
||||
LogError("utf8_to_wide get size error: " + std::to_string(::GetLastError()));
|
||||
return {};
|
||||
}
|
||||
|
||||
// MultiByteToWideChar returns number of chars of the input buffer, regardless of null terminitor
|
||||
wideText.resize(wideLength, 0);
|
||||
wchar_t* wideString = const_cast<wchar_t*>(wideText.data()); // mutable data() only exists in c++17
|
||||
const int length = ::MultiByteToWideChar(CP_UTF8, 0, utf8Text.data(), (int)utf8Text.size(), wideString, wideLength);
|
||||
if (length != wideLength) {
|
||||
LogError("utf8_to_wide convert string error: " + std::to_string(::GetLastError()));
|
||||
return {};
|
||||
}
|
||||
|
||||
return wideText;
|
||||
}
|
||||
|
||||
inline std::string wide_to_utf8(const std::wstring& wideText) {
|
||||
if (wideText.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string narrowText;
|
||||
int narrowLength = ::WideCharToMultiByte(CP_UTF8, 0, wideText.data(), (int)wideText.size(), nullptr, 0, nullptr, nullptr);
|
||||
if (narrowLength == 0) {
|
||||
LogError("wide_to_utf8 get size error: " + std::to_string(::GetLastError()));
|
||||
return {};
|
||||
}
|
||||
|
||||
// WideCharToMultiByte returns number of chars of the input buffer, regardless of null terminitor
|
||||
narrowText.resize(narrowLength, 0);
|
||||
char* narrowString = const_cast<char*>(narrowText.data()); // mutable data() only exists in c++17
|
||||
const int length =
|
||||
::WideCharToMultiByte(CP_UTF8, 0, wideText.data(), (int)wideText.size(), narrowString, narrowLength, nullptr, nullptr);
|
||||
if (length != narrowLength) {
|
||||
LogError("wide_to_utf8 convert string error: " + std::to_string(::GetLastError()));
|
||||
return {};
|
||||
}
|
||||
|
||||
return narrowText;
|
||||
}
|
||||
|
||||
static inline char* PlatformUtilsGetEnv(const char* name) {
|
||||
const std::wstring wname = utf8_to_wide(name);
|
||||
const DWORD valSize = ::GetEnvironmentVariableW(wname.c_str(), nullptr, 0);
|
||||
|
||||
// GetEnvironmentVariable returns 0 when environment variable does not exist
|
||||
if (valSize == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// GetEnvironmentVariable returns size including null terminator for "query size" call.
|
||||
std::wstring wValue(valSize, 0);
|
||||
wchar_t* wValueData = const_cast<wchar_t*>(wValue.data()); // mutable data() only exists in c++17
|
||||
|
||||
// GetEnvironmentVariable returns string length, excluding null terminator for "get value" call.
|
||||
const int length = ::GetEnvironmentVariableW(wname.c_str(), wValueData, (DWORD)wValue.size());
|
||||
if (!length) {
|
||||
LogError("GetEnvironmentVariable get value error: " + std::to_string(::GetLastError()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::string value = wide_to_utf8(wValue);
|
||||
|
||||
// Allocate the space necessary for the result
|
||||
char* retVal = new char[value.size() + 1]{};
|
||||
value.copy(retVal, value.size());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static inline char* PlatformUtilsGetSecureEnv(const char* name) {
|
||||
// No secure version for Windows as far as I know
|
||||
return PlatformUtilsGetEnv(name);
|
||||
}
|
||||
|
||||
static inline void PlatformUtilsFreeEnv(char* val) {
|
||||
if (nullptr != val) {
|
||||
delete[] val;
|
||||
val = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#else // Not Linux or Windows
|
||||
|
||||
static inline char *PlatformUtilsGetEnv(const char *name) {
|
||||
// Stub func
|
||||
(void)name;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline char *PlatformUtilsGetSecureEnv(const char *name) {
|
||||
// Stub func
|
||||
(void)name;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline void PlatformUtilsFreeEnv(char *val) {
|
||||
// Stub func
|
||||
(void)val;
|
||||
}
|
||||
|
||||
static inline bool PlatformGetGlobalRuntimeFileName(uint16_t major_version, std::string &file_name) {
|
||||
// Stub func
|
||||
(void)major_version;
|
||||
(void)file_name;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
78
extern/openxr/src/common/xr_dependencies.h
vendored
Normal file
78
extern/openxr/src/common/xr_dependencies.h
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright (c) 2018-2019 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// This file includes headers with types which openxr.h depends on in order
|
||||
// to compile when platforms, graphics apis, and the like are enabled.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
#include <android/native_window.h>
|
||||
#endif // XR_USE_PLATFORM_ANDROID
|
||||
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
|
||||
#include <winapifamily.h>
|
||||
#if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM))
|
||||
// Enable desktop partition APIs, such as RegOpenKeyEx, LoadLibraryEx, PathFileExists etc.
|
||||
#undef WINAPI_PARTITION_DESKTOP
|
||||
#define WINAPI_PARTITION_DESKTOP 1
|
||||
#endif
|
||||
|
||||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#endif // XR_USE_PLATFORM_WIN32
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_D3D11
|
||||
#include <d3d11.h>
|
||||
#endif // XR_USE_GRAPHICS_API_D3D11
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_D3D12
|
||||
#include <d3d12.h>
|
||||
#endif // XR_USE_GRAPHICS_API_D3D12
|
||||
|
||||
#ifdef XR_USE_PLATFORM_XLIB
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#endif // XR_USE_PLATFORM_XLIB
|
||||
|
||||
#ifdef XR_USE_PLATFORM_XCB
|
||||
#include <xcb/xcb.h>
|
||||
#endif // XR_USE_PLATFORM_XCB
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_OPENGL
|
||||
#if defined(XR_USE_PLATFORM_XLIB) || defined(XR_USE_PLATFORM_XCB)
|
||||
#include <GL/glx.h>
|
||||
#endif // (XR_USE_PLATFORM_XLIB || XR_USE_PLATFORM_XCB)
|
||||
#ifdef XR_USE_PLATFORM_XCB
|
||||
#include <xcb/glx.h>
|
||||
#endif // XR_USE_PLATFORM_XCB
|
||||
#ifdef XR_USE_PLATFORM_MACOS
|
||||
#include <CL/cl_gl_ext.h>
|
||||
#endif // XR_USE_PLATFORM_MACOS
|
||||
#endif // XR_USE_GRAPHICS_API_OPENGL
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
||||
#include <EGL/egl.h>
|
||||
#endif // XR_USE_GRAPHICS_API_OPENGL_ES
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_VULKAN
|
||||
#include <vulkan/vulkan.h>
|
||||
#endif // XR_USE_GRAPHICS_API_VULKAN
|
||||
|
||||
#ifdef XR_USE_PLATFORM_WAYLAND
|
||||
#include "wayland-client.h"
|
||||
#endif // XR_USE_PLATFORM_WAYLAND
|
773
extern/openxr/src/common/xr_linear.h
vendored
Normal file
773
extern/openxr/src/common/xr_linear.h
vendored
Normal file
@@ -0,0 +1,773 @@
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
// Copyright (c) 2016 Oculus VR, LLC.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: J.M.P. van Waveren
|
||||
//
|
||||
|
||||
#ifndef XR_LINEAR_H_
|
||||
#define XR_LINEAR_H_
|
||||
|
||||
#if defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX) || defined(OS_LINUX_WAYLAND)
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
|
||||
Description : Vector, matrix and quaternion math.
|
||||
Author : J.M.P. van Waveren
|
||||
Date : 12/10/2016
|
||||
Language : C99
|
||||
Format : Indent 4 spaces - no tabs.
|
||||
Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
===========
|
||||
|
||||
All matrices are column-major.
|
||||
|
||||
INTERFACE
|
||||
=========
|
||||
|
||||
XrVector2f
|
||||
XrVector3f
|
||||
XrVector4f
|
||||
XrQuaternionf
|
||||
XrMatrix4x4f
|
||||
|
||||
inline static void XrVector3f_Set(XrVector3f* v, const float value);
|
||||
inline static void XrVector3f_Add(XrVector3f* result, const XrVector3f* a, const XrVector3f* b);
|
||||
inline static void XrVector3f_Sub(XrVector3f* result, const XrVector3f* a, const XrVector3f* b);
|
||||
inline static void XrVector3f_Min(XrVector3f* result, const XrVector3f* a, const XrVector3f* b);
|
||||
inline static void XrVector3f_Max(XrVector3f* result, const XrVector3f* a, const XrVector3f* b);
|
||||
inline static void XrVector3f_Decay(XrVector3f* result, const XrVector3f* a, const float value);
|
||||
inline static void XrVector3f_Lerp(XrVector3f* result, const XrVector3f* a, const XrVector3f* b, const float fraction);
|
||||
inline static void XrVector3f_Normalize(XrVector3f* v);
|
||||
inline static float XrVector3f_Length(const XrVector3f* v);
|
||||
|
||||
inline static void XrQuaternionf_Lerp(XrQuaternionf* result, const XrQuaternionf* a, const XrQuaternionf* b, const float fraction);
|
||||
|
||||
inline static void XrMatrix4x4f_CreateIdentity(XrMatrix4x4f* result);
|
||||
inline static void XrMatrix4x4f_CreateTranslation(XrMatrix4x4f* result, const float x, const float y, const float z);
|
||||
inline static void XrMatrix4x4f_CreateRotation(XrMatrix4x4f* result, const float degreesX, const float degreesY,
|
||||
const float degreesZ);
|
||||
inline static void XrMatrix4x4f_CreateScale(XrMatrix4x4f* result, const float x, const float y, const float z);
|
||||
inline static void XrMatrix4x4f_CreateTranslationRotationScale(XrMatrix4x4f* result, const XrVector3f* translation,
|
||||
const XrQuaternionf* rotation, const XrVector3f* scale);
|
||||
inline static void XrMatrix4x4f_CreateProjection(XrMatrix4x4f* result, const float tanAngleLeft, const float tanAngleRight,
|
||||
const float tanAngleUp, float const tanAngleDown, const float nearZ,
|
||||
const float farZ);
|
||||
inline static void XrMatrix4x4f_CreateProjectionFov(XrMatrix4x4f* result, const float fovDegreesLeft, const float fovDegreesRight,
|
||||
const float fovDegreeUp, const float fovDegreesDown, const float nearZ,
|
||||
const float farZ);
|
||||
inline static void XrMatrix4x4f_CreateFromQuaternion(XrMatrix4x4f* result, const XrQuaternionf* src);
|
||||
inline static void XrMatrix4x4f_CreateOffsetScaleForBounds(XrMatrix4x4f* result, const XrMatrix4x4f* matrix, const XrVector3f* mins,
|
||||
const XrVector3f* maxs);
|
||||
|
||||
inline static bool XrMatrix4x4f_IsAffine(const XrMatrix4x4f* matrix, const float epsilon);
|
||||
inline static bool XrMatrix4x4f_IsOrthogonal(const XrMatrix4x4f* matrix, const float epsilon);
|
||||
inline static bool XrMatrix4x4f_IsOrthonormal(const XrMatrix4x4f* matrix, const float epsilon);
|
||||
inline static bool XrMatrix4x4f_IsRigidBody(const XrMatrix4x4f* matrix, const float epsilon);
|
||||
|
||||
inline static void XrMatrix4x4f_GetTranslation(XrVector3f* result, const XrMatrix4x4f* src);
|
||||
inline static void XrMatrix4x4f_GetRotation(XrQuaternionf* result, const XrMatrix4x4f* src);
|
||||
inline static void XrMatrix4x4f_GetScale(XrVector3f* result, const XrMatrix4x4f* src);
|
||||
|
||||
inline static void XrMatrix4x4f_Multiply(XrMatrix4x4f* result, const XrMatrix4x4f* a, const XrMatrix4x4f* b);
|
||||
inline static void XrMatrix4x4f_Transpose(XrMatrix4x4f* result, const XrMatrix4x4f* src);
|
||||
inline static void XrMatrix4x4f_Invert(XrMatrix4x4f* result, const XrMatrix4x4f* src);
|
||||
inline static void XrMatrix4x4f_InvertRigidBody(XrMatrix4x4f* result, const XrMatrix4x4f* src);
|
||||
|
||||
inline static void XrMatrix4x4f_TransformVector3f(XrVector3f* result, const XrMatrix4x4f* m, const XrVector3f* v);
|
||||
inline static void XrMatrix4x4f_TransformVector4f(XrVector4f* result, const XrMatrix4x4f* m, const XrVector4f* v);
|
||||
|
||||
inline static void XrMatrix4x4f_TransformBounds(XrVector3f* resultMins, XrVector3f* resultMaxs, const XrMatrix4x4f* matrix,
|
||||
const XrVector3f* mins, const XrVector3f* maxs);
|
||||
inline static bool XrMatrix4x4f_CullBounds(const XrMatrix4x4f* mvp, const XrVector3f* mins, const XrVector3f* maxs);
|
||||
|
||||
================================================================================================
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MATH_PI 3.14159265358979323846f
|
||||
|
||||
#define DEFAULT_NEAR_Z 0.015625f // exact floating point representation
|
||||
#define INFINITE_FAR_Z 0.0f
|
||||
|
||||
static const XrColor4f XrColorRed = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
static const XrColor4f XrColorGreen = {0.0f, 1.0f, 0.0f, 1.0f};
|
||||
static const XrColor4f XrColorBlue = {0.0f, 0.0f, 1.0f, 1.0f};
|
||||
static const XrColor4f XrColorYellow = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||
static const XrColor4f XrColorPurple = {1.0f, 0.0f, 1.0f, 1.0f};
|
||||
static const XrColor4f XrColorCyan = {0.0f, 1.0f, 1.0f, 1.0f};
|
||||
static const XrColor4f XrColorLightGrey = {0.7f, 0.7f, 0.7f, 1.0f};
|
||||
static const XrColor4f XrColorDarkGrey = {0.3f, 0.3f, 0.3f, 1.0f};
|
||||
|
||||
enum GraphicsAPI { GRAPHICS_VULKAN, GRAPHICS_OPENGL, GRAPHICS_OPENGL_ES, GRAPHICS_D3D };
|
||||
|
||||
// Column-major, pre-multiplied. This type does not exist in the OpenXR API and is provided for convenience.
|
||||
struct XrMatrix4x4f {
|
||||
float m[16];
|
||||
};
|
||||
|
||||
inline static float XrRcpSqrt(const float x) {
|
||||
const float SMALLEST_NON_DENORMAL = 1.1754943508222875e-038f; // ( 1U << 23 )
|
||||
const float rcp = (x >= SMALLEST_NON_DENORMAL) ? 1.0f / sqrtf(x) : 1.0f;
|
||||
return rcp;
|
||||
}
|
||||
|
||||
inline static void XrVector3f_Set(XrVector3f* v, const float value) {
|
||||
v->x = value;
|
||||
v->y = value;
|
||||
v->z = value;
|
||||
}
|
||||
|
||||
inline static void XrVector3f_Add(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
|
||||
result->x = a->x + b->x;
|
||||
result->y = a->y + b->y;
|
||||
result->z = a->z + b->z;
|
||||
}
|
||||
|
||||
inline static void XrVector3f_Sub(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
|
||||
result->x = a->x - b->x;
|
||||
result->y = a->y - b->y;
|
||||
result->z = a->z - b->z;
|
||||
}
|
||||
|
||||
inline static void XrVector3f_Min(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
|
||||
result->x = (a->x < b->x) ? a->x : b->x;
|
||||
result->y = (a->y < b->y) ? a->y : b->y;
|
||||
result->z = (a->z < b->z) ? a->z : b->z;
|
||||
}
|
||||
|
||||
inline static void XrVector3f_Max(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
|
||||
result->x = (a->x > b->x) ? a->x : b->x;
|
||||
result->y = (a->y > b->y) ? a->y : b->y;
|
||||
result->z = (a->z > b->z) ? a->z : b->z;
|
||||
}
|
||||
|
||||
inline static void XrVector3f_Decay(XrVector3f* result, const XrVector3f* a, const float value) {
|
||||
result->x = (fabsf(a->x) > value) ? ((a->x > 0.0f) ? (a->x - value) : (a->x + value)) : 0.0f;
|
||||
result->y = (fabsf(a->y) > value) ? ((a->y > 0.0f) ? (a->y - value) : (a->y + value)) : 0.0f;
|
||||
result->z = (fabsf(a->z) > value) ? ((a->z > 0.0f) ? (a->z - value) : (a->z + value)) : 0.0f;
|
||||
}
|
||||
|
||||
inline static void XrVector3f_Lerp(XrVector3f* result, const XrVector3f* a, const XrVector3f* b, const float fraction) {
|
||||
result->x = a->x + fraction * (b->x - a->x);
|
||||
result->y = a->y + fraction * (b->y - a->y);
|
||||
result->z = a->z + fraction * (b->z - a->z);
|
||||
}
|
||||
|
||||
inline static float XrVector3f_Dot(const XrVector3f* a, const XrVector3f* b) { return a->x * b->x + a->y * b->y + a->z * b->z; }
|
||||
|
||||
// Compute cross product, which generates a normal vector.
|
||||
// Direction vector can be determined by right-hand rule: Pointing index finder in
|
||||
// direction a and middle finger in direction b, thumb will point in Cross(a, b).
|
||||
inline static void XrVector3f_Cross(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
|
||||
result->x = a->y * b->z - a->z * b->y;
|
||||
result->y = a->z * b->x - a->x * b->z;
|
||||
result->x = a->x * b->y - a->y * b->x;
|
||||
}
|
||||
|
||||
inline static void XrVector3f_Normalize(XrVector3f* v) {
|
||||
const float lengthRcp = XrRcpSqrt(v->x * v->x + v->y * v->y + v->z * v->z);
|
||||
v->x *= lengthRcp;
|
||||
v->y *= lengthRcp;
|
||||
v->z *= lengthRcp;
|
||||
}
|
||||
|
||||
inline static float XrVector3f_Length(const XrVector3f* v) { return sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); }
|
||||
|
||||
inline static void XrQuaternionf_CreateFromAxisAngle(XrQuaternionf* result, const XrVector3f* axis, const float angleInRadians) {
|
||||
float s = sinf(angleInRadians / 2.0f);
|
||||
float lengthRcp = XrRcpSqrt(axis->x * axis->x + axis->y * axis->y + axis->z * axis->z);
|
||||
result->x = s * axis->x * lengthRcp;
|
||||
result->y = s * axis->y * lengthRcp;
|
||||
result->z = s * axis->z * lengthRcp;
|
||||
result->w = cosf(angleInRadians / 2.0f);
|
||||
}
|
||||
|
||||
inline static void XrQuaternionf_Lerp(XrQuaternionf* result, const XrQuaternionf* a, const XrQuaternionf* b, const float fraction) {
|
||||
const float s = a->x * b->x + a->y * b->y + a->z * b->z + a->w * b->w;
|
||||
const float fa = 1.0f - fraction;
|
||||
const float fb = (s < 0.0f) ? -fraction : fraction;
|
||||
const float x = a->x * fa + b->x * fb;
|
||||
const float y = a->y * fa + b->y * fb;
|
||||
const float z = a->z * fa + b->z * fb;
|
||||
const float w = a->w * fa + b->w * fb;
|
||||
const float lengthRcp = XrRcpSqrt(x * x + y * y + z * z + w * w);
|
||||
result->x = x * lengthRcp;
|
||||
result->y = y * lengthRcp;
|
||||
result->z = z * lengthRcp;
|
||||
result->w = w * lengthRcp;
|
||||
}
|
||||
|
||||
// Use left-multiplication to accumulate transformations.
|
||||
inline static void XrMatrix4x4f_Multiply(XrMatrix4x4f* result, const XrMatrix4x4f* a, const XrMatrix4x4f* b) {
|
||||
result->m[0] = a->m[0] * b->m[0] + a->m[4] * b->m[1] + a->m[8] * b->m[2] + a->m[12] * b->m[3];
|
||||
result->m[1] = a->m[1] * b->m[0] + a->m[5] * b->m[1] + a->m[9] * b->m[2] + a->m[13] * b->m[3];
|
||||
result->m[2] = a->m[2] * b->m[0] + a->m[6] * b->m[1] + a->m[10] * b->m[2] + a->m[14] * b->m[3];
|
||||
result->m[3] = a->m[3] * b->m[0] + a->m[7] * b->m[1] + a->m[11] * b->m[2] + a->m[15] * b->m[3];
|
||||
|
||||
result->m[4] = a->m[0] * b->m[4] + a->m[4] * b->m[5] + a->m[8] * b->m[6] + a->m[12] * b->m[7];
|
||||
result->m[5] = a->m[1] * b->m[4] + a->m[5] * b->m[5] + a->m[9] * b->m[6] + a->m[13] * b->m[7];
|
||||
result->m[6] = a->m[2] * b->m[4] + a->m[6] * b->m[5] + a->m[10] * b->m[6] + a->m[14] * b->m[7];
|
||||
result->m[7] = a->m[3] * b->m[4] + a->m[7] * b->m[5] + a->m[11] * b->m[6] + a->m[15] * b->m[7];
|
||||
|
||||
result->m[8] = a->m[0] * b->m[8] + a->m[4] * b->m[9] + a->m[8] * b->m[10] + a->m[12] * b->m[11];
|
||||
result->m[9] = a->m[1] * b->m[8] + a->m[5] * b->m[9] + a->m[9] * b->m[10] + a->m[13] * b->m[11];
|
||||
result->m[10] = a->m[2] * b->m[8] + a->m[6] * b->m[9] + a->m[10] * b->m[10] + a->m[14] * b->m[11];
|
||||
result->m[11] = a->m[3] * b->m[8] + a->m[7] * b->m[9] + a->m[11] * b->m[10] + a->m[15] * b->m[11];
|
||||
|
||||
result->m[12] = a->m[0] * b->m[12] + a->m[4] * b->m[13] + a->m[8] * b->m[14] + a->m[12] * b->m[15];
|
||||
result->m[13] = a->m[1] * b->m[12] + a->m[5] * b->m[13] + a->m[9] * b->m[14] + a->m[13] * b->m[15];
|
||||
result->m[14] = a->m[2] * b->m[12] + a->m[6] * b->m[13] + a->m[10] * b->m[14] + a->m[14] * b->m[15];
|
||||
result->m[15] = a->m[3] * b->m[12] + a->m[7] * b->m[13] + a->m[11] * b->m[14] + a->m[15] * b->m[15];
|
||||
}
|
||||
|
||||
// Creates the transpose of the given matrix.
|
||||
inline static void XrMatrix4x4f_Transpose(XrMatrix4x4f* result, const XrMatrix4x4f* src) {
|
||||
result->m[0] = src->m[0];
|
||||
result->m[1] = src->m[4];
|
||||
result->m[2] = src->m[8];
|
||||
result->m[3] = src->m[12];
|
||||
|
||||
result->m[4] = src->m[1];
|
||||
result->m[5] = src->m[5];
|
||||
result->m[6] = src->m[9];
|
||||
result->m[7] = src->m[13];
|
||||
|
||||
result->m[8] = src->m[2];
|
||||
result->m[9] = src->m[6];
|
||||
result->m[10] = src->m[10];
|
||||
result->m[11] = src->m[14];
|
||||
|
||||
result->m[12] = src->m[3];
|
||||
result->m[13] = src->m[7];
|
||||
result->m[14] = src->m[11];
|
||||
result->m[15] = src->m[15];
|
||||
}
|
||||
|
||||
// Returns a 3x3 minor of a 4x4 matrix.
|
||||
inline static float XrMatrix4x4f_Minor(const XrMatrix4x4f* matrix, int r0, int r1, int r2, int c0, int c1, int c2) {
|
||||
return matrix->m[4 * r0 + c0] *
|
||||
(matrix->m[4 * r1 + c1] * matrix->m[4 * r2 + c2] - matrix->m[4 * r2 + c1] * matrix->m[4 * r1 + c2]) -
|
||||
matrix->m[4 * r0 + c1] *
|
||||
(matrix->m[4 * r1 + c0] * matrix->m[4 * r2 + c2] - matrix->m[4 * r2 + c0] * matrix->m[4 * r1 + c2]) +
|
||||
matrix->m[4 * r0 + c2] *
|
||||
(matrix->m[4 * r1 + c0] * matrix->m[4 * r2 + c1] - matrix->m[4 * r2 + c0] * matrix->m[4 * r1 + c1]);
|
||||
}
|
||||
|
||||
// Calculates the inverse of a 4x4 matrix.
|
||||
inline static void XrMatrix4x4f_Invert(XrMatrix4x4f* result, const XrMatrix4x4f* src) {
|
||||
const float rcpDet =
|
||||
1.0f / (src->m[0] * XrMatrix4x4f_Minor(src, 1, 2, 3, 1, 2, 3) - src->m[1] * XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 2, 3) +
|
||||
src->m[2] * XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 1, 3) - src->m[3] * XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 1, 2));
|
||||
|
||||
result->m[0] = XrMatrix4x4f_Minor(src, 1, 2, 3, 1, 2, 3) * rcpDet;
|
||||
result->m[1] = -XrMatrix4x4f_Minor(src, 0, 2, 3, 1, 2, 3) * rcpDet;
|
||||
result->m[2] = XrMatrix4x4f_Minor(src, 0, 1, 3, 1, 2, 3) * rcpDet;
|
||||
result->m[3] = -XrMatrix4x4f_Minor(src, 0, 1, 2, 1, 2, 3) * rcpDet;
|
||||
result->m[4] = -XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 2, 3) * rcpDet;
|
||||
result->m[5] = XrMatrix4x4f_Minor(src, 0, 2, 3, 0, 2, 3) * rcpDet;
|
||||
result->m[6] = -XrMatrix4x4f_Minor(src, 0, 1, 3, 0, 2, 3) * rcpDet;
|
||||
result->m[7] = XrMatrix4x4f_Minor(src, 0, 1, 2, 0, 2, 3) * rcpDet;
|
||||
result->m[8] = XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 1, 3) * rcpDet;
|
||||
result->m[9] = -XrMatrix4x4f_Minor(src, 0, 2, 3, 0, 1, 3) * rcpDet;
|
||||
result->m[10] = XrMatrix4x4f_Minor(src, 0, 1, 3, 0, 1, 3) * rcpDet;
|
||||
result->m[11] = -XrMatrix4x4f_Minor(src, 0, 1, 2, 0, 1, 3) * rcpDet;
|
||||
result->m[12] = -XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 1, 2) * rcpDet;
|
||||
result->m[13] = XrMatrix4x4f_Minor(src, 0, 2, 3, 0, 1, 2) * rcpDet;
|
||||
result->m[14] = -XrMatrix4x4f_Minor(src, 0, 1, 3, 0, 1, 2) * rcpDet;
|
||||
result->m[15] = XrMatrix4x4f_Minor(src, 0, 1, 2, 0, 1, 2) * rcpDet;
|
||||
}
|
||||
|
||||
// Calculates the inverse of a rigid body transform.
|
||||
inline static void XrMatrix4x4f_InvertRigidBody(XrMatrix4x4f* result, const XrMatrix4x4f* src) {
|
||||
result->m[0] = src->m[0];
|
||||
result->m[1] = src->m[4];
|
||||
result->m[2] = src->m[8];
|
||||
result->m[3] = 0.0f;
|
||||
result->m[4] = src->m[1];
|
||||
result->m[5] = src->m[5];
|
||||
result->m[6] = src->m[9];
|
||||
result->m[7] = 0.0f;
|
||||
result->m[8] = src->m[2];
|
||||
result->m[9] = src->m[6];
|
||||
result->m[10] = src->m[10];
|
||||
result->m[11] = 0.0f;
|
||||
result->m[12] = -(src->m[0] * src->m[12] + src->m[1] * src->m[13] + src->m[2] * src->m[14]);
|
||||
result->m[13] = -(src->m[4] * src->m[12] + src->m[5] * src->m[13] + src->m[6] * src->m[14]);
|
||||
result->m[14] = -(src->m[8] * src->m[12] + src->m[9] * src->m[13] + src->m[10] * src->m[14]);
|
||||
result->m[15] = 1.0f;
|
||||
}
|
||||
|
||||
// Creates an identity matrix.
|
||||
inline static void XrMatrix4x4f_CreateIdentity(XrMatrix4x4f* result) {
|
||||
result->m[0] = 1.0f;
|
||||
result->m[1] = 0.0f;
|
||||
result->m[2] = 0.0f;
|
||||
result->m[3] = 0.0f;
|
||||
result->m[4] = 0.0f;
|
||||
result->m[5] = 1.0f;
|
||||
result->m[6] = 0.0f;
|
||||
result->m[7] = 0.0f;
|
||||
result->m[8] = 0.0f;
|
||||
result->m[9] = 0.0f;
|
||||
result->m[10] = 1.0f;
|
||||
result->m[11] = 0.0f;
|
||||
result->m[12] = 0.0f;
|
||||
result->m[13] = 0.0f;
|
||||
result->m[14] = 0.0f;
|
||||
result->m[15] = 1.0f;
|
||||
}
|
||||
|
||||
// Creates a translation matrix.
|
||||
inline static void XrMatrix4x4f_CreateTranslation(XrMatrix4x4f* result, const float x, const float y, const float z) {
|
||||
result->m[0] = 1.0f;
|
||||
result->m[1] = 0.0f;
|
||||
result->m[2] = 0.0f;
|
||||
result->m[3] = 0.0f;
|
||||
result->m[4] = 0.0f;
|
||||
result->m[5] = 1.0f;
|
||||
result->m[6] = 0.0f;
|
||||
result->m[7] = 0.0f;
|
||||
result->m[8] = 0.0f;
|
||||
result->m[9] = 0.0f;
|
||||
result->m[10] = 1.0f;
|
||||
result->m[11] = 0.0f;
|
||||
result->m[12] = x;
|
||||
result->m[13] = y;
|
||||
result->m[14] = z;
|
||||
result->m[15] = 1.0f;
|
||||
}
|
||||
|
||||
// Creates a rotation matrix.
|
||||
// If -Z=forward, +Y=up, +X=right, then degreesX=pitch, degreesY=yaw, degreesZ=roll.
|
||||
inline static void XrMatrix4x4f_CreateRotation(XrMatrix4x4f* result, const float degreesX, const float degreesY,
|
||||
const float degreesZ) {
|
||||
const float sinX = sinf(degreesX * (MATH_PI / 180.0f));
|
||||
const float cosX = cosf(degreesX * (MATH_PI / 180.0f));
|
||||
const XrMatrix4x4f rotationX = {{1, 0, 0, 0, 0, cosX, sinX, 0, 0, -sinX, cosX, 0, 0, 0, 0, 1}};
|
||||
const float sinY = sinf(degreesY * (MATH_PI / 180.0f));
|
||||
const float cosY = cosf(degreesY * (MATH_PI / 180.0f));
|
||||
const XrMatrix4x4f rotationY = {{cosY, 0, -sinY, 0, 0, 1, 0, 0, sinY, 0, cosY, 0, 0, 0, 0, 1}};
|
||||
const float sinZ = sinf(degreesZ * (MATH_PI / 180.0f));
|
||||
const float cosZ = cosf(degreesZ * (MATH_PI / 180.0f));
|
||||
const XrMatrix4x4f rotationZ = {{cosZ, sinZ, 0, 0, -sinZ, cosZ, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}};
|
||||
XrMatrix4x4f rotationXY;
|
||||
XrMatrix4x4f_Multiply(&rotationXY, &rotationY, &rotationX);
|
||||
XrMatrix4x4f_Multiply(result, &rotationZ, &rotationXY);
|
||||
}
|
||||
|
||||
// Creates a scale matrix.
|
||||
inline static void XrMatrix4x4f_CreateScale(XrMatrix4x4f* result, const float x, const float y, const float z) {
|
||||
result->m[0] = x;
|
||||
result->m[1] = 0.0f;
|
||||
result->m[2] = 0.0f;
|
||||
result->m[3] = 0.0f;
|
||||
result->m[4] = 0.0f;
|
||||
result->m[5] = y;
|
||||
result->m[6] = 0.0f;
|
||||
result->m[7] = 0.0f;
|
||||
result->m[8] = 0.0f;
|
||||
result->m[9] = 0.0f;
|
||||
result->m[10] = z;
|
||||
result->m[11] = 0.0f;
|
||||
result->m[12] = 0.0f;
|
||||
result->m[13] = 0.0f;
|
||||
result->m[14] = 0.0f;
|
||||
result->m[15] = 1.0f;
|
||||
}
|
||||
|
||||
// Creates a matrix from a quaternion.
|
||||
inline static void XrMatrix4x4f_CreateFromQuaternion(XrMatrix4x4f* result, const XrQuaternionf* quat) {
|
||||
const float x2 = quat->x + quat->x;
|
||||
const float y2 = quat->y + quat->y;
|
||||
const float z2 = quat->z + quat->z;
|
||||
|
||||
const float xx2 = quat->x * x2;
|
||||
const float yy2 = quat->y * y2;
|
||||
const float zz2 = quat->z * z2;
|
||||
|
||||
const float yz2 = quat->y * z2;
|
||||
const float wx2 = quat->w * x2;
|
||||
const float xy2 = quat->x * y2;
|
||||
const float wz2 = quat->w * z2;
|
||||
const float xz2 = quat->x * z2;
|
||||
const float wy2 = quat->w * y2;
|
||||
|
||||
result->m[0] = 1.0f - yy2 - zz2;
|
||||
result->m[1] = xy2 + wz2;
|
||||
result->m[2] = xz2 - wy2;
|
||||
result->m[3] = 0.0f;
|
||||
|
||||
result->m[4] = xy2 - wz2;
|
||||
result->m[5] = 1.0f - xx2 - zz2;
|
||||
result->m[6] = yz2 + wx2;
|
||||
result->m[7] = 0.0f;
|
||||
|
||||
result->m[8] = xz2 + wy2;
|
||||
result->m[9] = yz2 - wx2;
|
||||
result->m[10] = 1.0f - xx2 - yy2;
|
||||
result->m[11] = 0.0f;
|
||||
|
||||
result->m[12] = 0.0f;
|
||||
result->m[13] = 0.0f;
|
||||
result->m[14] = 0.0f;
|
||||
result->m[15] = 1.0f;
|
||||
}
|
||||
|
||||
// Creates a combined translation(rotation(scale(object))) matrix.
|
||||
inline static void XrMatrix4x4f_CreateTranslationRotationScale(XrMatrix4x4f* result, const XrVector3f* translation,
|
||||
const XrQuaternionf* rotation, const XrVector3f* scale) {
|
||||
XrMatrix4x4f scaleMatrix;
|
||||
XrMatrix4x4f_CreateScale(&scaleMatrix, scale->x, scale->y, scale->z);
|
||||
|
||||
XrMatrix4x4f rotationMatrix;
|
||||
XrMatrix4x4f_CreateFromQuaternion(&rotationMatrix, rotation);
|
||||
|
||||
XrMatrix4x4f translationMatrix;
|
||||
XrMatrix4x4f_CreateTranslation(&translationMatrix, translation->x, translation->y, translation->z);
|
||||
|
||||
XrMatrix4x4f combinedMatrix;
|
||||
XrMatrix4x4f_Multiply(&combinedMatrix, &rotationMatrix, &scaleMatrix);
|
||||
XrMatrix4x4f_Multiply(result, &translationMatrix, &combinedMatrix);
|
||||
}
|
||||
|
||||
// Creates a projection matrix based on the specified dimensions.
|
||||
// The projection matrix transforms -Z=forward, +Y=up, +X=right to the appropriate clip space for the graphics API.
|
||||
// The far plane is placed at infinity if farZ <= nearZ.
|
||||
// An infinite projection matrix is preferred for rasterization because, except for
|
||||
// things *right* up against the near plane, it always provides better precision:
|
||||
// "Tightening the Precision of Perspective Rendering"
|
||||
// Paul Upchurch, Mathieu Desbrun
|
||||
// Journal of Graphics Tools, Volume 16, Issue 1, 2012
|
||||
inline static void XrMatrix4x4f_CreateProjection(XrMatrix4x4f* result, GraphicsAPI graphicsApi, const float tanAngleLeft,
|
||||
const float tanAngleRight, const float tanAngleUp, float const tanAngleDown,
|
||||
const float nearZ, const float farZ) {
|
||||
const float tanAngleWidth = tanAngleRight - tanAngleLeft;
|
||||
|
||||
// Set to tanAngleDown - tanAngleUp for a clip space with positive Y down (Vulkan).
|
||||
// Set to tanAngleUp - tanAngleDown for a clip space with positive Y up (OpenGL / D3D / Metal).
|
||||
const float tanAngleHeight = graphicsApi == GRAPHICS_VULKAN ? (tanAngleDown - tanAngleUp) : (tanAngleUp - tanAngleDown);
|
||||
|
||||
// Set to nearZ for a [-1,1] Z clip space (OpenGL / OpenGL ES).
|
||||
// Set to zero for a [0,1] Z clip space (Vulkan / D3D / Metal).
|
||||
const float offsetZ = (graphicsApi == GRAPHICS_OPENGL || graphicsApi == GRAPHICS_OPENGL_ES) ? nearZ : 0;
|
||||
|
||||
if (farZ <= nearZ) {
|
||||
// place the far plane at infinity
|
||||
result->m[0] = 2 / tanAngleWidth;
|
||||
result->m[4] = 0;
|
||||
result->m[8] = (tanAngleRight + tanAngleLeft) / tanAngleWidth;
|
||||
result->m[12] = 0;
|
||||
|
||||
result->m[1] = 0;
|
||||
result->m[5] = 2 / tanAngleHeight;
|
||||
result->m[9] = (tanAngleUp + tanAngleDown) / tanAngleHeight;
|
||||
result->m[13] = 0;
|
||||
|
||||
result->m[2] = 0;
|
||||
result->m[6] = 0;
|
||||
result->m[10] = -1;
|
||||
result->m[14] = -(nearZ + offsetZ);
|
||||
|
||||
result->m[3] = 0;
|
||||
result->m[7] = 0;
|
||||
result->m[11] = -1;
|
||||
result->m[15] = 0;
|
||||
} else {
|
||||
// normal projection
|
||||
result->m[0] = 2 / tanAngleWidth;
|
||||
result->m[4] = 0;
|
||||
result->m[8] = (tanAngleRight + tanAngleLeft) / tanAngleWidth;
|
||||
result->m[12] = 0;
|
||||
|
||||
result->m[1] = 0;
|
||||
result->m[5] = 2 / tanAngleHeight;
|
||||
result->m[9] = (tanAngleUp + tanAngleDown) / tanAngleHeight;
|
||||
result->m[13] = 0;
|
||||
|
||||
result->m[2] = 0;
|
||||
result->m[6] = 0;
|
||||
result->m[10] = -(farZ + offsetZ) / (farZ - nearZ);
|
||||
result->m[14] = -(farZ * (nearZ + offsetZ)) / (farZ - nearZ);
|
||||
|
||||
result->m[3] = 0;
|
||||
result->m[7] = 0;
|
||||
result->m[11] = -1;
|
||||
result->m[15] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a projection matrix based on the specified FOV.
|
||||
inline static void XrMatrix4x4f_CreateProjectionFov(XrMatrix4x4f* result, GraphicsAPI graphicsApi, const XrFovf fov,
|
||||
const float nearZ, const float farZ) {
|
||||
const float tanLeft = tanf(fov.angleLeft);
|
||||
const float tanRight = tanf(fov.angleRight);
|
||||
|
||||
const float tanDown = tanf(fov.angleDown);
|
||||
const float tanUp = tanf(fov.angleUp);
|
||||
|
||||
XrMatrix4x4f_CreateProjection(result, graphicsApi, tanLeft, tanRight, tanUp, tanDown, nearZ, farZ);
|
||||
}
|
||||
|
||||
// Creates a matrix that transforms the -1 to 1 cube to cover the given 'mins' and 'maxs' transformed with the given 'matrix'.
|
||||
inline static void XrMatrix4x4f_CreateOffsetScaleForBounds(XrMatrix4x4f* result, const XrMatrix4x4f* matrix, const XrVector3f* mins,
|
||||
const XrVector3f* maxs) {
|
||||
const XrVector3f offset = {(maxs->x + mins->x) * 0.5f, (maxs->y + mins->y) * 0.5f, (maxs->z + mins->z) * 0.5f};
|
||||
const XrVector3f scale = {(maxs->x - mins->x) * 0.5f, (maxs->y - mins->y) * 0.5f, (maxs->z - mins->z) * 0.5f};
|
||||
|
||||
result->m[0] = matrix->m[0] * scale.x;
|
||||
result->m[1] = matrix->m[1] * scale.x;
|
||||
result->m[2] = matrix->m[2] * scale.x;
|
||||
result->m[3] = matrix->m[3] * scale.x;
|
||||
|
||||
result->m[4] = matrix->m[4] * scale.y;
|
||||
result->m[5] = matrix->m[5] * scale.y;
|
||||
result->m[6] = matrix->m[6] * scale.y;
|
||||
result->m[7] = matrix->m[7] * scale.y;
|
||||
|
||||
result->m[8] = matrix->m[8] * scale.z;
|
||||
result->m[9] = matrix->m[9] * scale.z;
|
||||
result->m[10] = matrix->m[10] * scale.z;
|
||||
result->m[11] = matrix->m[11] * scale.z;
|
||||
|
||||
result->m[12] = matrix->m[12] + matrix->m[0] * offset.x + matrix->m[4] * offset.y + matrix->m[8] * offset.z;
|
||||
result->m[13] = matrix->m[13] + matrix->m[1] * offset.x + matrix->m[5] * offset.y + matrix->m[9] * offset.z;
|
||||
result->m[14] = matrix->m[14] + matrix->m[2] * offset.x + matrix->m[6] * offset.y + matrix->m[10] * offset.z;
|
||||
result->m[15] = matrix->m[15] + matrix->m[3] * offset.x + matrix->m[7] * offset.y + matrix->m[11] * offset.z;
|
||||
}
|
||||
|
||||
// Returns true if the given matrix is affine.
|
||||
inline static bool XrMatrix4x4f_IsAffine(const XrMatrix4x4f* matrix, const float epsilon) {
|
||||
return fabsf(matrix->m[3]) <= epsilon && fabsf(matrix->m[7]) <= epsilon && fabsf(matrix->m[11]) <= epsilon &&
|
||||
fabsf(matrix->m[15] - 1.0f) <= epsilon;
|
||||
}
|
||||
|
||||
// Returns true if the given matrix is orthogonal.
|
||||
inline static bool XrMatrix4x4f_IsOrthogonal(const XrMatrix4x4f* matrix, const float epsilon) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (i != j) {
|
||||
if (fabsf(matrix->m[4 * i + 0] * matrix->m[4 * j + 0] + matrix->m[4 * i + 1] * matrix->m[4 * j + 1] +
|
||||
matrix->m[4 * i + 2] * matrix->m[4 * j + 2]) > epsilon) {
|
||||
return false;
|
||||
}
|
||||
if (fabsf(matrix->m[4 * 0 + i] * matrix->m[4 * 0 + j] + matrix->m[4 * 1 + i] * matrix->m[4 * 1 + j] +
|
||||
matrix->m[4 * 2 + i] * matrix->m[4 * 2 + j]) > epsilon) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if the given matrix is orthonormal.
|
||||
inline static bool XrMatrix4x4f_IsOrthonormal(const XrMatrix4x4f* matrix, const float epsilon) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
const float kd = (i == j) ? 1.0f : 0.0f; // Kronecker delta
|
||||
if (fabsf(kd - (matrix->m[4 * i + 0] * matrix->m[4 * j + 0] + matrix->m[4 * i + 1] * matrix->m[4 * j + 1] +
|
||||
matrix->m[4 * i + 2] * matrix->m[4 * j + 2])) > epsilon) {
|
||||
return false;
|
||||
}
|
||||
if (fabsf(kd - (matrix->m[4 * 0 + i] * matrix->m[4 * 0 + j] + matrix->m[4 * 1 + i] * matrix->m[4 * 1 + j] +
|
||||
matrix->m[4 * 2 + i] * matrix->m[4 * 2 + j])) > epsilon) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if the given matrix is a rigid body transform.
|
||||
inline static bool XrMatrix4x4f_IsRigidBody(const XrMatrix4x4f* matrix, const float epsilon) {
|
||||
return XrMatrix4x4f_IsAffine(matrix, epsilon) && XrMatrix4x4f_IsOrthonormal(matrix, epsilon);
|
||||
}
|
||||
|
||||
// Get the translation from a combined translation(rotation(scale(object))) matrix.
|
||||
inline static void XrMatrix4x4f_GetTranslation(XrVector3f* result, const XrMatrix4x4f* src) {
|
||||
assert(XrMatrix4x4f_IsAffine(src, 1e-4f));
|
||||
assert(XrMatrix4x4f_IsOrthogonal(src, 1e-4f));
|
||||
|
||||
result->x = src->m[12];
|
||||
result->y = src->m[13];
|
||||
result->z = src->m[14];
|
||||
}
|
||||
|
||||
// Get the rotation from a combined translation(rotation(scale(object))) matrix.
|
||||
inline static void XrMatrix4x4f_GetRotation(XrQuaternionf* result, const XrMatrix4x4f* src) {
|
||||
assert(XrMatrix4x4f_IsAffine(src, 1e-4f));
|
||||
assert(XrMatrix4x4f_IsOrthogonal(src, 1e-4f));
|
||||
|
||||
const float rcpScaleX = XrRcpSqrt(src->m[0] * src->m[0] + src->m[1] * src->m[1] + src->m[2] * src->m[2]);
|
||||
const float rcpScaleY = XrRcpSqrt(src->m[4] * src->m[4] + src->m[5] * src->m[5] + src->m[6] * src->m[6]);
|
||||
const float rcpScaleZ = XrRcpSqrt(src->m[8] * src->m[8] + src->m[9] * src->m[9] + src->m[10] * src->m[10]);
|
||||
const float m[9] = {src->m[0] * rcpScaleX, src->m[1] * rcpScaleX, src->m[2] * rcpScaleX,
|
||||
src->m[4] * rcpScaleY, src->m[5] * rcpScaleY, src->m[6] * rcpScaleY,
|
||||
src->m[8] * rcpScaleZ, src->m[9] * rcpScaleZ, src->m[10] * rcpScaleZ};
|
||||
if (m[0 * 3 + 0] + m[1 * 3 + 1] + m[2 * 3 + 2] > 0.0f) {
|
||||
float t = +m[0 * 3 + 0] + m[1 * 3 + 1] + m[2 * 3 + 2] + 1.0f;
|
||||
float s = XrRcpSqrt(t) * 0.5f;
|
||||
result->w = s * t;
|
||||
result->z = (m[0 * 3 + 1] - m[1 * 3 + 0]) * s;
|
||||
result->y = (m[2 * 3 + 0] - m[0 * 3 + 2]) * s;
|
||||
result->x = (m[1 * 3 + 2] - m[2 * 3 + 1]) * s;
|
||||
} else if (m[0 * 3 + 0] > m[1 * 3 + 1] && m[0 * 3 + 0] > m[2 * 3 + 2]) {
|
||||
float t = +m[0 * 3 + 0] - m[1 * 3 + 1] - m[2 * 3 + 2] + 1.0f;
|
||||
float s = XrRcpSqrt(t) * 0.5f;
|
||||
result->x = s * t;
|
||||
result->y = (m[0 * 3 + 1] + m[1 * 3 + 0]) * s;
|
||||
result->z = (m[2 * 3 + 0] + m[0 * 3 + 2]) * s;
|
||||
result->w = (m[1 * 3 + 2] - m[2 * 3 + 1]) * s;
|
||||
} else if (m[1 * 3 + 1] > m[2 * 3 + 2]) {
|
||||
float t = -m[0 * 3 + 0] + m[1 * 3 + 1] - m[2 * 3 + 2] + 1.0f;
|
||||
float s = XrRcpSqrt(t) * 0.5f;
|
||||
result->y = s * t;
|
||||
result->x = (m[0 * 3 + 1] + m[1 * 3 + 0]) * s;
|
||||
result->w = (m[2 * 3 + 0] - m[0 * 3 + 2]) * s;
|
||||
result->z = (m[1 * 3 + 2] + m[2 * 3 + 1]) * s;
|
||||
} else {
|
||||
float t = -m[0 * 3 + 0] - m[1 * 3 + 1] + m[2 * 3 + 2] + 1.0f;
|
||||
float s = XrRcpSqrt(t) * 0.5f;
|
||||
result->z = s * t;
|
||||
result->w = (m[0 * 3 + 1] - m[1 * 3 + 0]) * s;
|
||||
result->x = (m[2 * 3 + 0] + m[0 * 3 + 2]) * s;
|
||||
result->y = (m[1 * 3 + 2] + m[2 * 3 + 1]) * s;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the scale from a combined translation(rotation(scale(object))) matrix.
|
||||
inline static void XrMatrix4x4f_GetScale(XrVector3f* result, const XrMatrix4x4f* src) {
|
||||
assert(XrMatrix4x4f_IsAffine(src, 1e-4f));
|
||||
assert(XrMatrix4x4f_IsOrthogonal(src, 1e-4f));
|
||||
|
||||
result->x = sqrtf(src->m[0] * src->m[0] + src->m[1] * src->m[1] + src->m[2] * src->m[2]);
|
||||
result->y = sqrtf(src->m[4] * src->m[4] + src->m[5] * src->m[5] + src->m[6] * src->m[6]);
|
||||
result->z = sqrtf(src->m[8] * src->m[8] + src->m[9] * src->m[9] + src->m[10] * src->m[10]);
|
||||
}
|
||||
|
||||
// Transforms a 3D vector.
|
||||
inline static void XrMatrix4x4f_TransformVector3f(XrVector3f* result, const XrMatrix4x4f* m, const XrVector3f* v) {
|
||||
const float w = m->m[3] * v->x + m->m[7] * v->y + m->m[11] * v->z + m->m[15];
|
||||
const float rcpW = 1.0f / w;
|
||||
result->x = (m->m[0] * v->x + m->m[4] * v->y + m->m[8] * v->z + m->m[12]) * rcpW;
|
||||
result->y = (m->m[1] * v->x + m->m[5] * v->y + m->m[9] * v->z + m->m[13]) * rcpW;
|
||||
result->z = (m->m[2] * v->x + m->m[6] * v->y + m->m[10] * v->z + m->m[14]) * rcpW;
|
||||
}
|
||||
|
||||
// Transforms a 4D vector.
|
||||
inline static void XrMatrix4x4f_TransformVector4f(XrVector4f* result, const XrMatrix4x4f* m, const XrVector4f* v) {
|
||||
result->x = m->m[0] * v->x + m->m[4] * v->y + m->m[8] * v->z + m->m[12] * v->w;
|
||||
result->y = m->m[1] * v->x + m->m[5] * v->y + m->m[9] * v->z + m->m[13] * v->w;
|
||||
result->z = m->m[2] * v->x + m->m[6] * v->y + m->m[10] * v->z + m->m[14] * v->w;
|
||||
result->w = m->m[3] * v->x + m->m[7] * v->y + m->m[11] * v->z + m->m[15] * v->w;
|
||||
}
|
||||
|
||||
// Transforms the 'mins' and 'maxs' bounds with the given 'matrix'.
|
||||
inline static void XrMatrix4x4f_TransformBounds(XrVector3f* resultMins, XrVector3f* resultMaxs, const XrMatrix4x4f* matrix,
|
||||
const XrVector3f* mins, const XrVector3f* maxs) {
|
||||
assert(XrMatrix4x4f_IsAffine(matrix, 1e-4f));
|
||||
|
||||
const XrVector3f center = {(mins->x + maxs->x) * 0.5f, (mins->y + maxs->y) * 0.5f, (mins->z + maxs->z) * 0.5f};
|
||||
const XrVector3f extents = {maxs->x - center.x, maxs->y - center.y, maxs->z - center.z};
|
||||
const XrVector3f newCenter = {matrix->m[0] * center.x + matrix->m[4] * center.y + matrix->m[8] * center.z + matrix->m[12],
|
||||
matrix->m[1] * center.x + matrix->m[5] * center.y + matrix->m[9] * center.z + matrix->m[13],
|
||||
matrix->m[2] * center.x + matrix->m[6] * center.y + matrix->m[10] * center.z + matrix->m[14]};
|
||||
const XrVector3f newExtents = {
|
||||
fabsf(extents.x * matrix->m[0]) + fabsf(extents.y * matrix->m[4]) + fabsf(extents.z * matrix->m[8]),
|
||||
fabsf(extents.x * matrix->m[1]) + fabsf(extents.y * matrix->m[5]) + fabsf(extents.z * matrix->m[9]),
|
||||
fabsf(extents.x * matrix->m[2]) + fabsf(extents.y * matrix->m[6]) + fabsf(extents.z * matrix->m[10])};
|
||||
XrVector3f_Sub(resultMins, &newCenter, &newExtents);
|
||||
XrVector3f_Add(resultMaxs, &newCenter, &newExtents);
|
||||
}
|
||||
|
||||
// Returns true if the 'mins' and 'maxs' bounds is completely off to one side of the projection matrix.
|
||||
inline static bool XrMatrix4x4f_CullBounds(const XrMatrix4x4f* mvp, const XrVector3f* mins, const XrVector3f* maxs) {
|
||||
if (maxs->x <= mins->x && maxs->y <= mins->y && maxs->z <= mins->z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XrVector4f c[8];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
const XrVector4f corner = {(i & 1) ? maxs->x : mins->x, (i & 2) ? maxs->y : mins->y, (i & 4) ? maxs->z : mins->z, 1.0f};
|
||||
XrMatrix4x4f_TransformVector4f(&c[i], mvp, &corner);
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (c[i].x > -c[i].w) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 8) {
|
||||
return true;
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (c[i].x < c[i].w) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 8) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (c[i].y > -c[i].w) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 8) {
|
||||
return true;
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (c[i].y < c[i].w) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 8) {
|
||||
return true;
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (c[i].z > -c[i].w) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 8) {
|
||||
return true;
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (c[i].z < c[i].w) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 8) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // XR_LINEAR_H_
|
3
extern/openxr/src/common_cmake_config.h.in
vendored
Normal file
3
extern/openxr/src/common_cmake_config.h.in
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#cmakedefine HAVE_SECURE_GETENV
|
||||
#cmakedefine HAVE___SECURE_GETENV
|
||||
#cmakedefine XRLOADER_ENABLE_EXCEPTION_HANDLING
|
183
extern/openxr/src/loader/CMakeLists.txt
vendored
Normal file
183
extern/openxr/src/loader/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
# Copyright (c) 2017 The Khronos Group Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author:
|
||||
#
|
||||
|
||||
#set (CMAKE_VERBOSE_MAKEFILE 1)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Use this feature for Windows to automatically generate an exports file for the DLL.
|
||||
# See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
|
||||
include(GenerateExportHeader)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS false)
|
||||
|
||||
set(LOADER_NAME openxr_loader)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(FALLBACK_CONFIG_DIRS "/etc/xdg" CACHE STRING
|
||||
"Search path to use when XDG_CONFIG_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")
|
||||
set(FALLBACK_DATA_DIRS "/usr/local/share:/usr/share" CACHE STRING
|
||||
"Search path to use when XDG_DATA_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(openxr_loader_RESOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/loader.rc)
|
||||
set(LOADER_NAME ${LOADER_NAME}-${MAJOR}_${MINOR})
|
||||
endif()
|
||||
|
||||
# List of all files externally generated outside of the loader that the loader
|
||||
# needs to build with.
|
||||
SET(LOADER_EXTERNAL_GEN_FILES
|
||||
${COMMON_GENERATED_OUTPUT}
|
||||
)
|
||||
run_xr_xml_generate(loader_source_generator.py xr_generated_loader.hpp)
|
||||
run_xr_xml_generate(loader_source_generator.py xr_generated_loader.cpp)
|
||||
|
||||
if(DYNAMIC_LOADER)
|
||||
add_definitions(-DXRAPI_DLL_EXPORT)
|
||||
set(LIBRARY_TYPE SHARED)
|
||||
else() # build static lib
|
||||
set(LIBRARY_TYPE STATIC)
|
||||
endif()
|
||||
|
||||
set(JSONCPP_ROOT_DIR ${CMAKE_SOURCE_DIR}/extern/jsoncpp)
|
||||
|
||||
add_library(${LOADER_NAME} ${LIBRARY_TYPE}
|
||||
api_layer_interface.cpp
|
||||
api_layer_interface.hpp
|
||||
loader_core.cpp
|
||||
loader_instance.cpp
|
||||
loader_instance.hpp
|
||||
loader_logger.cpp
|
||||
loader_logger.hpp
|
||||
loader_logger_recorders.cpp
|
||||
loader_logger_recorders.hpp
|
||||
manifest_file.cpp
|
||||
${GENERATED_OUTPUT}
|
||||
manifest_file.hpp
|
||||
runtime_interface.cpp
|
||||
runtime_interface.hpp
|
||||
${OPENXR_ROOT_DIR}/src/common/filesystem_utils.cpp
|
||||
${OPENXR_ROOT_DIR}/src/common/filesystem_utils.hpp
|
||||
${OPENXR_ROOT_DIR}/src/common/hex_and_handles.cpp
|
||||
${OPENXR_ROOT_DIR}/src/common/hex_and_handles.h
|
||||
${JSONCPP_ROOT_DIR}/src/json_reader.cpp
|
||||
${JSONCPP_ROOT_DIR}/src/json_value.cpp
|
||||
${JSONCPP_ROOT_DIR}/src/json_writer.cpp
|
||||
${LOADER_EXTERNAL_GEN_FILES}
|
||||
${openxr_loader_RESOURCE_FILE}
|
||||
)
|
||||
set_target_properties(${LOADER_NAME} PROPERTIES FOLDER ${LOADER_FOLDER})
|
||||
|
||||
set_source_files_properties(
|
||||
${LOADER_EXTERNAL_GEN_FILES}
|
||||
PROPERTIES GENERATED TRUE
|
||||
)
|
||||
add_dependencies(${LOADER_NAME}
|
||||
generate_openxr_header
|
||||
xr_global_generated_files
|
||||
)
|
||||
target_include_directories(${LOADER_NAME}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||
PRIVATE ${CMAKE_BINARY_DIR}/include
|
||||
PRIVATE ${CMAKE_BINARY_DIR}/src
|
||||
PRIVATE ${OPENXR_ROOT_DIR}/src/common
|
||||
PRIVATE ${JSONCPP_ROOT_DIR}/include
|
||||
)
|
||||
if(VulkanHeaders_FOUND)
|
||||
target_include_directories(${LOADER_NAME}
|
||||
PRIVATE ${Vulkan_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${LOADER_NAME}
|
||||
PRIVATE API_NAME="OpenXR"
|
||||
)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_compile_definitions(${LOADER_NAME}
|
||||
PRIVATE FALLBACK_CONFIG_DIRS="${FALLBACK_CONFIG_DIRS}"
|
||||
PRIVATE FALLBACK_DATA_DIRS="${FALLBACK_DATA_DIRS}"
|
||||
PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}"
|
||||
)
|
||||
if(NOT(CMAKE_INSTALL_FULL_SYSCONFDIR STREQUAL "/etc"))
|
||||
target_compile_definitions(openxr_loader PRIVATE EXTRASYSCONFDIR="/etc")
|
||||
endif()
|
||||
|
||||
set_target_properties(${LOADER_NAME} PROPERTIES SOVERSION "${MAJOR}" VERSION "${MAJOR}.${MINOR}.${PATCH}")
|
||||
target_link_libraries(${LOADER_NAME} -lstdc++fs -ldl -lpthread -lm)
|
||||
|
||||
add_custom_target(lib${LOADER_NAME}.so.${MAJOR}.${MINOR} ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink lib${LOADER_NAME}.so.${MAJOR}.${MINOR}.${PATCH} lib${LOADER_NAME}.so.${MAJOR}.${MINOR})
|
||||
|
||||
install(TARGETS ${LOADER_NAME}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
set(XR_API_VERSION "${MAJOR}.${MINOR}")
|
||||
configure_file("openxr.pc.in" "openxr.pc" @ONLY)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/openxr.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
foreach(configuration in CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
# If building DLLs, force static CRT linkage
|
||||
if(DYNAMIC_LOADER)
|
||||
if (${configuration} MATCHES "/MD")
|
||||
# string(REGEX REPLACE "/MD" "/MT" ${configuration} "${${configuration}}")
|
||||
endif()
|
||||
else() # Otherwise for static libs, link the CRT dynamically
|
||||
if (${configuration} MATCHES "/MT")
|
||||
# string(REGEX REPLACE "/MT" "/MD" ${configuration} "${${configuration}}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
target_link_libraries(${LOADER_NAME} shlwapi)
|
||||
target_compile_options(${LOADER_NAME} PRIVATE)
|
||||
generate_export_header(${LOADER_NAME})
|
||||
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS false)
|
||||
|
||||
# Need to copy DLL to client directories so clients can easily load it.
|
||||
if( (DYNAMIC_LOADER) AND (CMAKE_GENERATOR MATCHES "^Visual Studio.*") )
|
||||
file( TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${LOADER_NAME}.dll COPY_SRC_PATH )
|
||||
# file( TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/triangle/$<CONFIGURATION>/ COPY_DST_TEST_PATH )
|
||||
file( TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/hello_xr/$<CONFIGURATION>/ COPY_DST_TEST_PATH )
|
||||
file( TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/loader_test/$<CONFIGURATION>/ COPY_DST_LOADER_TEST_PATH )
|
||||
add_custom_command( TARGET ${LOADER_NAME} POST_BUILD
|
||||
COMMAND xcopy /Y /I ${COPY_SRC_PATH} ${COPY_DST_TEST_PATH}
|
||||
COMMAND xcopy /Y /I ${COPY_SRC_PATH} ${COPY_DST_LOADER_TEST_PATH}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(openxr_loader
|
||||
PRIVATE -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wpointer-arith
|
||||
PRIVATE -fno-strict-aliasing -fno-builtin-memcmp "$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>"
|
||||
)
|
||||
# For GCC version 7.1 or greater, we need to disable the implicit fallthrough warning since
|
||||
# there's no consistent way to satisfy all compilers until they all accept the C++17 standard
|
||||
if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_CXX_COMPILER_VERSION LESS 7.1))
|
||||
target_compile_options(openxr_loader PRIVATE -Wimplicit-fallthrough=0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS ${LOADER_NAME} DESTINATION lib)
|
||||
|
||||
# Custom commands to build dependencies for above targets
|
403
extern/openxr/src/loader/api_layer_interface.cpp
vendored
Normal file
403
extern/openxr/src/loader/api_layer_interface.cpp
vendored
Normal file
@@ -0,0 +1,403 @@
|
||||
// Copyright (c) 2017-2019 The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2019 Valve Corporation
|
||||
// Copyright (c) 2017-2019 LunarG, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#include "api_layer_interface.hpp"
|
||||
|
||||
#include "loader_interfaces.h"
|
||||
#include "loader_logger.hpp"
|
||||
#include "loader_platform.hpp"
|
||||
#include "manifest_file.hpp"
|
||||
#include "platform_utils.hpp"
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#define OPENXR_ENABLE_LAYERS_ENV_VAR "XR_ENABLE_API_LAYERS"
|
||||
|
||||
// Add any layers defined in the loader layer environment variable.
|
||||
static void AddEnvironmentApiLayers(const std::string& openxr_command, std::vector<std::string>& enabled_layers) {
|
||||
char* layer_environment_variable = PlatformUtilsGetEnv(OPENXR_ENABLE_LAYERS_ENV_VAR);
|
||||
if (nullptr != layer_environment_variable) {
|
||||
std::string layers = layer_environment_variable;
|
||||
PlatformUtilsFreeEnv(layer_environment_variable);
|
||||
|
||||
std::size_t last_found = 0;
|
||||
std::size_t found = layers.find_first_of(PATH_SEPARATOR);
|
||||
std::string cur_search;
|
||||
|
||||
// Handle any path listings in the string (separated by the appropriate path separator)
|
||||
while (found != std::string::npos) {
|
||||
cur_search = layers.substr(last_found, found);
|
||||
enabled_layers.push_back(cur_search);
|
||||
last_found = found + 1;
|
||||
found = layers.find_first_of(PATH_SEPARATOR, last_found);
|
||||
}
|
||||
|
||||
// If there's something remaining in the string, copy it over
|
||||
if (last_found < layers.size()) {
|
||||
cur_search = layers.substr(last_found);
|
||||
enabled_layers.push_back(cur_search);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XrResult ApiLayerInterface::GetApiLayerProperties(const std::string& openxr_command, uint32_t incoming_count,
|
||||
uint32_t* outgoing_count, XrApiLayerProperties* api_layer_properties) {
|
||||
std::vector<std::unique_ptr<ApiLayerManifestFile>> manifest_files;
|
||||
uint32_t manifest_count = 0;
|
||||
|
||||
// Find any implicit layers which we may need to report information for.
|
||||
XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files);
|
||||
if (XR_SUCCESS == result) {
|
||||
// Find any explicit layers which we may need to report information for.
|
||||
result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, manifest_files);
|
||||
}
|
||||
if (XR_SUCCESS != result) {
|
||||
LoaderLogger::LogErrorMessage(openxr_command,
|
||||
"ApiLayerInterface::GetApiLayerProperties - failed searching for API layer manifest files");
|
||||
return result;
|
||||
}
|
||||
|
||||
manifest_count = static_cast<uint32_t>(manifest_files.size());
|
||||
if (0 == incoming_count) {
|
||||
if (nullptr == outgoing_count) {
|
||||
return XR_ERROR_VALIDATION_FAILURE;
|
||||
}
|
||||
*outgoing_count = manifest_count;
|
||||
} else if (nullptr != api_layer_properties) {
|
||||
if (incoming_count < manifest_count && nullptr != api_layer_properties) {
|
||||
LoaderLogger::LogErrorMessage(
|
||||
"xrEnumerateInstanceExtensionProperties",
|
||||
"VUID-xrEnumerateApiLayerProperties-propertyCapacityInput-parameter: insufficient space in array");
|
||||
*outgoing_count = manifest_count;
|
||||
return XR_ERROR_SIZE_INSUFFICIENT;
|
||||
}
|
||||
|
||||
uint32_t prop = 0;
|
||||
bool properties_valid = true;
|
||||
for (; prop < incoming_count && prop < manifest_count; ++prop) {
|
||||
if (XR_TYPE_API_LAYER_PROPERTIES != api_layer_properties[prop].type) {
|
||||
LoaderLogger::LogErrorMessage(openxr_command,
|
||||
"VUID-XrApiLayerProperties-type-type: unknown type in api_layer_properties");
|
||||
properties_valid = false;
|
||||
}
|
||||
if (nullptr != api_layer_properties[prop].next) {
|
||||
LoaderLogger::LogErrorMessage(openxr_command, "VUID-XrApiLayerProperties-next-next: expected NULL");
|
||||
properties_valid = false;
|
||||
}
|
||||
if (properties_valid) {
|
||||
api_layer_properties[prop] = manifest_files[prop]->GetApiLayerProperties();
|
||||
}
|
||||
}
|
||||
if (!properties_valid) {
|
||||
LoaderLogger::LogErrorMessage(openxr_command,
|
||||
"VUID-xrEnumerateApiLayerProperties-properties-parameter: invalid properties");
|
||||
return XR_ERROR_VALIDATION_FAILURE;
|
||||
}
|
||||
if (nullptr != outgoing_count) {
|
||||
*outgoing_count = prop;
|
||||
}
|
||||
}
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
XrResult ApiLayerInterface::GetInstanceExtensionProperties(const std::string& openxr_command, const char* layer_name,
|
||||
std::vector<XrExtensionProperties>& extension_properties) {
|
||||
std::vector<std::unique_ptr<ApiLayerManifestFile>> manifest_files;
|
||||
|
||||
// If a layer name is supplied, only use the information out of that one layer
|
||||
if (nullptr != layer_name && 0 != strlen(layer_name)) {
|
||||
XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files);
|
||||
if (XR_SUCCESS == result) {
|
||||
// Find any explicit layers which we may need to report information for.
|
||||
result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, manifest_files);
|
||||
if (XR_SUCCESS != result) {
|
||||
LoaderLogger::LogErrorMessage(
|
||||
openxr_command,
|
||||
"ApiLayerInterface::GetInstanceExtensionProperties - failed searching for API layer manifest files");
|
||||
return result;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
auto num_files = static_cast<uint32_t>(manifest_files.size());
|
||||
for (uint32_t man_file = 0; man_file < num_files; ++man_file) {
|
||||
// If a layer with the provided name exists, get it's instance extension information.
|
||||
if (manifest_files[man_file]->LayerName() == layer_name) {
|
||||
manifest_files[man_file]->GetInstanceExtensionProperties(extension_properties);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If nothing found, report 0
|
||||
if (!found) {
|
||||
return XR_ERROR_API_LAYER_NOT_PRESENT;
|
||||
}
|
||||
}
|
||||
// Otherwise, we want to add only implicit API layers and explicit API layers enabled using the environment variables
|
||||
} else {
|
||||
XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files);
|
||||
if (XR_SUCCESS == result) {
|
||||
// Find any environmentally enabled explicit layers. If they're present, treat them like implicit layers
|
||||
// since we know that they're going to be enabled.
|
||||
std::vector<std::string> env_enabled_layers;
|
||||
AddEnvironmentApiLayers(openxr_command, env_enabled_layers);
|
||||
if (!env_enabled_layers.empty()) {
|
||||
std::vector<std::unique_ptr<ApiLayerManifestFile>> exp_layer_man_files = {};
|
||||
result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, exp_layer_man_files);
|
||||
if (XR_SUCCESS == result) {
|
||||
for (auto l_iter = exp_layer_man_files.begin();
|
||||
!exp_layer_man_files.empty() && l_iter != exp_layer_man_files.end();
|
||||
/* No iterate */) {
|
||||
for (std::string& enabled_layer : env_enabled_layers) {
|
||||
// If this is an enabled layer, transfer it over to the manifest list.
|
||||
if (enabled_layer == (*l_iter)->LayerName()) {
|
||||
manifest_files.push_back(std::move(*l_iter));
|
||||
break;
|
||||
}
|
||||
}
|
||||
exp_layer_man_files.erase(l_iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Grab the layer instance extensions information
|
||||
auto num_files = static_cast<uint32_t>(manifest_files.size());
|
||||
for (uint32_t man_file = 0; man_file < num_files; ++man_file) {
|
||||
manifest_files[man_file]->GetInstanceExtensionProperties(extension_properties);
|
||||
}
|
||||
}
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uint32_t enabled_api_layer_count,
|
||||
const char* const* enabled_api_layer_names,
|
||||
std::vector<std::unique_ptr<ApiLayerInterface>>& api_layer_interfaces) {
|
||||
XrResult last_error = XR_SUCCESS;
|
||||
bool any_loaded = false;
|
||||
std::vector<bool> layer_found;
|
||||
std::vector<std::unique_ptr<ApiLayerManifestFile>> layer_manifest_files = {};
|
||||
|
||||
// Find any implicit layers which we may need to report information for.
|
||||
XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, layer_manifest_files);
|
||||
if (XR_SUCCESS == result) {
|
||||
// Find any explicit layers which we may need to report information for.
|
||||
result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, layer_manifest_files);
|
||||
}
|
||||
|
||||
// Put all the enabled layers into a string vector
|
||||
std::vector<std::string> enabled_api_layers = {};
|
||||
AddEnvironmentApiLayers(openxr_command, enabled_api_layers);
|
||||
if (enabled_api_layer_count > 0) {
|
||||
if (nullptr == enabled_api_layer_names) {
|
||||
LoaderLogger::LogErrorMessage(
|
||||
"xrCreateInstance",
|
||||
"VUID-XrInstanceCreateInfo-enabledApiLayerNames-parameter: enabledApiLayerCount is non-0 but array is NULL");
|
||||
LoaderLogger::LogErrorMessage(
|
||||
"xrCreateInstance", "VUID-xrCreateInstance-info-parameter: something wrong with XrInstanceCreateInfo contents");
|
||||
return XR_ERROR_VALIDATION_FAILURE;
|
||||
}
|
||||
auto num_env_api_layers = static_cast<uint32_t>(enabled_api_layers.size());
|
||||
uint32_t total_api_layers = num_env_api_layers + enabled_api_layer_count;
|
||||
enabled_api_layers.resize(total_api_layers);
|
||||
for (uint32_t layer = 0; layer < enabled_api_layer_count; ++layer) {
|
||||
enabled_api_layers[num_env_api_layers + layer] = enabled_api_layer_names[layer];
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the layer found vector to false
|
||||
layer_found.resize(enabled_api_layers.size());
|
||||
for (auto&& layer : layer_found) {
|
||||
layer = false;
|
||||
}
|
||||
|
||||
for (std::unique_ptr<ApiLayerManifestFile>& manifest_file : layer_manifest_files) {
|
||||
bool enabled = false;
|
||||
|
||||
// Always add implicit layers. They would only be in this list if they were enabled
|
||||
// (i.e. the disable environment variable is not set).
|
||||
if (manifest_file->Type() == MANIFEST_TYPE_IMPLICIT_API_LAYER) {
|
||||
enabled = true;
|
||||
} else {
|
||||
// Only add explicit layers if they are called out by the application
|
||||
for (uint32_t layer = 0; layer < enabled_api_layers.size(); ++layer) {
|
||||
if (enabled_api_layers[layer] == manifest_file->LayerName()) {
|
||||
layer_found[layer] = true;
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this layer isn't enabled, skip it.
|
||||
if (!enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LoaderPlatformLibraryHandle layer_library = LoaderPlatformLibraryOpen(manifest_file->LibraryPath());
|
||||
if (nullptr == layer_library) {
|
||||
if (!any_loaded) {
|
||||
last_error = XR_ERROR_FILE_ACCESS_ERROR;
|
||||
}
|
||||
std::string library_message = LoaderPlatformLibraryOpenError(manifest_file->LibraryPath());
|
||||
std::string warning_message = "ApiLayerInterface::LoadApiLayers skipping layer ";
|
||||
warning_message += manifest_file->LayerName();
|
||||
warning_message += ", failed to load with message \"";
|
||||
warning_message += library_message;
|
||||
warning_message += "\"";
|
||||
LoaderLogger::LogWarningMessage(openxr_command, warning_message);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get and settle on an layer interface version (using any provided name if required).
|
||||
std::string function_name = manifest_file->GetFunctionName("xrNegotiateLoaderApiLayerInterface");
|
||||
auto negotiate = reinterpret_cast<PFN_xrNegotiateLoaderApiLayerInterface>(
|
||||
LoaderPlatformLibraryGetProcAddr(layer_library, function_name));
|
||||
|
||||
if (nullptr == negotiate) {
|
||||
std::ostringstream oss;
|
||||
oss << "ApiLayerInterface::LoadApiLayers skipping layer " << manifest_file->LayerName()
|
||||
<< " because negotiation function " << function_name << " was not found";
|
||||
LoaderLogger::LogErrorMessage(openxr_command, oss.str());
|
||||
LoaderPlatformLibraryClose(layer_library);
|
||||
last_error = XR_ERROR_API_LAYER_NOT_PRESENT;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Loader info for negotiation
|
||||
XrNegotiateLoaderInfo loader_info = {};
|
||||
loader_info.structType = XR_LOADER_INTERFACE_STRUCT_LOADER_INFO;
|
||||
loader_info.structVersion = XR_LOADER_INFO_STRUCT_VERSION;
|
||||
loader_info.structSize = sizeof(XrNegotiateLoaderInfo);
|
||||
loader_info.minInterfaceVersion = 1;
|
||||
loader_info.maxInterfaceVersion = XR_CURRENT_LOADER_API_LAYER_VERSION;
|
||||
loader_info.minApiVersion = XR_MAKE_VERSION(1, 0, 0);
|
||||
loader_info.maxApiVersion = XR_MAKE_VERSION(1, 0x3ff, 0xfff); // Maximum allowed version for this major version.
|
||||
|
||||
// Set up the layer return structure
|
||||
XrNegotiateApiLayerRequest api_layer_info = {};
|
||||
api_layer_info.structType = XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST;
|
||||
api_layer_info.structVersion = XR_API_LAYER_INFO_STRUCT_VERSION;
|
||||
api_layer_info.structSize = sizeof(XrNegotiateApiLayerRequest);
|
||||
|
||||
XrResult res = negotiate(&loader_info, manifest_file->LayerName().c_str(), &api_layer_info);
|
||||
// If we supposedly succeeded, but got a nullptr for getInstanceProcAddr
|
||||
// then something still went wrong, so return with an error.
|
||||
if (XR_SUCCESS == res && nullptr == api_layer_info.getInstanceProcAddr) {
|
||||
std::string warning_message = "ApiLayerInterface::LoadApiLayers skipping layer ";
|
||||
warning_message += manifest_file->LayerName();
|
||||
warning_message += ", negotiation did not return a valid getInstanceProcAddr";
|
||||
LoaderLogger::LogWarningMessage(openxr_command, warning_message);
|
||||
res = XR_ERROR_FILE_CONTENTS_INVALID;
|
||||
}
|
||||
if (XR_SUCCESS != res) {
|
||||
if (!any_loaded) {
|
||||
last_error = res;
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << "ApiLayerInterface::LoadApiLayers skipping layer " << manifest_file->LayerName()
|
||||
<< " due to failed negotiation with error " << res;
|
||||
LoaderLogger::LogWarningMessage(openxr_command, oss.str());
|
||||
LoaderPlatformLibraryClose(layer_library);
|
||||
continue;
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "ApiLayerInterface::LoadApiLayers succeeded loading layer " << manifest_file->LayerName()
|
||||
<< " using interface version " << api_layer_info.layerInterfaceVersion << " and OpenXR API version "
|
||||
<< XR_VERSION_MAJOR(api_layer_info.layerApiVersion) << "." << XR_VERSION_MINOR(api_layer_info.layerApiVersion);
|
||||
LoaderLogger::LogInfoMessage(openxr_command, oss.str());
|
||||
}
|
||||
|
||||
// Grab the list of extensions this layer supports for easy filtering after the
|
||||
// xrCreateInstance call
|
||||
std::vector<std::string> supported_extensions;
|
||||
std::vector<XrExtensionProperties> extension_properties;
|
||||
manifest_file->GetInstanceExtensionProperties(extension_properties);
|
||||
supported_extensions.reserve(extension_properties.size());
|
||||
for (XrExtensionProperties& ext_prop : extension_properties) {
|
||||
supported_extensions.emplace_back(ext_prop.extensionName);
|
||||
}
|
||||
|
||||
// Add this runtime to the vector
|
||||
api_layer_interfaces.emplace_back(new ApiLayerInterface(manifest_file->LayerName(), layer_library, supported_extensions,
|
||||
api_layer_info.getInstanceProcAddr,
|
||||
api_layer_info.createApiLayerInstance));
|
||||
|
||||
// If we load one, clear all errors.
|
||||
any_loaded = true;
|
||||
last_error = XR_SUCCESS;
|
||||
}
|
||||
|
||||
// If even one of the layers wasn't found, we want to return an error
|
||||
for (uint32_t layer = 0; layer < layer_found.size(); ++layer) {
|
||||
if (!layer_found[layer]) {
|
||||
std::string error_message = "ApiLayerInterface::LoadApiLayers - failed to find layer ";
|
||||
error_message += enabled_api_layers[layer];
|
||||
LoaderLogger::LogErrorMessage(openxr_command, error_message);
|
||||
last_error = XR_ERROR_API_LAYER_NOT_PRESENT;
|
||||
}
|
||||
}
|
||||
|
||||
// Always clear the manifest file list. Either we use them or we don't.
|
||||
layer_manifest_files.clear();
|
||||
|
||||
// If we failed catastrophically for some reason, clean up everything.
|
||||
if (XR_SUCCESS != last_error) {
|
||||
api_layer_interfaces.clear();
|
||||
}
|
||||
|
||||
return last_error;
|
||||
}
|
||||
|
||||
ApiLayerInterface::ApiLayerInterface(const std::string& layer_name, LoaderPlatformLibraryHandle layer_library,
|
||||
std::vector<std::string>& supported_extensions,
|
||||
PFN_xrGetInstanceProcAddr get_instant_proc_addr,
|
||||
PFN_xrCreateApiLayerInstance create_api_layer_instance)
|
||||
: _layer_name(layer_name),
|
||||
_layer_library(layer_library),
|
||||
_get_instant_proc_addr(get_instant_proc_addr),
|
||||
_create_api_layer_instance(create_api_layer_instance),
|
||||
_supported_extensions(supported_extensions) {}
|
||||
|
||||
ApiLayerInterface::~ApiLayerInterface() {
|
||||
std::string info_message = "ApiLayerInterface being destroyed for layer ";
|
||||
info_message += _layer_name;
|
||||
LoaderLogger::LogInfoMessage("", info_message);
|
||||
LoaderPlatformLibraryClose(_layer_library);
|
||||
}
|
||||
|
||||
bool ApiLayerInterface::SupportsExtension(const std::string& extension_name) {
|
||||
bool found_prop = false;
|
||||
for (const std::string& supported_extension : _supported_extensions) {
|
||||
if (supported_extension == extension_name) {
|
||||
found_prop = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found_prop;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user