mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
Compare commits
923 Commits
vkd3d-1.15
...
vkd3d-1.17
Author | SHA1 | Date | |
---|---|---|---|
|
f732fb7889 | ||
|
44fffee5e1 | ||
|
bb2a6a0322 | ||
|
975ba8f9da | ||
|
7007a1e264 | ||
|
cab0bd07e5 | ||
|
9336b4647c | ||
|
8334386d99 | ||
|
880cb1083f | ||
|
a91b880afa | ||
|
0ed34c22c9 | ||
|
14643b02f6 | ||
|
bd52ed8918 | ||
|
f7890fc54c | ||
|
f95fc28851 | ||
|
85603dc9c6 | ||
|
e7be5aa9fd | ||
|
7c37fc6a8b | ||
|
e4bb77ecef | ||
|
f9bb84e5ef | ||
|
731b94f6f9 | ||
|
9c605c942c | ||
|
a4f69d4ae6 | ||
|
2201c32e6d | ||
|
f6d0c689ee | ||
|
aab02b1bca | ||
|
6c840b80d6 | ||
|
e428528a7c | ||
|
f818d052cd | ||
|
b3badec039 | ||
|
304caa885f | ||
|
37ca1b55c9 | ||
|
97e3877aa4 | ||
|
6dc9ff1bd8 | ||
|
ce20f9d4b2 | ||
|
47a183c75b | ||
|
4bb880f9ed | ||
|
8d0d8d106b | ||
|
c8d2d40b91 | ||
|
fa560b589e | ||
|
3802344e97 | ||
|
e615e435d9 | ||
|
e718546ee5 | ||
|
5dbf859029 | ||
|
161d463f3c | ||
|
721859005f | ||
|
243207701b | ||
|
5dca0da2da | ||
|
be5a9c2ca8 | ||
|
81488ce330 | ||
|
8717fe9c47 | ||
|
3817df1164 | ||
|
d898923b1c | ||
|
1d71cf9af1 | ||
|
bec000b88e | ||
|
691dd49e49 | ||
|
1293db7536 | ||
|
bd3d0f3495 | ||
|
b9fe19701c | ||
|
cd8cea6913 | ||
|
55fe8df979 | ||
|
74d8c23f71 | ||
|
d0ce3e61bf | ||
|
75cb4336ec | ||
|
67fd9bb76b | ||
|
f6a9def564 | ||
|
bb2979aa4c | ||
|
49b857c5b7 | ||
|
dbaecb3f36 | ||
|
6805612918 | ||
|
247fbd869a | ||
|
812f6faa11 | ||
|
50afaf4ac6 | ||
|
aba355896f | ||
|
22f84317c0 | ||
|
3797c922a5 | ||
|
52b9ef0426 | ||
|
53754f0583 | ||
|
bdccdd9996 | ||
|
f7866df201 | ||
|
3cf35ce22e | ||
|
7df92b6e50 | ||
|
9476a235b2 | ||
|
16b06c295b | ||
|
6ed0bd0bab | ||
|
19bc3ec104 | ||
|
3a0a96b851 | ||
|
a4f5225229 | ||
|
2c49f04411 | ||
|
dcd1747f12 | ||
|
0652cb4adb | ||
|
9b0087a111 | ||
|
b3cac7b86d | ||
|
eaebef4265 | ||
|
4300e6c8b5 | ||
|
b3e367b099 | ||
|
a4c25b81c5 | ||
|
f02405350e | ||
|
b88be5b92b | ||
|
b8c73e4a2c | ||
|
ed2a06af35 | ||
|
7295a8d0b5 | ||
|
795211141f | ||
|
aebe64ecac | ||
|
f74b56622a | ||
|
ca24aada9a | ||
|
b055a16e03 | ||
|
ed695cc551 | ||
|
ed27427508 | ||
|
2f4be1dbb6 | ||
|
17ffd21113 | ||
|
bb51b976df | ||
|
83e54bdc0c | ||
|
969b6f5946 | ||
|
a7266284ee | ||
|
db80f09c7a | ||
|
f4d95af91d | ||
|
66895e2605 | ||
|
844f33025e | ||
|
f420e25fd5 | ||
|
68cd72c7fc | ||
|
b3db78e3c1 | ||
|
f3f8056800 | ||
|
59738c7a4a | ||
|
6266f89827 | ||
|
1c7c66912b | ||
|
4789295e91 | ||
|
3234c428b3 | ||
|
14ee6b86e0 | ||
|
4a1ca99cba | ||
|
42f53c82f3 | ||
|
ddb65aac35 | ||
|
01068dada2 | ||
|
7d9a86790e | ||
|
7e76e62db7 | ||
|
0789578175 | ||
|
b4bf2af315 | ||
|
1487764e23 | ||
|
742cce9a08 | ||
|
163b87444f | ||
|
40bbd61abd | ||
|
a04e4e4010 | ||
|
8f05fbc75d | ||
|
13c9826c30 | ||
|
7b36453b9d | ||
|
b3c1fb6740 | ||
|
dfc18781cc | ||
|
b02c3759be | ||
|
226afa47c4 | ||
|
f0906e9c5c | ||
|
decc155cca | ||
|
079e989b8e | ||
|
f5cd0b4a15 | ||
|
59253a5e7f | ||
|
834f762cb5 | ||
|
18ef9a4f9f | ||
|
9f453fbb66 | ||
|
3d23ef6bf8 | ||
|
ee0447b973 | ||
|
61c46f95da | ||
|
87545dc4fd | ||
|
366c899a00 | ||
|
5dd226ffeb | ||
|
2237e251fa | ||
|
34cb8c63f4 | ||
|
a8e8a9ee64 | ||
|
db149cd8cf | ||
|
c5c1c03430 | ||
|
d1dcbc26e5 | ||
|
0126beb3b2 | ||
|
53dd048ad5 | ||
|
8d4222764c | ||
|
5407c8b975 | ||
|
55b8002bf6 | ||
|
c1f7720075 | ||
|
0f18d25987 | ||
|
faeff50548 | ||
|
a9a5c77222 | ||
|
7e9834ee36 | ||
|
f08fed5ffb | ||
|
28f74a73aa | ||
|
4f5d34265c | ||
|
9836c88ac6 | ||
|
7e66d0db6f | ||
|
e9d3b9dfd3 | ||
|
a7807dea08 | ||
|
ccc82a184b | ||
|
2c1d210d21 | ||
|
791a93d0b1 | ||
|
68ad2becdb | ||
|
fb1fc9eb38 | ||
|
df18a05303 | ||
|
b287e7959c | ||
|
195e62430e | ||
|
a12d64fba1 | ||
|
9867d48c3a | ||
|
2d848b5bc0 | ||
|
ba545669cd | ||
|
126ff8e4f5 | ||
|
94d999bd8a | ||
|
636e9a91bb | ||
|
7d92142fe0 | ||
|
d288d3c088 | ||
|
2a62b7035c | ||
|
5fc8baabfb | ||
|
56247130c1 | ||
|
32bf71ba96 | ||
|
9c040caa40 | ||
|
5c0e6747b8 | ||
|
39db6731c0 | ||
|
3163e589bc | ||
|
46c75137c7 | ||
|
1a5a2969be | ||
|
fb91bd7b8b | ||
|
fc77bddb9c | ||
|
15561c1e56 | ||
|
44ca7b7b1b | ||
|
ad1aa739c2 | ||
|
b6725a3a00 | ||
|
00f53b72a1 | ||
|
673c26a040 | ||
|
1a20395e6f | ||
|
955fff7570 | ||
|
90b6412daa | ||
|
ed464a4f4c | ||
|
715d23ebbb | ||
|
9f455667eb | ||
|
c29e8188ff | ||
|
4d1fabd350 | ||
|
e954f75862 | ||
|
5dd452a5c7 | ||
|
cc42581a34 | ||
|
395d456386 | ||
|
98b0ca544a | ||
|
0c3250122c | ||
|
f2238deea9 | ||
|
e312207124 | ||
|
b58ff893a5 | ||
|
587c2dc76e | ||
|
04d3996b07 | ||
|
22ebccfeb7 | ||
|
043f6f21b0 | ||
|
96cd4cc954 | ||
|
3376015d88 | ||
|
3c469edc8e | ||
|
e267ea9551 | ||
|
8feeb07900 | ||
|
32cab7c81e | ||
|
afec7cc96b | ||
|
8cf7a12502 | ||
|
a6e6e36994 | ||
|
17b0e0d1d9 | ||
|
596f02210d | ||
|
82ef9bf2e5 | ||
|
78e0f8412d | ||
|
ada09d003d | ||
|
823a8724de | ||
|
f4a4e2afec | ||
|
752a48f4ac | ||
|
543ee120fc | ||
|
b9ce945e61 | ||
|
06a0453762 | ||
|
cdfaeb209a | ||
|
d219cccc99 | ||
|
cd43ab1ca2 | ||
|
bcb2acbdab | ||
|
a1eb53df3c | ||
|
ecb19b33ba | ||
|
41cacba5ce | ||
|
3a4f95aca6 | ||
|
5452e79a19 | ||
|
c2a01fff1e | ||
|
6f8ce6df72 | ||
|
449804623a | ||
|
841cf65a41 | ||
|
3cc404759d | ||
|
99db7270f0 | ||
|
cbd508fce6 | ||
|
7acebfc978 | ||
|
6bf25800c2 | ||
|
95e095992d | ||
|
96bb2953cc | ||
|
ad320776a1 | ||
|
19c2734d31 | ||
|
bcaa1d50b0 | ||
|
1862c28b90 | ||
|
318d7466a8 | ||
|
65c23999e8 | ||
|
0252e2e660 | ||
|
85dcbf7a51 | ||
|
31581b0002 | ||
|
4a39db797b | ||
|
f3dec58423 | ||
|
4ede2f1365 | ||
|
84a0a8ae86 | ||
|
3bf232e841 | ||
|
d8edf20c2b | ||
|
dda2ec1814 | ||
|
b8cbe03308 | ||
|
ba5d5a8091 | ||
|
92c711a7d5 | ||
|
3537feb45c | ||
|
43a29044d6 | ||
|
9f9cf59b6e | ||
|
99d61aeb89 | ||
|
f6af47f9b6 | ||
|
bc4dda75dd | ||
|
6ef23544f4 | ||
|
2d783da3a7 | ||
|
eec2b13dc6 | ||
|
a115cd9ec0 | ||
|
402c2bf10a | ||
|
32746c664d | ||
|
2f4038bae7 | ||
|
bd4681622d | ||
|
dc33622919 | ||
|
666eb98ab6 | ||
|
227df56c6c | ||
|
2b922e6b8e | ||
|
ead690a17a | ||
|
be2c8041d0 | ||
|
e5bf48a2ba | ||
|
83979ec07a | ||
|
2e0cbff3a0 | ||
|
e0359c5299 | ||
|
cf726cf521 | ||
|
46265061c3 | ||
|
db89687807 | ||
|
f30510a9b3 | ||
|
0c8bc0f42c | ||
|
af8b3f94e7 | ||
|
d5237ec1cc | ||
|
288020bce8 | ||
|
7b9d04fff8 | ||
|
5e4c61eba6 | ||
|
34dbd60e01 | ||
|
9d490b83d4 | ||
|
c3110d2f94 | ||
|
a410c448ce | ||
|
f135f7fe07 | ||
|
93e1a8c784 | ||
|
37c2f709d1 | ||
|
6f092fb84a | ||
|
322f2e5496 | ||
|
b7fbd3c0f0 | ||
|
3689d3076c | ||
|
e1ca552173 | ||
|
b2e1c3b90a | ||
|
eb3383b04e | ||
|
46fac7f264 | ||
|
4da83fe83b | ||
|
813021e60b | ||
|
16e142465c | ||
|
0edd654c9e | ||
|
475e16b87f | ||
|
65e896fd60 | ||
|
5911e410a8 | ||
|
d572f4ac1f | ||
|
cef3e07e3d | ||
|
8b78747629 | ||
|
b05153e6f9 | ||
|
39603f4bc2 | ||
|
5e1c8056ae | ||
|
7c0da1747a | ||
|
d08673bad1 | ||
|
7281f4ed39 | ||
|
586b2b5a79 | ||
|
e28af05957 | ||
|
3f6013ea27 | ||
|
ddb433d552 | ||
|
590ea03255 | ||
|
bf92190924 | ||
|
c3c36d8517 | ||
|
eb988e95e1 | ||
|
f46c8ea03c | ||
|
81279b763b | ||
|
0778fb93df | ||
|
616fea0c2b | ||
|
a8ca1f95c5 | ||
|
229f792db6 | ||
|
8eeefc2906 | ||
|
d92ef93611 | ||
|
6aeb168d63 | ||
|
dfb3494600 | ||
|
a5ff884605 | ||
|
9c2643b9f7 | ||
|
2d90f51d57 | ||
|
5899d8f54b | ||
|
36a999e09f | ||
|
6a159a5565 | ||
|
1913f5e6f9 | ||
|
90032acbcf | ||
|
d403705de9 | ||
|
b098af3ef8 | ||
|
f525399545 | ||
|
d6a4084321 | ||
|
47b9316a86 | ||
|
94cbb333f8 | ||
|
0b5a96d963 | ||
|
73940cde73 | ||
|
5e86d5c21b | ||
|
1d780e1a6b | ||
|
14477b1066 | ||
|
cea7b4e920 | ||
|
9c987e5a0b | ||
|
95cf0a8b2c | ||
|
73820756d1 | ||
|
b09e9159ba | ||
|
261cdb0f29 | ||
|
7dfa9e8f81 | ||
|
f538085e41 | ||
|
79be1d3051 | ||
|
a570932b82 | ||
|
a2eb3324d4 | ||
|
83ed825e5a | ||
|
c8e6d35e17 | ||
|
66c0530a05 | ||
|
6a06929f6b | ||
|
1214359022 | ||
|
1b389f29c5 | ||
|
20d8ba7f8d | ||
|
873043226c | ||
|
59fb3a7893 | ||
|
31e4cbba2e | ||
|
2e3f99e61e | ||
|
f4f2617584 | ||
|
361ecd6cf5 | ||
|
0ac20b3029 | ||
|
fcb5650dbf | ||
|
b22ebe73bc | ||
|
8aacee8eae | ||
|
8da518f2cd | ||
|
45ef9fdbe8 | ||
|
d881356ab2 | ||
|
3673b65485 | ||
|
cc33439f19 | ||
|
fc6249a228 | ||
|
ea5cf883fa | ||
|
66d0c2a426 | ||
|
d65be3d0c5 | ||
|
7e134f85a4 | ||
|
0e406cf0a8 | ||
|
00b3fb96d9 | ||
|
a9a3100cca | ||
|
af5e5fe31b | ||
|
5e6def0843 | ||
|
d768ea6709 | ||
|
0eb5fee633 | ||
|
5ea697b8eb | ||
|
34d8be3b2e | ||
|
a8defb4e21 | ||
|
1cdfed919a | ||
|
cf312e14a9 | ||
|
e948098ae3 | ||
|
f14a0dfe07 | ||
|
0b829db149 | ||
|
fadcbf3eeb | ||
|
6a93c503cd | ||
|
02d7d6038d | ||
|
671fbfea7d | ||
|
87fe08fe0e | ||
|
1d77d51ca4 | ||
|
bda2be3423 | ||
|
0236308866 | ||
|
f1b36edc07 | ||
|
a4c727ac40 | ||
|
c82d1aac4d | ||
|
7f04060f33 | ||
|
b9ce828451 | ||
|
a91fb0523a | ||
|
a90b74baaa | ||
|
0e006715d8 | ||
|
9552dab5aa | ||
|
85d2703c03 | ||
|
2b257caea9 | ||
|
b6ef417e71 | ||
|
c895f63a1c | ||
|
108f4fe47e | ||
|
4e2fefdfdf | ||
|
4ef4baa6bf | ||
|
68386f5180 | ||
|
6b2800fa99 | ||
|
e33189546a | ||
|
9f0185f304 | ||
|
bc0dd891c3 | ||
|
ed60dd5926 | ||
|
10be58a74f | ||
|
9f5db1e3e4 | ||
|
df8b611334 | ||
|
5998723e7c | ||
|
215dfe0450 | ||
|
0b9268a91b | ||
|
ea4f1dece5 | ||
|
c8b07e9fa6 | ||
|
898bc5c4c8 | ||
|
de8dbdc2cb | ||
|
12da0f9d24 | ||
|
308d3aa676 | ||
|
7f7077a156 | ||
|
8106c5a199 | ||
|
752b13b111 | ||
|
847c008b49 | ||
|
b25362e036 | ||
|
618d8e6a4a | ||
|
7929ba9747 | ||
|
9983d9c4de | ||
|
d5dcf31123 | ||
|
d368d18527 | ||
|
7da7ccaf45 | ||
|
a743d9ae60 | ||
|
0a1e7b5f64 | ||
|
79ec2fe9f2 | ||
|
93fb51c899 | ||
|
d36e37555a | ||
|
c050c8be75 | ||
|
87ec2d9897 | ||
|
bb50117747 | ||
|
365f6d3be9 | ||
|
85dcd03642 | ||
|
9ab1cadaa5 | ||
|
6fe0d71ae1 | ||
|
70c51984c9 | ||
|
7261b40df7 | ||
|
e6267dd6b4 | ||
|
bd1b737e4e | ||
|
d214f9ebca | ||
|
6a699d2872 | ||
|
1496ddc52f | ||
|
deb3b74c66 | ||
|
adca5a66e7 | ||
|
f7c2fbfe85 | ||
|
ffafa7fdaa | ||
|
ee85e6b534 | ||
|
5581c42a79 | ||
|
0a28abd8f6 | ||
|
e17a98f870 | ||
|
c4c7f10d99 | ||
|
2e40154801 | ||
|
a06ecb6867 | ||
|
11d4fcff46 | ||
|
a4e43402e5 | ||
|
e7b2ca28ab | ||
|
f5e0c47811 | ||
|
3fb662c9e7 | ||
|
cb1ee9cdd5 | ||
|
a477502a05 | ||
|
fdc173506e | ||
|
bd6dbd096f | ||
|
6a85df013b | ||
|
b0940729ff | ||
|
6b9df6b7a5 | ||
|
fe747b065f | ||
|
ef3e10a14e | ||
|
9156de0593 | ||
|
4eab50755e | ||
|
a58b1f7011 | ||
|
18ec4caded | ||
|
a93d258a86 | ||
|
379b297d2c | ||
|
07d8fe0462 | ||
|
129b3a8c4b | ||
|
1aa33ebc80 | ||
|
d5410e3115 | ||
|
f5a26fd2b8 | ||
|
1efbcebed4 | ||
|
c1adf54a44 | ||
|
8ca50a2f7e | ||
|
5ad2e7ee6d | ||
|
bfa655a01f | ||
|
e16176672a | ||
|
cfb59828f3 | ||
|
a06b9f6646 | ||
|
cdc74a9377 | ||
|
8f6616993b | ||
|
65e1ef047f | ||
|
d40422592a | ||
|
d4032f7d09 | ||
|
3c8fd8a2f2 | ||
|
a2d5358ac6 | ||
|
dd34899e97 | ||
|
820430001f | ||
|
4a5411aa6e | ||
|
4cdea712d0 | ||
|
42df4517c6 | ||
|
fd918062d6 | ||
|
cb5a548740 | ||
|
8635a7ff6e | ||
|
1d88638bd3 | ||
|
960244bf1e | ||
|
5d5d892830 | ||
|
d660a0d2ae | ||
|
fd1f74f44d | ||
|
44e0b17606 | ||
|
7381598310 | ||
|
e9e02884e5 | ||
|
7c344bdfd0 | ||
|
326f3624d9 | ||
|
527c1518f2 | ||
|
b389fa89e4 | ||
|
7b07d77396 | ||
|
cb4b5641ea | ||
|
3fabac3f70 | ||
|
9222f5e5b1 | ||
|
52b947a005 | ||
|
3ea84156c7 | ||
|
75ce9cef92 | ||
|
e54070c2d7 | ||
|
615dce0eaa | ||
|
4289ec60a1 | ||
|
9fdaee1529 | ||
|
31f8ed1d1e | ||
|
fae03b2ba5 | ||
|
bd73de7198 | ||
|
b8c6092a16 | ||
|
9e7ad75944 | ||
|
648a60d4c8 | ||
|
8b58ce9e85 | ||
|
5b06fe83df | ||
|
c8c1e270e0 | ||
|
729a3ac089 | ||
|
34b4b34f2c | ||
|
e6db0ab614 | ||
|
b89f0bc730 | ||
|
a975c56695 | ||
|
758a4bef09 | ||
|
541060215e | ||
|
315247bf02 | ||
|
50ca4a2101 | ||
|
bb78c06193 | ||
|
a1f48d2575 | ||
|
8882d324a6 | ||
|
c69d2ab0ae | ||
|
dfe3ad5551 | ||
|
883ffc5fd6 | ||
|
ceb2787d46 | ||
|
aa8161a7ad | ||
|
88bbc106c7 | ||
|
4c8c31fa2e | ||
|
c75b318805 | ||
|
5d29554fed | ||
|
2a89b23ede | ||
|
f2f44b054d | ||
|
d620ad4942 | ||
|
8059608af9 | ||
|
9525eb2f0c | ||
|
9b65cc8895 | ||
|
6ca9395368 | ||
|
bc637f2633 | ||
|
c1d04b84c7 | ||
|
f890db872a | ||
|
f932af7f18 | ||
|
4324817c68 | ||
|
c764f71cf5 | ||
|
ee7895465c | ||
|
834017c198 | ||
|
a189a4cfb7 | ||
|
dbd1938ce4 | ||
|
3186d66596 | ||
|
9db9f3bdaf | ||
|
26656808e6 | ||
|
df1aecb7bd | ||
|
0ac661f571 | ||
|
64bd2af015 | ||
|
9378d51b18 | ||
|
77941b131e | ||
|
ff5f9cbcb6 | ||
|
f3ba7a84f4 | ||
|
128688a573 | ||
|
58706474ec | ||
|
922cb47a4b | ||
|
be94a37e23 | ||
|
01f47e00f2 | ||
|
0da80c1f25 | ||
|
869e6ef583 | ||
|
f02ea94c42 | ||
|
0417f4f162 | ||
|
bac6949365 | ||
|
fd16bba29d | ||
|
f4e10ea9d5 | ||
|
24e61cf74e | ||
|
4412a83655 | ||
|
85e848289b | ||
|
4e783e2d66 | ||
|
7b21059ee5 | ||
|
2dce34d7e0 | ||
|
0c18736370 | ||
|
d91d552a5e | ||
|
1a1f1f1369 | ||
|
7331c70e9e | ||
|
ba7a9a0b29 | ||
|
015a751ea0 | ||
|
3493688a4d | ||
|
ed677a8f32 | ||
|
e5bb3a5233 | ||
|
eb9e254b8c | ||
|
cbce3a8631 | ||
|
bb8f1304ba | ||
|
fdd21470b9 | ||
|
bb8b4f3827 | ||
|
3c950e5977 | ||
|
88a85024e2 | ||
|
7fb288819a | ||
|
0c139ef7a0 | ||
|
7ba84b7787 | ||
|
d3b32fefa3 | ||
|
05f8dd8273 | ||
|
ec2f18ab17 | ||
|
d1df10ac86 | ||
|
70655012ab | ||
|
b12e3d8eec | ||
|
89d3e667e0 | ||
|
cc9f4ac587 | ||
|
7b21183f45 | ||
|
3e8b56c509 | ||
|
8866a43b2d | ||
|
f576ecc992 | ||
|
1a999f74fc | ||
|
7b4a29da81 | ||
|
653e4f47ac | ||
|
aab8ba02d8 | ||
|
2540081988 | ||
|
4ff14104b0 | ||
|
ea21dddec9 | ||
|
33cd10581e | ||
|
4b9c23272a | ||
|
875c5df519 | ||
|
c181f147ce | ||
|
9b7256c0c8 | ||
|
10d8760134 | ||
|
3e44bd4e5b | ||
|
7aebed0eea | ||
|
b1d8915440 | ||
|
3ead8d532b | ||
|
f65e6265e0 | ||
|
fd02d69dda | ||
|
0e0ed72652 | ||
|
2327f87e37 | ||
|
b6ce1479fe | ||
|
20b76f87bf | ||
|
7cb5a7bebc | ||
|
950f78041a | ||
|
856f4b55f6 | ||
|
227e2cc0f5 | ||
|
110edf32d0 | ||
|
21e08955d3 | ||
|
803bf59654 | ||
|
05f7f03dab | ||
|
8f19d02501 | ||
|
62c00be873 | ||
|
bd055fac1c | ||
|
b1ace5763a | ||
|
8af3173955 | ||
|
2377db33db | ||
|
4308fa3f68 | ||
|
fc520e7b4c | ||
|
5ce03258b5 | ||
|
549659dab6 | ||
|
ea99d2c2cd | ||
|
828afe188c | ||
|
e3923876c0 | ||
|
080672478d | ||
|
a3f80061b1 | ||
|
bc382c6835 | ||
|
e418bbcfac | ||
|
44072062ff | ||
|
c3f01d7db9 | ||
|
8cf61c859d | ||
|
101f070f12 | ||
|
0dff53ada7 | ||
|
674614cc7a | ||
|
0761d73e9c | ||
|
0c9c29fb34 | ||
|
808931b108 | ||
|
ba79890398 | ||
|
ff7591171b | ||
|
fb16ae2325 | ||
|
36e1a0ceae | ||
|
3e86484091 | ||
|
fb5d53bf57 | ||
|
fc4316f664 | ||
|
0b273ea88c | ||
|
a4f58be00c | ||
|
c9a5f586b7 | ||
|
09b9f8ff9f | ||
|
bff9068a7f | ||
|
a87b1efbd2 | ||
|
193e40c271 | ||
|
7b5b5dbb8d | ||
|
2ee19c4d34 | ||
|
25f476c7ad | ||
|
0642531c2a | ||
|
f8c53fae37 | ||
|
b9ebf87114 | ||
|
b4296e1a2d | ||
|
dd1072a99b | ||
|
ae5261b98b | ||
|
4137ea5ab7 | ||
|
b650e7a503 | ||
|
870c68dd27 | ||
|
57bb28e841 | ||
|
e880b11626 | ||
|
7be7e589a9 | ||
|
1b03676a36 | ||
|
7ab7b2ab8b | ||
|
f484527cfb | ||
|
2bc7fa568f | ||
|
2368ff6637 | ||
|
c6f18c9394 | ||
|
f6c35144e4 | ||
|
261b5120f6 | ||
|
1c2434f4d3 | ||
|
766492d1cc | ||
|
16b0afc192 | ||
|
81dc67b1ef | ||
|
8f28956108 | ||
|
d075c3c274 | ||
|
553e37314a | ||
|
3749171656 | ||
|
d34f5fbae2 | ||
|
5a898254b0 | ||
|
f05386e006 | ||
|
2f260a344e | ||
|
f4042ba752 | ||
|
e7ff5da5b1 | ||
|
e5cabeafe5 | ||
|
62196b2bf1 | ||
|
20aa37237d | ||
|
5d55a5894c | ||
|
00039ba629 | ||
|
321154d25a | ||
|
0e092aef70 | ||
|
8afeb13035 | ||
|
b9e78f2e2e | ||
|
e83f4f40f9 | ||
|
bebc550f02 | ||
|
997f3f8266 | ||
|
8c785f1dc9 | ||
|
1417af2eab | ||
|
fb76e5daa2 | ||
|
36b8186021 | ||
|
a6fda3e65d | ||
|
18ca7affad | ||
|
16be9181a0 | ||
|
3cf4a4e95e | ||
|
bd34ec1fb3 | ||
|
6cdfe38319 | ||
|
c2ca6b6bdf | ||
|
055625448b | ||
|
d52df527ba | ||
|
7b486fe239 | ||
|
009f5765df | ||
|
9e3ac35669 | ||
|
5ab5a721a1 | ||
|
871c9c61a5 | ||
|
1c43b7b55c | ||
|
db7c22d9d6 | ||
|
50254c284b | ||
|
9809bda0e5 | ||
|
9f09ac6893 | ||
|
aa032f31bb | ||
|
e76c596d56 | ||
|
fc4f440245 | ||
|
eafc97bcb3 | ||
|
d053f3665d | ||
|
662d60ad6b | ||
|
f24cc55c14 | ||
|
7cb1970952 | ||
|
0ce2b1359f | ||
|
57518d5312 | ||
|
8297ea9aa6 | ||
|
e746a4c12f | ||
|
09226543fe | ||
|
58aed8fd0d | ||
|
2989373212 | ||
|
858b6a3e0b | ||
|
2e09257d94 | ||
|
b7ea23303e | ||
|
e830cdee71 | ||
|
439652f023 | ||
|
1fd89abcc3 | ||
|
73c0356861 | ||
|
fe4143ad19 | ||
|
f5d702b09a | ||
|
b8d740ebfc | ||
|
3bcdb85ddc | ||
|
2feb3a3bba | ||
|
42b65e80cf | ||
|
0796af7b4b | ||
|
2e62e9ea7e | ||
|
ce5164e26e | ||
|
4e28d1c658 | ||
|
f4a3d17269 | ||
|
970a1a2b35 | ||
|
d5a2ff5c12 | ||
|
992d20def3 | ||
|
79ad8c9354 | ||
|
4072aa4a4b | ||
|
ba868ed4a6 | ||
|
153b7c8460 | ||
|
e60c89c532 | ||
|
321fda9c26 | ||
|
8e6ddb0c1a | ||
|
1d74ff075e | ||
|
f830ac1206 | ||
|
07b7975d09 | ||
|
6415c6b0e0 | ||
|
67d8cf744c | ||
|
36f9510bb3 | ||
|
6ee650f316 | ||
|
2b325d3b59 | ||
|
94b8747da4 | ||
|
e355cdbae0 | ||
|
a7337bc999 | ||
|
604fe3ccee | ||
|
681b839419 | ||
|
72b603780c | ||
|
3aecbc5ac1 | ||
|
665c29f0be | ||
|
4b84fb486b | ||
|
b5350f9387 | ||
|
ec7bac7ba7 | ||
|
8887501042 | ||
|
84a59fe4c0 |
179
ChangeLog.md
179
ChangeLog.md
@@ -1,3 +1,182 @@
|
||||
# What's new in vkd3d 1.17 (21 August 2025)
|
||||
|
||||
### libvkd3d
|
||||
|
||||
- The EnumerateMetaCommands() method of the ID3D12Device5 interface is
|
||||
implemented.
|
||||
|
||||
### libvkd3d-shader
|
||||
|
||||
- Several new features and improvements for the HLSL source type:
|
||||
- Initial thread group shared memory support.
|
||||
- Improved support for geometry shaders: shader model 5 multiple output
|
||||
streams, as well as SV_IsFrontFace, SV_RenderTargetArrayIndex, and
|
||||
SV_ViewportArrayIndex outputs.
|
||||
- Structure variable input/output semantics are propagated to the
|
||||
constituent structure fields.
|
||||
- Shader entry point return values are allocated before any other outputs
|
||||
in the output signature. This matches d3dcompiler/fxc more closely.
|
||||
- Hull shader control point pass-through.
|
||||
- Reflection information can be retrieved using vkd3d_shader_scan().
|
||||
- Improved preprocessor handling of comments inside include directives, as
|
||||
well as inclusion of empty files.
|
||||
- Memory barrier intrinsics are supported in shader model 4 target
|
||||
profiles. Previous these were only supported in shader model 5 target
|
||||
profiles.
|
||||
- Parser support for the noise() intrinsic. Although the intrinsic itself
|
||||
isn't implemented, parser support for the intrinsic is required to allow
|
||||
compilation of any other shaders in the same source file to succeed as
|
||||
well.
|
||||
- Parser support for StructuredBuffer resources.
|
||||
|
||||
- Various new features and improvements for the effects (FX) source type:
|
||||
- Shader blob assignments and FXLVM value expressions in ‘fx_2_0’ effects.
|
||||
- Nameless structure types.
|
||||
- Explicit constant buffer bind points and constant packing offsets.
|
||||
- The ‘d3ds_noiseswiz’, ‘ge’, ‘lt’, and ‘noise’ FXLVM operations.
|
||||
|
||||
- The experimental Metal Shading Language (MSL) target supports the
|
||||
following features:
|
||||
- Texture sampling and gather operations.
|
||||
- Loops and switches.
|
||||
- Screen-space partial derivatives.
|
||||
- Various integer arithmetic and comparison operations.
|
||||
- Indirect addressing of constant buffers.
|
||||
- Indexable temporary registers.
|
||||
- Fragment shader output sample coverage masks.
|
||||
- SV_Position and SV_SampleIndex fragment shader inputs.
|
||||
- SV_VertexID inputs.
|
||||
|
||||
- When the experimental MSL target is enabled, the ‘dxbc-dxil’ source type
|
||||
can be used in combination with the ‘msl’ target type to convert DXIL
|
||||
shaders to MSL.
|
||||
|
||||
- The new ‘tx’ source type can be used in combination with the ‘d3d-asm’
|
||||
target type to disassemble D3DX ‘tx_1_0’ texture shaders.
|
||||
|
||||
- The FX target takes alignment and padding into account in ‘fx_4_0’ buffer
|
||||
size calculations.
|
||||
|
||||
- The SPIR-V target is capable of outputting OpSource and OpLine debug
|
||||
information.
|
||||
|
||||
- The core grammar for the experimental SPIR-V disassembler has been updated
|
||||
to the ‘vulkan-sdk-1.4.313.0’ release.
|
||||
|
||||
- New interfaces:
|
||||
- The VKD3D_SHADER_SOURCE_TX source type specifies D3DX ‘tx_1_0’ texture
|
||||
shaders.
|
||||
|
||||
### vkd3d-compiler
|
||||
|
||||
- The new ‘tx’ source type specifies D3DX ‘tx_1_0’ texture shaders.
|
||||
|
||||
### demos
|
||||
|
||||
- The new vkd3d-teapot demo uses tessellation shaders to render a version of
|
||||
Martin Newell's famous teapot. It should be noted that current versions of
|
||||
MoltenVK unfortunately do not support all features required to execute
|
||||
this demo correctly.
|
||||
|
||||
# What's new in vkd3d 1.16 (20 May 2025)
|
||||
|
||||
### libvkd3d
|
||||
|
||||
- DXIL shaders are supported in the default configuration. Previously this
|
||||
required building vkd3d with the ‘-DVKD3D_SHADER_UNSUPPORTED_DXIL’
|
||||
preprocessor option. The also raises the maximum supported shader model to
|
||||
version 6.0.
|
||||
|
||||
- Graphics pipeline state objects can be created from shaders with embedded
|
||||
root signatures. This was already possible for compute pipeline state
|
||||
objects.
|
||||
|
||||
- The SetEventOnMultipleFenceCompletion() method of the ID3D12Device1
|
||||
interface is implemented.
|
||||
|
||||
- When the VK_KHR_zero_initialize_workgroup_memory extension is supported,
|
||||
libvkd3d supports zero-initialising compute shader thread group shared
|
||||
memory.
|
||||
|
||||
- The VK_KHR_maintenance2 extension is now explicitly required. libvkd3d
|
||||
already unconditionally used features provided by this extension, but
|
||||
unfortunately didn't explicitly require it. Support for this extension is
|
||||
widespread, and the extension is part of Vulkan 1.1.
|
||||
|
||||
### libvkd3d-shader
|
||||
|
||||
- The previously experimental support for compiling DXIL shaders is now a
|
||||
supported feature and enabled by default. Please note that this feature is
|
||||
nevertheless still far from perfect.
|
||||
|
||||
- New features for the HLSL source type:
|
||||
- Initial support for geometry shaders.
|
||||
- Indirect addressing in shader model 1-3 target profiles.
|
||||
- Modulus and truncation operations in shader model 1-3 target profiles.
|
||||
- Vectorised output code.
|
||||
- Further improved constant folding and propagation.
|
||||
- The following intrinsic functions are supported:
|
||||
- AllMemoryBarrier()
|
||||
- AllMemoryBarrierWithGroupSync()
|
||||
- DeviceMemoryBarrier()
|
||||
- DeviceMemoryBarrierWithGroupSync()
|
||||
- GroupMemoryBarrier()
|
||||
- GroupMemoryBarrierWithGroupSync()
|
||||
- The ‘.Length’ Texture object property.
|
||||
- The ‘SV_RenderTargetArrayIndex’ and ‘SV_ViewportArrayIndex’ semantics in
|
||||
tessellation shaders.
|
||||
|
||||
- Disassembler support for binary ‘fx_2_0’ effects.
|
||||
|
||||
- Experimental built-in support for disassembling SPIR-V shaders, enabled by
|
||||
building vkd3d with the ‘-DVKD3D_SHADER_UNSUPPORTED_SPIRV_PARSER’
|
||||
preprocessor option. When enabled, the built-in SPIR-V disassembler is
|
||||
used instead of SPIRV-Tools for the ‘spirv-text’ target type, as well as
|
||||
for the debug output enabled by the VKD3D_SHADER_DEBUG environment
|
||||
variable.
|
||||
|
||||
- The experimental OpenGL Shading Language (GLSL) target supports indirect
|
||||
addressing of constant buffers.
|
||||
|
||||
- The experimental Metal Shading Language (MSL) target supports texture
|
||||
loads.
|
||||
|
||||
- New interfaces:
|
||||
- The VKD3D_SHADER_COMPILE_OPTION_FEATURE_ZERO_INITIALIZE_WORKGROUP_MEMORY
|
||||
flag indicates support for zero-initialising workgroup memory in the
|
||||
SPIR-V target environment.
|
||||
- The VKD3D_SHADER_COMPONENT_INT64 enumeration value indicates a 64-bit
|
||||
signed integer value.
|
||||
- The VKD3D_SHADER_COMPONENT_FLOAT16 enumeration value indicates a 16-bit
|
||||
IEEE floating-point value.
|
||||
- The VKD3D_SHADER_COMPONENT_UINT16 enumeration value indicates a 16-bit
|
||||
unsigned integer value.
|
||||
- The VKD3D_SHADER_COMPONENT_INT16 enumeration value indicates a 16-bit
|
||||
signed integer value.
|
||||
- When targeting VKD3D_SHADER_API_1_16, the
|
||||
VKD3D_SHADER_RESOURCE_DATA_NONE enumeration value is returned for the
|
||||
‘resource_data_type’ field in the vkd3d_shader_descriptor_info structure
|
||||
for sampler descriptors. VKD3D_SHADER_API_1_15 and before use the
|
||||
VKD3D_SHADER_RESOURCE_DATA_UINT enumeration value for this.
|
||||
|
||||
### demos
|
||||
|
||||
- The vkd3d demos now work on both the Microsoft Windows and Apple macOS
|
||||
builds. The macOS versions of the vkd3d demos are completely new in vkd3d
|
||||
1.16, while the Windows demos could previously be built, but only worked
|
||||
on Wine. Note that the vkd3d demos produced by a Windows build of vkd3d
|
||||
are distinct from those produced by the ‘make crosstest’ target: the
|
||||
former are Vulkan applications using vkd3d, while the latter are Direct3D
|
||||
12 applications.
|
||||
|
||||
- The vkd3d demos have basic support for DPI scaling.
|
||||
|
||||
### build
|
||||
|
||||
- Perl and the ‘JSON’ Perl module have been added as build dependencies.
|
||||
These are used for the experimental built-in SPIR-V disassembler, as well
|
||||
as for the macOS versions of the vkd3d demos.
|
||||
|
||||
# What's new in vkd3d 1.15 (19 February 2025)
|
||||
|
||||
### libvkd3d
|
||||
|
79
Makefile.am
79
Makefile.am
@@ -2,6 +2,12 @@ ACLOCAL_AMFLAGS = -I m4
|
||||
AM_CFLAGS = @VKD3D_CFLAGS@
|
||||
AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include/private
|
||||
AM_LDFLAGS = -no-undefined
|
||||
VKD3D_PERL = $(PERL) -w
|
||||
|
||||
objc_headers = \
|
||||
include/private/appkit.h \
|
||||
include/private/foundation.h \
|
||||
include/private/quartzcore.h
|
||||
|
||||
widl_headers = \
|
||||
include/vkd3d_d3d12.h \
|
||||
@@ -63,6 +69,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/asint.shader_test \
|
||||
tests/hlsl/asuint.shader_test \
|
||||
tests/hlsl/attributes.shader_test \
|
||||
tests/hlsl/barriers.shader_test \
|
||||
tests/hlsl/bitwise-assignment.shader_test \
|
||||
tests/hlsl/bitwise.shader_test \
|
||||
tests/hlsl/bool-cast.shader_test \
|
||||
@@ -108,6 +115,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/effect-compile.shader_test \
|
||||
tests/hlsl/effect-initial-values-fx_2.shader_test \
|
||||
tests/hlsl/effect-initial-values-fx_4.shader_test \
|
||||
tests/hlsl/effect-pass-states-fx_4.shader_test \
|
||||
tests/hlsl/effect-pass-states-fx_5.shader_test \
|
||||
tests/hlsl/effect-shader-objects-fx_2.shader_test \
|
||||
tests/hlsl/effect-shader-objects-fx_5.shader_test \
|
||||
@@ -116,6 +124,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/effect-technique-fx_5.shader_test \
|
||||
tests/hlsl/effect-variables-fx_2.shader_test \
|
||||
tests/hlsl/effect-variables-fx_4.shader_test \
|
||||
tests/hlsl/effect-variables-fx_4_1.shader_test \
|
||||
tests/hlsl/effect-variables-fx_5.shader_test \
|
||||
tests/hlsl/entry-point-semantics.shader_test \
|
||||
tests/hlsl/eval-attrib.shader_test \
|
||||
@@ -124,11 +133,11 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/f16tof32.shader_test \
|
||||
tests/hlsl/f32tof16.shader_test \
|
||||
tests/hlsl/faceforward.shader_test \
|
||||
tests/hlsl/fog.shader_test \
|
||||
tests/hlsl/ffp-point-size.shader_test \
|
||||
tests/hlsl/float-comparison.shader_test \
|
||||
tests/hlsl/floor.shader_test \
|
||||
tests/hlsl/fmod.shader_test \
|
||||
tests/hlsl/fog.shader_test \
|
||||
tests/hlsl/for.shader_test \
|
||||
tests/hlsl/frac.shader_test \
|
||||
tests/hlsl/function-cast.shader_test \
|
||||
@@ -140,6 +149,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/gather-cmp.shader_test \
|
||||
tests/hlsl/gather-offset.shader_test \
|
||||
tests/hlsl/gather.shader_test \
|
||||
tests/hlsl/geometry-shader-syntax.shader_test \
|
||||
tests/hlsl/geometry.shader_test \
|
||||
tests/hlsl/get-sample-pos.shader_test \
|
||||
tests/hlsl/getdimensions.shader_test \
|
||||
@@ -166,6 +176,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/is-front-face.shader_test \
|
||||
tests/hlsl/isinf.shader_test \
|
||||
tests/hlsl/ldexp.shader_test \
|
||||
tests/hlsl/length-property.shader_test \
|
||||
tests/hlsl/length.shader_test \
|
||||
tests/hlsl/lerp.shader_test \
|
||||
tests/hlsl/lhs-cast.shader_test \
|
||||
@@ -188,6 +199,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/multiple-rt.shader_test \
|
||||
tests/hlsl/nested-arrays.shader_test \
|
||||
tests/hlsl/nointerpolation.shader_test \
|
||||
tests/hlsl/noise.shader_test \
|
||||
tests/hlsl/non-const-indexing.shader_test \
|
||||
tests/hlsl/normalize.shader_test \
|
||||
tests/hlsl/null.shader_test \
|
||||
@@ -198,10 +210,13 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/object-parameters.shader_test \
|
||||
tests/hlsl/object-references.shader_test \
|
||||
tests/hlsl/patch-syntax.shader_test \
|
||||
tests/hlsl/pixel-position.shader_test \
|
||||
tests/hlsl/point-sprite.shader_test \
|
||||
tests/hlsl/pointer-cast.shader_test \
|
||||
tests/hlsl/pow.shader_test \
|
||||
tests/hlsl/precise-modifier.shader_test \
|
||||
tests/hlsl/primitive-id.shader_test \
|
||||
tests/hlsl/ps1-sampler.shader_test \
|
||||
tests/hlsl/rasteriser-ordered-views.shader_test \
|
||||
tests/hlsl/rcp.shader_test \
|
||||
tests/hlsl/reflect.shader_test \
|
||||
@@ -211,6 +226,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/register-reservations-resources.shader_test \
|
||||
tests/hlsl/register-reservations-space.shader_test \
|
||||
tests/hlsl/return-implicit-conversion.shader_test \
|
||||
tests/hlsl/return-semantics.shader_test \
|
||||
tests/hlsl/return.shader_test \
|
||||
tests/hlsl/round.shader_test \
|
||||
tests/hlsl/rt-array-index.shader_test \
|
||||
@@ -225,6 +241,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/sampler.shader_test \
|
||||
tests/hlsl/saturate.shader_test \
|
||||
tests/hlsl/scope.shader_test \
|
||||
tests/hlsl/semantic-cascading.shader_test \
|
||||
tests/hlsl/shade-mode.shader_test \
|
||||
tests/hlsl/shader-interstage-interface.shader_test \
|
||||
tests/hlsl/shader-point-size.shader_test \
|
||||
@@ -241,6 +258,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/sqrt.shader_test \
|
||||
tests/hlsl/srv-buffers.shader_test \
|
||||
tests/hlsl/srv-byteaddressbuffer.shader_test \
|
||||
tests/hlsl/srv-structuredbuffer.shader_test \
|
||||
tests/hlsl/state-block-function-syntax.shader_test \
|
||||
tests/hlsl/state-block-syntax.shader_test \
|
||||
tests/hlsl/static-initializer.shader_test \
|
||||
@@ -251,6 +269,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/struct-assignment.shader_test \
|
||||
tests/hlsl/struct-inheritance.shader_test \
|
||||
tests/hlsl/struct-semantics.shader_test \
|
||||
tests/hlsl/struct-syntax.shader_test \
|
||||
tests/hlsl/switch.shader_test \
|
||||
tests/hlsl/swizzle-constant-prop.shader_test \
|
||||
tests/hlsl/swizzle-matrix.shader_test \
|
||||
@@ -285,6 +304,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl/vector-indexing-uniform.shader_test \
|
||||
tests/hlsl/vector-indexing.shader_test \
|
||||
tests/hlsl/vertex-shader-ops.shader_test \
|
||||
tests/hlsl/vp-array-index.shader_test \
|
||||
tests/hlsl/wave-ops-float.shader_test \
|
||||
tests/hlsl/wave-ops-int.shader_test \
|
||||
tests/hlsl/wave-ops-uint.shader_test \
|
||||
@@ -311,14 +331,19 @@ vkd3d_test_headers = \
|
||||
|
||||
vkd3d_demos = \
|
||||
demos/vkd3d-gears \
|
||||
demos/vkd3d-teapot \
|
||||
demos/vkd3d-triangle
|
||||
|
||||
vkd3d_demos_headers = \
|
||||
demos/demo.h \
|
||||
demos/demo_d3d12.h \
|
||||
demos/demo_macos.h \
|
||||
demos/demo_vkd3d.h \
|
||||
demos/demo_win32.h \
|
||||
demos/demo_xcb.h
|
||||
|
||||
BUILT_SOURCES = $(widl_headers) \
|
||||
BUILT_SOURCES = $(objc_headers) $(widl_headers) \
|
||||
include/private/spirv_grammar.h \
|
||||
include/private/vkd3d_version.h
|
||||
|
||||
noinst_LTLIBRARIES = libvkd3d-common.la
|
||||
@@ -377,6 +402,7 @@ nodist_libvkd3d_shader_la_SOURCES = $(vkd3d_shader_yyfiles)
|
||||
libvkd3d_shader_la_SOURCES = \
|
||||
include/private/list.h \
|
||||
include/private/rbtree.h \
|
||||
include/private/spirv_grammar.h \
|
||||
include/private/vkd3d_common.h \
|
||||
include/private/vkd3d_memory.h \
|
||||
include/vkd3d_shader.h \
|
||||
@@ -400,7 +426,7 @@ libvkd3d_shader_la_SOURCES = \
|
||||
libs/vkd3d-shader/vkd3d_shader_main.c \
|
||||
libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
libvkd3d_shader_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_SHADER_SOURCE -I$(srcdir)/libs/vkd3d-shader @SPIRV_TOOLS_CFLAGS@
|
||||
libvkd3d_shader_la_LDFLAGS = $(AM_LDFLAGS) -version-info 14:0:13
|
||||
libvkd3d_shader_la_LDFLAGS = $(AM_LDFLAGS) -version-info 16:0:15
|
||||
libvkd3d_shader_la_LIBADD = libvkd3d-common.la @SPIRV_TOOLS_LIBS@ -lm
|
||||
if HAVE_LD_VERSION_SCRIPT
|
||||
libvkd3d_shader_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d-shader/vkd3d_shader.map
|
||||
@@ -435,7 +461,7 @@ libvkd3d_la_SOURCES = \
|
||||
libs/vkd3d/vkd3d_shaders.h \
|
||||
libs/vkd3d/vulkan_procs.h
|
||||
libvkd3d_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_SOURCE
|
||||
libvkd3d_la_LDFLAGS = $(AM_LDFLAGS) -version-info 16:0:15
|
||||
libvkd3d_la_LDFLAGS = $(AM_LDFLAGS) -version-info 18:0:17
|
||||
libvkd3d_la_LIBADD = libvkd3d-common.la libvkd3d-shader.la @DL_LIBS@ @PTHREAD_LIBS@
|
||||
if HAVE_LD_VERSION_SCRIPT
|
||||
libvkd3d_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d/vkd3d.map
|
||||
@@ -448,7 +474,7 @@ libvkd3d_utils_la_SOURCES = \
|
||||
libs/vkd3d-utils/vkd3d_utils_main.c \
|
||||
libs/vkd3d-utils/vkd3d_utils_private.h
|
||||
libvkd3d_utils_la_CFLAGS = $(AM_CFLAGS) -DLIBVKD3D_UTILS_SOURCE
|
||||
libvkd3d_utils_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:1:6
|
||||
libvkd3d_utils_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:3:6
|
||||
libvkd3d_utils_la_LIBADD = libvkd3d-common.la libvkd3d-shader.la libvkd3d.la @PTHREAD_LIBS@
|
||||
if HAVE_LD_VERSION_SCRIPT
|
||||
libvkd3d_utils_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libs/vkd3d-utils/vkd3d_utils.map
|
||||
@@ -513,7 +539,7 @@ tests_vkd3d_api_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
|
||||
tests_vkd3d_api_LDADD = libvkd3d.la @DL_LIBS@
|
||||
tests_vkd3d_shader_api_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
|
||||
tests_vkd3d_shader_api_CFLAGS = $(AM_CFLAGS) @OPENGL_CFLAGS@
|
||||
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la @OPENGL_LIBS@
|
||||
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la @OPENGL_LIBS@ @DL_LIBS@
|
||||
SHADER_TEST_LOG_COMPILER = tests/shader_runner
|
||||
SHADER_TEST_LOG_DRIVER = $(srcdir)/tests/test-driver.sh
|
||||
endif
|
||||
@@ -521,8 +547,8 @@ endif
|
||||
EXTRA_DIST += $(vkd3d_shader_tests)
|
||||
|
||||
if BUILD_DEMOS
|
||||
DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @DL_LIBS@ @DEMO_LIBS@
|
||||
DEMOS_CFLAGS = $(AM_CFLAGS) @DEMO_CFLAGS@ -Wa,-I$(srcdir)/demos
|
||||
DEMOS_LDADD = $(LDADD) @DL_LIBS@ @DEMO_LIBS@
|
||||
DEMOS_CFLAGS = $(AM_CFLAGS) @DEMO_CFLAGS@ -I$(srcdir)/demos -Wa,-I$(srcdir)/demos
|
||||
bin_PROGRAMS += $(vkd3d_demos)
|
||||
|
||||
demos_vkd3d_gears_SOURCES = demos/gears.c demos/gears.hlsl
|
||||
@@ -530,6 +556,18 @@ demos_vkd3d_gears_CFLAGS = $(DEMOS_CFLAGS)
|
||||
demos_vkd3d_gears_LDADD = $(DEMOS_LDADD) -lm
|
||||
demos/vkd3d_gears-gears.$(OBJEXT): demos/gears.hlsl
|
||||
|
||||
teapot_shaders = \
|
||||
demos/teapot.hlsl \
|
||||
demos/text.hlsl
|
||||
demos_vkd3d_teapot_SOURCES = \
|
||||
$(teapot_shaders) \
|
||||
demos/etl16-unicode.h \
|
||||
demos/teapot.c \
|
||||
demos/teapot.h
|
||||
demos_vkd3d_teapot_CFLAGS = $(DEMOS_CFLAGS)
|
||||
demos_vkd3d_teapot_LDADD = $(DEMOS_LDADD) -lm
|
||||
demos/vkd3d_teapot-teapot.$(OBJEXT): $(teapot_shaders)
|
||||
|
||||
demos_vkd3d_triangle_SOURCES = demos/triangle.c demos/triangle.hlsl
|
||||
demos_vkd3d_triangle_CFLAGS = $(DEMOS_CFLAGS)
|
||||
demos_vkd3d_triangle_LDADD = $(DEMOS_LDADD)
|
||||
@@ -537,6 +575,17 @@ demos/vkd3d_triangle-triangle.$(OBJEXT): demos/triangle.hlsl
|
||||
endif
|
||||
|
||||
noinst_HEADERS = $(vkd3d_test_headers) $(vkd3d_demos_headers)
|
||||
dist_noinst_SCRIPTS = libs/vkd3d-shader/make_spirv demos/make_objc
|
||||
|
||||
VKD3D_V_PERL = $(vkd3d_v_perl_@AM_V@)
|
||||
vkd3d_v_perl_ = $(vkd3d_v_perl_@AM_DEFAULT_V@)
|
||||
vkd3d_v_perl_0 = @echo " PERL " $@;
|
||||
vkd3d_v_perl_1 =
|
||||
|
||||
CLEANFILES += $(objc_headers)
|
||||
${objc_headers}: %.h: demos/make_objc %.json
|
||||
@$(MKDIR_P) $(@D)
|
||||
$(VKD3D_V_PERL)$(VKD3D_PERL) $^ > $@.tmp && mv $@.tmp $@
|
||||
|
||||
VKD3D_V_WIDL = $(vkd3d_v_widl_@AM_V@)
|
||||
vkd3d_v_widl_ = $(vkd3d_v_widl_@AM_DEFAULT_V@)
|
||||
@@ -546,7 +595,11 @@ vkd3d_v_widl_1 =
|
||||
if HAVE_WIDL
|
||||
CLEANFILES += $(widl_headers)
|
||||
endif
|
||||
EXTRA_DIST += $(widl_headers) $(widl_headers:.h=.idl)
|
||||
EXTRA_DIST += \
|
||||
$(widl_headers) \
|
||||
$(widl_headers:.h=.idl) \
|
||||
$(objc_headers:.h=.json) \
|
||||
include/private/spirv.core.grammar.json
|
||||
$(widl_headers): %.h: %.idl
|
||||
if HAVE_WIDL
|
||||
$(VKD3D_V_WIDL)$(WIDL) -I$(srcdir)/include -h -o $@ $<
|
||||
@@ -578,6 +631,10 @@ libvkd3d.pc: $(srcdir)/libs/vkd3d/libvkd3d.pc.in Makefile
|
||||
-e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \
|
||||
$< > $@
|
||||
|
||||
include/private/spirv_grammar.h: libs/vkd3d-shader/make_spirv include/private/spirv.core.grammar.json
|
||||
@$(MKDIR_P) $(@D)
|
||||
$(VKD3D_V_PERL)$(VKD3D_PERL) $^ > $@.tmp && mv $@.tmp $@
|
||||
|
||||
include/private/vkd3d_version.h: dummy-vkd3d-version
|
||||
@$(MKDIR_P) include/private
|
||||
version=`(GIT_DIR=$(top_srcdir)/.git git rev-parse --short HEAD 2>/dev/null || echo '') \
|
||||
@@ -586,7 +643,7 @@ include/private/vkd3d_version.h: dummy-vkd3d-version
|
||||
&& (echo $$version | cmp -s - $@) \
|
||||
|| echo $$version >$@ || ($(RM) $@ && exit 1)
|
||||
.SILENT: include/private/vkd3d_version.h
|
||||
CLEANFILES += include/private/vkd3d_version.h
|
||||
CLEANFILES += include/private/spirv_grammar.h include/private/vkd3d_version.h
|
||||
|
||||
.PHONY: dummy-vkd3d-version
|
||||
dummy-vkd3d-version:
|
||||
@@ -619,6 +676,7 @@ endif
|
||||
if BUILD_DEMOS
|
||||
CROSS32_EXEFILES += $(vkd3d_demos:demos/vkd3d-%=demos/%.cross32.exe)
|
||||
demos/gears.cross32.exe: demos/gears.hlsl
|
||||
demos/teapot.cross32.exe: $(teapot_shaders)
|
||||
demos/triangle.cross32.exe: demos/triangle.hlsl
|
||||
endif
|
||||
|
||||
@@ -668,6 +726,7 @@ endif
|
||||
if BUILD_DEMOS
|
||||
CROSS64_EXEFILES += $(vkd3d_demos:demos/vkd3d-%=demos/%.cross64.exe)
|
||||
demos/gears.cross64.exe: demos/gears.hlsl
|
||||
demos/teapot.cross64.exe: $(teapot_shaders)
|
||||
demos/triangle.cross64.exe: demos/triangle.hlsl
|
||||
endif
|
||||
|
||||
|
9
README
9
README
@@ -9,7 +9,8 @@ similar, but not identical, to Direct3D 12.
|
||||
Building vkd3d
|
||||
==============
|
||||
|
||||
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.3.228).
|
||||
Vkd3d depends on SPIRV-Headers and Vulkan-Headers (>= 1.3.228), as well as Perl
|
||||
and libjson-perl.
|
||||
|
||||
Vkd3d generates some of its headers from IDL files. If you are using the
|
||||
release tarballs, then these headers are pre-generated and are included. If
|
||||
@@ -149,12 +150,6 @@ in future versions of vkd3d.
|
||||
emitted; this can be useful for developers to make error conditions as
|
||||
conspicuous as possible.
|
||||
|
||||
* VKD3D_SHADER_UNSUPPORTED_DXIL - enable DXIL (DirectX Intermediate Language)
|
||||
support in vkd3d-shader, which is disabled by default because it is not
|
||||
considered ready for release yet. Please note that this feature is not
|
||||
currently supported, and it might change in a non-compatible way before it is
|
||||
released.
|
||||
|
||||
* VKD3D_SHADER_UNSUPPORTED_GLSL - enable GLSL (GL Shading Language) support in
|
||||
vkd3d-shader, which is disabled by default because it is not considered ready
|
||||
for release yet. Please note that this feature is not currently supported,
|
||||
|
15
configure.ac
15
configure.ac
@@ -1,10 +1,11 @@
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([vkd3d],[1.15])
|
||||
AC_INIT([vkd3d],[1.17])
|
||||
|
||||
AC_CONFIG_AUX_DIR([bin])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_HEADERS(include/config.h)
|
||||
|
||||
AC_ARG_VAR([PERL], [The Perl 5 language interpreter])
|
||||
AC_ARG_VAR([WIDL], [widl IDL compiler])
|
||||
AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler])
|
||||
AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler])
|
||||
@@ -32,6 +33,11 @@ AC_PROG_MKDIR_P
|
||||
VKD3D_PROG_WIDL(3, 21)
|
||||
AS_IF([test "x$WIDL" = "xno"], [AC_MSG_WARN([widl is required to build header files.])])
|
||||
|
||||
AC_CHECK_PROGS([PERL], [perl], [none])
|
||||
AS_IF([test "$PERL" = "none"], [AC_MSG_ERROR([no suitable perl found. Please install the 'perl-base' package.])])
|
||||
VKD3D_CHECK_PERL_MODULE([JSON],
|
||||
[AC_MSG_ERROR([perl module 'JSON' not found. Please install the 'libjson-perl' package.])])
|
||||
|
||||
AC_CHECK_PROGS([FLEX], [flex], [none])
|
||||
AS_IF([test "$FLEX" = "none"], [AC_MSG_ERROR([no suitable flex found. Please install the 'flex' package.])])
|
||||
AC_ARG_VAR([LFLAGS], [extra flags for flex])
|
||||
@@ -178,15 +184,20 @@ AC_CHECK_FUNCS([pthread_threadid_np])
|
||||
dnl Makefiles
|
||||
case $host_os in
|
||||
mingw32*)
|
||||
AC_SUBST([DEMO_LIBS],["-ld3d12 -ldxgi -lgdi32"])
|
||||
AC_SUBST([DEMO_LIBS],["-lgdi32"])
|
||||
AC_SUBST([DEMO_CFLAGS],["-municode"])
|
||||
;;
|
||||
darwin*)
|
||||
AC_SUBST([DEMO_LIBS],["-framework Foundation -framework AppKit -framework QuartzCore"])
|
||||
AC_SUBST([DEMO_CFLAGS],[""])
|
||||
;;
|
||||
*) AS_IF([test "x$enable_demos" = "xyes" -a "x$HAVE_XCB" != "xyes"],
|
||||
[AC_MSG_ERROR([libxcb is required for demos.])])
|
||||
AC_SUBST([DEMO_LIBS],[$XCB_LIBS])
|
||||
AC_SUBST([DEMO_CFLAGS],[$XCB_CFLAGS])
|
||||
;;
|
||||
esac
|
||||
VKD3D_CHECK_CFLAGS([-fno-lto], [DEMO_CFLAGS="$DEMO_CFLAGS -fno-lto"])
|
||||
AM_CONDITIONAL([BUILD_DEMOS], [test "x$enable_demos" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_DOC], [test $DX_FLAG_doc = 1])
|
||||
AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" != "xno"])
|
||||
|
146
demos/demo.h
146
demos/demo.h
@@ -38,18 +38,23 @@
|
||||
#define COBJMACROS
|
||||
#include <vkd3d_d3d12.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __WIN32__
|
||||
#define DEMO_ASM_PUSHSECTION ".section rdata\n\t"
|
||||
#define DEMO_ASM_POPSECTION ".text\n\t"
|
||||
#define DEMO_ASM_OBJECT_TYPE(name)
|
||||
#elif defined(__APPLE__)
|
||||
#define DEMO_ASM_PUSHSECTION ".pushsection __TEXT,__const\n\t"
|
||||
#define DEMO_ASM_POPSECTION ".popsection\n\t"
|
||||
#define DEMO_ASM_OBJECT_TYPE(name)
|
||||
#else
|
||||
#define DEMO_ASM_PUSHSECTION ".pushsection .rodata\n\t"
|
||||
#define DEMO_ASM_POPSECTION ".popsection\n\t"
|
||||
#define DEMO_ASM_OBJECT_TYPE(name) ".type "name", @object\n\t"
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__) && defined(__i386__)
|
||||
#if (defined(__WIN32__) && defined(__i386__)) || defined(__APPLE__)
|
||||
#define DEMO_ASM_NAME(name) "_"#name
|
||||
#else
|
||||
#define DEMO_ASM_NAME(name) #name
|
||||
@@ -75,14 +80,27 @@
|
||||
extern const uint8_t name[]; \
|
||||
__asm__(DEMO_EMBED_ASM(DEMO_ASM_NAME(name), file))
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# ifdef __MINGW_PRINTF_FORMAT
|
||||
# define DEMO_PRINTF_FUNC(fmt, args) __attribute__((format(__MINGW_PRINTF_FORMAT, fmt, args)))
|
||||
# else
|
||||
# define DEMO_PRINTF_FUNC(fmt, args) __attribute__((format(printf, fmt, args)))
|
||||
# endif
|
||||
#else
|
||||
# define DEMO_PRINTF_FUNC(fmt, args)
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))
|
||||
|
||||
#define DEMO_KEY_UNKNOWN 0x0000
|
||||
#define DEMO_KEY_ESCAPE 0xff1b
|
||||
#define DEMO_KEY_LEFT 0xff51
|
||||
#define DEMO_KEY_UP 0xff52
|
||||
#define DEMO_KEY_RIGHT 0xff53
|
||||
#define DEMO_KEY_DOWN 0xff54
|
||||
#define DEMO_KEY_UNKNOWN 0x0000
|
||||
#define DEMO_KEY_ESCAPE 0xff1b
|
||||
#define DEMO_KEY_LEFT 0xff51
|
||||
#define DEMO_KEY_UP 0xff52
|
||||
#define DEMO_KEY_RIGHT 0xff53
|
||||
#define DEMO_KEY_DOWN 0xff54
|
||||
#define DEMO_KEY_KP_ADD 0xffab
|
||||
#define DEMO_KEY_KP_SUBTRACT 0xffad
|
||||
#define DEMO_KEY_F1 0xffbe
|
||||
|
||||
struct demo_vec3
|
||||
{
|
||||
@@ -94,6 +112,26 @@ struct demo_vec4
|
||||
float x, y, z, w;
|
||||
};
|
||||
|
||||
struct demo_uvec2
|
||||
{
|
||||
uint32_t x, y;
|
||||
};
|
||||
|
||||
struct demo_uvec4
|
||||
{
|
||||
uint32_t x, y, z, w;
|
||||
};
|
||||
|
||||
struct demo_matrix
|
||||
{
|
||||
float m[4][4];
|
||||
};
|
||||
|
||||
struct demo_patch
|
||||
{
|
||||
uint16_t p[4][4];
|
||||
};
|
||||
|
||||
struct demo_swapchain_desc
|
||||
{
|
||||
unsigned int width;
|
||||
@@ -111,6 +149,36 @@ static inline void demo_vec3_set(struct demo_vec3 *v, float x, float y, float z)
|
||||
v->z = z;
|
||||
}
|
||||
|
||||
static inline void demo_vec3_subtract(struct demo_vec3 *v, const struct demo_vec3 *a, const struct demo_vec3 *b)
|
||||
{
|
||||
demo_vec3_set(v, a->x - b->x, a->y - b->y, a->z - b->z);
|
||||
}
|
||||
|
||||
static inline float demo_vec3_dot(const struct demo_vec3 *a, const struct demo_vec3 *b)
|
||||
{
|
||||
return a->x * b->x + a->y * b->y + a->z * b->z;
|
||||
}
|
||||
|
||||
static inline float demo_vec3_length(const struct demo_vec3 *v)
|
||||
{
|
||||
return sqrtf(demo_vec3_dot(v, v));
|
||||
}
|
||||
|
||||
static inline void demo_vec3_scale(struct demo_vec3 *v, const struct demo_vec3 *a, float s)
|
||||
{
|
||||
demo_vec3_set(v, a->x * s, a->y * s, a->z *s);
|
||||
}
|
||||
|
||||
static inline void demo_vec3_normalise(struct demo_vec3 *v, const struct demo_vec3 *a)
|
||||
{
|
||||
demo_vec3_scale(v, a, 1.0f / demo_vec3_length(a));
|
||||
}
|
||||
|
||||
static inline void demo_vec3_cross(struct demo_vec3 *v, const struct demo_vec3 *a, const struct demo_vec3 *b)
|
||||
{
|
||||
demo_vec3_set(v, a->y * b->z - a->z * b->y, a->z * b->x - a->x * b->z, a->x * b->y - a->y * b->x);
|
||||
}
|
||||
|
||||
static inline void demo_vec4_set(struct demo_vec4 *v, float x, float y, float z, float w)
|
||||
{
|
||||
v->x = x;
|
||||
@@ -119,6 +187,60 @@ static inline void demo_vec4_set(struct demo_vec4 *v, float x, float y, float z,
|
||||
v->w = w;
|
||||
}
|
||||
|
||||
static inline void demo_matrix_look_at_rh(struct demo_matrix *m, const struct demo_vec3 *eye,
|
||||
const struct demo_vec3 *ref, const struct demo_vec3 *up)
|
||||
{
|
||||
struct demo_vec3 f, s, t, u;
|
||||
|
||||
demo_vec3_subtract(&f, eye, ref);
|
||||
demo_vec3_normalise(&f, &f);
|
||||
demo_vec3_cross(&s, up, &f);
|
||||
demo_vec3_normalise(&s, &s);
|
||||
demo_vec3_cross(&u, &f, &s);
|
||||
demo_vec3_set(&t, demo_vec3_dot(&s, eye), demo_vec3_dot(&u, eye), demo_vec3_dot(&f, eye));
|
||||
|
||||
*m = (struct demo_matrix)
|
||||
{{
|
||||
{ s.x, u.x, f.x, 0.0f},
|
||||
{ s.y, u.y, f.y, 0.0f},
|
||||
{ s.z, u.z, f.z, 0.0f},
|
||||
{-t.x, -t.y, -t.z, 1.0f},
|
||||
}};
|
||||
}
|
||||
|
||||
static inline void demo_matrix_multiply(struct demo_matrix *out,
|
||||
const struct demo_matrix *a, const struct demo_matrix *b)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
for (j = 0; j < 4; ++j)
|
||||
{
|
||||
out->m[i][j] = a->m[i][0] * b->m[0][j]
|
||||
+ a->m[i][1] * b->m[1][j]
|
||||
+ a->m[i][2] * b->m[2][j]
|
||||
+ a->m[i][3] * b->m[3][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void demo_matrix_perspective_rh(struct demo_matrix *m, float w, float h, float z_near, float z_far)
|
||||
{
|
||||
float sx = 2.0 * z_near / w;
|
||||
float sy = 2.0 * z_near / h;
|
||||
float sz = z_far / (z_near - z_far);
|
||||
float d = z_near * sz;
|
||||
|
||||
*m = (struct demo_matrix)
|
||||
{{
|
||||
{ sx, 0.0f, 0.0f, 0.0f},
|
||||
{0.0f, sy, 0.0f, 0.0f},
|
||||
{0.0f, 0.0f, sz, -1.0f},
|
||||
{0.0f, 0.0f, d, 0.0f},
|
||||
}};
|
||||
}
|
||||
|
||||
static inline void demo_rasterizer_desc_init_default(D3D12_RASTERIZER_DESC *desc)
|
||||
{
|
||||
desc->FillMode = D3D12_FILL_MODE_SOLID;
|
||||
@@ -174,9 +296,11 @@ static inline HRESULT demo_create_root_signature(ID3D12Device *device,
|
||||
return hr;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "demo_win32.h"
|
||||
#ifdef VKD3D_CROSSTEST
|
||||
#include "demo_d3d12.h"
|
||||
#else
|
||||
#define INFINITE VKD3D_INFINITE
|
||||
#include "demo_xcb.h"
|
||||
# ifndef _WIN32
|
||||
# define INFINITE VKD3D_INFINITE
|
||||
# endif
|
||||
#include "demo_vkd3d.h"
|
||||
#endif
|
||||
|
261
demos/demo_d3d12.h
Normal file
261
demos/demo_d3d12.h
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright 2016 Józef Kucia for CodeWeavers
|
||||
* Copyright 2016 Henri Verbeet for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <vkd3d_dxgi1_4.h>
|
||||
#include <vkd3d_d3dcompiler.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct demo_win32
|
||||
{
|
||||
UINT (*GetDpiForSystem)(void);
|
||||
};
|
||||
|
||||
struct demo
|
||||
{
|
||||
union
|
||||
{
|
||||
struct demo_win32 win32;
|
||||
} u;
|
||||
|
||||
size_t window_count;
|
||||
|
||||
void *user_data;
|
||||
void (*idle_func)(struct demo *demo, void *user_data);
|
||||
};
|
||||
|
||||
struct demo_window
|
||||
{
|
||||
struct demo *demo;
|
||||
|
||||
void *user_data;
|
||||
void (*expose_func)(struct demo_window *window, void *user_data);
|
||||
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data);
|
||||
};
|
||||
|
||||
static inline bool demo_window_init(struct demo_window *window, struct demo *demo, void *user_data)
|
||||
{
|
||||
window->demo = demo;
|
||||
window->user_data = user_data;
|
||||
window->expose_func = NULL;
|
||||
window->key_press_func = NULL;
|
||||
++demo->window_count;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void demo_window_cleanup(struct demo_window *window)
|
||||
{
|
||||
--window->demo->window_count;
|
||||
}
|
||||
|
||||
#include "demo_win32.h"
|
||||
|
||||
struct demo_swapchain
|
||||
{
|
||||
IDXGISwapChain3 *swapchain;
|
||||
unsigned int buffer_count;
|
||||
char device_name[128];
|
||||
};
|
||||
|
||||
static inline void demo_cleanup(struct demo *demo)
|
||||
{
|
||||
demo_win32_cleanup(demo);
|
||||
}
|
||||
|
||||
static inline bool demo_init(struct demo *demo, void *user_data)
|
||||
{
|
||||
if (!demo_win32_init(&demo->u.win32))
|
||||
{
|
||||
fprintf(stderr, "Failed to initialise demo.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
demo->window_count = 0;
|
||||
demo->user_data = user_data;
|
||||
demo->idle_func = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void demo_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
|
||||
{
|
||||
demo_win32_get_dpi(demo, dpi_x, dpi_y);
|
||||
}
|
||||
|
||||
static inline const char *demo_get_platform_name(void)
|
||||
{
|
||||
return "Direct3D 12";
|
||||
}
|
||||
|
||||
static inline void demo_process_events(struct demo *demo)
|
||||
{
|
||||
demo_win32_process_events(demo);
|
||||
}
|
||||
|
||||
static inline void demo_set_idle_func(struct demo *demo,
|
||||
void (*idle_func)(struct demo *demo, void *user_data))
|
||||
{
|
||||
demo->idle_func = idle_func;
|
||||
}
|
||||
|
||||
static inline void demo_window_destroy(struct demo_window *window)
|
||||
{
|
||||
demo_window_win32_destroy(window);
|
||||
}
|
||||
|
||||
static inline struct demo_window *demo_window_create(struct demo *demo, const char *title,
|
||||
unsigned int width, unsigned int height, void *user_data)
|
||||
{
|
||||
return demo_window_win32_create(demo, title, width, height, user_data);
|
||||
}
|
||||
|
||||
static inline void demo_window_set_expose_func(struct demo_window *window,
|
||||
void (*expose_func)(struct demo_window *window, void *user_data))
|
||||
{
|
||||
window->expose_func = expose_func;
|
||||
}
|
||||
|
||||
static inline void demo_window_set_key_press_func(struct demo_window *window,
|
||||
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data))
|
||||
{
|
||||
window->key_press_func = key_press_func;
|
||||
}
|
||||
|
||||
static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *command_queue,
|
||||
struct demo_window *window, const struct demo_swapchain_desc *desc)
|
||||
{
|
||||
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
|
||||
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
|
||||
struct demo_swapchain *swapchain;
|
||||
DXGI_ADAPTER_DESC adapter_desc;
|
||||
IDXGISwapChain1 *swapchain1;
|
||||
IDXGIFactory2 *factory;
|
||||
IDXGIAdapter *adapter;
|
||||
ID3D12Device *device;
|
||||
unsigned int i;
|
||||
HRESULT hr;
|
||||
LUID luid;
|
||||
|
||||
if (!(swapchain = malloc(sizeof(*swapchain))))
|
||||
return NULL;
|
||||
|
||||
if (FAILED(CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&factory)))
|
||||
goto fail;
|
||||
|
||||
if (FAILED(ID3D12CommandQueue_GetDevice(command_queue, &IID_ID3D12Device, (void **)&device)))
|
||||
goto fail;
|
||||
luid = ID3D12Device_GetAdapterLuid(device);
|
||||
ID3D12Device_Release(device);
|
||||
|
||||
sprintf(swapchain->device_name, "Unknown");
|
||||
for (i = 0; IDXGIFactory2_EnumAdapters(factory, i, &adapter) == S_OK; ++i)
|
||||
{
|
||||
hr = IDXGIAdapter_GetDesc(adapter, &adapter_desc);
|
||||
IDXGIAdapter_Release(adapter);
|
||||
if (FAILED(hr))
|
||||
continue;
|
||||
|
||||
if (adapter_desc.AdapterLuid.LowPart == luid.LowPart
|
||||
&& adapter_desc.AdapterLuid.HighPart == luid.HighPart)
|
||||
{
|
||||
snprintf(swapchain->device_name, ARRAY_SIZE(swapchain->device_name), "%ls", adapter_desc.Description);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
|
||||
swapchain_desc.BufferCount = desc->buffer_count;
|
||||
swapchain_desc.Width = desc->width;
|
||||
swapchain_desc.Height = desc->height;
|
||||
swapchain_desc.Format = desc->format;
|
||||
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
swapchain_desc.SampleDesc.Count = 1;
|
||||
|
||||
hr = IDXGIFactory2_CreateSwapChainForHwnd(factory, (IUnknown *)command_queue,
|
||||
window_win32->window, &swapchain_desc, NULL, NULL, &swapchain1);
|
||||
IDXGIFactory2_Release(factory);
|
||||
if (FAILED(hr))
|
||||
goto fail;
|
||||
|
||||
swapchain->buffer_count = desc->buffer_count;
|
||||
hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain3, (void **)&swapchain->swapchain);
|
||||
IDXGISwapChain1_Release(swapchain1);
|
||||
if (FAILED(hr))
|
||||
goto fail;
|
||||
|
||||
return swapchain;
|
||||
|
||||
fail:
|
||||
free(swapchain);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline const char *demo_swapchain_get_device_name(struct demo_swapchain *swapchain)
|
||||
{
|
||||
return swapchain->device_name;
|
||||
}
|
||||
|
||||
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
|
||||
{
|
||||
return IDXGISwapChain3_GetCurrentBackBufferIndex(swapchain->swapchain);
|
||||
}
|
||||
|
||||
static inline ID3D12Resource *demo_swapchain_get_back_buffer(struct demo_swapchain *swapchain, unsigned int index)
|
||||
{
|
||||
ID3D12Resource *buffer;
|
||||
|
||||
if (FAILED(IDXGISwapChain3_GetBuffer(swapchain->swapchain, index,
|
||||
&IID_ID3D12Resource, (void **)&buffer)))
|
||||
return NULL;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static inline unsigned int demo_swapchain_get_back_buffer_count(struct demo_swapchain *swapchain)
|
||||
{
|
||||
return swapchain->buffer_count;
|
||||
}
|
||||
|
||||
static inline void demo_swapchain_present(struct demo_swapchain *swapchain)
|
||||
{
|
||||
IDXGISwapChain3_Present(swapchain->swapchain, 1, 0);
|
||||
}
|
||||
|
||||
static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
|
||||
{
|
||||
IDXGISwapChain3_Release(swapchain->swapchain);
|
||||
free(swapchain);
|
||||
}
|
||||
|
||||
static inline HANDLE demo_create_event(void)
|
||||
{
|
||||
return CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||
}
|
||||
|
||||
static inline unsigned int demo_wait_event(HANDLE event, unsigned int ms)
|
||||
{
|
||||
return WaitForSingleObject(event, ms);
|
||||
}
|
||||
|
||||
static inline void demo_destroy_event(HANDLE event)
|
||||
{
|
||||
CloseHandle(event);
|
||||
}
|
324
demos/demo_macos.h
Normal file
324
demos/demo_macos.h
Normal file
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Copyright 2025 Henri Verbeet
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
typedef long NSInteger;
|
||||
typedef unsigned long NSUInteger;
|
||||
|
||||
typedef struct NSPoint
|
||||
{
|
||||
double x, y;
|
||||
} NSPoint;
|
||||
|
||||
typedef struct NSRect
|
||||
{
|
||||
double x, y;
|
||||
double w, h;
|
||||
} NSRect;
|
||||
|
||||
#define BOOL OBJC_BOOL
|
||||
#include "private/appkit.h"
|
||||
#include "private/foundation.h"
|
||||
#include "private/quartzcore.h"
|
||||
#undef BOOL
|
||||
|
||||
extern const id NSDefaultRunLoopMode;
|
||||
|
||||
enum NSBackingStoreType
|
||||
{
|
||||
NSBackingStoreBuffered = 2,
|
||||
};
|
||||
|
||||
enum NSEventType
|
||||
{
|
||||
NSEventTypeKeyDown = 0xa,
|
||||
NSEventTypeApplicationDefined = 0xf,
|
||||
};
|
||||
|
||||
enum NSWindowStyleMask
|
||||
{
|
||||
NSWindowStyleMaskBorderless = 0x0000,
|
||||
NSWindowStyleMaskTitled = 0x0001,
|
||||
NSWindowStyleMaskClosable = 0x0002,
|
||||
NSWindowStyleMaskMiniaturizable = 0x0004,
|
||||
NSWindowStyleMaskResizable = 0x0008,
|
||||
NSWindowStyleMaskUtilityWindow = 0x0010,
|
||||
NSWindowStyleMaskDocModalWindow = 0x0040,
|
||||
NSWindowStyleMaskNonactivatingPanel = 0x0080,
|
||||
NSWindowStyleMaskUnifiedTitleAndToolbar = 0x1000,
|
||||
NSWindowStyleMaskHUDWindow = 0x2000,
|
||||
NSWindowStyleMaskFullScreen = 0x4000,
|
||||
NSWindowStyleMaskFullSizeContentView = 0x8000,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
DemoWindowDestroyed,
|
||||
};
|
||||
|
||||
struct demo_window_macos
|
||||
{
|
||||
struct demo_window w;
|
||||
id window;
|
||||
id layer;
|
||||
};
|
||||
|
||||
static struct demo_window_macos *demo_macos_find_macos_window(struct demo *demo, id window)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < demo->window_count; ++i)
|
||||
{
|
||||
struct demo_window_macos *window_macos = CONTAINING_RECORD(demo->windows[i], struct demo_window_macos, w);
|
||||
|
||||
if (window_macos->window == window)
|
||||
return window_macos;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VkSurfaceKHR demo_window_macos_create_vk_surface(struct demo_window *window, VkInstance vk_instance)
|
||||
{
|
||||
struct demo_window_macos *window_macos = CONTAINING_RECORD(window, struct demo_window_macos, w);
|
||||
struct VkMetalSurfaceCreateInfoEXT surface_desc;
|
||||
VkSurfaceKHR vk_surface;
|
||||
id l, v;
|
||||
|
||||
l = window_macos->layer = CAMetalLayer_layer();
|
||||
CAMetalLayer_setContentsScale(l, NSScreen_backingScaleFactor(NSScreen_mainScreen()));
|
||||
v = NSWindow_contentView(window_macos->window);
|
||||
NSView_setLayer(v, l);
|
||||
NSView_setWantsLayer(v, true);
|
||||
|
||||
surface_desc.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
|
||||
surface_desc.pNext = NULL;
|
||||
surface_desc.flags = 0;
|
||||
surface_desc.pLayer = l;
|
||||
if (vkCreateMetalSurfaceEXT(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
|
||||
return VK_NULL_HANDLE;
|
||||
|
||||
return vk_surface;
|
||||
}
|
||||
|
||||
static void demo_window_macos_destroy(struct demo_window *window)
|
||||
{
|
||||
struct demo_window_macos *window_macos = CONTAINING_RECORD(window, struct demo_window_macos, w);
|
||||
|
||||
NSWindow_close(window_macos->window);
|
||||
}
|
||||
|
||||
static void demo_window_macos_destroyed(struct demo_window_macos *window_macos)
|
||||
{
|
||||
CAMetalLayer_release(window_macos->layer);
|
||||
NSWindow_release(window_macos->window);
|
||||
demo_window_cleanup(&window_macos->w);
|
||||
free(window_macos);
|
||||
}
|
||||
|
||||
static struct demo_window *demo_window_macos_create(struct demo *demo,
|
||||
const char *title, unsigned int width, unsigned int height, void *user_data)
|
||||
{
|
||||
unsigned long style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable;
|
||||
struct demo_window_macos *window_macos;
|
||||
NSRect r = {0, 0, width, height};
|
||||
double scale;
|
||||
id w, s;
|
||||
|
||||
if (!(window_macos = malloc(sizeof(*window_macos))))
|
||||
return NULL;
|
||||
|
||||
if (!demo_window_init(&window_macos->w, demo, user_data,
|
||||
demo_window_macos_create_vk_surface, demo_window_macos_destroy))
|
||||
{
|
||||
free(window_macos);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = NSScreen_mainScreen();
|
||||
scale = NSScreen_backingScaleFactor(s);
|
||||
r.w /= scale;
|
||||
r.h /= scale;
|
||||
|
||||
w = window_macos->window = class_createInstance(objc_getClass("DemoWindow"), 0);
|
||||
NSWindow_initWithContentRect(w, r, style, NSBackingStoreBuffered, true, s);
|
||||
NSWindow_setReleasedWhenClosed(w, false);
|
||||
NSWindow_setDelegate(w, w);
|
||||
NSWindow_center(w);
|
||||
NSWindow_setTitle(w, NSString_stringWithUTF8String(title));
|
||||
|
||||
NSWindow_makeKeyAndOrderFront(w, nil);
|
||||
window_macos->layer = nil;
|
||||
|
||||
return &window_macos->w;
|
||||
}
|
||||
|
||||
static void demo_macos_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
|
||||
{
|
||||
*dpi_x = *dpi_y = 96.0 * NSScreen_backingScaleFactor(NSScreen_mainScreen());
|
||||
}
|
||||
|
||||
static demo_key demo_key_from_nsevent(id event)
|
||||
{
|
||||
enum vkey
|
||||
{
|
||||
kVK_ANSI_A = 0x00,
|
||||
kVK_ANSI_F = 0x03,
|
||||
kVK_ANSI_W = 0x0d,
|
||||
kVK_ANSI_Equal = 0x18,
|
||||
kVK_ANSI_Minus = 0x1b,
|
||||
kVK_Escape = 0x35,
|
||||
kVK_ANSI_KeypadPlus = 0x45,
|
||||
kVK_ANSI_KeypadMinus = 0x4e,
|
||||
kVK_F1 = 0x7a,
|
||||
kVK_LeftArrow = 0x7b,
|
||||
kVK_RightArrow = 0x7c,
|
||||
kVK_DownArrow = 0x7d,
|
||||
kVK_UpArrow = 0x7e,
|
||||
} vkey;
|
||||
size_t i;
|
||||
|
||||
static const struct
|
||||
{
|
||||
enum vkey vkey;
|
||||
demo_key demo_key;
|
||||
}
|
||||
lookup[] =
|
||||
{
|
||||
{kVK_ANSI_A, 'a'},
|
||||
{kVK_ANSI_F, 'f'},
|
||||
{kVK_ANSI_W, 'w'},
|
||||
{kVK_ANSI_Equal, '='},
|
||||
{kVK_ANSI_Minus, '-'},
|
||||
{kVK_Escape, DEMO_KEY_ESCAPE},
|
||||
{kVK_ANSI_KeypadPlus, DEMO_KEY_KP_ADD},
|
||||
{kVK_ANSI_KeypadMinus, DEMO_KEY_KP_SUBTRACT},
|
||||
{kVK_F1, DEMO_KEY_F1},
|
||||
{kVK_LeftArrow, DEMO_KEY_LEFT},
|
||||
{kVK_RightArrow, DEMO_KEY_RIGHT},
|
||||
{kVK_DownArrow, DEMO_KEY_DOWN},
|
||||
{kVK_UpArrow, DEMO_KEY_UP},
|
||||
};
|
||||
|
||||
vkey = NSEvent_keyCode(event);
|
||||
for (i = 0; i < ARRAY_SIZE(lookup); ++i)
|
||||
{
|
||||
if (lookup[i].vkey == vkey)
|
||||
return lookup[i].demo_key;
|
||||
}
|
||||
|
||||
return DEMO_KEY_UNKNOWN;
|
||||
}
|
||||
|
||||
static void demo_macos_process_events(struct demo *demo)
|
||||
{
|
||||
struct demo_window_macos *window_macos;
|
||||
struct demo_window *window;
|
||||
id a, event;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < demo->window_count; ++i)
|
||||
{
|
||||
if ((window = demo->windows[i])->expose_func)
|
||||
window->expose_func(window, window->user_data);
|
||||
}
|
||||
|
||||
a = NSApplication_sharedApplication();
|
||||
while (demo->window_count)
|
||||
{
|
||||
if (!demo->idle_func)
|
||||
{
|
||||
if (!(event = NSApplication_nextEventMatchingMask(a, ~(uint64_t)0,
|
||||
NSDate_distantFuture(), NSDefaultRunLoopMode, true)))
|
||||
break;
|
||||
}
|
||||
else if (!(event = NSApplication_nextEventMatchingMask(a, ~(uint64_t)0, nil, NSDefaultRunLoopMode, true)))
|
||||
{
|
||||
demo->idle_func(demo, demo->user_data);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (NSEvent_type(event))
|
||||
{
|
||||
case NSEventTypeKeyDown:
|
||||
if (NSMenu_performKeyEquivalent(NSApplication_mainMenu(a), event))
|
||||
continue;
|
||||
if (!(window_macos = demo_macos_find_macos_window(demo, NSEvent_window(event)))
|
||||
|| !window_macos->w.key_press_func)
|
||||
break;
|
||||
window_macos->w.key_press_func(&window_macos->w,
|
||||
demo_key_from_nsevent(event), window_macos->w.user_data);
|
||||
continue;
|
||||
|
||||
case NSEventTypeApplicationDefined:
|
||||
if (NSEvent_subtype(event) != DemoWindowDestroyed
|
||||
|| !(window_macos = demo_macos_find_macos_window(demo, NSEvent_window(event))))
|
||||
break;
|
||||
demo_window_macos_destroyed(window_macos);
|
||||
continue;
|
||||
}
|
||||
|
||||
NSApplication_sendEvent(a, event);
|
||||
}
|
||||
}
|
||||
|
||||
static void DemoWindow_windowWillClose(id window, SEL sel, id notification)
|
||||
{
|
||||
id event;
|
||||
|
||||
event = NSEvent_otherEventWithType(NSEventTypeApplicationDefined, (NSPoint){0.0, 0.0},
|
||||
0, 0.0, NSWindow_windowNumber(window), nil, DemoWindowDestroyed, 0, 0);
|
||||
NSApplication_postEvent(NSApplication_sharedApplication(), event, true);
|
||||
}
|
||||
|
||||
static void demo_macos_cleanup(struct demo *demo)
|
||||
{
|
||||
}
|
||||
|
||||
static bool demo_macos_init(struct demo_macos *macos)
|
||||
{
|
||||
id application, item, menu, submenu;
|
||||
Class c;
|
||||
|
||||
if ((c = objc_allocateClassPair(objc_getClass("NSWindow"), "DemoWindow", 0)))
|
||||
{
|
||||
class_addMethod(c, sel_registerName("windowWillClose:"), (IMP)DemoWindow_windowWillClose, "v@:@");
|
||||
objc_registerClassPair(c);
|
||||
}
|
||||
|
||||
application = NSApplication_sharedApplication();
|
||||
NSApplication_setActivationPolicy(application, 0);
|
||||
|
||||
menu = NSMenu_new();
|
||||
|
||||
submenu = NSMenu_new();
|
||||
NSMenu_addItemWithTitle(submenu, NSString_stringWithUTF8String("Quit"),
|
||||
sel_registerName("terminate:"), NSString_stringWithUTF8String("q"));
|
||||
|
||||
item = NSMenuItem_new();
|
||||
NSMenuItem_setSubmenu(item, submenu);
|
||||
NSMenu_release(submenu);
|
||||
NSMenu_addItem(menu, item);
|
||||
NSMenuItem_release(item);
|
||||
|
||||
NSApplication_setMainMenu(application, menu);
|
||||
NSMenu_release(menu);
|
||||
|
||||
NSApplication_finishLaunching(application);
|
||||
|
||||
return true;
|
||||
}
|
640
demos/demo_vkd3d.h
Normal file
640
demos/demo_vkd3d.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -17,85 +17,108 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <vkd3d_dxgi1_4.h>
|
||||
#include <vkd3d_d3dcompiler.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#define DEMO_WIN32_WINDOW_CLASS_NAME L"demo_wc"
|
||||
|
||||
#define DEMO_WINDOW_CLASS_NAME L"demo_wc"
|
||||
|
||||
struct demo
|
||||
struct demo_window_win32
|
||||
{
|
||||
size_t window_count;
|
||||
bool quit;
|
||||
struct demo_window w;
|
||||
|
||||
void *user_data;
|
||||
void (*idle_func)(struct demo *demo, void *user_data);
|
||||
};
|
||||
|
||||
struct demo_window
|
||||
{
|
||||
HINSTANCE instance;
|
||||
HWND hwnd;
|
||||
struct demo *demo;
|
||||
void *user_data;
|
||||
void (*expose_func)(struct demo_window *window, void *user_data);
|
||||
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data);
|
||||
HWND window;
|
||||
};
|
||||
|
||||
struct demo_swapchain
|
||||
#ifndef VKD3D_CROSSTEST
|
||||
static VkSurfaceKHR demo_window_win32_create_vk_surface(struct demo_window *window, VkInstance vk_instance)
|
||||
{
|
||||
IDXGISwapChain3 *swapchain;
|
||||
};
|
||||
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
|
||||
struct VkWin32SurfaceCreateInfoKHR surface_desc;
|
||||
VkSurfaceKHR vk_surface;
|
||||
|
||||
static inline struct demo_window *demo_window_create(struct demo *demo, const char *title,
|
||||
surface_desc.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
surface_desc.pNext = NULL;
|
||||
surface_desc.flags = 0;
|
||||
surface_desc.hinstance = window_win32->instance;
|
||||
surface_desc.hwnd = window_win32->window;
|
||||
if (vkCreateWin32SurfaceKHR(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
|
||||
return VK_NULL_HANDLE;
|
||||
|
||||
return vk_surface;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void demo_window_win32_destroy(struct demo_window *window)
|
||||
{
|
||||
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
|
||||
|
||||
DestroyWindow(window_win32->window);
|
||||
}
|
||||
|
||||
static void demo_window_win32_destroyed(struct demo_window *window)
|
||||
{
|
||||
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
|
||||
|
||||
demo_window_cleanup(&window_win32->w);
|
||||
free(window_win32);
|
||||
}
|
||||
|
||||
static struct demo_window *demo_window_win32_create(struct demo *demo, const char *title,
|
||||
unsigned int width, unsigned int height, void *user_data)
|
||||
{
|
||||
struct demo_window_win32 *window_win32;
|
||||
RECT rect = {0, 0, width, height};
|
||||
struct demo_window *window;
|
||||
int title_size;
|
||||
WCHAR *title_w;
|
||||
DWORD style;
|
||||
|
||||
if (!(window = malloc(sizeof(*window))))
|
||||
if (!(window_win32 = malloc(sizeof(*window_win32))))
|
||||
return NULL;
|
||||
|
||||
#ifdef VKD3D_CROSSTEST
|
||||
if (!demo_window_init(&window_win32->w, demo, user_data))
|
||||
#else
|
||||
if (!demo_window_init(&window_win32->w, demo, user_data,
|
||||
demo_window_win32_create_vk_surface, demo_window_win32_destroy))
|
||||
#endif
|
||||
{
|
||||
free(window_win32);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
title_size = MultiByteToWideChar(CP_UTF8, 0, title, -1, NULL, 0);
|
||||
if (!(title_w = calloc(title_size, sizeof(*title_w))))
|
||||
{
|
||||
free(window);
|
||||
demo_window_cleanup(&window_win32->w);
|
||||
free(window_win32);
|
||||
return NULL;
|
||||
}
|
||||
MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w, title_size);
|
||||
|
||||
window->instance = GetModuleHandle(NULL);
|
||||
window->user_data = user_data;
|
||||
window->expose_func = NULL;
|
||||
window->key_press_func = NULL;
|
||||
window_win32->instance = GetModuleHandle(NULL);
|
||||
|
||||
style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE;
|
||||
AdjustWindowRect(&rect, style, FALSE);
|
||||
window->hwnd = CreateWindowExW(0, DEMO_WINDOW_CLASS_NAME, title_w, style, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, window->instance, NULL);
|
||||
window_win32->window = CreateWindowExW(0, DEMO_WIN32_WINDOW_CLASS_NAME, title_w, style, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, window_win32->instance, NULL);
|
||||
free(title_w);
|
||||
if (!window->hwnd)
|
||||
if (!window_win32->window)
|
||||
{
|
||||
free(window);
|
||||
demo_window_cleanup(&window_win32->w);
|
||||
free(window_win32);
|
||||
return NULL;
|
||||
}
|
||||
SetWindowLongPtrW(window->hwnd, GWLP_USERDATA, (LONG_PTR)window);
|
||||
window->demo = demo;
|
||||
++demo->window_count;
|
||||
SetWindowLongPtrW(window_win32->window, GWLP_USERDATA, (LONG_PTR)window_win32);
|
||||
|
||||
return window;
|
||||
return &window_win32->w;
|
||||
}
|
||||
|
||||
static inline void demo_window_destroy(struct demo_window *window)
|
||||
static void demo_win32_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
|
||||
{
|
||||
DestroyWindow(window->hwnd);
|
||||
struct demo_win32 *win32 = &demo->u.win32;
|
||||
|
||||
*dpi_x = *dpi_y = win32->GetDpiForSystem();
|
||||
}
|
||||
|
||||
static inline demo_key demo_key_from_vkey(DWORD vkey)
|
||||
static demo_key demo_key_from_win32_vkey(DWORD vkey)
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
@@ -104,18 +127,23 @@ static inline demo_key demo_key_from_vkey(DWORD vkey)
|
||||
}
|
||||
lookup[] =
|
||||
{
|
||||
{VK_ESCAPE, DEMO_KEY_ESCAPE},
|
||||
{VK_LEFT, DEMO_KEY_LEFT},
|
||||
{VK_RIGHT, DEMO_KEY_RIGHT},
|
||||
{VK_UP, DEMO_KEY_UP},
|
||||
{VK_DOWN, DEMO_KEY_DOWN},
|
||||
{VK_OEM_MINUS, '-'},
|
||||
{VK_OEM_PLUS, '='},
|
||||
{VK_ESCAPE, DEMO_KEY_ESCAPE},
|
||||
{VK_LEFT, DEMO_KEY_LEFT},
|
||||
{VK_UP, DEMO_KEY_UP},
|
||||
{VK_RIGHT, DEMO_KEY_RIGHT},
|
||||
{VK_DOWN, DEMO_KEY_DOWN},
|
||||
{VK_ADD, DEMO_KEY_KP_ADD},
|
||||
{VK_SUBTRACT, DEMO_KEY_KP_SUBTRACT},
|
||||
{VK_F1, DEMO_KEY_F1},
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
if (vkey >= '0' && vkey <= '9')
|
||||
return vkey;
|
||||
if (vkey >= 'A' && vkey <= 'Z')
|
||||
return vkey;
|
||||
return vkey + 0x20;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(lookup); ++i)
|
||||
{
|
||||
@@ -126,46 +154,33 @@ static inline demo_key demo_key_from_vkey(DWORD vkey)
|
||||
return DEMO_KEY_UNKNOWN;
|
||||
}
|
||||
|
||||
static inline LRESULT CALLBACK demo_window_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
|
||||
static LRESULT CALLBACK demo_win32_window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
struct demo_window *window = (void *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||
struct demo_window_win32 *window_win32 = (void *)GetWindowLongPtrW(window, GWLP_USERDATA);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_PAINT:
|
||||
if (window && window->expose_func)
|
||||
window->expose_func(window, window->user_data);
|
||||
if (window_win32 && window_win32->w.expose_func)
|
||||
window_win32->w.expose_func(&window_win32->w, window_win32->w.user_data);
|
||||
return 0;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
if (!window->key_press_func)
|
||||
if (!window_win32->w.key_press_func)
|
||||
break;
|
||||
window->key_press_func(window, demo_key_from_vkey(wparam), window->user_data);
|
||||
window_win32->w.key_press_func(&window_win32->w,
|
||||
demo_key_from_win32_vkey(wparam), window_win32->w.user_data);
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (!--window->demo->window_count)
|
||||
window->demo->quit = true;
|
||||
free(window);
|
||||
demo_window_win32_destroyed(&window_win32->w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProcW(hwnd, message, wparam, lparam);
|
||||
return DefWindowProcW(window, message, wparam, lparam);
|
||||
}
|
||||
|
||||
static inline void demo_window_set_key_press_func(struct demo_window *window,
|
||||
void (*key_press_func)(struct demo_window *window, demo_key key, void *user_data))
|
||||
{
|
||||
window->key_press_func = key_press_func;
|
||||
}
|
||||
|
||||
static inline void demo_window_set_expose_func(struct demo_window *window,
|
||||
void (*expose_func)(struct demo_window *window, void *user_data))
|
||||
{
|
||||
window->expose_func = expose_func;
|
||||
}
|
||||
|
||||
static inline void demo_process_events(struct demo *demo)
|
||||
static void demo_win32_process_events(struct demo *demo)
|
||||
{
|
||||
MSG msg = {0};
|
||||
|
||||
@@ -186,18 +201,28 @@ static inline void demo_process_events(struct demo *demo)
|
||||
break;
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
if (demo->quit)
|
||||
if (!demo->window_count)
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool demo_init(struct demo *demo, void *user_data)
|
||||
static void demo_win32_cleanup(struct demo *demo)
|
||||
{
|
||||
UnregisterClassW(DEMO_WIN32_WINDOW_CLASS_NAME, GetModuleHandle(NULL));
|
||||
}
|
||||
|
||||
static inline UINT demo_win32_GetDpiForSystem(void)
|
||||
{
|
||||
return 96;
|
||||
}
|
||||
|
||||
static bool demo_win32_init(struct demo_win32 *win32)
|
||||
{
|
||||
WNDCLASSEXW wc;
|
||||
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = demo_window_proc;
|
||||
wc.lpfnWndProc = demo_win32_window_proc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = GetModuleHandle(NULL);
|
||||
@@ -205,110 +230,15 @@ static inline bool demo_init(struct demo *demo, void *user_data)
|
||||
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = DEMO_WINDOW_CLASS_NAME;
|
||||
wc.lpszClassName = DEMO_WIN32_WINDOW_CLASS_NAME;
|
||||
wc.hIconSm = LoadIconW(NULL, IDI_WINLOGO);
|
||||
if (!RegisterClassExW(&wc))
|
||||
return false;
|
||||
|
||||
demo->window_count = 0;
|
||||
demo->quit = false;
|
||||
demo->user_data = user_data;
|
||||
demo->idle_func = NULL;
|
||||
if ((win32->GetDpiForSystem = (void *)GetProcAddress(GetModuleHandleA("user32"), "GetDpiForSystem")))
|
||||
SetProcessDPIAware();
|
||||
else
|
||||
win32->GetDpiForSystem = demo_win32_GetDpiForSystem;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void demo_cleanup(struct demo *demo)
|
||||
{
|
||||
UnregisterClassW(DEMO_WINDOW_CLASS_NAME, GetModuleHandle(NULL));
|
||||
}
|
||||
|
||||
static inline void demo_set_idle_func(struct demo *demo,
|
||||
void (*idle_func)(struct demo *demo, void *user_data))
|
||||
{
|
||||
demo->idle_func = idle_func;
|
||||
}
|
||||
|
||||
static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *command_queue,
|
||||
struct demo_window *window, const struct demo_swapchain_desc *desc)
|
||||
{
|
||||
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
|
||||
struct demo_swapchain *swapchain;
|
||||
IDXGISwapChain1 *swapchain1;
|
||||
IDXGIFactory2 *factory;
|
||||
HRESULT hr;
|
||||
|
||||
if (!(swapchain = malloc(sizeof(*swapchain))))
|
||||
return NULL;
|
||||
|
||||
if (FAILED(CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&factory)))
|
||||
goto fail;
|
||||
|
||||
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
|
||||
swapchain_desc.BufferCount = desc->buffer_count;
|
||||
swapchain_desc.Width = desc->width;
|
||||
swapchain_desc.Height = desc->height;
|
||||
swapchain_desc.Format = desc->format;
|
||||
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
swapchain_desc.SampleDesc.Count = 1;
|
||||
|
||||
hr = IDXGIFactory2_CreateSwapChainForHwnd(factory, (IUnknown *)command_queue,
|
||||
window->hwnd, &swapchain_desc, NULL, NULL, &swapchain1);
|
||||
IDXGIFactory2_Release(factory);
|
||||
if (FAILED(hr))
|
||||
goto fail;
|
||||
|
||||
hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain3, (void **)&swapchain->swapchain);
|
||||
IDXGISwapChain1_Release(swapchain1);
|
||||
if (FAILED(hr))
|
||||
goto fail;
|
||||
|
||||
return swapchain;
|
||||
|
||||
fail:
|
||||
free(swapchain);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
|
||||
{
|
||||
return IDXGISwapChain3_GetCurrentBackBufferIndex(swapchain->swapchain);
|
||||
}
|
||||
|
||||
static inline ID3D12Resource *demo_swapchain_get_back_buffer(struct demo_swapchain *swapchain, unsigned int index)
|
||||
{
|
||||
ID3D12Resource *buffer;
|
||||
|
||||
if (FAILED(IDXGISwapChain3_GetBuffer(swapchain->swapchain, index,
|
||||
&IID_ID3D12Resource, (void **)&buffer)))
|
||||
return NULL;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static inline void demo_swapchain_present(struct demo_swapchain *swapchain)
|
||||
{
|
||||
IDXGISwapChain3_Present(swapchain->swapchain, 1, 0);
|
||||
}
|
||||
|
||||
static inline void demo_swapchain_destroy(struct demo_swapchain *swapchain)
|
||||
{
|
||||
IDXGISwapChain3_Release(swapchain->swapchain);
|
||||
free(swapchain);
|
||||
}
|
||||
|
||||
static inline HANDLE demo_create_event(void)
|
||||
{
|
||||
return CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||
}
|
||||
|
||||
static inline unsigned int demo_wait_event(HANDLE event, unsigned int ms)
|
||||
{
|
||||
return WaitForSingleObject(event, ms);
|
||||
}
|
||||
|
||||
static inline void demo_destroy_event(HANDLE event)
|
||||
{
|
||||
CloseHandle(event);
|
||||
}
|
||||
|
612
demos/demo_xcb.h
612
demos/demo_xcb.h
File diff suppressed because it is too large
Load Diff
145
demos/etl16-unicode.h
Normal file
145
demos/etl16-unicode.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright 2025 Henri Verbeet
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* The glyph data is derived from etl16-unicode.bdf as found on
|
||||
* ftp://ftp.ring.gr.jp/pub/X/opengroup/contrib/fonts/etl-unicode.tar.gz
|
||||
* with the following license:
|
||||
*
|
||||
* Public domain font. Share and enjoy.
|
||||
*/
|
||||
|
||||
/* Each line in etl16_unicode[] below contains the bitmap data for a single
|
||||
* 8x16 glyph, starting at ASCII 0x20 (space). Each byte corresponds to a
|
||||
* single line in the glyph.
|
||||
*
|
||||
* The BDF bitmap data is essentially the same format we're using here, so we
|
||||
* could have extracted the glyphs manually, or perhaps using a small script.
|
||||
* However, bdf2psf can do most of the work for us, by creating a PSF1 font
|
||||
* from the BDF.
|
||||
*
|
||||
* A PSF1 font has a 4 byte header, followed by at least 256 glyphs.
|
||||
* For a 8x16 font, each glyph consists of 16 bytes, one byte for each row.
|
||||
*
|
||||
* We're not interested in control characters or extended ASCII, so we skip
|
||||
* the first 0x4 (header) + 0x20 (control characters) * 0x10 = 516 bytes, and
|
||||
* extract the next (0x80 - 0x20) * 0x10 = 1536 bytes:
|
||||
*
|
||||
* bdf2psf etl16-unicode.bdf standard.equivalents ascii.set 256 /dev/stdout | xxd -i -c 16 -s 516 -l 1536
|
||||
*
|
||||
* and we're done.
|
||||
*/
|
||||
|
||||
static const uint8_t etl16_unicode[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x66, 0x22, 0x22, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x12, 0x7e, 0x24, 0x24, 0x7e, 0x48, 0x48, 0x48, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x3e, 0x49, 0x48, 0x38, 0x0e, 0x09, 0x49, 0x3e, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x31, 0x4a, 0x4a, 0x34, 0x08, 0x08, 0x16, 0x29, 0x29, 0x46, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x39, 0x45, 0x42, 0x46, 0x39, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x00,
|
||||
0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x49, 0x2a, 0x1c, 0x2a, 0x49, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x7f, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x02, 0x0c, 0x10, 0x20, 0x40, 0x40, 0x7e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x02, 0x1c, 0x02, 0x02, 0x42, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x0c, 0x14, 0x24, 0x44, 0x44, 0x7e, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c, 0x02, 0x02, 0x02, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1c, 0x20, 0x40, 0x40, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7e, 0x02, 0x02, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x02, 0x04, 0x38, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x02, 0x04, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1c, 0x22, 0x4a, 0x56, 0x52, 0x52, 0x52, 0x4e, 0x20, 0x1e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x24, 0x42, 0x42, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x7c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x40, 0x7e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x40, 0x40, 0x4e, 0x42, 0x42, 0x46, 0x3a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x42, 0x44, 0x48, 0x50, 0x60, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x66, 0x66, 0x5a, 0x5a, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x42, 0x62, 0x62, 0x52, 0x52, 0x4a, 0x4a, 0x46, 0x46, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x5a, 0x66, 0x3c, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x48, 0x44, 0x44, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x40, 0x30, 0x0c, 0x02, 0x42, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7f, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x41, 0x22, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x5a, 0x5a, 0x66, 0x66, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7e, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x7e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0e, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00,
|
||||
0x00, 0x00, 0x18, 0x24, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00,
|
||||
0x00, 0x00, 0x18, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x02, 0x3e, 0x42, 0x42, 0x46, 0x3a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x3a, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0x10, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3a, 0x44, 0x44, 0x44, 0x38, 0x20, 0x3c, 0x42, 0x42, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x48, 0x30,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5c, 0x40, 0x40,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3a, 0x02, 0x02,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x62, 0x42, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x40, 0x30, 0x0c, 0x02, 0x42, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x18, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x42, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x26, 0x1a, 0x02, 0x02, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x0c, 0x00,
|
||||
0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x00, 0x30, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x30, 0x00,
|
||||
0x00, 0x00, 0x00, 0x31, 0x49, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xfc, 0x1b, 0x26, 0xef, 0xc8, 0xe0, 0x43, 0x20, 0x89, 0x58, 0x62, 0x5e, 0x79, 0xba, 0xee, 0x7e,
|
||||
};
|
127
demos/gears.c
127
demos/gears.c
@@ -45,7 +45,6 @@
|
||||
#include <sys/time.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "demo.h"
|
||||
|
||||
DEMO_EMBED(gears_hlsl, "gears.hlsl");
|
||||
@@ -59,7 +58,7 @@ struct cxg_fence
|
||||
|
||||
struct cxg_cb_data
|
||||
{
|
||||
float mvp_matrix[16];
|
||||
struct demo_matrix mvp_matrix;
|
||||
float normal_matrix[12];
|
||||
};
|
||||
|
||||
@@ -120,14 +119,17 @@ struct cx_gears
|
||||
ID3D12Device *device;
|
||||
ID3D12CommandQueue *command_queue;
|
||||
struct demo_swapchain *swapchain;
|
||||
struct
|
||||
{
|
||||
ID3D12Resource *render_target;
|
||||
ID3D12CommandAllocator *command_allocator;
|
||||
ID3D12GraphicsCommandList *command_list;
|
||||
} *swapchain_images;
|
||||
ID3D12DescriptorHeap *rtv_heap, *dsv_heap;
|
||||
unsigned int rtv_descriptor_size;
|
||||
ID3D12Resource *render_targets[3];
|
||||
ID3D12CommandAllocator *command_allocator[3];
|
||||
|
||||
ID3D12RootSignature *root_signature;
|
||||
ID3D12PipelineState *pipeline_state_smooth, *pipeline_state_flat;
|
||||
ID3D12GraphicsCommandList *command_list[3];
|
||||
ID3D12Resource *ds, *cb, *vb[2], *ib;
|
||||
D3D12_VERTEX_BUFFER_VIEW vbv[2];
|
||||
D3D12_INDEX_BUFFER_VIEW ibv;
|
||||
@@ -142,7 +144,7 @@ struct cx_gears
|
||||
|
||||
static void cxg_populate_command_list(struct cx_gears *cxg, unsigned int rt_idx)
|
||||
{
|
||||
ID3D12GraphicsCommandList *command_list = cxg->command_list[rt_idx];
|
||||
ID3D12GraphicsCommandList *command_list = cxg->swapchain_images[rt_idx].command_list;
|
||||
static const float clear_colour[] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle, dsv_handle;
|
||||
@@ -150,10 +152,11 @@ static void cxg_populate_command_list(struct cx_gears *cxg, unsigned int rt_idx)
|
||||
HRESULT hr;
|
||||
size_t i;
|
||||
|
||||
hr = ID3D12CommandAllocator_Reset(cxg->command_allocator[rt_idx]);
|
||||
hr = ID3D12CommandAllocator_Reset(cxg->swapchain_images[rt_idx].command_allocator);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
hr = ID3D12GraphicsCommandList_Reset(command_list, cxg->command_allocator[rt_idx], cxg->pipeline_state_flat);
|
||||
hr = ID3D12GraphicsCommandList_Reset(command_list,
|
||||
cxg->swapchain_images[rt_idx].command_allocator, cxg->pipeline_state_flat);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, cxg->root_signature);
|
||||
@@ -165,7 +168,7 @@ static void cxg_populate_command_list(struct cx_gears *cxg, unsigned int rt_idx)
|
||||
|
||||
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||
barrier.Transition.pResource = cxg->render_targets[rt_idx];
|
||||
barrier.Transition.pResource = cxg->swapchain_images[rt_idx].render_target;
|
||||
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
|
||||
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
|
||||
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||
@@ -226,44 +229,24 @@ static void cxg_wait_for_previous_frame(struct cx_gears *cxg)
|
||||
|
||||
static void cxg_update_mvp(struct cx_gears *cxg)
|
||||
{
|
||||
struct demo_matrix projection, world;
|
||||
float s1 = sinf(cxg->theta);
|
||||
float c1 = cosf(cxg->theta);
|
||||
float s2 = sinf(cxg->phi);
|
||||
float c2 = cosf(cxg->phi);
|
||||
float z_offset = -40.0f;
|
||||
float z_max = 60.0f;
|
||||
float z_min = 5.0f;
|
||||
float sx = z_min;
|
||||
float sy = z_min * cxg->aspect_ratio;
|
||||
float sz = -((z_max + z_min) / (z_max - z_min));
|
||||
float d = (-2.0f * z_max * z_min) / (z_max - z_min);
|
||||
unsigned int i, j;
|
||||
float world[] =
|
||||
{
|
||||
c1, s2 * s1, c2 * -s1, 0.0f,
|
||||
0.0f, c2, s2, 0.0f,
|
||||
s1, -s2 * c1, c2 * c1, 0.0f,
|
||||
0.0f, 0.0f, z_offset, 1.0f,
|
||||
};
|
||||
float projection[] =
|
||||
{
|
||||
sx, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, sy, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, sz, -1.0f,
|
||||
0.0f, 0.0f, d, 0.0f,
|
||||
};
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
for (j = 0; j < 4; ++j)
|
||||
{
|
||||
cxg->cb_data->mvp_matrix[i * 4 + j] = projection[j] * world[i * 4]
|
||||
+ projection[j + 4] * world[i * 4 + 1]
|
||||
+ projection[j + 8] * world[i * 4 + 2]
|
||||
+ projection[j + 12] * world[i * 4 + 3];
|
||||
}
|
||||
}
|
||||
memcpy(cxg->cb_data->normal_matrix, world, sizeof(cxg->cb_data->normal_matrix));
|
||||
world = (struct demo_matrix)
|
||||
{{
|
||||
{ c1, s2 * s1, c2 * -s1, 0.0f},
|
||||
{0.0f, c2, s2, 0.0f},
|
||||
{ s1, -s2 * c1, c2 * c1, 0.0f},
|
||||
{0.0f, 0.0f, z_offset, 1.0f},
|
||||
}};
|
||||
demo_matrix_perspective_rh(&projection, 2.0f, 2.0f / cxg->aspect_ratio, 5.0f, 60.0f);
|
||||
|
||||
demo_matrix_multiply(&cxg->cb_data->mvp_matrix, &world, &projection);
|
||||
memcpy(cxg->cb_data->normal_matrix, &world, sizeof(cxg->cb_data->normal_matrix));
|
||||
}
|
||||
|
||||
static void cxg_render_frame(struct cx_gears *cxg)
|
||||
@@ -295,7 +278,7 @@ static void cxg_render_frame(struct cx_gears *cxg)
|
||||
demo_vec4_set(&cxg->instance_data[2].transform, cosf(a), sinf(a), -3.1f, 4.2f);
|
||||
|
||||
ID3D12CommandQueue_ExecuteCommandLists(cxg->command_queue, 1,
|
||||
(ID3D12CommandList **)&cxg->command_list[cxg->rt_idx]);
|
||||
(ID3D12CommandList **)&cxg->swapchain_images[cxg->rt_idx].command_list);
|
||||
demo_swapchain_present(cxg->swapchain);
|
||||
cxg_wait_for_previous_frame(cxg);
|
||||
}
|
||||
@@ -304,16 +287,14 @@ static void cxg_destroy_pipeline(struct cx_gears *cxg)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cxg->command_allocator); ++i)
|
||||
{
|
||||
ID3D12CommandAllocator_Release(cxg->command_allocator[i]);
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(cxg->render_targets); ++i)
|
||||
{
|
||||
ID3D12Resource_Release(cxg->render_targets[i]);
|
||||
}
|
||||
ID3D12DescriptorHeap_Release(cxg->dsv_heap);
|
||||
ID3D12DescriptorHeap_Release(cxg->rtv_heap);
|
||||
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxg->swapchain); ++i)
|
||||
{
|
||||
ID3D12CommandAllocator_Release(cxg->swapchain_images[i].command_allocator);
|
||||
ID3D12Resource_Release(cxg->swapchain_images[i].render_target);
|
||||
}
|
||||
free(cxg->swapchain_images);
|
||||
demo_swapchain_destroy(cxg->swapchain);
|
||||
ID3D12CommandQueue_Release(cxg->command_queue);
|
||||
ID3D12Device_Release(cxg->device);
|
||||
@@ -325,7 +306,7 @@ static void cxg_load_pipeline(struct cx_gears *cxg)
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle;
|
||||
D3D12_DESCRIPTOR_HEAP_DESC heap_desc;
|
||||
D3D12_COMMAND_QUEUE_DESC queue_desc;
|
||||
unsigned int i;
|
||||
unsigned int i, rt_count;
|
||||
HRESULT hr;
|
||||
|
||||
hr = D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&cxg->device);
|
||||
@@ -338,16 +319,19 @@ static void cxg_load_pipeline(struct cx_gears *cxg)
|
||||
&IID_ID3D12CommandQueue, (void **)&cxg->command_queue);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
swapchain_desc.buffer_count = ARRAY_SIZE(cxg->render_targets);
|
||||
swapchain_desc.buffer_count = 3;
|
||||
swapchain_desc.format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
swapchain_desc.width = cxg->width;
|
||||
swapchain_desc.height = cxg->height;
|
||||
cxg->swapchain = demo_swapchain_create(cxg->command_queue, cxg->window, &swapchain_desc);
|
||||
assert(cxg->swapchain);
|
||||
rt_count = demo_swapchain_get_back_buffer_count(cxg->swapchain);
|
||||
cxg->swapchain_images = calloc(rt_count, sizeof(*cxg->swapchain_images));
|
||||
assert(cxg->swapchain_images);
|
||||
cxg->rt_idx = demo_swapchain_get_current_back_buffer_index(cxg->swapchain);
|
||||
|
||||
memset(&heap_desc, 0, sizeof(heap_desc));
|
||||
heap_desc.NumDescriptors = ARRAY_SIZE(cxg->render_targets);
|
||||
heap_desc.NumDescriptors = rt_count;
|
||||
heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
||||
heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
||||
hr = ID3D12Device_CreateDescriptorHeap(cxg->device, &heap_desc,
|
||||
@@ -357,10 +341,10 @@ static void cxg_load_pipeline(struct cx_gears *cxg)
|
||||
cxg->rtv_descriptor_size = ID3D12Device_GetDescriptorHandleIncrementSize(cxg->device,
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||
rtv_handle = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(cxg->rtv_heap);
|
||||
for (i = 0; i < ARRAY_SIZE(cxg->render_targets); ++i)
|
||||
for (i = 0; i < rt_count; ++i)
|
||||
{
|
||||
cxg->render_targets[i] = demo_swapchain_get_back_buffer(cxg->swapchain, i);
|
||||
ID3D12Device_CreateRenderTargetView(cxg->device, cxg->render_targets[i], NULL, rtv_handle);
|
||||
cxg->swapchain_images[i].render_target = demo_swapchain_get_back_buffer(cxg->swapchain, i);
|
||||
ID3D12Device_CreateRenderTargetView(cxg->device, cxg->swapchain_images[i].render_target, NULL, rtv_handle);
|
||||
rtv_handle.ptr += cxg->rtv_descriptor_size;
|
||||
}
|
||||
|
||||
@@ -371,10 +355,10 @@ static void cxg_load_pipeline(struct cx_gears *cxg)
|
||||
&IID_ID3D12DescriptorHeap, (void **)&cxg->dsv_heap);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cxg->command_allocator); ++i)
|
||||
for (i = 0; i < rt_count; ++i)
|
||||
{
|
||||
hr = ID3D12Device_CreateCommandAllocator(cxg->device, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
&IID_ID3D12CommandAllocator, (void **)&cxg->command_allocator[i]);
|
||||
&IID_ID3D12CommandAllocator, (void **)&cxg->swapchain_images[i].command_allocator);
|
||||
assert(SUCCEEDED(hr));
|
||||
}
|
||||
}
|
||||
@@ -397,8 +381,8 @@ static void cxg_destroy_assets(struct cx_gears *cxg)
|
||||
ID3D12Resource_Unmap(cxg->cb, 0, NULL);
|
||||
ID3D12Resource_Release(cxg->cb);
|
||||
ID3D12Resource_Release(cxg->ds);
|
||||
for (i = 0; i < ARRAY_SIZE(cxg->command_list); ++i)
|
||||
ID3D12GraphicsCommandList_Release(cxg->command_list[i]);
|
||||
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxg->swapchain); ++i)
|
||||
ID3D12GraphicsCommandList_Release(cxg->swapchain_images[i].command_list);
|
||||
ID3D12PipelineState_Release(cxg->pipeline_state_smooth);
|
||||
ID3D12PipelineState_Release(cxg->pipeline_state_flat);
|
||||
ID3D12RootSignature_Release(cxg->root_signature);
|
||||
@@ -727,13 +711,13 @@ static void cxg_load_assets(struct cx_gears *cxg)
|
||||
ID3D10Blob_Release(ps_flat);
|
||||
ID3D10Blob_Release(ps_smooth);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cxg->command_list); ++i)
|
||||
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxg->swapchain); ++i)
|
||||
{
|
||||
hr = ID3D12Device_CreateCommandList(cxg->device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
cxg->command_allocator[i], cxg->pipeline_state_flat,
|
||||
&IID_ID3D12GraphicsCommandList, (void **)&cxg->command_list[i]);
|
||||
cxg->swapchain_images[i].command_allocator, cxg->pipeline_state_flat,
|
||||
&IID_ID3D12GraphicsCommandList, (void **)&cxg->swapchain_images[i].command_list);
|
||||
assert(SUCCEEDED(hr));
|
||||
hr = ID3D12GraphicsCommandList_Close(cxg->command_list[i]);
|
||||
hr = ID3D12GraphicsCommandList_Close(cxg->swapchain_images[i].command_list);
|
||||
assert(SUCCEEDED(hr));
|
||||
}
|
||||
|
||||
@@ -808,7 +792,6 @@ static void cxg_key_press(struct demo_window *window, demo_key key, void *user_d
|
||||
switch (key)
|
||||
{
|
||||
case 'a':
|
||||
case 'A':
|
||||
cxg->animate = !cxg->animate;
|
||||
break;
|
||||
case DEMO_KEY_ESCAPE:
|
||||
@@ -849,12 +832,17 @@ static int cxg_main(void)
|
||||
{
|
||||
unsigned int width = 300, height = 300;
|
||||
struct cx_gears cxg;
|
||||
double dpi_x, dpi_y;
|
||||
size_t i;
|
||||
|
||||
memset(&cxg, 0, sizeof(cxg));
|
||||
if (!demo_init(&cxg.demo, &cxg))
|
||||
return EXIT_FAILURE;
|
||||
demo_set_idle_func(&cxg.demo, cxg_idle);
|
||||
|
||||
demo_get_dpi(&cxg.demo, &dpi_x, &dpi_y);
|
||||
width *= dpi_x / 96.0;
|
||||
height *= dpi_y / 96.0;
|
||||
cxg.window = demo_window_create(&cxg.demo, "Vkd3d Gears", width, height, &cxg);
|
||||
demo_window_set_key_press_func(cxg.window, cxg_key_press);
|
||||
demo_window_set_expose_func(cxg.window, cxg_expose);
|
||||
@@ -876,10 +864,13 @@ static int cxg_main(void)
|
||||
|
||||
cxg_load_pipeline(&cxg);
|
||||
cxg_load_assets(&cxg);
|
||||
cxg_populate_command_list(&cxg, 0);
|
||||
cxg_populate_command_list(&cxg, 1);
|
||||
cxg_populate_command_list(&cxg, 2);
|
||||
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxg.swapchain); ++i)
|
||||
{
|
||||
cxg_populate_command_list(&cxg, i);
|
||||
}
|
||||
|
||||
printf("vkd3d-gears: Running on \"%s\" using %s.\n",
|
||||
demo_swapchain_get_device_name(cxg.swapchain), demo_get_platform_name());
|
||||
demo_process_events(&cxg.demo);
|
||||
|
||||
cxg_wait_for_previous_frame(&cxg);
|
||||
|
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* Copyright 2016 Henri Verbeet for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
cbuffer gear_block : register(b0)
|
||||
{
|
||||
float4x4 mvp_matrix;
|
||||
|
151
demos/make_objc
Executable file
151
demos/make_objc
Executable file
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright 2025 Henri Verbeet
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use JSON;
|
||||
use open ':utf8';
|
||||
binmode STDOUT, ':utf8';
|
||||
|
||||
sub method_name($)
|
||||
{
|
||||
shift->{selector} =~ s/(:.*)//r;
|
||||
}
|
||||
|
||||
sub method_parameters($$)
|
||||
{
|
||||
my ($method, $method_type) = @_;
|
||||
|
||||
my $parameters = join ", ", $method_type eq "class" ? () : "id self",
|
||||
map {"$_->{type} $_->{name}"} @{$method->{parameters}};
|
||||
|
||||
length $parameters ? $parameters : "void";
|
||||
}
|
||||
|
||||
sub send_function($)
|
||||
{
|
||||
shift->{'return-float'} ? "vkd3d_objc_msgSend_fpret" : "objc_msgSend";
|
||||
}
|
||||
|
||||
sub invocation_type($$)
|
||||
{
|
||||
my ($method, $method_type) = @_;
|
||||
|
||||
"$method->{'return-type'} (*)(" . join(", ", $method_type eq "class" ? "Class" : "id", "SEL",
|
||||
map {$_->{type}} @{$method->{parameters}}) . ")";
|
||||
}
|
||||
|
||||
sub invocation_parameters($$$)
|
||||
{
|
||||
my ($method, $interface_name, $method_type) = @_;
|
||||
|
||||
join ", ", $method_type eq "class" ? "objc_getClass(\"$interface_name\")" : "self",
|
||||
"sel_registerName(\"$method->{selector}\")", map {$_->{name}} @{$method->{parameters}};
|
||||
}
|
||||
|
||||
sub invocation($$$)
|
||||
{
|
||||
my ($method, $interface_name, $method_type) = @_;
|
||||
|
||||
($method->{'return-type'} eq "void" ? "" : "return ")
|
||||
. "((${\invocation_type $method, $method_type})f)"
|
||||
. "(${\invocation_parameters $method, $interface_name, $method_type});";
|
||||
}
|
||||
|
||||
sub print_method($$$)
|
||||
{
|
||||
my ($method, $interface_name, $method_type) = @_;
|
||||
|
||||
print "static inline $method->{'return-type'} "
|
||||
. "${interface_name}_${\method_name $method}(${\method_parameters $method, $method_type})\n";
|
||||
print "{\n";
|
||||
print " void *f = ${\send_function $method};\n";
|
||||
print " ${\invocation $method, $interface_name, $method_type}\n";
|
||||
print "}\n\n";
|
||||
}
|
||||
|
||||
sub print_property($$)
|
||||
{
|
||||
my ($property, $interface_name) = @_;
|
||||
|
||||
my $method =
|
||||
{
|
||||
'return-type' => $property->{type},
|
||||
'return-float' => $property->{float},
|
||||
selector => $property->{getter} // $property->{name},
|
||||
};
|
||||
my $method_type = $property->{class} ? "class" : "instance";
|
||||
|
||||
print_method $method, $interface_name, $method_type;
|
||||
if (!$property->{readonly})
|
||||
{
|
||||
$method->{'return-type'} = "void";
|
||||
$method->{'return-float'} = 0;
|
||||
$method->{selector} = "set${\ucfirst $property->{name}}:";
|
||||
$method->{parameters} = [$property];
|
||||
print_method $method, $interface_name, $method_type;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_interface(_)
|
||||
{
|
||||
my ($interface) = @_;
|
||||
|
||||
print_method $_, $interface->{name}, "class" foreach (@{$interface->{'class-methods'}});
|
||||
print_method $_, $interface->{name}, "instance" foreach (@{$interface->{'instance-methods'}});
|
||||
print_property $_, $interface->{name} foreach (@{$interface->{properties}});
|
||||
}
|
||||
|
||||
sub print_header($)
|
||||
{
|
||||
my ($grammar) = @_;
|
||||
|
||||
my $guard = "__VKD3D_${\uc $grammar->{name}}_H__";
|
||||
|
||||
print "/*\n";
|
||||
print " * This file is automatically generated.\n";
|
||||
print " * The original source is covered by the following license:\n";
|
||||
print " *\n";
|
||||
print map {" * $_" =~ s/ +$//r . "\n"} @{$grammar->{copyright}};
|
||||
print " */\n\n";
|
||||
|
||||
print "#ifndef $guard\n";
|
||||
print "#define $guard\n\n";
|
||||
|
||||
print "#include <objc/objc-runtime.h>\n\n";
|
||||
|
||||
print "#ifdef __arm64__\n";
|
||||
print "# define vkd3d_objc_msgSend_fpret objc_msgSend\n";
|
||||
print "#else\n";
|
||||
print "# define vkd3d_objc_msgSend_fpret objc_msgSend_fpret\n";
|
||||
print "#endif /* __arm64__ */\n\n";
|
||||
|
||||
print_interface foreach (@{$grammar->{interfaces}});
|
||||
|
||||
print "#undef vkd3d_objc_msgSend_fpret\n\n";
|
||||
|
||||
print "#endif /* $guard */\n";
|
||||
}
|
||||
|
||||
die "No input file specified.\n" unless @ARGV;
|
||||
print_header do
|
||||
{
|
||||
local $/;
|
||||
open my $fh, '<', $ARGV[0] or die $!;
|
||||
decode_json <$fh>;
|
||||
};
|
1083
demos/teapot.c
Normal file
1083
demos/teapot.c
Normal file
File diff suppressed because it is too large
Load Diff
129
demos/teapot.h
Normal file
129
demos/teapot.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright 2025 Henri Verbeet
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* Teapot data adapted from freeglut's fg_teapot_data.h with the following license:
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* The data is of course ultimately derived from Martin Newell's famous
|
||||
* teapot, also known as the Utah teapot.
|
||||
*/
|
||||
|
||||
/* Rim, body, lid, and bottom data must be rotated along all four quadrants;
|
||||
* handle and spout data is flipped (negate y values) only. */
|
||||
|
||||
static const struct demo_patch teapot_rotate_patches[] =
|
||||
{
|
||||
{{{ 0, 1, 2, 3}, { 4, 5, 6, 7}, { 8, 9, 10, 11}, { 12, 13, 14, 15}}}, /* rim */
|
||||
{{{ 12, 13, 14, 15}, { 16, 17, 18, 19}, { 20, 21, 22, 23}, { 24, 25, 26, 27}}}, /* body */
|
||||
{{{ 24, 25, 26, 27}, { 28, 29, 30, 31}, { 32, 33, 34, 35}, { 36, 37, 38, 39}}},
|
||||
{{{ 40, 40, 40, 40}, { 43, 44, 45, 46}, { 47, 47, 47, 47}, { 48, 49, 50, 51}}}, /* lid */
|
||||
{{{ 48, 49, 50, 51}, { 52, 53, 54, 55}, { 56, 57, 58, 59}, { 60, 61, 62, 63}}},
|
||||
{{{ 64, 64, 64, 64}, { 65, 66, 67, 68}, { 69, 70, 71, 72}, { 39, 38, 37, 36}}}, /* bottom */
|
||||
},
|
||||
teapot_flip_patches[] =
|
||||
{
|
||||
{{{ 73, 74, 75, 76}, { 77, 78, 79, 80}, { 81, 82, 83, 84}, { 85, 86, 87, 88}}}, /* handle */
|
||||
{{{ 85, 86, 87, 88}, { 89, 90, 91, 92}, { 93, 94, 95, 96}, { 97, 98, 99, 100}}},
|
||||
{{{101, 102, 103, 104}, {105, 106, 107, 108}, {109, 110, 111, 112}, {113, 114, 115, 116}}}, /* spout */
|
||||
{{{113, 114, 115, 116}, {117, 118, 119, 120}, {121, 122, 123, 124}, {125, 126, 127, 128}}},
|
||||
};
|
||||
|
||||
static const struct demo_vec3 teapot_control_points[] =
|
||||
{
|
||||
{ 1.40000f, 0.00000f, 2.40000f}, { 1.40000f, -0.78400f, 2.40000f},
|
||||
{ 0.78400f, -1.40000f, 2.40000f}, { 0.00000f, -1.40000f, 2.40000f},
|
||||
{ 1.33750f, 0.00000f, 2.53125f}, { 1.33750f, -0.74900f, 2.53125f},
|
||||
{ 0.74900f, -1.33750f, 2.53125f}, { 0.00000f, -1.33750f, 2.53125f},
|
||||
{ 1.43750f, 0.00000f, 2.53125f}, { 1.43750f, -0.80500f, 2.53125f},
|
||||
{ 0.80500f, -1.43750f, 2.53125f}, { 0.00000f, -1.43750f, 2.53125f},
|
||||
{ 1.50000f, 0.00000f, 2.40000f}, { 1.50000f, -0.84000f, 2.40000f},
|
||||
{ 0.84000f, -1.50000f, 2.40000f}, { 0.00000f, -1.50000f, 2.40000f},
|
||||
{ 1.75000f, 0.00000f, 1.87500f}, { 1.75000f, -0.98000f, 1.87500f},
|
||||
{ 0.98000f, -1.75000f, 1.87500f}, { 0.00000f, -1.75000f, 1.87500f},
|
||||
{ 2.00000f, 0.00000f, 1.35000f}, { 2.00000f, -1.12000f, 1.35000f},
|
||||
{ 1.12000f, -2.00000f, 1.35000f}, { 0.00000f, -2.00000f, 1.35000f},
|
||||
{ 2.00000f, 0.00000f, 0.90000f}, { 2.00000f, -1.12000f, 0.90000f},
|
||||
{ 1.12000f, -2.00000f, 0.90000f}, { 0.00000f, -2.00000f, 0.90000f},
|
||||
{ 2.00000f, 0.00000f, 0.45000f}, { 2.00000f, -1.12000f, 0.45000f},
|
||||
{ 1.12000f, -2.00000f, 0.45000f}, { 0.00000f, -2.00000f, 0.45000f},
|
||||
{ 1.50000f, 0.00000f, 0.22500f}, { 1.50000f, -0.84000f, 0.22500f},
|
||||
{ 0.84000f, -1.50000f, 0.22500f}, { 0.00000f, -1.50000f, 0.22500f},
|
||||
{ 1.50000f, 0.00000f, 0.15000f}, { 1.50000f, -0.84000f, 0.15000f},
|
||||
{ 0.84000f, -1.50000f, 0.15000f}, { 0.00000f, -1.50000f, 0.15000f},
|
||||
{ 0.00000f, 0.00000f, 3.15000f}, { 0.00000f, -0.00200f, 3.15000f},
|
||||
{ 0.00200f, 0.00000f, 3.15000f}, { 0.80000f, 0.00000f, 3.15000f},
|
||||
{ 0.80000f, -0.45000f, 3.15000f}, { 0.45000f, -0.80000f, 3.15000f},
|
||||
{ 0.00000f, -0.80000f, 3.15000f}, { 0.00000f, 0.00000f, 2.85000f},
|
||||
{ 0.20000f, 0.00000f, 2.70000f}, { 0.20000f, -0.11200f, 2.70000f},
|
||||
{ 0.11200f, -0.20000f, 2.70000f}, { 0.00000f, -0.20000f, 2.70000f},
|
||||
{ 0.40000f, 0.00000f, 2.55000f}, { 0.40000f, -0.22400f, 2.55000f},
|
||||
{ 0.22400f, -0.40000f, 2.55000f}, { 0.00000f, -0.40000f, 2.55000f},
|
||||
{ 1.30000f, 0.00000f, 2.55000f}, { 1.30000f, -0.72800f, 2.55000f},
|
||||
{ 0.72800f, -1.30000f, 2.55000f}, { 0.00000f, -1.30000f, 2.55000f},
|
||||
{ 1.30000f, 0.00000f, 2.40000f}, { 1.30000f, -0.72800f, 2.40000f},
|
||||
{ 0.72800f, -1.30000f, 2.40000f}, { 0.00000f, -1.30000f, 2.40000f},
|
||||
{ 0.00000f, 0.00000f, 0.00000f}, { 0.00000f, -1.42500f, 0.00000f},
|
||||
{ 0.79800f, -1.42500f, 0.00000f}, { 1.42500f, -0.79800f, 0.00000f},
|
||||
{ 1.42500f, 0.00000f, 0.00000f}, { 0.00000f, -1.50000f, 0.07500f},
|
||||
{ 0.84000f, -1.50000f, 0.07500f}, { 1.50000f, -0.84000f, 0.07500f},
|
||||
{ 1.50000f, 0.00000f, 0.07500f}, {-1.60000f, 0.00000f, 2.02500f},
|
||||
{-1.60000f, -0.30000f, 2.02500f}, {-1.50000f, -0.30000f, 2.25000f},
|
||||
{-1.50000f, 0.00000f, 2.25000f}, {-2.30000f, 0.00000f, 2.02500f},
|
||||
{-2.30000f, -0.30000f, 2.02500f}, {-2.50000f, -0.30000f, 2.25000f},
|
||||
{-2.50000f, 0.00000f, 2.25000f}, {-2.70000f, 0.00000f, 2.02500f},
|
||||
{-2.70000f, -0.30000f, 2.02500f}, {-3.00000f, -0.30000f, 2.25000f},
|
||||
{-3.00000f, 0.00000f, 2.25000f}, {-2.70000f, 0.00000f, 1.80000f},
|
||||
{-2.70000f, -0.30000f, 1.80000f}, {-3.00000f, -0.30000f, 1.80000f},
|
||||
{-3.00000f, 0.00000f, 1.80000f}, {-2.70000f, 0.00000f, 1.57500f},
|
||||
{-2.70000f, -0.30000f, 1.57500f}, {-3.00000f, -0.30000f, 1.35000f},
|
||||
{-3.00000f, 0.00000f, 1.35000f}, {-2.50000f, 0.00000f, 1.12500f},
|
||||
{-2.50000f, -0.30000f, 1.12500f}, {-2.65000f, -0.30000f, 0.93750f},
|
||||
{-2.65000f, 0.00000f, 0.93750f}, {-2.00000f, 0.00000f, 0.90000f},
|
||||
{-2.00000f, -0.30000f, 0.90000f}, {-1.90000f, -0.30000f, 0.60000f},
|
||||
{-1.90000f, 0.00000f, 0.60000f}, { 1.70000f, 0.00000f, 1.42500f},
|
||||
{ 1.70000f, -0.66000f, 1.42500f}, { 1.70000f, -0.66000f, 0.60000f},
|
||||
{ 1.70000f, 0.00000f, 0.60000f}, { 2.60000f, 0.00000f, 1.42500f},
|
||||
{ 2.60000f, -0.66000f, 1.42500f}, { 3.10000f, -0.66000f, 0.82500f},
|
||||
{ 3.10000f, 0.00000f, 0.82500f}, { 2.30000f, 0.00000f, 2.10000f},
|
||||
{ 2.30000f, -0.25000f, 2.10000f}, { 2.40000f, -0.25000f, 2.02500f},
|
||||
{ 2.40000f, 0.00000f, 2.02500f}, { 2.70000f, 0.00000f, 2.40000f},
|
||||
{ 2.70000f, -0.25000f, 2.40000f}, { 3.30000f, -0.25000f, 2.40000f},
|
||||
{ 3.30000f, 0.00000f, 2.40000f}, { 2.80000f, 0.00000f, 2.47500f},
|
||||
{ 2.80000f, -0.25000f, 2.47500f}, { 3.52500f, -0.25000f, 2.49375f},
|
||||
{ 3.52500f, 0.00000f, 2.49375f}, { 2.90000f, 0.00000f, 2.47500f},
|
||||
{ 2.90000f, -0.15000f, 2.47500f}, { 3.45000f, -0.15000f, 2.51250f},
|
||||
{ 3.45000f, 0.00000f, 2.51250f}, { 2.80000f, 0.00000f, 2.40000f},
|
||||
{ 2.80000f, -0.15000f, 2.40000f}, { 3.20000f, -0.15000f, 2.40000f},
|
||||
{ 3.20000f, 0.00000f, 2.40000f}
|
||||
};
|
265
demos/teapot.hlsl
Normal file
265
demos/teapot.hlsl
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright 2025 Henri Verbeet
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define M_PI 3.14159265
|
||||
|
||||
cbuffer teapot_cb : register(b0)
|
||||
{
|
||||
float4x4 mvp_matrix;
|
||||
float3 eye;
|
||||
float level;
|
||||
uint wireframe, flat;
|
||||
};
|
||||
|
||||
struct control_point
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
};
|
||||
|
||||
struct patch_constant_data
|
||||
{
|
||||
float edges[4] : SV_TessFactor;
|
||||
float inside[2] : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
struct gs_in
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float3 pos : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
struct ps_in
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float3 pos : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 barycentric : BARYCENTRIC;
|
||||
};
|
||||
|
||||
float4 vs_main(float4 position : POSITION, uint id : SV_InstanceID) : SV_POSITION
|
||||
{
|
||||
/* Mirror/flip patches based on the instance ID. */
|
||||
position.w = -1.0;
|
||||
if (id & 1)
|
||||
position.yw = -position.yw;
|
||||
if (id & 2)
|
||||
position.xw = -position.xw;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
struct patch_constant_data patch_constant(InputPatch<control_point, 16> input)
|
||||
{
|
||||
struct patch_constant_data output;
|
||||
|
||||
output.edges[0] = level;
|
||||
output.edges[1] = level;
|
||||
output.edges[2] = level;
|
||||
output.edges[3] = level;
|
||||
output.inside[0] = level;
|
||||
output.inside[1] = level;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[domain("quad")]
|
||||
[outputcontrolpoints(16)]
|
||||
[outputtopology("triangle_ccw")]
|
||||
[partitioning("integer")]
|
||||
[patchconstantfunc("patch_constant")]
|
||||
struct control_point hs_main(InputPatch<control_point, 16> input, uint i : SV_OutputControlPointID)
|
||||
{
|
||||
/* Reorder mirrored/flipped control points. */
|
||||
if (input[0].position.w < 0.0)
|
||||
{
|
||||
uint u = i % 4, v = i / 4;
|
||||
return input[v * 4 + (3 - u)];
|
||||
}
|
||||
|
||||
return input[i];
|
||||
}
|
||||
|
||||
float3 eval_quadratic(float3 p0, float3 p1, float3 p2, float t)
|
||||
{
|
||||
return lerp(lerp(p0, p1, t), lerp(p1, p2, t), t);
|
||||
}
|
||||
|
||||
float3 eval_cubic(float3 p0, float3 p1, float3 p2, float3 p3, float t)
|
||||
{
|
||||
return lerp(eval_quadratic(p0, p1, p2, t),
|
||||
eval_quadratic(p1, p2, p3, t), t);
|
||||
}
|
||||
|
||||
struct gs_in eval_patch(float2 t, float4 p[16])
|
||||
{
|
||||
float3 position, normal, q[4], u, v;
|
||||
struct gs_in o;
|
||||
|
||||
q[0] = eval_cubic( p[0].xyz, p[1].xyz, p[2].xyz, p[3].xyz, t.x);
|
||||
q[1] = eval_cubic( p[4].xyz, p[5].xyz, p[6].xyz, p[7].xyz, t.x);
|
||||
q[2] = eval_cubic( p[8].xyz, p[9].xyz, p[10].xyz, p[11].xyz, t.x);
|
||||
q[3] = eval_cubic(p[12].xyz, p[13].xyz, p[14].xyz, p[15].xyz, t.x);
|
||||
u = eval_quadratic(q[0], q[1], q[2], t.y) - eval_quadratic(q[1], q[2], q[3], t.y);
|
||||
|
||||
q[0] = eval_cubic(p[0].xyz, p[4].xyz, p[8].xyz, p[12].xyz, t.y);
|
||||
q[1] = eval_cubic(p[1].xyz, p[5].xyz, p[9].xyz, p[13].xyz, t.y);
|
||||
q[2] = eval_cubic(p[2].xyz, p[6].xyz, p[10].xyz, p[14].xyz, t.y);
|
||||
q[3] = eval_cubic(p[3].xyz, p[7].xyz, p[11].xyz, p[15].xyz, t.y);
|
||||
v = eval_quadratic(q[0], q[1], q[2], t.x) - eval_quadratic(q[1], q[2], q[3], t.x);
|
||||
|
||||
position = eval_cubic(q[0], q[1], q[2], q[3], t.x);
|
||||
o.position = mul(mvp_matrix, float4(position, 1.0));
|
||||
o.pos = position;
|
||||
|
||||
/* The patches for the bottom of the teapot and the top of its lid are
|
||||
* degenerate. Technically this isn't the right way to deal with that, but
|
||||
* it's easy and gets the right result for these patches. */
|
||||
if (length(v) == 0.0)
|
||||
normal = cross(p[4].xyz - p[0].xyz, p[7].xyz - p[3].xyz);
|
||||
else
|
||||
normal = cross(u, v);
|
||||
o.normal = normalize(normal);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
[domain("quad")]
|
||||
struct gs_in ds_main(struct patch_constant_data input,
|
||||
float2 tess_coord : SV_DomainLocation, const OutputPatch<control_point, 16> patch)
|
||||
{
|
||||
return eval_patch(tess_coord, patch);
|
||||
}
|
||||
|
||||
[maxvertexcount(3)]
|
||||
void gs_main(triangle struct gs_in i[3], inout TriangleStream<struct ps_in> stream)
|
||||
{
|
||||
struct ps_in v[3];
|
||||
float3 n;
|
||||
|
||||
v[0].position = i[0].position;
|
||||
v[0].pos = i[0].pos;
|
||||
v[0].normal = i[0].normal;
|
||||
v[0].barycentric = float2(1.0, 0.0);
|
||||
|
||||
v[1].position = i[1].position;
|
||||
v[1].pos = i[1].pos;
|
||||
v[1].normal = i[1].normal;
|
||||
v[1].barycentric = float2(0.0, 1.0);
|
||||
|
||||
v[2].position = i[2].position;
|
||||
v[2].pos = i[2].pos;
|
||||
v[2].normal = i[2].normal;
|
||||
v[2].barycentric = float2(0.0, 0.0);
|
||||
|
||||
if (flat)
|
||||
{
|
||||
n = normalize(cross(i[1].pos - i[0].pos, i[2].pos - i[0].pos));
|
||||
v[0].normal = n;
|
||||
v[1].normal = n;
|
||||
v[2].normal = n;
|
||||
}
|
||||
|
||||
stream.Append(v[0]);
|
||||
stream.Append(v[1]);
|
||||
stream.Append(v[2]);
|
||||
}
|
||||
|
||||
/* Lambertian diffuse. */
|
||||
float3 brdf_lambert(float3 diffuse)
|
||||
{
|
||||
return diffuse / M_PI;
|
||||
}
|
||||
|
||||
/* The Schlick Fresnel approximation:
|
||||
*
|
||||
* R(θ) ≈ R₀ + (1 - R₀)(1 - c̅o̅s̅ θ)⁵
|
||||
*/
|
||||
float3 fresnel_schlick(float3 r0, float cos_theta)
|
||||
{
|
||||
return lerp(r0, 1.0, pow(1.0 - cos_theta, 5.0));
|
||||
}
|
||||
|
||||
float g1(float cos_theta, float alpha_sq)
|
||||
{
|
||||
return cos_theta + sqrt(alpha_sq + (cos_theta - alpha_sq * cos_theta) * cos_theta);
|
||||
}
|
||||
|
||||
/* Trowbridge-Reitz, "Average irregularity representation of a rough surface for ray reflection".
|
||||
* Also known as "GGX".
|
||||
*
|
||||
* G1(θ) = 2 / (1 + sqrt(α² + (1 - α²)c̅o̅s̅² θ))
|
||||
* G(θᵢ, θₒ) = G1(θᵢ) * G1(θₒ)
|
||||
*
|
||||
* This returns G / (4 c̅o̅s̅ θᵢ c̅o̅s̅ θₒ)
|
||||
*/
|
||||
float geometric_att_trowbridge_reitz(float cos_theta_i, float cos_theta_o, float alpha_sq)
|
||||
{
|
||||
return 1.0 / (g1(cos_theta_i, alpha_sq) * g1(cos_theta_o, alpha_sq));
|
||||
}
|
||||
|
||||
/* Trowbridge-Reitz, "Average irregularity representation of a rough surface for ray reflection".
|
||||
* Also known as "GGX".
|
||||
*
|
||||
* D(θ) = α² / π((cos² θ)(α² - 1) + 1)²
|
||||
*/
|
||||
float ndf_trowbridge_reitz(float cos_theta_h, float alpha_sq)
|
||||
{
|
||||
float f = (cos_theta_h * alpha_sq - cos_theta_h) * cos_theta_h + 1.0;
|
||||
return alpha_sq / (M_PI * f * f);
|
||||
}
|
||||
|
||||
float4 ps_main(struct ps_in i) : SV_TARGET
|
||||
{
|
||||
float3 barycentric, diffuse, diffuse_colour, radiance, specular, f, h, n, v;
|
||||
float alpha, alpha_sq, cos_theta_h, cos_theta_i, cos_theta_o, d, g, wire;
|
||||
float3 light_dir = normalize(float3(5.0, 5.0, 10.0));
|
||||
float3 light_colour = float3(1.0, 0.95, 0.88);
|
||||
float3 light_irradiance = 5.0 * light_colour;
|
||||
float3 base_colour = float3(0.8, 0.8, 0.8);
|
||||
float3 f0 = float3(0.04, 0.04, 0.04);
|
||||
float3 ambient = 0.3 * light_colour;
|
||||
float roughness = 0.2;
|
||||
float metallic = 0.3;
|
||||
|
||||
n = normalize(i.normal);
|
||||
v = normalize(eye - i.pos);
|
||||
h = normalize(light_dir + v);
|
||||
cos_theta_h = dot(n, h);
|
||||
cos_theta_i = saturate(dot(n, light_dir));
|
||||
cos_theta_o = saturate(dot(n, v));
|
||||
|
||||
diffuse_colour = base_colour * (float3(1.0, 1.0, 1.0) - f0) * (1.0 - metallic);
|
||||
alpha = roughness * roughness;
|
||||
alpha_sq = alpha * alpha;
|
||||
|
||||
/* Cook-Torrance. The division by (4 c̅o̅s̅ θᵢ c̅o̅s̅ θₒ) is folded into G. */
|
||||
f = fresnel_schlick(lerp(f0, base_colour, metallic), dot(v, h));
|
||||
g = geometric_att_trowbridge_reitz(cos_theta_i, cos_theta_o, alpha_sq);
|
||||
d = ndf_trowbridge_reitz(cos_theta_h, alpha_sq);
|
||||
diffuse = (1.0 - f) * brdf_lambert(diffuse_colour);
|
||||
specular = f * g * d;
|
||||
radiance = (diffuse + specular) * light_irradiance * cos_theta_i;
|
||||
radiance += ambient * base_colour;
|
||||
|
||||
barycentric = float3(i.barycentric, 1.0 - (i.barycentric.x + i.barycentric.y));
|
||||
barycentric /= fwidth(barycentric);
|
||||
wire = wireframe ? min(min(barycentric.x, barycentric.y), barycentric.z) : 1.0;
|
||||
|
||||
return float4(lerp(float3(1.00, 0.69, 0.0), saturate(radiance), saturate(wire)), 1.0);
|
||||
}
|
95
demos/text.hlsl
Normal file
95
demos/text.hlsl
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2025 Henri Verbeet
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
cbuffer text_cb : register(b0)
|
||||
{
|
||||
uint4 screen_size;
|
||||
uint4 glyphs[96];
|
||||
};
|
||||
|
||||
Buffer<uint> text : register(t0);
|
||||
|
||||
struct text_run
|
||||
{
|
||||
float4 colour : COLOUR;
|
||||
uint2 position : POSITION;
|
||||
uint start_idx : IDX; /* The start offset of the run in the "text" Buffer. */
|
||||
uint char_count : COUNT;
|
||||
uint reverse : REVERSE;
|
||||
float scale : SCALE;
|
||||
};
|
||||
|
||||
struct ps_in
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD;
|
||||
uint start_idx : IDX; /* The start offset of the run in the "text" Buffer. */
|
||||
uint reverse : REVERSE;
|
||||
float4 colour : COLOUR;
|
||||
};
|
||||
|
||||
struct ps_in vs_main(struct text_run t, uint id : SV_VertexID)
|
||||
{
|
||||
float2 pixel, pos, size;
|
||||
struct ps_in o;
|
||||
|
||||
pixel = float2(2.0, 2.0) / float2(screen_size.x, screen_size.y);
|
||||
pos = pixel * t.position - float2(1.0, 1.0);
|
||||
size = pixel * t.scale * float2(t.char_count * 9.0, 16.0);
|
||||
|
||||
o.position.x = (id & 0x1) * size.x + pos.x;
|
||||
o.position.y = ((id >> 1) & 0x1) * size.y + pos.y;
|
||||
o.position.z = 0.0;
|
||||
o.position.w = 1.0;
|
||||
|
||||
o.texcoord.x = (id & 0x1) * t.char_count;
|
||||
o.texcoord.y = (~id >> 1) & 0x1;
|
||||
|
||||
o.start_idx = t.start_idx;
|
||||
o.reverse = t.reverse;
|
||||
o.colour = t.colour;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 ps_main(struct ps_in i) : SV_TARGET
|
||||
{
|
||||
uint idx, glyph_id, row;
|
||||
uint4 glyph;
|
||||
uint2 texel;
|
||||
|
||||
/* We determine the current character based on the start offset and texture
|
||||
* coordinate. We then lookup the corresponding glyph in glyphs[]. */
|
||||
idx = i.start_idx + i.texcoord.x;
|
||||
glyph_id = text[idx] - 0x20;
|
||||
glyph = glyphs[glyph_id];
|
||||
|
||||
/* Find the row within the glyph bitmap, and then the pixel within that row.
|
||||
* Note that we apply dot stretching here; a single pixel in the source
|
||||
* glyph results in two pixels in the output. */
|
||||
texel = frac(i.texcoord.xy) * float2(9, 16);
|
||||
row = (glyph[texel.y / 4] >> (8 * (texel.y % 4))) & 0xff;
|
||||
if (!(i.reverse ^ (((row | (row << 1)) >> (8 - texel.x)) & 0x1)))
|
||||
discard;
|
||||
|
||||
/* Scan line gaps. */
|
||||
if (uint(i.position.y) & 1)
|
||||
return float4(i.colour.xyz * (screen_size.z >= 2 ? 0.5 : 0.8), 1.0);
|
||||
|
||||
return i.colour;
|
||||
}
|
@@ -72,7 +72,7 @@ struct cx_triangle
|
||||
struct demo_swapchain *swapchain;
|
||||
ID3D12DescriptorHeap *rtv_heap;
|
||||
unsigned int rtv_descriptor_size;
|
||||
ID3D12Resource *render_targets[3];
|
||||
ID3D12Resource **render_targets;
|
||||
ID3D12CommandAllocator *command_allocator;
|
||||
|
||||
ID3D12RootSignature *root_signature;
|
||||
@@ -164,10 +164,11 @@ static void cxt_destroy_pipeline(struct cx_triangle *cxt)
|
||||
unsigned int i;
|
||||
|
||||
ID3D12CommandAllocator_Release(cxt->command_allocator);
|
||||
for (i = 0; i < ARRAY_SIZE(cxt->render_targets); ++i)
|
||||
for (i = 0; i < demo_swapchain_get_back_buffer_count(cxt->swapchain); ++i)
|
||||
{
|
||||
ID3D12Resource_Release(cxt->render_targets[i]);
|
||||
}
|
||||
free(cxt->render_targets);
|
||||
ID3D12DescriptorHeap_Release(cxt->rtv_heap);
|
||||
demo_swapchain_destroy(cxt->swapchain);
|
||||
ID3D12CommandQueue_Release(cxt->command_queue);
|
||||
@@ -180,7 +181,7 @@ static void cxt_load_pipeline(struct cx_triangle *cxt)
|
||||
D3D12_DESCRIPTOR_HEAP_DESC rtv_heap_desc;
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle;
|
||||
D3D12_COMMAND_QUEUE_DESC queue_desc;
|
||||
unsigned int i;
|
||||
unsigned int i, rt_count;
|
||||
HRESULT hr;
|
||||
|
||||
hr = D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&cxt->device);
|
||||
@@ -193,16 +194,19 @@ static void cxt_load_pipeline(struct cx_triangle *cxt)
|
||||
&IID_ID3D12CommandQueue, (void **)&cxt->command_queue);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
swapchain_desc.buffer_count = ARRAY_SIZE(cxt->render_targets);
|
||||
swapchain_desc.buffer_count = 3;
|
||||
swapchain_desc.format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
swapchain_desc.width = cxt->width;
|
||||
swapchain_desc.height = cxt->height;
|
||||
cxt->swapchain = demo_swapchain_create(cxt->command_queue, cxt->window, &swapchain_desc);
|
||||
assert(cxt->swapchain);
|
||||
rt_count = demo_swapchain_get_back_buffer_count(cxt->swapchain);
|
||||
cxt->render_targets = calloc(rt_count, sizeof(*cxt->render_targets));
|
||||
assert(cxt->render_targets);
|
||||
cxt->frame_idx = demo_swapchain_get_current_back_buffer_index(cxt->swapchain);
|
||||
|
||||
memset(&rtv_heap_desc, 0, sizeof(rtv_heap_desc));
|
||||
rtv_heap_desc.NumDescriptors = ARRAY_SIZE(cxt->render_targets);
|
||||
rtv_heap_desc.NumDescriptors = rt_count;
|
||||
rtv_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
||||
rtv_heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
||||
hr = ID3D12Device_CreateDescriptorHeap(cxt->device, &rtv_heap_desc,
|
||||
@@ -212,7 +216,7 @@ static void cxt_load_pipeline(struct cx_triangle *cxt)
|
||||
cxt->rtv_descriptor_size = ID3D12Device_GetDescriptorHandleIncrementSize(cxt->device,
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||
rtv_handle = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(cxt->rtv_heap);
|
||||
for (i = 0; i < ARRAY_SIZE(cxt->render_targets); ++i)
|
||||
for (i = 0; i < rt_count; ++i)
|
||||
{
|
||||
cxt->render_targets[i] = demo_swapchain_get_back_buffer(cxt->swapchain, i);
|
||||
ID3D12Device_CreateRenderTargetView(cxt->device, cxt->render_targets[i], NULL, rtv_handle);
|
||||
@@ -368,12 +372,16 @@ static int cxt_main(void)
|
||||
{
|
||||
unsigned int width = 640, height = 480;
|
||||
struct cx_triangle cxt;
|
||||
double dpi_x, dpi_y;
|
||||
|
||||
memset(&cxt, 0, sizeof(cxt));
|
||||
|
||||
if (!demo_init(&cxt.demo, NULL))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
demo_get_dpi(&cxt.demo, &dpi_x, &dpi_y);
|
||||
width *= dpi_x / 96.0;
|
||||
height *= dpi_y / 96.0;
|
||||
cxt.window = demo_window_create(&cxt.demo, "Vkd3d Triangle", width, height, &cxt);
|
||||
demo_window_set_expose_func(cxt.window, cxt_render_frame);
|
||||
demo_window_set_key_press_func(cxt.window, cxt_key_press);
|
||||
@@ -392,6 +400,8 @@ static int cxt_main(void)
|
||||
cxt_load_pipeline(&cxt);
|
||||
cxt_load_assets(&cxt);
|
||||
|
||||
printf("vkd3d-triangle: Running on \"%s\" using %s.\n",
|
||||
demo_swapchain_get_device_name(cxt.swapchain), demo_get_platform_name());
|
||||
demo_process_events(&cxt.demo);
|
||||
|
||||
cxt_wait_for_previous_frame(&cxt);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user