Skip to content

Commit 560fbb5

Browse files
Merge pull request #1416 from madeline-underwood/WebGPU
Web GPU_KB to approve
2 parents ff2fbd3 + e92a2fa commit 560fbb5

File tree

9 files changed

+201
-202
lines changed

9 files changed

+201
-202
lines changed
Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Introduction to WebGPU
2+
title: Overview of WebGPU
33
weight: 2
44

55
### FIXED, DO NOT MODIFY
@@ -8,61 +8,69 @@ layout: learningpathall
88

99
## What is WebGPU?
1010

11-
WebGPU is the successor to WebGL, a well adopted modern API standard for interfacing with GPUs. WebGPU provides better compatibility with modern GPUs, support for general-purpose GPU computations, faster operations, and access to more advanced GPU features. It is designed to provide a _unified access_ to GPUs, agnostic to GPU vendors and operating systems.
11+
WebGPU is the successor to WebGL, a well-adopted modern API standard for interfacing with GPUs.
1212

13-
WebGPU is a Render Hardware Interface built on top of various backend APIs like Vulkan, DirectX, and Metal (depending on the operating system).
13+
WebGPU offers the following benefits:
14+
15+
* Improved compatibility with modern GPUs.
16+
* Support for general-purpose GPU computations.
17+
* Fast operations.
18+
* Access to advanced GPU features.
19+
* Unified access to GPUs, which is both GPU vendor-agnostic and OS-agnostic.
20+
21+
WebGPU is a render hardware interface built on top of various backend APIs such as Vulkan, DirectX, and Metal, though this is OS-dependent.
1422

1523
WebGPU is available through web browsers using the webgpu.h header file.
1624

17-
The high level view of WebGPU is shown below:
25+
The high-level view of WebGPU is shown below in Figure 1:
1826

