-
Notifications
You must be signed in to change notification settings - Fork 67
/
meson.build
798 lines (670 loc) · 29.5 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
#############################################################################
# Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
#
# 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
# THE AUTHORS OR COPYRIGHT HOLDERS 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.
#############################################################################
project(
'dxvk', ['c', 'cpp'],
version : 'remix-main',
meson_version : '>= 0.58',
default_options : ['werror=true', 'b_vscrt=from_buildtype']
)
global_src_root_norm = meson.global_source_root().replace('\\', '/')
current_build_dir_norm = meson.current_build_dir().replace('\\', '/')
# Fetch dependencies
# `get_dependencies` is intentionally called twice. Why?:
# (1) On a clean clone, the `include_directories` calls below will fail without
# having fetched the dependencies, since all meson scripts complete entirely
# before the first build target (fetch_packman_target) is called.
# (2) On already built trees with no meson changes, the script is not rerun, so
# run_command will not be executed again, therefore a default build target
# version is required to pull updated packman info.
# Implications: in very rare circumstances (clean clone, editing meson), get_dependencies
# script will be called twice on the same build. This will not be noticeable as packman
# early outs if everything's already fetched, so the waste is negligible + forgiveable.
get_dependencies_script_path = join_paths(global_src_root_norm, 'scripts-common/update-deps.cmd')
message('Downloading dependencies...')
packman_out = run_command(get_dependencies_script_path, check: true)
message(packman_out.stdout().strip())
if packman_out.returncode() != 0
message(packman_out.stderr().strip())
error('Failed to get dependencies.')
endif
fetch_packman_target = custom_target('fetch_packman',
output : ['fetch_packman'],
build_by_default : true,
depends : [],
command : [get_dependencies_script_path] )
fs = import('fs')
cpu_family = target_machine.cpu_family()
build_os = build_machine.system()
assert(cpu_family != 'x86', 'dxvk-remix-nv can\'t be built in x86. Make sure you\'re running this from a regular Powershell window.')
add_project_arguments('-DNOMINMAX', language : 'cpp')
vs_project_defines = 'NOMINMAX;'
dxvk_compiler = meson.get_compiler('cpp')
dxvk_is_msvc = dxvk_compiler.get_id() == 'msvc'
dxvk_is_ninja = meson.backend() == 'ninja'
enable_rtxio = get_option('enable_rtxio')
external_dll_paths = []
if dxvk_is_msvc
if get_option('buildtype') == 'release'
add_global_arguments('/Zi', language : 'cpp')
add_global_arguments('/FS', language : 'cpp')
add_global_link_arguments('/DEBUG', language : 'cpp')
add_global_link_arguments('/OPT:REF', language : 'cpp')
add_global_link_arguments('/OPT:ICF', language : 'cpp')
endif
endif
if enable_rtxio == true
add_global_arguments('/DWITH_RTXIO', language : 'cpp')
vs_project_defines += 'WITH_RTXIO;'
endif
if get_option('buildtype') == 'release'
add_project_arguments('/DNDEBUG', language : 'cpp')
# note: this define depends on the build type, so it's not included in vs_project_defines
elif get_option('buildtype') == 'debugoptimized'
add_project_arguments('/DDEBUG_OPTIMIZED', language : 'cpp')
# note: this define depends on the build type, so it's not included in vs_project_defines
endif
if dxvk_is_ninja
# workarounds for our strange symbol name differences when embedding MDL
add_global_arguments('/DBUILD_NINJA=1', language : 'cpp')
vs_project_defines += 'BUILD_NINJA=1;'
else
add_global_arguments('/DBUILD_NINJA=0', language : 'cpp')
vs_project_defines += 'BUILD_NINJA=0;'
endif
# Note: Runtime shader recompilation requires source paths based on the project root, so making a build-time define is the easiest way
# to give it this information reliably for a local build (when distributing a build to others a manual source root must be specified in the runtime
# configuration).
add_global_arguments('/DBUILD_SOURCE_ROOT="' + global_src_root_norm + '/"', language : 'cpp')
vs_project_defines += 'BUILD_SOURCE_ROOT=' + global_src_root_norm + '/"' + ';'
# c++17 was added in 15.3, older version needs c++latest
if dxvk_is_msvc and dxvk_compiler.version().version_compare('<15.3')
if dxvk_is_ninja
# for whatever reason, ninja gets /fpermissive- when using c++latest/c++17 but vs does not
dxvk_cpp_std='vc++latest'
else
dxvk_cpp_std='c++latest'
endif
else
if dxvk_is_ninja
dxvk_cpp_std='vc++17'
else
dxvk_cpp_std='c++17'
endif
endif
if dxvk_is_msvc
if not dxvk_is_ninja
add_project_arguments('/std:' + dxvk_cpp_std, language : 'cpp')
endif
add_global_arguments('/MP', language : 'cpp')
endif
if dxvk_compiler.get_id() == 'clang'
if dxvk_compiler.has_argument('-Wno-unused-private-field')
add_project_arguments('-Wno-unused-private-field', language: 'cpp')
endif
if dxvk_compiler.has_argument('-Wno-microsoft-exception-spec')
add_project_arguments('-Wno-microsoft-exception-spec', language: 'cpp')
endif
endif
if not dxvk_is_msvc
add_project_arguments('-D_WIN32_WINNT=0xa00', language : 'cpp')
if get_option('build_id') and dxvk_compiler.has_link_argument('-Wl,--build-id')
add_global_link_arguments('-Wl,--build-id', language: 'cpp')
endif
# We need to set the section alignment for debug symbols to
# work properly as well as avoiding a memcpy from the Wine loader.
if dxvk_compiler.has_link_argument('-Wl,--file-alignment=4096')
add_global_link_arguments('-Wl,--file-alignment=4096', language: 'cpp')
endif
# Wine's built-in back traces only work with dwarf2 symbols
if get_option('debug') and target_machine.system() == 'windows'
if dxvk_compiler.has_argument('-gstrict-dwarf') and dxvk_compiler.has_argument('-gdwarf-2')
add_project_arguments('-gstrict-dwarf', '-gdwarf-2', language: ['c', 'cpp'])
endif
endif
endif
remix_api_include_path = include_directories('./public/include')
add_global_arguments('/DREMIX_LIBRARY_EXPORTS=1', language : 'cpp')
dxvk_include_dirs = [
'./include',
'./include/vulkan/include'
]
dxvk_include_path = include_directories(dxvk_include_dirs)
dxvk_shader_include_path = include_directories('./src/dxvk/shaders')
test_include_dirs = [
'./include',
'./include/vulkan/include',
'./src/dxvk',
'./src/dxvk/shaders'
]
test_include_path = include_directories(test_include_dirs)
if (cpu_family == 'x86_64')
dxvk_library_path = join_paths(global_src_root_norm, 'lib')
else
dxvk_library_path = join_paths(global_src_root_norm, 'lib32')
endif
dxvk_extradep = [ ]
if dxvk_is_msvc
wrc = find_program('rc')
else
add_global_link_arguments('-static', '-static-libgcc', language: 'c')
add_global_link_arguments('-static', '-static-libgcc', '-static-libstdc++', language: 'cpp')
wrc = find_program('windres')
endif
if cpu_family == 'x86_64'
if dxvk_compiler.has_argument('-msse3')
add_project_arguments('-msse3', language: ['c', 'cpp'])
endif
elif cpu_family == 'x86'
if dxvk_compiler.has_link_argument('-Wl,--add-stdcall-alias')
add_global_link_arguments('-Wl,--add-stdcall-alias', language: 'cpp')
endif
if dxvk_compiler.has_link_argument('-Wl,--enable-stdcall-fixup')
add_global_link_arguments('-Wl,--enable-stdcall-fixup', language: 'cpp')
endif
if dxvk_compiler.has_argument('-msse') and dxvk_compiler.has_argument('-msse2') and dxvk_compiler.has_argument('-msse3')
add_project_arguments('-msse', '-msse2', '-msse3', language: ['c', 'cpp'])
endif
if dxvk_compiler.has_argument('-mfpmath=sse')
add_project_arguments('-mfpmath=sse', language: ['c', 'cpp'])
endif
endif
lib_vulkan = dxvk_compiler.find_library('vulkan-1', dirs : dxvk_library_path)
lib_d3d9 = dxvk_compiler.find_library('d3d9')
lib_d3d11 = dxvk_compiler.find_library('d3d11')
lib_dxgi = dxvk_compiler.find_library('dxgi')
lib_d3dcompiler_43 = dxvk_compiler.find_library('d3dcompiler_43', dirs : dxvk_library_path)
if not dxvk_is_msvc
lib_ws2_32 = dxvk_compiler.find_library('ws2_32', dirs : dxvk_library_path)
endif
if dxvk_is_msvc
lib_d3dcompiler_47 = dxvk_compiler.find_library('d3dcompiler')
else
lib_d3dcompiler_47 = dxvk_compiler.find_library('d3dcompiler_47')
endif
lib_shlwapi = dxvk_compiler.find_library('shlwapi')
dxvk_extradep += lib_shlwapi
if enable_rtxio == true
rtxio_bin_path = join_paths(global_src_root_norm, 'external/rtxio/bin')
external_dll_paths += rtxio_bin_path
rtxio_lib = dxvk_compiler.find_library('rtxio', dirs : join_paths(global_src_root_norm, 'external/rtxio/lib'))
rtxio_include_path = include_directories('external/rtxio/include')
dxvk_extradep += rtxio_lib
endif
exe_ext = ''
dll_ext = ''
if dxvk_is_msvc
res_ext = '.res'
else
res_ext = '.o'
endif
def_spec_ext = '.def'
# Shader compile tools
glsl_compiler = find_program('external/glslangvalidator/glslangValidator')
slang_compiler = find_program('external/slang/slangc')
python_interpreter = find_program('python3', 'python')
shader_compile_script = join_paths(global_src_root_norm, 'scripts-common/compile_shaders.py')
# GLSL compiler...
# The ShaderManager::compileShaders() function also uses glslangValidator to compile shader source for debug purpose.
# If the command here is changed, the command in that function should also be updated.
glsl_args = [ '-V', '--vn', '@BASENAME@', '@INPUT@', '-o', '@OUTPUT@', '--target-env', 'vulkan1.2', '@EXTRA_ARGS@' ]
if run_command(glsl_compiler, [ '--quiet', '--version' ], check: false).returncode() == 0
glsl_args += [ '--quiet' ]
endif
if get_option('buildtype').startswith('debug')
glsl_args += [ '-g' ]
endif
glsl_generator = generator(
glsl_compiler,
output : [ '@[email protected]' ],
arguments : glsl_args
)
if dxvk_is_msvc
wrc_generator = generator(wrc,
output : [ '@BASENAME@' + res_ext ],
arguments : [ '/fo', '@OUTPUT@', '@INPUT@' ])
else
wrc_generator = generator(wrc,
output : [ '@BASENAME@' + res_ext ],
arguments : [ '-i', '@INPUT@', '-o', '@OUTPUT@' ])
endif
message('##############')
message('# Versioning #')
message('##############')
full_version = meson.project_version()
git_rev_parse_out = run_command('git', ['rev-parse','--verify','--short=8', 'HEAD'], check: false)
git_hash = ''
if git_rev_parse_out.returncode() != 0
error('Failed to get current git hash')
else
git_hash = git_rev_parse_out.stdout().replace('\n','')
message('Current git hash: ' + git_hash)
endif
found_tag = ''
ci_commit_tag = ''
get_env_out = run_command(python_interpreter.full_path(), [join_paths(global_src_root_norm, 'scripts-common/get_env.py'), 'CI_COMMIT_TAG'], check: false)
if get_env_out.returncode() != 0
warning('get_env.py failed, ' + get_env_out.stderr().strip())
else
ci_commit_tag = get_env_out.stdout().replace('\n','')
endif
b_found_ci_commit_tag = (ci_commit_tag != '')
if b_found_ci_commit_tag
message('Found tag in CI_COMMIT_TAG envvar: ' + ci_commit_tag)
found_tag = ci_commit_tag
else
git_describe_tag = ''
git_describe_out = run_command('git', ['describe','--always','--exact-match', git_hash], check: false)
if git_describe_out.returncode() == 0
git_describe_tag = git_describe_out.stdout().replace('\n','')
message('Found tag via git describe: ' + git_describe_tag)
endif
found_tag = git_describe_tag
endif
b_found_tag = found_tag != ''
b_found_tag_matches = false
if b_found_tag
b_found_tag_matches = found_tag == meson.project_version()
endif
if b_found_tag
if not b_found_tag_matches
warning('Tag does not match current version: ' + meson.project_version() + '. Please reconcile tag with version in meson.build.')
else
message('Found tag matches current version: ' + meson.project_version())
message('This is a release version.')
endif
else
message('No tag found at current commit.')
message('This is NOT a release version')
full_version += '+' + git_hash
endif
message('Full version: ' + full_version)
dxvk_version = vcs_tag(
command: [python_interpreter.full_path(), join_paths(global_src_root_norm, 'scripts-common/echo.py'), full_version],
input: 'version.h.in',
output: 'version.h')
#################################
# Handle external dependencies ##
#################################
output_dir = join_paths(global_src_root_norm, '_output/')
# Get script paths
if build_os == 'windows'
script_extension = '.bat'
recursive_arg = '/E'
elif build_os == 'linux'
script_extension = '.sh'
recursive_arg = '-r'
else
script_extension = ''
endif
copy_script_path = join_paths(global_src_root_norm, 'scripts-common/copy' + script_extension)
recursive_copy_path = join_paths(global_src_root_norm, 'scripts-common/recursive_copy' + script_extension)
if get_option('enable_tracy')
add_project_arguments('-DTRACY_ENABLE', language : 'cpp')
vs_project_defines += 'TRACY_ENABLE;'
# only enable profiling when the profiler-application is connected
add_project_arguments('-DTRACY_ON_DEMAND', language : 'cpp')
vs_project_defines += 'TRACY_ON_DEMAND;'
endif
if get_option('buildtype') == 'debug'
usd_debug_or_release = 'Debug'
else
usd_debug_or_release = 'Release'
endif
# embedding compiler
xxd_exe = find_program('external/nv_xxd/nv_xxd')
embedding_compiler = generator(xxd_exe,
output : '@[email protected]',
arguments : [ '@INPUT@', '@OUTPUT@', '@BASENAME@' ]
)
mdl_include_dir = include_directories('external/omni_core_materials')
nv_usd_include_path = include_directories('external/nv_usd/include/')
boost_include_path = include_directories('external/nv_usd/include/boost-1_78/')
usd_include_paths = [nv_usd_include_path, boost_include_path]
vk_include_path = include_directories('./include/vulkan/include')
lssusd_include_paths = [nv_usd_include_path, boost_include_path, vk_include_path]
nvapi_include_paths = include_directories('external/nvapi')
nvapi_lib_path = join_paths(global_src_root_norm, 'external/nvapi/amd64')
nvapi_lib = dxvk_compiler.find_library('nvapi64', dirs : nvapi_lib_path)
# Cache lib locations
usd_lib_path = join_paths(global_src_root_norm, 'external/nv_usd/' + usd_debug_or_release + '/')
external_dll_paths += usd_lib_path
usd_lib = dxvk_compiler.find_library('usd_ms', dirs : usd_lib_path)
if get_option('buildtype') == 'debug'
tbb_lib = dxvk_compiler.find_library('tbb_debug', dirs : usd_lib_path)
else
tbb_lib = dxvk_compiler.find_library('tbb', dirs : usd_lib_path)
endif
reflex_include_path = include_directories( 'external/reflex/inc')
reflex_lib_path = join_paths(global_src_root_norm, 'external/reflex/lib')
external_dll_paths += reflex_lib_path
reflex_lib = dxvk_compiler.find_library('NvLowLatencyVk', dirs : reflex_lib_path)
aftermath_include_path = include_directories( 'external/aftermath/include')
aftermath_lib_path = join_paths(global_src_root_norm, 'external/aftermath/lib/x64/')
external_dll_paths += aftermath_lib_path
aftermath_lib = dxvk_compiler.find_library('GFSDK_Aftermath_Lib.x64', dirs : aftermath_lib_path)
# this is repeated below, since we overwrite dlss_lib_path in src/dxvk/meson.build for some reason
dlss_root_path = 'external/ngx_sdk_dldn'
dlss_lib_path = join_paths(global_src_root_norm, dlss_root_path, 'lib/Windows_x86_64/rel/')
external_dll_paths += dlss_lib_path
dlfg_root_path = 'external/ngx_sdk_dlfg'
dlfg_lib_path = join_paths(global_src_root_norm, dlfg_root_path, 'lib/Windows_x86_64/rel/')
external_dll_paths += dlfg_lib_path
nrd_lib_path = join_paths(global_src_root_norm, 'external/nrd/Lib/Release/')
if get_option('buildtype') == 'debug'
nrd_lib_path = join_paths(global_src_root_norm, 'external/nrd/Lib/Debug/')
endif
rtxdi_include_path = include_directories('submodules/rtxdi/rtxdi-sdk/include')
# Need to use the include path as an argument to the shader build string,
# and I couldn't find how to convert the IncludeDirs thing to a string... Meson.
rtxdi_include_path_string = join_paths(global_src_root_norm, 'submodules/rtxdi/rtxdi-sdk/include')
if not dxvk_is_ninja
# Copy dependencies that must be in same dir as executable to _output dir
recursive_copy_usd_target = custom_target('recursive_copy_usd',
output : ['recursive_copy_usd'],
build_by_default : true,
command : [recursive_copy_path, join_paths(usd_lib_path, 'usd/'), join_paths(output_dir, 'usd/')] )
copy_usd_dll_target = custom_target('copy_usd_dll',
output : ['copy_usd_dll'],
build_by_default : true,
command : [copy_script_path, usd_lib_path, output_dir, 'usd_ms.dll'] )
if get_option('buildtype') == 'debug'
tbb_dll_name = 'tbb_debug.dll'
tbbmalloc_dll_name = 'tbbmalloc_debug.dll'
else
tbb_dll_name = 'tbb.dll'
tbbmalloc_dll_name = 'tbbmalloc.dll'
endif
copy_tbb_dll_target = custom_target('copy_tbb_dll',
output : ['copy_tbb_dll'],
build_by_default : true,
command : [copy_script_path, usd_lib_path, output_dir, tbb_dll_name] )
copy_tbbmalloc_dll_target = custom_target('copy_tbbmalloc_dll',
output : ['copy_tbbmalloc_dll'],
build_by_default : true,
command : [copy_script_path, usd_lib_path, output_dir, tbbmalloc_dll_name] )
copy_nrd_dll_target = custom_target('copy_nrd_dll',
output : ['copy_nrd_dll'],
build_by_default : true,
command : [copy_script_path, nrd_lib_path, output_dir, 'NRD.dll'] )
copy_dlss_dll_target = custom_target('copy_dlss_dll',
output : ['copy_dlss_dll'],
build_by_default : true,
command : [copy_script_path, dlss_lib_path, output_dir, 'nvngx_*.*'] )
copy_dlfg_dll_target = custom_target('copy_dlfg_dll',
output : ['copy_dlfg_dll'],
build_by_default : true,
command : [copy_script_path, dlfg_lib_path, output_dir, 'nvngx_dlssg.dll'] )
copy_reflex_dll_target = custom_target('copy_reflex_dll',
output : ['copy_reflex_dll'],
build_by_default : true,
depends : [],
command : [copy_script_path, reflex_lib_path, output_dir, 'NvLowLatencyVk.dll'] )
copy_aftermath_dll_target = custom_target('copy_aftermath_dll',
output : ['copy_aftermath_dll'],
build_by_default : true,
depends : [],
command : [copy_script_path, aftermath_lib_path, output_dir, 'GFSDK_Aftermath_Lib.x64.dll'] )
if enable_rtxio == true
copy_rtxio_target = custom_target('copy_rtxio',
output : ['copy_rtxio'],
build_by_default : true,
depends : [],
command : [copy_script_path, rtxio_bin_path, output_dir, 'rtxio.*'] )
endif
endif
# Build meson dependency types
usd_dep = declare_dependency(
dependencies : [ usd_lib, tbb_lib ],
# link_args : ['-L'+usd_lib_path],
include_directories : usd_include_paths
)
reflex_dep = declare_dependency(
dependencies : [ reflex_lib ],
include_directories : reflex_include_path
)
aftermath_dep = declare_dependency(
dependencies : [ aftermath_lib ],
include_directories : aftermath_include_path
)
nvapi_dep = declare_dependency(
dependencies : [ nvapi_lib ],
include_directories : nvapi_include_paths
)
embedded_includes = [ mdl_include_dir ]
if enable_rtxio == true
rtxio_dep = declare_dependency(
dependencies : [ rtxio_lib ],
include_directories : rtxio_include_path
)
endif
embedded_dep = declare_dependency(
dependencies : [ ],
include_directories : embedded_includes
)
subdir('src')
enable_tests = get_option('enable_tests')
if enable_tests
subdir('tests')
endif
# dict of "output" targets --- key is an output path, value is an optional executable inside that path,
# which is used to run that "output" from the IDE
dxvkrt_output_targets = {
'_output': '',
'_sdk': '',
}
subdir('tests/rtx')
if dxvk_is_ninja
# this is how we force meson to reconfigure when external files change
# (meson does not do globbing)
if fs.exists('gametargets.conf')
fs.read('gametargets.conf')
endif
fs.read('vsgen/dxvk_project.py')
fs.read('vsgen/dxvk-remix.vcxproj.template')
fs.read('vsgen/get_game_target_list.py')
fs.read('vsgen/sln.py')
fs.read('vsgen/testcase_project.py')
fs.read('vsgen/testcase_project.vcxproj.template')
fs.read('vsgen/testcase_project.vcxproj.user.template')
fs.read('vsgen/testcase_project.args.json.template')
fs.read('vsgen/vsutil.py')
# ... and now we do this again, because src/dxvk/meson.build overwrites this for some reason
dlss_root_path = 'external/ngx_sdk_dldn'
dlss_lib_path = join_paths(global_src_root_norm, dlss_root_path, 'lib/Windows_x86_64/rel/')
dlfg_root_path = 'external/ngx_sdk_dlfg'
dlfg_lib_path = join_paths(global_src_root_norm, dlfg_root_path, 'lib/Windows_x86_64/rel/')
# meson seems to force / as the path separator in custom_target
# ... except in the case where the path separators are inconsistent, in which case it does nothing
# force / as the path separator here to make sure it stays consistent
nrd_lib_path = join_paths(global_src_root_norm, 'external/nrd/Lib/Release/')
if get_option('buildtype') == 'debug'
nrd_lib_path = join_paths(global_src_root_norm, 'external/nrd/Lib/Debug/')
endif
apic_copy_targets = []
vs_gen_cmdline = [ vs_project_defines ]
# dict of: { <projectname>: { 'output_path': <copy_output_path>, 'target_suffix': <copy_target_suffix>, 'src_exe': <if non-empty, copy exe from this absolute path> } }
dxvkrt_copy_targets = {}
# fill in all of the above
foreach t, exe : dxvkrt_output_targets
if t == '_output'
# _output target is special
target_suffix = 'output'
output_path = output_dir
src_exe = ''
elif t == '_sdk'
# _sdk target is special
target_suffix = 'sdk'
output_path = join_paths(global_src_root_norm, 'public/bin/')
src_exe = ''
else
target_suffix = t.underscorify()
output_path = dxvkrt_test_root + t
if fs.is_absolute(exe)
src_exe = exe
vs_gen_cmdline += t + ',' + fs.name(exe)
else
src_exe = ''
# capture data for VS generator
vs_gen_cmdline += t + ',' + exe
endif
endif
dxvkrt_copy_targets += { t : { 'output_path': output_path, 'target_suffix': target_suffix, 'src_exe': src_exe } }
endforeach
# add data from gametargets.conf to dxvkrt_copy_targets
game_targets_run = run_command(python_interpreter,
join_paths(global_src_root_norm, 'vsgen/get_game_target_list.py'),
check: true)
game_targets = game_targets_run.stdout().strip()
if game_targets != ''
foreach t : game_targets.split('\n')
s = t.split(',')
key = s[0]
target_suffix = key.underscorify()
output_path = s[1]
dxvkrt_copy_targets += { key : { 'output_path': output_path, 'target_suffix': target_suffix, 'src_exe': '' } }
# note: this doesn't go into the VS generator command line, gametargets.conf is read from python directly
endforeach
endif
foreach key : dxvkrt_copy_targets.keys()
target_suffix = dxvkrt_copy_targets[key]['target_suffix']
output_path = dxvkrt_copy_targets[key]['output_path']
src_exe = dxvkrt_copy_targets[key]['src_exe']
# generate targets to copy DLLs to individual test dirs, with names of the form 'copy_Portal1_SingleFrame_A'
# these targets are not run by default, since we have a lot of tests: the intent is that we run this as a build task from the IDE before launching the test
# also, meson feature: we *can not* pass down paths using \ as arguments to the command in custom_target, they are forced to / somewhere,
# except if the path separators are inconsistent, where meson skips all munging
copy_usd = custom_target('recursive_copy_usd_' + target_suffix,
output : ['recursive_copy_usd_' + target_suffix],
command : [recursive_copy_path,
join_paths(usd_lib_path, 'usd/'),
join_paths(output_path, 'usd/')] )
copy_usd_dll = custom_target('copy_usd_dll_' + target_suffix,
output : ['copy_usd_dll_' + target_suffix],
command : [copy_script_path,
usd_lib_path,
output_path,
'usd_ms.dll'] )
if get_option('buildtype') == 'debug'
tbb_dll_name = 'tbb_debug.dll'
tbbmalloc_dll_name = 'tbbmalloc_debug.dll'
else
tbb_dll_name = 'tbb.dll'
tbbmalloc_dll_name = 'tbbmalloc.dll'
endif
copy_tbb_dll = custom_target('copy_tbb_dll_' + target_suffix,
output : ['copy_tbb_dll_' + target_suffix],
command : [copy_script_path,
usd_lib_path,
output_path,
tbb_dll_name] )
copy_tbbmalloc_dll = custom_target('copy_tbbmalloc_dll_' + target_suffix,
output : ['copy_tbbmalloc_dll_' + target_suffix],
command : [copy_script_path,
usd_lib_path,
output_path,
tbbmalloc_dll_name] )
copy_nrd_dll = custom_target('copy_nrd_dll_' + target_suffix,
output : ['copy_nrd_dll_' + target_suffix],
command : [copy_script_path,
nrd_lib_path,
output_path,
'NRD.dll'] )
copy_dlss_dll = custom_target('copy_dlss_dll_' + target_suffix,
output : ['copy_dlss_dll_' + target_suffix],
command : [copy_script_path,
dlss_lib_path,
output_path,
'nvngx_*.*'] )
copy_dlfg_dll = custom_target('copy_dlfg_dll_' + target_suffix,
output : ['copy_dlfg_dll_' + target_suffix],
command : [copy_script_path,
dlfg_lib_path,
output_path,
'nvngx_dlssg.dll'] )
copy_reflex_dll = custom_target('copy_reflex_dll_' + target_suffix,
output : ['copy_reflex_dll_' + target_suffix],
depends : [],
command : [copy_script_path,
reflex_lib_path,
output_path,
'NvLowLatencyVk.dll'] )
copy_aftermath_dll = custom_target('copy_aftermath_dll_' + target_suffix,
output : ['copy_aftermath_dll_' + target_suffix],
depends : [],
command : [copy_script_path, aftermath_lib_path, output_path, 'GFSDK_Aftermath_Lib.x64.dll'] )
if enable_rtxio == true
copy_rtxio = custom_target('copy_rtxio_' + target_suffix,
output : ['copy_rtxio_' + target_suffix],
depends : [],
command : [copy_script_path, rtxio_bin_path, output_path, 'rtxio.*'] )
endif
# the copy target is special
# if we use custom_target for the d3d9 DLL, meson generates a target that does nothing in ninja
# as a workaround, we do the copy as part of the test_* target itself
copy_target_depends = [ copy_usd,
copy_usd_dll,
copy_tbb_dll,
copy_tbbmalloc_dll,
copy_nrd_dll,
copy_dlss_dll,
copy_dlfg_dll,
copy_aftermath_dll,
d3d9_dll ]
copy_target_depends += copy_reflex_dll
if enable_rtxio == true
copy_target_depends += copy_rtxio
endif
if src_exe != ''
copy_target_depends += custom_target('copy_exe_' + target_suffix,
output : ['copy_exe_' + target_suffix],
depends : [],
command : [copy_script_path, fs.parent(src_exe) + '/', output_path + '/', fs.name(src_exe)] )
endif
copy_target = run_target('copy_' + target_suffix.replace('apics_', ''),
depends: copy_target_depends,
command : [copy_script_path,
join_paths(current_build_dir_norm, 'src/d3d9'),
output_path,
'd3d9*'])
if t != '_output'
apic_copy_targets += copy_target
endif
endforeach
# xxxnsubtil: this one line replaces a bunch of python code used for the vscode build, but requires meson 0.61.3
# (specifically, https://github.com/mesonbuild/meson/pull/9202)
# alias_target('copy_to_all_apics', apic_copy_targets)
# generate VS project files for ninja
# note: this writes to <source root>/_vs, which is outside the build directory
vsproj = run_command(python_interpreter,
join_paths(global_src_root_norm, 'vsgen/generate_vs_project_files.py'),
vs_gen_cmdline,
check: false)
if vsproj.stdout().strip() != ''
message(vsproj.stdout().strip())
endif
if vsproj.stderr().strip() != ''
message(vsproj.stderr().strip())
endif
if vsproj.returncode() != 0
error('generate_vs_project_files failed')
endif
endif # dxvk_is_ninja