mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
Compare commits
557 Commits
vkd3d-1.16
...
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 |
80
ChangeLog.md
80
ChangeLog.md
@@ -1,3 +1,83 @@
|
||||
# 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
|
||||
|
27
Makefile.am
27
Makefile.am
@@ -199,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 \
|
||||
@@ -214,6 +215,8 @@ vkd3d_shader_tests = \
|
||||
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 \
|
||||
@@ -223,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 \
|
||||
@@ -237,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 \
|
||||
@@ -299,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 \
|
||||
@@ -325,6 +331,7 @@ vkd3d_test_headers = \
|
||||
|
||||
vkd3d_demos = \
|
||||
demos/vkd3d-gears \
|
||||
demos/vkd3d-teapot \
|
||||
demos/vkd3d-triangle
|
||||
|
||||
vkd3d_demos_headers = \
|
||||
@@ -419,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 15:0:14
|
||||
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
|
||||
@@ -454,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 17:0:16
|
||||
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
|
||||
@@ -467,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:2: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
|
||||
@@ -549,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)
|
||||
@@ -657,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
|
||||
|
||||
@@ -706,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
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([vkd3d],[1.16])
|
||||
AC_INIT([vkd3d],[1.17])
|
||||
|
||||
AC_CONFIG_AUX_DIR([bin])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
130
demos/demo.h
130
demos/demo.h
@@ -38,6 +38,7 @@
|
||||
#define COBJMACROS
|
||||
#include <vkd3d_d3d12.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __WIN32__
|
||||
#define DEMO_ASM_PUSHSECTION ".section rdata\n\t"
|
||||
@@ -79,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
|
||||
{
|
||||
@@ -98,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;
|
||||
@@ -115,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;
|
||||
@@ -123,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;
|
||||
|
@@ -70,6 +70,8 @@ static inline void demo_window_cleanup(struct demo_window *window)
|
||||
struct demo_swapchain
|
||||
{
|
||||
IDXGISwapChain3 *swapchain;
|
||||
unsigned int buffer_count;
|
||||
char device_name[128];
|
||||
};
|
||||
|
||||
static inline void demo_cleanup(struct demo *demo)
|
||||
@@ -97,6 +99,11 @@ 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);
|
||||
@@ -137,9 +144,14 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
||||
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;
|
||||
@@ -147,6 +159,27 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
||||
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;
|
||||
@@ -162,6 +195,7 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
||||
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))
|
||||
@@ -174,6 +208,11 @@ fail:
|
||||
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);
|
||||
@@ -190,6 +229,11 @@ static inline ID3D12Resource *demo_swapchain_get_back_buffer(struct demo_swapcha
|
||||
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);
|
||||
|
@@ -176,12 +176,19 @@ static demo_key demo_key_from_nsevent(id event)
|
||||
{
|
||||
enum vkey
|
||||
{
|
||||
kVK_ANSI_A = 0x00,
|
||||
kVK_Escape = 0x35,
|
||||
kVK_LeftArrow = 0x7b,
|
||||
kVK_RightArrow = 0x7c,
|
||||
kVK_DownArrow = 0x7d,
|
||||
kVK_UpArrow = 0x7e,
|
||||
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;
|
||||
|
||||
@@ -192,12 +199,19 @@ static demo_key demo_key_from_nsevent(id event)
|
||||
}
|
||||
lookup[] =
|
||||
{
|
||||
{kVK_ANSI_A, 'a'},
|
||||
{kVK_Escape, DEMO_KEY_ESCAPE},
|
||||
{kVK_LeftArrow, DEMO_KEY_LEFT},
|
||||
{kVK_RightArrow, DEMO_KEY_RIGHT},
|
||||
{kVK_UpArrow, DEMO_KEY_UP},
|
||||
{kVK_DownArrow, DEMO_KEY_DOWN},
|
||||
{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);
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#ifdef HAVE_XCB
|
||||
# define VK_USE_PLATFORM_XCB_KHR
|
||||
#endif
|
||||
#define VKD3D_UTILS_API_VERSION VKD3D_API_VERSION_1_16
|
||||
#define VKD3D_UTILS_API_VERSION VKD3D_API_VERSION_1_17
|
||||
#include <vkd3d.h>
|
||||
#include <vkd3d_utils.h>
|
||||
#ifdef HAVE_XCB
|
||||
@@ -59,6 +59,7 @@ DECLARE_VK_PFN(vkCreateXcbSurfaceKHR)
|
||||
DECLARE_VK_PFN(vkDestroyFence)
|
||||
DECLARE_VK_PFN(vkDestroySurfaceKHR)
|
||||
DECLARE_VK_PFN(vkDestroySwapchainKHR)
|
||||
DECLARE_VK_PFN(vkGetPhysicalDeviceProperties)
|
||||
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)
|
||||
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceFormatsKHR)
|
||||
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceSupportKHR)
|
||||
@@ -228,6 +229,7 @@ static void load_vulkan_procs(void)
|
||||
LOAD_VK_PFN(vkDestroyFence)
|
||||
LOAD_VK_PFN(vkDestroySurfaceKHR)
|
||||
LOAD_VK_PFN(vkDestroySwapchainKHR)
|
||||
LOAD_VK_PFN(vkGetPhysicalDeviceProperties)
|
||||
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)
|
||||
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceFormatsKHR)
|
||||
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceSupportKHR)
|
||||
@@ -239,6 +241,7 @@ static void load_vulkan_procs(void)
|
||||
|
||||
struct demo_swapchain
|
||||
{
|
||||
VkPhysicalDeviceProperties vk_device_properties;
|
||||
VkSurfaceKHR vk_surface;
|
||||
VkSwapchainKHR vk_swapchain;
|
||||
VkFence vk_fence;
|
||||
@@ -310,6 +313,11 @@ static inline void demo_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
|
||||
demo->get_dpi(demo, dpi_x, dpi_y);
|
||||
}
|
||||
|
||||
static inline const char *demo_get_platform_name(void)
|
||||
{
|
||||
return "vkd3d";
|
||||
}
|
||||
|
||||
static inline void demo_process_events(struct demo *demo)
|
||||
{
|
||||
demo->process_events(demo);
|
||||
@@ -392,9 +400,13 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
||||
if (vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vk_physical_device, vk_surface, &surface_caps) < 0)
|
||||
goto fail;
|
||||
|
||||
if ((surface_caps.maxImageCount && desc->buffer_count > surface_caps.maxImageCount)
|
||||
|| desc->buffer_count < surface_caps.minImageCount
|
||||
|| desc->width > surface_caps.maxImageExtent.width || desc->width < surface_caps.minImageExtent.width
|
||||
image_count = desc->buffer_count;
|
||||
if (image_count < surface_caps.minImageCount)
|
||||
image_count = surface_caps.minImageCount;
|
||||
else if (surface_caps.maxImageCount && image_count > surface_caps.maxImageCount)
|
||||
image_count = surface_caps.maxImageCount;
|
||||
|
||||
if (desc->width > surface_caps.maxImageExtent.width || desc->width < surface_caps.minImageExtent.width
|
||||
|| desc->height > surface_caps.maxImageExtent.height || desc->height < surface_caps.minImageExtent.height
|
||||
|| !(surface_caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR))
|
||||
goto fail;
|
||||
@@ -432,7 +444,7 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
||||
vk_swapchain_desc.pNext = NULL;
|
||||
vk_swapchain_desc.flags = 0;
|
||||
vk_swapchain_desc.surface = vk_surface;
|
||||
vk_swapchain_desc.minImageCount = desc->buffer_count;
|
||||
vk_swapchain_desc.minImageCount = image_count;
|
||||
vk_swapchain_desc.imageFormat = format;
|
||||
vk_swapchain_desc.imageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||
vk_swapchain_desc.imageExtent.width = desc->width;
|
||||
@@ -471,6 +483,7 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
||||
free(vk_images);
|
||||
goto fail;
|
||||
}
|
||||
vkGetPhysicalDeviceProperties(vk_physical_device, &swapchain->vk_device_properties);
|
||||
swapchain->vk_surface = vk_surface;
|
||||
swapchain->vk_swapchain = vk_swapchain;
|
||||
swapchain->vk_fence = vk_fence;
|
||||
@@ -540,6 +553,11 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline const char *demo_swapchain_get_device_name(struct demo_swapchain *swapchain)
|
||||
{
|
||||
return swapchain->vk_device_properties.deviceName;
|
||||
}
|
||||
|
||||
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
|
||||
{
|
||||
return swapchain->current_buffer;
|
||||
@@ -555,6 +573,11 @@ static inline ID3D12Resource *demo_swapchain_get_back_buffer(struct demo_swapcha
|
||||
return resource;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
VkPresentInfoKHR present_desc;
|
||||
|
@@ -127,18 +127,23 @@ static demo_key demo_key_from_win32_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)
|
||||
{
|
||||
|
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,
|
||||
};
|
123
demos/gears.c
123
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:
|
||||
@@ -850,6 +833,7 @@ 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))
|
||||
@@ -880,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);
|
||||
|
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);
|
||||
@@ -396,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);
|
||||
|
@@ -158,8 +158,7 @@ build-mac:
|
||||
- mkdir artifacts
|
||||
- export PATH="/opt/homebrew/opt/bison/bin:/opt/homebrew/opt/flex/bin:$PATH"
|
||||
- export VK_DRIVER_FILES="$PWD/image/moltenvk/MoltenVK_icd.json"
|
||||
# Currently disabled because it has too many failures
|
||||
#- export SONAME_LIBDXCOMPILER="$PWD/image/dxc/libdxcompiler.dylib"
|
||||
- export SONAME_LIBDXCOMPILER="$PWD/image/dxc/libdxcompiler.dylib"
|
||||
- system_profiler SPSoftwareDataType SPHardwareDataType > artifacts/systeminfo.txt
|
||||
- vulkaninfo > artifacts/vulkaninfo.txt
|
||||
- git rebase $CI_MERGE_REQUEST_DIFF_BASE_SHA --exec ./gitlab/build-mac
|
||||
|
@@ -41,12 +41,10 @@ image-mac:
|
||||
- mkdir image/dxc
|
||||
- mkdir image/moltenvk
|
||||
|
||||
# The specified commit includes an update to the DirectXShaderCompiler's
|
||||
# CMakeList.txt which makes it compatible with cmake (4+).
|
||||
- git clone https://github.com/microsoft/DirectXShaderCompiler.git
|
||||
- git clone --recursive --branch v1.8.2502 https://github.com/microsoft/DirectXShaderCompiler.git
|
||||
- cd DirectXShaderCompiler
|
||||
- git checkout 3035d316c35289b68e8fc9d8cf21d86a204fb0e2
|
||||
- git submodule update --init --recursive
|
||||
# Include a fix for CMake 4+.
|
||||
- git cherry-pick 3035d316c35289b68e8fc9d8cf21d86a204fb0e2
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -C ../cmake/caches/PredefinedParams.cmake -D CMAKE_BUILD_TYPE=Release
|
||||
|
5
include/.gitignore
vendored
5
include/.gitignore
vendored
@@ -1,9 +1,14 @@
|
||||
config.h
|
||||
config.h.in
|
||||
private/appkit.h
|
||||
private/foundation.h
|
||||
private/quartzcore.h
|
||||
private/spirv_grammar.h
|
||||
private/vkd3d_version.h
|
||||
stamp-h1
|
||||
vkd3d_d3d12.h
|
||||
vkd3d_d3d12sdklayers.h
|
||||
vkd3d_d3d12shader.h
|
||||
vkd3d_d3dcommon.h
|
||||
vkd3d_d3dx9shader.h
|
||||
vkd3d_dxgi.h
|
||||
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user