19-
![WebGPU high level view #center](images/webgpu_highlevel.png "WebGPU High Level View")
27+
![Figure 1: WebGPU high level view #center](images/webgpu_highlevel.png "Figure 1: WebGPU High-Level View")
2028

2129
## What are the benefits of WebGPU?
2230

23-
WebGPU takes into account learnings from older standards like WebGL and OpenGL and provides the following benefits:
31+
WebGPU uses lessons learned from earlier standards such as WebGL and OpenGL to develop an improved offering, and provides the following benefits:
2432

25-
* A reasonable level of abstraction
26-
* Good performance
27-
* Cross-platform
28-
* Backed by W3C standards group
29-
* Future-proof design
33+
* A reasonable level of abstraction.
34+
* Improved performance.
35+
* Cross-platform functionality.
36+
* Backing from the W3C standards group.
37+
* A future-proof design.
3038

31-
WebGPU is a standard and not a true API, so the implementation can be adopted and developed as an interface between native applications developed in any programming language.
39+
It is important to note that WebGPU is a standard, and not a true API, so the implementation can be adopted and developed as an interface between native applications developed in any programming language.
3240

33-
The performance requirements for web pages is actually the same as for native application.
41+
The performance requirements for web pages are the same as for native applications.
3442

3543
{{% notice Note %}}
3644
When designing an API for the Web, the two key constraints are portability and privacy.
3745

38-
The limitations of the API due to privacy considerations can be disabled when using WebGPU as a native API.
46+
Any limitations of the API caused by privacy constraints can be disabled when using WebGPU as a native API.
3947
{{% /notice %}}
4048

4149
## What are the benefits of using C++ for WebGPU?
4250

43-
The initial target for WebGPU was JavaScript. The initial `webgpu.h` header file is written in C.
51+
The initial focus for WebGPU was JavaScript. The initial `webgpu.h` header file is written in C.
4452

45-
This Learning Path uses C++ rather than JavaScript or C because for the following reasons:
53+
This Learning Path uses C++ rather than JavaScript or C, for the following reasons:
4654

47-
* C++ is still the primary language used for high performance graphics applications, such as video games, render engines, and modeling tools.
48-
* The level of abstraction and control of C++ is well suited for interacting with graphics APIs in general.
49-
* Graphics programming is a good way to learn more C++.
55+
* C++ remains the primary language used for high performance graphics applications, such as video games, render engines, and modeling tools.
56+
* The level of abstraction and control of C++ is well-suited for interacting with graphics APIs in general.
57+
* Graphics programming is a good way to improve skills in C++.
5058

5159
## Dawn: the Google WebGPU implementation
5260

53-
Since WebGPU is a standard and not an implementation, there are different implementations.
61+
Since WebGPU is a standard and not an implementation itself, there are various possible options for implementation.
5462

55-
[Dawn](https://github.com/google/dawn) is an open-source, cross-platform implementation of the WebGPU standard.
63+
[Dawn](https://github.com/google/dawn) is an open-source, cross-platform implementation of the WebGPU standard. It implements the WebGPU functionality specified in `webgpu.h`.
5664

57-
It implements the WebGPU functionality specified in `webgpu.h`. Dawn is meant to be integrated as part of a larger system like Chromium or a native Android Application.
65+
Dawn is designed to be integrated as part of a larger system such as Chromium or a native Android Application.
5866

5967
Dawn provides several WebGPU building blocks:
6068

61-
* WebGPU C/C++ headers that applications and other building blocks use, including a header file and C++ wrapper.
62-
* A "native" implementation of WebGPU using appropriate APIs: D3D12, Metal, Vulkan and OpenGL.
63-
* A client-server implementation of WebGPU for applications that are in a sandbox without access to native drivers.
69+
* WebGPU C/C++ headers that applications and other building blocks use, including a header file and a C++ wrapper.
70+
* A "native" implementation of WebGPU using appropriate APIs, such as D3D12, Metal, Vulkan, and OpenGL.
71+
* A client-server implementation of WebGPU, for applications that are in a sandbox without access to native drivers.
6472
* Tint, a compiler for the WebGPU Shader Language (WGSL), that converts shaders to and from WGSL.
6573

66-
Because it is written in C++, Dawn provides better error messages and logging. Because it is open-source, it is easier to inspect stack traces when applications crash.
74+
As it is written in C++, Dawn provides enhanced error message reporting and logging. The fact that it is open source, also means that it is easier to inspect stack traces when applications crash.
6775

68-
Dawn is usually ahead of `wgpu-native`, another WebGPU implementation, when it comes to new functionalities and standards changes.
76+
Dawn is usually ahead of `wgpu-native`, another WebGPU implementation, in terms of new functionality developments and standards changes.

content/learning-paths/smartphones-and-mobile/android_webgpu_dawn/2-env-setup.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,57 @@ weight: 3
66
layout: learningpathall
77
---
88

9-
In this Learning Path, you will learn how to:
10-
11-
* Integrate Dawn (WebGPU) in an application.
12-
* Use the APIs to render a simple 3D object.
13-
* Profile and analyze the application.
14-
159
The first step is to prepare a development environment with the required software:
1610

17-
* [Android Studio](https://developer.android.com/studio)
18-
* [Arm Performance Studio](https://www.arm.com/products/development-tools/graphics/arm-performance-studio)
19-
* Python 3.10 or later
11+
* Android Studio.
12+
* Arm Performance Studio.
13+
* Python 3.10 or later.
2014

21-
You can use any computer and operating system which supports the above software.
15+
You can use any computer and operating system that supports this software.
2216

2317
## Install Android Studio and the Android NDK
2418

2519
1. Download and install the latest version of [Android Studio](https://developer.android.com/studio/).
2620

2721
2. Start Android Studio.
2822

29-
3. Open the `Settings` dialog.
23+
3. Open the **Settings** dialog.
3024

31-
4. Navigate to `Languages & Frameworks`, then select `Android SDK`.
25+
4. Navigate to **Languages & Frameworks**, then select **Android SDK**.
3226

33-
5. In the `SDK Platforms` tab, check `Android 14.0 ("UpsideDownCake")`
27+
5. In the **SDK Platforms** tab, select the checkbox **Android 14.0** ("UpsideDownCake").
3428

35-
![SDK Platforms #center](images/sdk-platforms.png "SDK Platforms")
29+
![SDK Platforms #center](images/sdk-platforms.png "Figure 2: SDK Platforms")
3630

37-
6. In the `SDK Tools` tab check the following:
38-
* Check `Android SDK Build-Tools 35`
39-
* Check `NDK (Side by side)`
40-
* Check `CMake`
31+
6. In the **SDK Tools** tab, select the following:
32+
33+
* **Android SDK Build-Tools 35**.
34+
* **NDK (Side by side)**.
35+
* **CMake**.
4136

42-
![SDK Tools #center](images/sdk-tools.png "SDK Tools")
37+
![SDK Tools #center](images/sdk-tools.png "Figure 3: SDK Tools")
4338

44-
Click OK to install and update the selected components.
39+
Click **OK** to install and update the selected components.
4540

4641
## Install Arm Performance Studio
4742

4843
Profiling is an important step in the Android application development cycle.
4944

50-
The default profiler in the Android Studio is great to profile CPU related metrics, but does not provide GPU details.
45+
The default profiler in Android Studio is great to profile CPU-related metrics, but it does not provide GPU details.
5146

5247
Arm Performance Studio is a comprehensive profiling tool to profile both CPUs and GPUs.
5348

5449
One of the components of Performance Studio is Streamline. Streamline captures data from multiple sources, including:
5550

5651
* Program Counter (PC) samples from running application threads.
5752
* Samples from the hardware Performance Monitoring Unit (PMU) counters in Arm CPUs, Arm Mali GPUs, and Arm Immortalis GPUs.
58-
* Thread scheduling information from the Linux kernel.
53+
* Thread-scheduling information from the Linux kernel.
5954
* Software-generated annotations and counters from running applications.
6055

61-
Install Arm Performance Studio using the [install guide](/install-guides/ams/).
56+
Install Arm Performance Studio using the [Arm Performance Studio Install Guide](/install-guides/ams/).
6257

6358
{{% notice Tip %}}
64-
If you want to learn more about Arm Performance Studio and Streamline before continuing, refer to [Get started with Arm Performance Studio for mobile](https://learn.arm.com/learning-paths/smartphones-and-mobile/ams/ams/)
59+
To learn more about Arm Performance Studio and Streamline, see [Get started with Arm Performance Studio for mobile](https://learn.arm.com/learning-paths/smartphones-and-mobile/ams/ams/).
6560
{{% /notice %}}
6661

67-
Android Studio and Arm Performance Studio are now installed and you are ready to create a WebGPU Android application.
62+
Android Studio and Arm Performance Studio are now installed, and you are ready to create a WebGPU Android application.

content/learning-paths/smartphones-and-mobile/android_webgpu_dawn/3-integrate-dawn.md

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
---
2-
title: Create an application which includes Dawn
2+
title: Create an application with Dawn
33
weight: 4
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Set up Android Project
9+
## Set up your Android Studio Project
1010

11-
You can start by creating a new Android Studio project.
11+
Start by creating a new Android Studio project.
1212

13-
Open Android studio, click `New Project` and select `Game Activity (C++)` as shown below:
13+
Open Android Studio, click **New Project**, and select **Game Activity (C++)** as shown below:
1414

15-
![New Game Activity #center](./images/android_studio_new_game_activity.png "New C++ Game Activity")
15+
![New Game Activity #center](./images/android_studio_new_game_activity.png "Figure 4: New C++ Game Activity")
1616

17-
Set the `Name` to be `dawnwebgpu`.
18-
19-
Select `Next` to continue.
20-
21-
Finish the new project creation by accepting all defaults until the project is created.
17+
* Set the **Name** field to **dawnwebgpu**.
18+
* Click **Next** to continue.
19+
* Finish setting up the new project by accepting all the default selections until the project is created.
2220

2321
The project is created in `~/AndroidStudioProjects`.
2422

@@ -28,23 +26,25 @@ GameActivity is a Jetpack library designed to assist Android games in processing
2826

2927
GameActivity is a direct descendant of NativeActivity and shares a similar architecture:
3028

31-
![Game Activity Architecture #center](./images/GameActivityArchitecture.png "Game Activity Architecture")
29+
![Game Activity Architecture #center](./images/GameActivityArchitecture.png "Figure 5: Game Activity Architecture")
3230

33-
With GameActivity, you can focus on your game development and avoid spending excessive time dealing with the Java Native Interface (JNI) code.
31+
With GameActivity, you can focus on game development and avoid spending excessive amounts of time dealing with the Java Native Interface (JNI) code.
3432

3533
GameActivity performs the following functions:
3634

37-
* Interacts with the Android framework through the Java-side component.
38-
* Passes app cycle commands, input events, and input text to the native side.
39-
* Renders into a SurfaceView, making it easier for games to interact with other UI components.
35+
* It interacts with the Android framework through the Java-side component.
36+
* It passes app cycle commands, input events, and input text to the native side.
37+
* It renders into a SurfaceView, making it easier for games to interact with other UI components.
4038

4139
{{% notice Tip %}}
42-
You can find more information about Android Game Activity and its capabilities in the [Game Activity documentation](https://developer.android.com/games/agdk/game-activity).
40+
You can find more information about Android Game Activity and its capabilities in the [Game Activity Documentation](https://developer.android.com/games/agdk/game-activity).
4341
{{% /notice %}}
4442

4543
## Download project source files
4644

47-
To create a WebGPU application, a number of files from GitHub are doing to be added to your Game Activity project. The objective is to show you how to take the Game Activity template and modify it to become a WebGPU application.
45+
The process of creating a WebGPU application involves adding a number of files from GitHub to your Game Activity project.
46+
47+
The objective of this part of the Learning Path is to show you how to take the Game Activity template and modify it to become a WebGPU application.
4848

4949
To get started, open a terminal, create a new directory, and download the project files:
5050

@@ -59,27 +59,22 @@ Unzip the project files:
5959
unzip main.zip
6060
```
6161

62-
Yow now have a directory named `Android_DawnWebGPU-main` in your `webgpu-files` directory.
62+
You now have a directory named **Android_DawnWebGPU-main** in the **webgpu-files** directory.
6363

64-
During the next sections you will copy some of the required files from the `Android_DawnWebGPU-main` directory to your Game Activity project to learn how to create WebGPU applications.
64+
During the following sections, you will copy some of the required files from the **Android_DawnWebGPU-main** directory into your Game Activity project to learn how to create WebGPU applications.
6565

6666
## Upgrade the application to include Dawn
6767

6868
Return to Android Studio and start work on the WebGPU application.
6969

70-
The Android Game Activity framework uses OpenGLES3 for graphics.
71-
72-
You can remove this dependency and replace it with WebGPU.
70+
The Android Game Activity framework uses OpenGLES3 for graphics. You can remove this dependency and replace it with WebGPU.
7371

7472
Add WebGPU to the project using the following steps:
7573

76-
1. In Android Studio, navigate to the project view and find the `app` --> `cpp` folder.
77-
78-
Open terminal in Android Studio. You should be in the `dawnwebgpu` directory.
79-
80-
2. Create a new directory and download the WebGPU header file from GitHub
81-
82-
Run the commands below to download the `webgpu.hpp` header file:
74+
* In Android Studio, navigate to the project view, and find the **app** --> **cpp** folder.
75+
* Open the terminal in Android Studio. You are now in the **dawnwebgpu** directory.
76+
* Create a new directory and download the WebGPU header file from GitHub.
77+
* Run the commands below to download the `webgpu.hpp` header file:
8378

8479
```console
8580
mkdir -p app/src/main/cpp/webgpu/include/webgpu
@@ -88,7 +83,7 @@ cp ~/webgpu-files/Android_DawnWebGPU-main/app/src/main/cpp/webgpu/include/webgpu
8883
cd ../..
8984
```
9085

91-
3. Next copy the remaining WebGPU files to your project.
86+
Next, copy the remaining WebGPU files to your project.
9287

9388
```console
9489
cp ~/webgpu-files/Android_DawnWebGPU-main/app/src/main/cpp/webgpu/CMakeLists.txt .
@@ -101,19 +96,19 @@ cd ..
10196
Notice that `FetchDawn.cmake` uses a stable `chromium/6536` branch of Dawn repository.
10297

10398
{{% notice Note %}}
104-
WebGPU is constantly evolving standard and hence its implementation, Dawn is also under active development. For sake of stability, we have chosen a stable branch for our development. Updating to latest or different branch may cause breakage.
99+
WebGPU is a constantly evolving standard and hence its implementation, Dawn is also under active development. For sake of stability, we have chosen a stable branch for our development. Updating to latest or different branch may cause breakage.
105100
{{% /notice %}}
106101

107-
To add Dawn to our application, there are 2 options:
102+
To add Dawn to our application, there are two options:
108103

109104
* Create a shared/static library from the Dawn source and use it in application.
110105
* Download the source as a dependency and build it as part of the project build.
111106

112-
You will use the second option, since it provides more debug flexibility.
107+
You will use the second option here, since it provides more flexibility for debug.
113108

114109
The files `webgpu/webgpu.cmake` and `CMakeLists.txt` facilitate downloading and building WebGPU with Dawn implementation and integrating Dawn into the project.
115110

116-
4. Add WebGPU to the project.
111+
## Add WebGPU to the project
117112

118113
WebGPU is added to the project in the file `CMakeLists.txt`.
119114

@@ -153,6 +148,6 @@ target_link_libraries(dawnwebgpu
153148
```
154149

155150

156-
The `webgpu.hpp` header file acts like an interface, exposing all WebGPU functions and variables to the main Application.
151+
The `webgpu.hpp` header file acts like an interface, exposing all the WebGPU functions and variables to the main Application.
157152

158153
Navigate to the next section to continue building the WebGPU application.

0 commit comments

Comments
 (0)