Building Windows Dawn (and optionally ANGLE)
These are based on Dawn's build instructions but tailored for Windows (and specifically a DLL that can be linked with MSVC).
-
Install Visual Studio (here VS2019 was used but 2015 or 2017 should also work; 2022 is currently failing). The Community edition is fine. Add CMake (and Ninja) in the VS install options.
-
You need the the full Windows 10 SDK; the VS installer will install the Win10 SDK but it misses the required Debugging Tools for Windows (alternatively this can be added afterwards following the Chrome build instructions).
-
Make sure you have up-to-date graphics drivers. If you're running Windows on Boot Camp install one of the unofficial AMD drivers (if only to get Vulkan support; it'd be nice if Apple made this step unnecessary).
-
Install the Vulkan SDK. Make sure the examples run (
vkcube.exe
, for example). -
Install Git. I installed Git for Windows.
-
Install Google's Depot Tools. I didn't install Depot Tools the recommended way, instead I did this:
-
Make sure Git is on the
PATH
(via the environment variable control panel). -
Launch a VS2019 x64 Native Tools Command Prompt (found in the Windows menu; note to investigate: a regular Prompt might be enough, since Depot Tools knows how to find the compiler).
-
Set-up Git following the Bootstrapping section in the Depot Tools page above.
-
cd
into your dev/work/code directory (mine isC:\Volumes\Data\Work\Native
). -
Clone Depot Tools:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
-
Add Depot Tools to the front of your
PATH
in the current Command Prompt:set PATH=C:\Volumes\Data\Work\Native\depot_tools;%PATH%
-
Run
gclient
(which should download the CIPD client then show you some options). -
Add
win32file
to Depot Tools' Python (and verify withwhere python
that Depot Tools is the preferred python executable):python -m pip install pywin32
The reason for doing it this way is it keeps Depot Tools from permanently being the first
PATH
entry and interferring with other tools (and plus the Google instructions are a bit clunky for Windows). -
-
In the same VS2019 x64 Prompt above, with the same
PATH
, etc., clone Dawn following the Building Dawn instructions. We need to make these steps a little more Windows friendly:git clone https://dawn.googlesource.com/dawn dawn && cd dawn copy scripts\standalone.gclient .gclient set DEPOT_TOOLS_WIN_TOOLCHAIN=0 gclient sync
-
Configure then build Dawn:
-
gn args out\Release
-
In the text file that just opened add
is_debug=false
then save and close it.
Note: building Dawn as of November 2022 is failing due to missing
chrome/VERSION
, which can be fixed by creating a file with:MAJOR=1 MINOR=0 BUILD=0 PATCH=0
ninja -C out\Release dawn_samples
(omit the samples target to build the unit tests, etc.)
-
-
That should be it. Run the samples in the
out
directory (CHelloTriangle.exe
, for example). Now that the basic install builds and runs the configuration can be investigated and tweaked:gn args out\Release --list
For release I went with:
# Build with VS is_clang=false visual_studio_version="2019" # Make the smallest release is_official_build=true strip_debug_info=true symbol_level=0 # Don't need these features dawn_use_angle=false dawn_use_swiftshader=false
Some toggles to investigate, seen in the Dawn Element room:
skip_validation=true disable_robustness=true disable_workgroup_init=true lazy_clear_resource_on_first_use=false
Note the the all-important
is_clang=false
, needed since we want to link with MSVC (a step which saves everyone the headache of wondering why the returnedstd::vector
and other types have the wrong signature). It's also the reason for thewin32file
addition to Python in the earlier steps. Also note theis_official_build=true
to enable all the right optimisation flags.For debug:
# Build with VS is_clang=false visual_studio_version="2019" # Debug build is_debug=true enable_iterator_debugging=true symbol_level=1 # Don't need these features dawn_use_angle=false dawn_use_swiftshader=false
If you don't set the
enable_iterator_debugging
option then you'll need_ITERATOR_DEBUG_LEVEL=0
setting in the preprocessor.At this point you might want to produce builds for both
target_cpu="x64"
andtarget_cpu="x86"
, and optionally for the ARM64-based Surface Pro X, withtarget_cpu="arm64"
anddawn_enable_vulkan=false
(Windows on ARM only supports DX). -
If you only built the samples, to get the DLLs you'll need to either build all (omit
dawn_samples
in step 8) or specify the shared libraries you need. See the full list here:gn ls out\Release
These should be enough:
ninja -C out\Release src/dawn/native:shared src/dawn/platform:shared proc_shared webgpu_dawn
-
That's it for Dawn but (optionally) almost the same steps can be used to build ANGLE.
Taking the same arguments as Dawn plus:
angle_enable_swiftshader=false angle_enable_vulkan=false
Note: ANGLE currently fails to build when disabling D3D9.