You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WebGPU is the successor to WebGL, a welladopted 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.
12
12
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.
14
22
15
23
WebGPU is available through web browsers using the webgpu.h header file.
16
24
17
-
The highlevel view of WebGPU is shown below:
25
+
The high-level view of WebGPU is shown below in Figure 1:
18
26
19
-

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:
24
32
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.
30
38
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.
32
40
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.
34
42
35
43
{{% notice Note %}}
36
44
When designing an API for the Web, the two key constraints are portability and privacy.
37
45
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.
39
47
{{% /notice %}}
40
48
41
49
## What are the benefits of using C++ for WebGPU?
42
50
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.
44
52
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:
46
54
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 wellsuited 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++.
50
58
51
59
## Dawn: the Google WebGPU implementation
52
60
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.
54
62
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`.
56
64
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.
58
66
59
67
Dawn provides several WebGPU building blocks:
60
68
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.
64
72
* Tint, a compiler for the WebGPU Shader Language (WGSL), that converts shaders to and from WGSL.
65
73
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 opensource, also means that it is easier to inspect stack traces when applications crash.
67
75
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.
Click OK to install and update the selected components.
39
+
Click **OK** to install and update the selected components.
45
40
46
41
## Install Arm Performance Studio
47
42
48
43
Profiling is an important step in the Android application development cycle.
49
44
50
-
The default profiler in the Android Studio is great to profile CPUrelated 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.
51
46
52
47
Arm Performance Studio is a comprehensive profiling tool to profile both CPUs and GPUs.
53
48
54
49
One of the components of Performance Studio is Streamline. Streamline captures data from multiple sources, including:
55
50
56
51
* Program Counter (PC) samples from running application threads.
57
52
* Samples from the hardware Performance Monitoring Unit (PMU) counters in Arm CPUs, Arm Mali GPUs, and Arm Immortalis GPUs.
58
-
* Threadscheduling information from the Linux kernel.
53
+
* Thread-scheduling information from the Linux kernel.
59
54
* Software-generated annotations and counters from running applications.
60
55
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/).
62
57
63
58
{{% 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/).
65
60
{{% /notice %}}
66
61
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.

32
30
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.
34
32
35
33
GameActivity performs the following functions:
36
34
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.
40
38
41
39
{{% 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).
43
41
{{% /notice %}}
44
42
45
43
## Download project source files
46
44
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.
48
48
49
49
To get started, open a terminal, create a new directory, and download the project files:
50
50
@@ -59,27 +59,22 @@ Unzip the project files:
59
59
unzip main.zip
60
60
```
61
61
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.
63
63
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.
65
65
66
66
## Upgrade the application to include Dawn
67
67
68
68
Return to Android Studio and start work on the WebGPU application.
69
69
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.
73
71
74
72
Add WebGPU to the project using the following steps:
75
73
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:
Notice that `FetchDawn.cmake` uses a stable `chromium/6536` branch of Dawn repository.
102
97
103
98
{{% 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.
105
100
{{% /notice %}}
106
101
107
-
To add Dawn to our application, there are 2 options:
102
+
To add Dawn to our application, there are two options:
108
103
109
104
* Create a shared/static library from the Dawn source and use it in application.
110
105
* Download the source as a dependency and build it as part of the project build.
111
106
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.
113
108
114
109
The files `webgpu/webgpu.cmake` and `CMakeLists.txt` facilitate downloading and building WebGPU with Dawn implementation and integrating Dawn into the project.
115
110
116
-
4. Add WebGPU to the project.
111
+
##Add WebGPU to the project
117
112
118
113
WebGPU is added to the project in the file `CMakeLists.txt`.
0 commit comments