Dawn 简介
WebGPU 是一个正在开发中的新一代 Web 图形标准,而 Dawn 是一个它的开源跨平台实现。webgpu.h 定义了 C 接口到 WebGPU IDL 的一对一映射,Dawn 提供了实现。Dawn 也作为 Chromium 项目中 WebGPU 的底层实现。
Dawn 提供了几个 WebGPU 构建块:
- WebGPU C/C++ 头文件,供应用程序和其他构建块使用
-
- Dawn 实现
webgpu.h版本 webgpu.h的 C++ wrapper
- Dawn 实现
- WebGPU 的 native 实现,使用了各平台的图形 API
-
- D3D12 on Windows 10
- Metal on macOS and iOS
- Vulkan on Windows, Linux, ChromeOS, Android and Fuchsia
- OpenGL 在可用的平台上尽量实现
- WebGPU 的 client-server 模式实现, 用于那些在沙盒环境中无法访问原生驱动的应用程序
Dawn 编译
系统需求
- Windows
-
- Visual Studio 2019
- CMake
- Mac
-
- Xcode 12.2+
- CMake
安装 depot_tools
Dawn 使用了 Chromium 的编译系统和依赖管理,需要安装 depot_tools 并把它添加到系统环境变量。
获取代码
# 克隆 Dawn 项目
git clone https://dawn.googlesource.com/dawn dawn && cd dawn
# 引导 gclient 配置
cp scripts/standalone.gclient .gclient
# 使用 gclient 拉取外部依赖与工具链
gclient sync
工程生成与编译
-
在项目顶层目录创建
cmake_build目录(名字没有要求) -
生成工程
- Windows
cd cmake_build
cmake ..
- Mac
cd cmake_build
cmake .. -G Xcode
- 打开 VS 或 Xcode 编译项目