Writing this here cause it was one heck of an adventure to finally get Dawn built on Windows. It's unclear if things are truly built and whether or not there might be more issues to resolve, but for now, by following these instructions, you should be able to at the very least, get Dawn built, set things up properly without any compiler complaints, and with a slight tweak, get the samples up and running.
Note that Google has suggested that the current build system setup is not recommended for producing libraries to be included into your own projects, but there is the desire to include CMake build support for this purpose in the future.
As you might imagine, Dawn is stil being developed so things are bound to be broken. Hopefully things will smooth out as the project reaches it's first major milestone. I am just a casual hobyist so I have no idea as to the current progress but there is a mailing list you can keep up with here
- Windows 10
- Visual Studio 2017 with the Visual C++ ATL and MFC components. Those extra components are not automatically installed, so you will have to modify your Visual Studio installation.
- Win 10 OS build 18362.592
- Win 10 SDK 10.0.17763.0
- I am intending to build static libraries, note that I have not tried to build shared libraries.
- Integration is done within a Visual Studio "console application" template.
- My intention is to use the Vulkan backend (see DirectX gotcha below)
- Download and setup depot_tools
- Clone the Dawn project
- For some reason, the Python setup that ships with depot_tools does not include the pywin32 package which is needed to build on Windows. The easist way I've found to install the package is to cd into
depot_tools\bootstrap-3_8_0_chromium_8_bin\python\bin
and runpython -m pip install pywin32
which should utilize the depot_tools python and properly install the pywin32 package into depot_tools. - You will probably need to setup the Vulkan SDK for Vulkan support(I already had it installed hence my uncertainty).
Now, you can continue following the directions found here. The settings you ought to use are
is_clang
=falsedawn_complete_static_libs
= truedawn_enable_d3d12
=false (see gotchas on why this might be necessary)is_debug=false
(I was not able to get a Debug build working :/)
For headers you will need to include everything in
<repo root>/src
<repo root>/<build folder>/gen/src
For libraries
- dawn_bindings.lib
- dawn_sample_utils.lib
- dawn_utils.lib
- glfw.lib
- libdawn_native.lib
- libdawn_proc.lib
- libdawn_wire.lib
- libshaderc.lib (see gotchas for note on this)
- libshaderc_spvc.lib
- spvtools.lib
- spvtools_link.lib
- spvtools_opt.lib
- spvtools_reduce.lib
- spvtools_val.lib
Note that this list is only included for completeness and were all the library files I could find, you may not need all of them. You can find all of these files within <repo root>/<build folder>/obj
The absolutely neccessary ones seem to be
- glfw.lib
- dawn_bindings.lib
- dawn_sample_utils.lib
- dawn_utils.lib
- libdawn_native.lib
- libdawn_proc.lib
- libdawn_wire.lib
- libshaderc.lib / shaderc_combined.lib(if you build your own)
webgpu_cpp.cpp
needs to be included in your project- The
shaderc
third party library gets compiled with missing symbols somehow, I have not found the correct magical incantation to correctly compile with all the necessary functions. As a result, you may (for now hopefully) have to compileshaderc
on your own for now. If you need to compileshaderc
see the named section below. - DirectX might cause issues(see following section)
- The samples default to utilizing an object called a
TerribleCommandBuffer
, along with using that object, it also sets updawn_wire::WireServer
anddawn_wire::WireClient
objects; currently it's unclear as to what the objects in thedawn_wire
namespace are for exactly, but I had to change the SampleUtils file to not utilize those objects in order to get things to work.
There currently appears to be an issue with how the Dawn links the necessary libraries needed to take advantage of the DirectX backend. You may get a compiler error stating that the symbol DXGI_DEBUG_ALL
doesn't exist which, assuming you have a relatively recent Windows build should actually exist. It's unclear as to why the symbol is not included during the build but there are some possible workarounds.
- If you are building a shared library or using
gn
to build your project directly, you can add the parameterlibs=["dxguid.lib"]
to your build arguments(note I have not fully tested this). - Visual Studio should automatically have the DirectX paths available assuming you set things up using a project template, you can just set up dxguid.lib within the linker section of your project's properties
Or if you're like me, you can just disable DirectX by including dawn_enable_d3d12=false
in your build arguments. (^O^)
There is a possibility you may have to build the shaderc
library yourself. For some reason, building it during your dawn
build ends up with a final library that's still missing some symbols. It is currently unclear as to why this is, my assumption is that there is a build setting that needs to get applied. There is a possibly related setting , called dawn_enable_cross_reflection
that can be set; however I have tried building with and without that build setting being set with the same result.
Building shaderc
is fairly straightforward. Assuming you're using CMake
- Clone the shaderc project.
- You will also need to clone
SPIRV-Tools
into the<shaderc repo>/third_party
folder. - Like the readme suggests, you'll also have to clone
glslang
into the third_party folder. - You can but don't have to install Google Test. If you don't install Google Test(which I believe also should go in the third_party folder), you need to pass
-DSHADERC_SKIP_TESTS=true
(assuming you're using CMake) - Note that none of the libraries you clone into the
third_party
folder need to be built. - It's best to build release, otherwise with debug content the resulting libraries are quite large.