Skip to content

Commit d6640cb

Browse files
committed
Merge branch 'dev/adunn/fix_meson_' into 'main'
Improve meson compile stability and performance See merge request lightspeedrtx/dxvk-remix-nv!1606
2 parents f181f22 + 1cf3f25 commit d6640cb

File tree

12 files changed

+190
-198
lines changed

12 files changed

+190
-198
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@
3636
/external
3737
**/_batch_output/**
3838
/public/bin/
39-
tests/rtx/dxvk_rt_testing/apics
39+
tests/rtx/dxvk_rt_testing/apics
40+
*.log

build_common.ps1

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ If (Test-Path env:LIBPATH) {
5555
# Load VC vars
5656
Push-Location "${vsPath}\VC\Auxiliary\Build"
5757
cmd /c "vcvarsall.bat x64&set" |
58-
ForEach-Object {
59-
# Due to some odd behavior with how powershell core (pwsh) (powershell 5.X not tested) interprets a specific
60-
# predefined gitlab CI variable (in this case CI_MERGE_REQUEST_DESCRIPTION) with a value that includes ===
61-
# The `Contains` method is used to ignore the string === to prevent pwsh from erroneously encountering an error.
62-
If ($_ -match "=") {
63-
If (-not ($_.Contains('==='))) {
64-
$v = $_.split("="); Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
65-
}
66-
}
67-
}
58+
ForEach-Object {
59+
# Due to some odd behavior with how powershell core (pwsh) (powershell 5.X not tested) interprets a specific
60+
# predefined gitlab CI variable (in this case CI_MERGE_REQUEST_DESCRIPTION) with a value that includes ===
61+
# The `Contains` method is used to ignore the string === to prevent pwsh from erroneously encountering an error.
62+
If ($_ -match "=") {
63+
If (-not ($_.Contains('==='))) {
64+
$v = $_.split("="); Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
65+
}
66+
}
67+
}
6868
Pop-Location
6969
Write-Host "Visual Studio Command Prompt variables set." -ForegroundColor Yellow
7070
}
@@ -83,7 +83,9 @@ function PerformBuild {
8383
[Parameter(Mandatory)]
8484
[string]$EnableTracy,
8585

86-
[string]$BuildTarget
86+
[string]$BuildTarget,
87+
88+
[string[]]$InstallTags
8789
)
8890

8991
$CurrentDir = Get-Location
@@ -101,7 +103,16 @@ function PerformBuild {
101103
}
102104

103105
Push-Location $BuildDir
104-
& meson compile -v $BuildTarget
106+
& meson compile -v
107+
108+
if ($InstallTags -and $InstallTags.Count -gt 0) {
109+
# join array into comma-separated list
110+
$tagList = $InstallTags -join ','
111+
& meson install --tags $tagList
112+
}
113+
else {
114+
& meson install
115+
}
105116
Pop-Location
106117

107118
if ( $LASTEXITCODE -ne 0 ) {

meson.build

Lines changed: 62 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
project(
2424
'dxvk', ['c', 'cpp'],
2525
version : 'remix-main',
26-
meson_version : '>= 0.58',
26+
meson_version : '>= 0.60',
2727
default_options : ['werror=true', 'b_vscrt=from_buildtype']
2828
)
2929

@@ -43,17 +43,16 @@ current_build_dir_norm = meson.current_build_dir().replace('\\', '/')
4343
# early outs if everything's already fetched, so the waste is negligible + forgiveable.
4444
get_dependencies_script_path = join_paths(global_src_root_norm, 'scripts-common/update-deps.cmd')
4545
message('Downloading dependencies...')
46-
packman_out = run_command(get_dependencies_script_path, check: true)
46+
packman_out = run_command(get_dependencies_script_path, 'packman-external.xml', 'update-deps.log', check: true)
4747
message(packman_out.stdout().strip())
4848
if packman_out.returncode() != 0
4949
message(packman_out.stderr().strip())
5050
error('Failed to get dependencies.')
5151
endif
5252
fetch_packman_target = custom_target('fetch_packman',
53-
output : ['fetch_packman'],
54-
build_by_default : true,
55-
depends : [],
56-
command : [get_dependencies_script_path] )
53+
input : ['packman-external.xml', get_dependencies_script_path],
54+
output : 'update-deps.log',
55+
command : [get_dependencies_script_path, '@INPUT0@', '@OUTPUT0@' ] )
5756

5857
fs = import('fs')
5958

@@ -599,11 +598,14 @@ if enable_tests
599598
subdir('tests')
600599
endif
601600

601+
hdremix_outdir = join_paths(meson.current_source_dir(), 'nv-private', 'hdremix', 'bin', get_option('buildtype'))
602+
602603
# dict of "output" targets --- key is an output path, value is an optional executable inside that path,
603604
# which is used to run that "output" from the IDE
604605
dxvkrt_output_targets = {
605606
'_output': '',
606607
'_sdk': '',
608+
'_hdremix': '',
607609
}
608610

609611
subdir('tests/rtx')
@@ -658,6 +660,11 @@ if dxvk_is_ninja
658660
target_suffix = 'sdk'
659661
output_path = join_paths(global_src_root_norm, 'public/bin/')
660662
src_exe = ''
663+
elif t == '_hdremix'
664+
# _hdremix target is special
665+
target_suffix = 'hdremix'
666+
output_path = hdremix_outdir
667+
src_exe = ''
661668
else
662669
target_suffix = t.underscorify()
663670
output_path = dxvkrt_test_root + t
@@ -671,10 +678,10 @@ if dxvk_is_ninja
671678
vs_gen_cmdline += t + ',' + exe
672679
endif
673680
endif
674-
681+
675682
dxvkrt_copy_targets += { t : { 'output_path': output_path, 'target_suffix': target_suffix, 'src_exe': src_exe } }
676683
endforeach
677-
684+
678685
# add data from gametargets.conf to dxvkrt_copy_targets
679686
game_targets_run = run_command(python_interpreter,
680687
join_paths(global_src_root_norm, 'vsgen/get_game_target_list.py'),
@@ -699,173 +706,68 @@ if dxvk_is_ninja
699706
output_path = dxvkrt_copy_targets[key]['output_path']
700707
src_exe = dxvkrt_copy_targets[key]['src_exe']
701708

702-
# generate targets to copy DLLs to individual test dirs, with names of the form 'copy_Portal1_SingleFrame_A'
703-
# 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
704-
# also, meson feature: we *can not* pass down paths using \ as arguments to the command in custom_target, they are forced to / somewhere,
705-
# except if the path separators are inconsistent, where meson skips all munging
706-
707-
copy_usd = custom_target('recursive_copy_usd_' + target_suffix,
708-
output : ['recursive_copy_usd_' + target_suffix],
709-
command : [recursive_copy_path,
710-
join_paths(usd_lib_path, 'lib/usd/'),
711-
join_paths(output_path, 'usd/')] )
712-
copy_usd_dll = []
709+
# using tagged install targets to get the files in the right place at install time (each project in VS knows which tag to use)
710+
711+
install_subdir(join_paths(usd_lib_path, 'lib/usd/'), install_dir : output_path, install_tag: target_suffix)
712+
713713
foreach ulib : nvusd_deplibs
714-
copy_usd_dll += custom_target('copy_usd_dll_' + ulib + '_' + target_suffix,
715-
output : ['copy_usd_dll_' + ulib + '_' + target_suffix],
716-
command : [copy_script_path,
717-
join_paths(usd_lib_path, 'lib/'),
718-
output_path,
719-
ulib + '.dll'] )
714+
install_data(join_paths(usd_lib_path, 'lib', ulib + '.dll'), install_dir : output_path, install_tag: target_suffix)
720715
endforeach
721716

722-
copy_usd_plugins_dlls = []
723-
724-
copy_usd_plugins_dlls += custom_target('copy_usd_plugins_json_' + target_suffix,
725-
output : ['copy_usd_plugins_json_' + target_suffix],
726-
command : [copy_script_path,
727-
join_paths(global_src_root_norm, 'src', 'usd-plugins'),
728-
join_paths(output_path, 'usd/plugins/'),
729-
'plugInfo.json'] )
730-
foreach usd_plugin : usd_plugins
731-
copy_usd_plugins_dlls += custom_target('copy_usd_plugins_' + usd_plugin.name() + '_dll_' + target_suffix,
732-
depends : [ usd_plugin ],
733-
output : ['copy_usd_plugins_' + usd_plugin.name() + '_dll_' + target_suffix],
734-
command : [copy_script_path,
735-
fs.parent(usd_plugin.full_path()) ,
736-
join_paths(output_path, 'usd/plugins', usd_plugin.name() + '/'),
737-
usd_plugin.name() + '.dll'] )
738-
739-
copy_usd_plugins_dlls += custom_target('copy_usd_plugins_' + usd_plugin.name() + '_json_' + target_suffix,
740-
depends : [ usd_plugin ],
741-
output : ['copy_usd_plugins_' + usd_plugin.name() + '_json_' + target_suffix],
742-
command : [copy_script_path,
743-
fs.parent(usd_plugin.full_path()),
744-
join_paths(output_path, 'usd/plugins', usd_plugin.name(), 'resources/'),
745-
'plugInfo.json'] )
746-
747-
copy_usd_plugins_dlls += custom_target('copy_usd_plugins_' + usd_plugin.name() + '_schema_' + target_suffix,
748-
depends : [ usd_plugin ],
749-
output : ['copy_usd_plugins_' + usd_plugin.name() + '_schema_' + target_suffix],
750-
command : [copy_script_path,
751-
fs.parent(usd_plugin.full_path()),
752-
join_paths(output_path, 'usd/plugins', usd_plugin.name() + '/'),
753-
'generatedSchema.usda'] )
754-
endforeach
717+
install_data(join_paths(global_src_root_norm, 'src', 'usd-plugins', 'plugInfo.json'), install_dir : join_paths(output_path, 'usd', 'plugins'), install_tag: target_suffix)
755718

756-
copy_nrc_dll = custom_target('copy_nrc_dll_' + target_suffix,
757-
output : ['copy_nrc_dll_' + target_suffix],
758-
command : [copy_script_path,
759-
nrc_dll_path,
760-
output_path,
761-
nrc_dll_name] )
762-
763-
copy_nrc_cuda_deps_dll = custom_target('copy_nrc_cuda_deps_dll_' + target_suffix,
764-
output : ['copy_nrc_cuda_deps_dll_' + target_suffix],
765-
command : [copy_script_path,
766-
nrc_dll_path,
767-
output_path,
768-
'cudart64_12.dll'] )
769-
770-
copy_nrc_cuda_nv_deps_dll = custom_target('copy_nrc_cuda_nv_deps_dll_' + target_suffix,
771-
output : ['copy_nrc_cuda_nv_deps_dll_' + target_suffix],
772-
command : [copy_script_path,
773-
nrc_dll_path,
774-
output_path,
775-
'nvrtc*.dll'] )
776-
777-
copy_nrd_dll = custom_target('copy_nrd_dll_' + target_suffix,
778-
output : ['copy_nrd_dll_' + target_suffix],
779-
command : [copy_script_path,
780-
nrd_lib_path,
781-
output_path,
782-
'NRD.dll'] )
783-
784-
copy_dlss_dll = custom_target('copy_dlss_dll_' + target_suffix,
785-
output : ['copy_dlss_dll_' + target_suffix],
786-
command : [copy_script_path,
787-
dlss_lib_path,
788-
output_path,
789-
'nvngx_*.*'] )
790-
791-
copy_dlfg_dll = custom_target('copy_dlfg_dll_' + target_suffix,
792-
output : ['copy_dlfg_dll_' + target_suffix],
793-
command : [copy_script_path,
794-
dlfg_lib_path,
795-
output_path,
796-
'nvngx_dlssg.dll'] )
797-
798-
copy_reflex_dll = custom_target('copy_reflex_dll_' + target_suffix,
799-
output : ['copy_reflex_dll_' + target_suffix],
800-
depends : [],
801-
command : [copy_script_path,
802-
reflex_lib_path,
803-
output_path,
804-
'NvLowLatencyVk.dll'] )
805-
806-
copy_aftermath_dll = custom_target('copy_aftermath_dll_' + target_suffix,
807-
output : ['copy_aftermath_dll_' + target_suffix],
808-
depends : [],
809-
command : [copy_script_path, aftermath_lib_path, output_path, 'GFSDK_Aftermath_Lib.x64.dll'] )
719+
# install USD plugins
720+
meson.add_install_script(
721+
join_paths(global_src_root_norm, 'scripts-common/install_usd_plugins.bat'),
722+
output_path,
723+
install_tag: target_suffix
724+
)
810725

811-
if enable_rtxio == true
812-
copy_rtxio = custom_target('copy_rtxio_' + target_suffix,
813-
output : ['copy_rtxio_' + target_suffix],
814-
depends : [],
815-
command : [copy_script_path, rtxio_bin_path, output_path, 'rtxio.*'] )
816-
endif
726+
install_data(join_paths(nrc_dll_path, nrc_dll_name), install_dir : output_path, install_tag: target_suffix)
727+
install_data(join_paths(nrc_dll_path, 'cudart64_12.dll'), install_dir : output_path, install_tag: target_suffix)
728+
install_data(join_paths(nrc_dll_path, 'nvrtc64_120_0.dll'), install_dir : output_path, install_tag: target_suffix)
729+
install_data(join_paths(nrc_dll_path, 'nvrtc-builtins64_125.dll'), install_dir : output_path, install_tag: target_suffix)
730+
731+
install_data(join_paths(nrd_lib_path, 'NRD.dll'), install_dir : output_path, install_tag: target_suffix)
732+
733+
install_data(join_paths(dlss_lib_path, 'nvngx_dlss.dll'), install_dir : output_path, install_tag: target_suffix)
734+
install_data(join_paths(dlss_lib_path, 'nvngx_dlssd.dll'), install_dir : output_path, install_tag: target_suffix)
735+
736+
install_data(join_paths(dlfg_lib_path, 'nvngx_dlssg.dll'), install_dir : output_path, install_tag: target_suffix)
737+
738+
install_data(join_paths(reflex_lib_path, 'NvLowLatencyVk.dll'), install_dir : output_path, install_tag: target_suffix)
817739

818-
# the copy target is special
819-
# if we use custom_target for the d3d9 DLL, meson generates a target that does nothing in ninja
820-
# as a workaround, we do the copy as part of the test_* target itself
821-
copy_target_depends = [ copy_usd,
822-
copy_usd_dll,
823-
copy_nrc_dll,
824-
copy_nrc_cuda_deps_dll,
825-
copy_nrc_cuda_nv_deps_dll,
826-
copy_nrd_dll,
827-
copy_dlss_dll,
828-
copy_dlfg_dll,
829-
copy_aftermath_dll,
830-
d3d9_dll ] + copy_usd_plugins_dlls
831-
832-
copy_target_depends += copy_reflex_dll
740+
install_data(join_paths(aftermath_lib_path, 'GFSDK_Aftermath_Lib.x64.dll'), install_dir : output_path, install_tag: target_suffix)
833741

834742
if enable_rtxio == true
835-
copy_target_depends += copy_rtxio
743+
install_data(join_paths(rtxio_bin_path, 'rtxio.dll'), install_dir : output_path, install_tag: target_suffix)
836744
endif
837745

838746
if src_exe != ''
839-
copy_target_depends += custom_target('copy_exe_' + target_suffix,
840-
output : ['copy_exe_' + target_suffix],
841-
depends : [],
842-
command : [copy_script_path, fs.parent(src_exe) + '/', output_path + '/', fs.name(src_exe)] )
747+
# intentionally using two install jobs here so we can have unique tags
748+
# the exe only allows test applications to be compiled and installed, without installing the runtime. Such copy-less runtime testing scenarios exist in CI.
749+
meson.add_install_script(
750+
join_paths(global_src_root_norm, 'scripts-common/install_file_in_dir.bat'),
751+
src_exe, output_path,
752+
install_tag: target_suffix + '_exeonly'
753+
)
754+
# the regular path allows the exe to be built and deployed along with a runtime. Such scenarios exist during local development, when launching from VS for example.
755+
meson.add_install_script(
756+
join_paths(global_src_root_norm, 'scripts-common/install_file_in_dir.bat'),
757+
src_exe, output_path,
758+
install_tag: target_suffix
759+
)
843760
endif
844761

845-
copy_target = run_target('copy_' + target_suffix.replace('apics_', ''),
846-
depends: copy_target_depends,
847-
command : [copy_script_path,
848-
join_paths(current_build_dir_norm, 'src/d3d9'),
849-
output_path,
850-
'd3d9*'])
851-
852-
if t != '_output'
853-
apic_copy_targets += copy_target
854-
endif
855-
if target_suffix == 'sdk'
856-
remixsdk_target = custom_target('ct_copy_remixsdk',
857-
output: ['ct_copy_remixsdk'],
858-
depends: copy_target_depends,
859-
command: [copy_script_path,
860-
join_paths(current_build_dir_norm, 'src/d3d9'),
861-
output_path,
862-
'd3d9*'])
762+
if t != '_output' or target_suffix == 'sdk'
763+
meson.add_install_script(
764+
join_paths(global_src_root_norm, 'scripts-common/install_file_in_dir.bat'),
765+
join_paths(current_build_dir_norm, 'src/d3d9', 'd3d9.*'), output_path,
766+
install_tag: target_suffix
767+
)
863768
endif
864-
endforeach
865769

866-
# xxxnsubtil: this one line replaces a bunch of python code used for the vscode build, but requires meson 0.61.3
867-
# (specifically, https://github.com/mesonbuild/meson/pull/9202)
868-
# alias_target('copy_to_all_apics', apic_copy_targets)
770+
endforeach
869771

870772
# generate VS project files for ninja
871773
# note: this writes to <source root>/_vs, which is outside the build directory

scripts-common/copy.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ set DST=%2
1010
set FILES=%3
1111

1212
rem echo ////////////////////////////////////////////////////
13-
echo copy of:
14-
echo %SRC:/=\%
15-
echo to
16-
echo %DST:/=\%
13+
rem echo copy of:
14+
rem echo %SRC:/=\%
15+
rem echo to
16+
rem echo %DST:/=\%
1717

1818
rem robocopy seems to lock input files and ends up hanging sometimes (/w:1 helps, but doesn't solve the problem)
1919
rem robocopy /w:1 /njh /njs /nc /ns /np /ndl /is /it %1 %2 %3

0 commit comments

Comments
 (0)