Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Direct3D 12 setup script for distribution with binary releases #91475

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions misc/dist/windows/optimize_d3d12_support.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@echo off

set godot_version=4.3
set agility_sdk_version=1.614.0

echo.
echo --------------------------------------------------------------------------------
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.
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.
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 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%\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! Optimized Direct3D 12 support is now enabled for this Godot installation (%godot_version%).
echo.
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 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 --------------------------------------------------------------------------------
pause
exit /b 0

:unzipfile <extractTo> <newZipFile>
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
Loading