From 75e31bc7325d00f47528edcc50b6832e79917526 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 30 Apr 2024 19:56:10 +0200 Subject: [PATCH 1/2] Add Direct3D 12 setup script for distribution with binary releases This script is meant to be packaged with binary releases so that Direct3D 12 support can be set up in an automated manner. To use the script, double-click it and follow the instructions. The EULA can be accepted automatically using the `-y` or `/y` command line argument (e.g. for use on CI). This installs `dxil.dll` and the Agility SDK, both of which are copied on export if a project uses Direct3D 12 or requests it with the `application/export_d3d12` option in its Windows export preset. PIX is not set up by this script, as it requires further conversion to work with MinGW (which official Godot binaries use). It's also only required for engine developers anyway, not regular users of an exported project. --- misc/dist/windows/setup_d3d12_support.bat | 126 ++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 misc/dist/windows/setup_d3d12_support.bat diff --git a/misc/dist/windows/setup_d3d12_support.bat b/misc/dist/windows/setup_d3d12_support.bat new file mode 100644 index 000000000000..2d3823f8c4c4 --- /dev/null +++ b/misc/dist/windows/setup_d3d12_support.bat @@ -0,0 +1,126 @@ +@echo off + +set godot_version=4.3.dev +set dxc_version=v1.8.2403.2 +set dxc_filename=dxc_2024_03_29.zip +set agility_sdk_version=1.610.4 + +echo. +echo -------------------------------------------------------------------------------- +echo This script sets up Direct3D 12 support for Godot %godot_version%. +echo. +echo As Direct3D 12 support requires a proprietary library, it is not enabled by default. +echo Note that you don't need Direct3D 12 to use Godot, as Godot already comes with +echo Vulkan and OpenGL support out of the box. +echo. +echo This script will download and install the required libraries for Direct3D 12 support. +echo The libraries will also be installed in the export templates folder, so they can be +echo copied on export when a project is configured to use Direct3D 12. +echo The total download size is about 65 MB. +echo. +echo By installing DirectX Shader Compiler, you accept the terms of the Microsoft EULA: +echo. +echo TODO +echo. +echo Tip: Use the -y or /y command line argument to automatically accept the EULA. +echo -------------------------------------------------------------------------------- +echo. + +echo Do you accept the Microsoft EULA linked above? (y/n) +if "%1" == "-y" set eula_accepted_cli=1 +if "%1" == "/y" set eula_accepted_cli=1 +if "%eula_accepted_cli%" == "1" ( + echo EULA accepted via command line argument. + goto yes +) +set /p eula_accepted="> " %=% +if /i "%eula_accepted%" == "y" goto yes +if /i "%eula_accepted%" == "yes" goto yes +goto no + +:yes +echo. +echo [1/2] Downloading DirectX Shader Compiler release %dxc_version%... +curl.exe -L https://github.com/microsoft/DirectXShaderCompiler/releases/download/%dxc_version%/%dxc_filename% -o "%TEMP%\dxc.zip" +echo Download completed. +echo Extracting DirectX Shader Compiler... +call :unzipfile "%TEMP%\dxc" "%TEMP%\dxc.zip" +del "%TEMP%\dxc.zip" +mkdir "%APPDATA%\Godot" 2>nul +mkdir "%APPDATA%\Godot\export_templates" 2>nul +mkdir "%APPDATA%\Godot\export_templates\%godot_version%" 2>nul +mkdir x64 2>nul +mkdir arm64 2>nul +mkdir x86 2>nul +copy "%TEMP%\dxc\bin\x64\dxil.dll" %APPDATA%\Godot\export_templates\%godot_version%\dxil.x64.dll >nul +move "%TEMP%\dxc\bin\x64\dxil.dll" x64\dxil.dll >nul +copy "%TEMP%\dxc\bin\arm64\dxil.dll" %APPDATA%\Godot\export_templates\%godot_version%\dxil.arm64.dll >nul +move "%TEMP%\dxc\bin\arm64\dxil.dll" arm64\dxil.dll >nul +copy "%TEMP%\dxc\bin\x86\dxil.dll" %APPDATA%\Godot\export_templates\%godot_version%\dxil.x86.dll >nul +move "%TEMP%\dxc\bin\x86\dxil.dll" x86\dxil.dll >nul +del /s /q "%TEMP%\dxc" >nul 2>&1 +echo Done installing `dxil.dll` from DirectX Shader Compiler. + +echo. +echo [2/2] Downloading DirectX 12 Agility SDK release %agility_sdk_version%... +curl.exe -L https://www.nuget.org/api/v2/package/Microsoft.Direct3D.D3D12/%agility_sdk_version% -o "%TEMP%\agility_sdk.zip" +echo Download completed. +echo Extracting DirectX 12 Agility SDK... +call :unzipfile "%TEMP%\agility_sdk" "%TEMP%\agility_sdk.zip" +del "%TEMP%\agility_sdk.zip" +copy "%TEMP%\agility_sdk\build\native\bin\x64\D3D12Core.dll" %APPDATA%\Godot\export_templates\%godot_version%\D3D12Core.x64.dll >nul +move "%TEMP%\agility_sdk\build\native\bin\x64\D3D12Core.dll" x64\D3D12Core.dll >nul +copy "%TEMP%\agility_sdk\build\native\bin\arm64\D3D12Core.dll" %APPDATA%\Godot\export_templates\%godot_version%\D3D12Core.arm64.dll >nul +move "%TEMP%\agility_sdk\build\native\bin\arm64\D3D12Core.dll" arm64\D3D12Core.dll >nul +copy "%TEMP%\agility_sdk\build\native\bin\win32\D3D12Core.dll" %APPDATA%\Godot\export_templates\%godot_version%\D3D12Core.x86.dll >nul +move "%TEMP%\agility_sdk\build\native\bin\win32\D3D12Core.dll" x86\D3D12Core.dll >nul +copy "%TEMP%\agility_sdk\build\native\bin\x64\d3d12SDKLayers.dll" %APPDATA%\Godot\export_templates\%godot_version%\d3d12SDKLayers.x64.dll >nul +move "%TEMP%\agility_sdk\build\native\bin\x64\d3d12SDKLayers.dll" x64\d3d12SDKLayers.dll >nul +copy "%TEMP%\agility_sdk\build\native\bin\arm64\d3d12SDKLayers.dll" %APPDATA%\Godot\export_templates\%godot_version%\d3d12SDKLayers.arm64.dll >nul +move "%TEMP%\agility_sdk\build\native\bin\arm64\d3d12SDKLayers.dll" arm64\d3d12SDKLayers.dll >nul +copy "%TEMP%\agility_sdk\build\native\bin\win32\d3d12SDKLayers.dll" %APPDATA%\Godot\export_templates\%godot_version%\d3d12SDKLayers.x86.dll >nul +move "%TEMP%\agility_sdk\build\native\bin\win32\d3d12SDKLayers.dll" x86\d3d12SDKLayers.dll >nul +del /s /q "%TEMP%\agility_sdk" >nul 2>&1 +echo Done installing Agility SDK libraries. + +echo. +echo -------------------------------------------------------------------------------- +echo Success! Direct3D 12 support is now enabled for this Godot installation (%godot_version%). +echo You can now choose the `d3d12` rendering driver project setting in any project, +echo or run a project with the `--rendering-driver d3d12` command line argument +echo to override the rendering driver for a single session. +echo. +echo Direct3D 12 libraries will automatically be copied along with a project exported +echo for Windows if the project is configured to use Direct3D 12, or if the +echo `application/export_d3d12` option is enabled in the Windows export preset +echo in a given project. +echo. +echo After updating Godot to a newer version, remember to run the Direct3D 12 +echo setup script that comes with it to install the Direct3D 12 libraries +echo corresponding to the new Godot version. Each Godot version stores +echo Direct3D 12 libraries in a version-specific folder to be copied when exporting. +echo -------------------------------------------------------------------------------- +pause +exit /b 0 + +:unzipfile +set vbs="%TEMP%\_.vbs" +if exist %vbs% del /f /q %vbs% +>%vbs% echo Set fso = CreateObject("Scripting.FileSystemObject") +>>%vbs% echo If NOT fso.FolderExists(%1) Then +>>%vbs% echo fso.CreateFolder(%1) +>>%vbs% echo End If +>>%vbs% echo Set objShell = CreateObject("Shell.Application") +>>%vbs% echo Set filesInZip=objShell.NameSpace(%2).items +>>%vbs% echo objShell.NameSpace(%1).CopyHere(filesInZip) +>>%vbs% echo Set fso = Nothing +>>%vbs% echo Set objShell = Nothing +cscript //nologo %vbs% +if exist %vbs% del /f /q %vbs% +goto :eof + +:no +echo. +echo You must accept the Microsoft EULA to set up Direct3D 12 support. Aborting. +pause +exit /b 1 From 1a6f19cf082642f504bd6dd2825e4afe84ea80bb Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 13 Jul 2024 04:35:02 +0200 Subject: [PATCH 2/2] Remove DXIL installation which is no longer needed The script now only sets up Agility SDK, which mostly benefits users on Windows 10. --- ...support.bat => optimize_d3d12_support.bat} | 82 ++++--------------- 1 file changed, 17 insertions(+), 65 deletions(-) rename misc/dist/windows/{setup_d3d12_support.bat => optimize_d3d12_support.bat} (53%) diff --git a/misc/dist/windows/setup_d3d12_support.bat b/misc/dist/windows/optimize_d3d12_support.bat similarity index 53% rename from misc/dist/windows/setup_d3d12_support.bat rename to misc/dist/windows/optimize_d3d12_support.bat index 2d3823f8c4c4..db128050fd06 100644 --- a/misc/dist/windows/setup_d3d12_support.bat +++ b/misc/dist/windows/optimize_d3d12_support.bat @@ -1,73 +1,34 @@ @echo off -set godot_version=4.3.dev -set dxc_version=v1.8.2403.2 -set dxc_filename=dxc_2024_03_29.zip -set agility_sdk_version=1.610.4 +set godot_version=4.3 +set agility_sdk_version=1.614.0 echo. echo -------------------------------------------------------------------------------- -echo This script sets up Direct3D 12 support for Godot %godot_version%. -echo. -echo As Direct3D 12 support requires a proprietary library, it is not enabled by default. -echo Note that you don't need Direct3D 12 to use Godot, as Godot already comes with -echo Vulkan and OpenGL support out of the box. -echo. -echo This script will download and install the required libraries for Direct3D 12 support. -echo The libraries will also be installed in the export templates folder, so they can be +echo This script sets up optimized Direct3D 12 support on Windows 10 for Godot %godot_version%. + +echo This script will download and install an optional library for enhanced Direct3D 12 support. +echo The library will also be installed in the export templates folder, so they can be echo copied on export when a project is configured to use Direct3D 12. -echo The total download size is about 65 MB. -echo. -echo By installing DirectX Shader Compiler, you accept the terms of the Microsoft EULA: -echo. -echo TODO echo. -echo Tip: Use the -y or /y command line argument to automatically accept the EULA. +echo This library is not as useful on Windows 11, but installing it will still benefit +echo players on Windows 10 for projects you export from this PC. echo -------------------------------------------------------------------------------- echo. -echo Do you accept the Microsoft EULA linked above? (y/n) -if "%1" == "-y" set eula_accepted_cli=1 -if "%1" == "/y" set eula_accepted_cli=1 -if "%eula_accepted_cli%" == "1" ( - echo EULA accepted via command line argument. - goto yes -) -set /p eula_accepted="> " %=% -if /i "%eula_accepted%" == "y" goto yes -if /i "%eula_accepted%" == "yes" goto yes -goto no - -:yes echo. -echo [1/2] Downloading DirectX Shader Compiler release %dxc_version%... -curl.exe -L https://github.com/microsoft/DirectXShaderCompiler/releases/download/%dxc_version%/%dxc_filename% -o "%TEMP%\dxc.zip" +echo Downloading DirectX 12 Agility SDK release %agility_sdk_version%... +curl.exe -L https://www.nuget.org/api/v2/package/Microsoft.Direct3D.D3D12/%agility_sdk_version% -o "%TEMP%\agility_sdk.zip" echo Download completed. -echo Extracting DirectX Shader Compiler... -call :unzipfile "%TEMP%\dxc" "%TEMP%\dxc.zip" -del "%TEMP%\dxc.zip" +echo Extracting DirectX 12 Agility SDK... +call :unzipfile "%TEMP%\agility_sdk" "%TEMP%\agility_sdk.zip" +del "%TEMP%\agility_sdk.zip" mkdir "%APPDATA%\Godot" 2>nul mkdir "%APPDATA%\Godot\export_templates" 2>nul mkdir "%APPDATA%\Godot\export_templates\%godot_version%" 2>nul mkdir x64 2>nul mkdir arm64 2>nul mkdir x86 2>nul -copy "%TEMP%\dxc\bin\x64\dxil.dll" %APPDATA%\Godot\export_templates\%godot_version%\dxil.x64.dll >nul -move "%TEMP%\dxc\bin\x64\dxil.dll" x64\dxil.dll >nul -copy "%TEMP%\dxc\bin\arm64\dxil.dll" %APPDATA%\Godot\export_templates\%godot_version%\dxil.arm64.dll >nul -move "%TEMP%\dxc\bin\arm64\dxil.dll" arm64\dxil.dll >nul -copy "%TEMP%\dxc\bin\x86\dxil.dll" %APPDATA%\Godot\export_templates\%godot_version%\dxil.x86.dll >nul -move "%TEMP%\dxc\bin\x86\dxil.dll" x86\dxil.dll >nul -del /s /q "%TEMP%\dxc" >nul 2>&1 -echo Done installing `dxil.dll` from DirectX Shader Compiler. - -echo. -echo [2/2] Downloading DirectX 12 Agility SDK release %agility_sdk_version%... -curl.exe -L https://www.nuget.org/api/v2/package/Microsoft.Direct3D.D3D12/%agility_sdk_version% -o "%TEMP%\agility_sdk.zip" -echo Download completed. -echo Extracting DirectX 12 Agility SDK... -call :unzipfile "%TEMP%\agility_sdk" "%TEMP%\agility_sdk.zip" -del "%TEMP%\agility_sdk.zip" copy "%TEMP%\agility_sdk\build\native\bin\x64\D3D12Core.dll" %APPDATA%\Godot\export_templates\%godot_version%\D3D12Core.x64.dll >nul move "%TEMP%\agility_sdk\build\native\bin\x64\D3D12Core.dll" x64\D3D12Core.dll >nul copy "%TEMP%\agility_sdk\build\native\bin\arm64\D3D12Core.dll" %APPDATA%\Godot\export_templates\%godot_version%\D3D12Core.arm64.dll >nul @@ -85,18 +46,15 @@ echo Done installing Agility SDK libraries. echo. echo -------------------------------------------------------------------------------- -echo Success! Direct3D 12 support is now enabled for this Godot installation (%godot_version%). -echo You can now choose the `d3d12` rendering driver project setting in any project, -echo or run a project with the `--rendering-driver d3d12` command line argument -echo to override the rendering driver for a single session. +echo Success! Optimized Direct3D 12 support is now enabled for this Godot installation (%godot_version%). echo. -echo Direct3D 12 libraries will automatically be copied along with a project exported -echo for Windows if the project is configured to use Direct3D 12, or if the +echo The Direct3D 12 Agility SDK will automatically be copied along with a project +echo exported for Windows if the project is configured to use Direct3D 12, or if the echo `application/export_d3d12` option is enabled in the Windows export preset echo in a given project. echo. echo After updating Godot to a newer version, remember to run the Direct3D 12 -echo setup script that comes with it to install the Direct3D 12 libraries +echo setup script that comes with it to install the Agility SDK[0m echo corresponding to the new Godot version. Each Godot version stores echo Direct3D 12 libraries in a version-specific folder to be copied when exporting. echo -------------------------------------------------------------------------------- @@ -118,9 +76,3 @@ if exist %vbs% del /f /q %vbs% cscript //nologo %vbs% if exist %vbs% del /f /q %vbs% goto :eof - -:no -echo. -echo You must accept the Microsoft EULA to set up Direct3D 12 support. Aborting. -pause -exit /b 1