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
Before getting our hands on a **device**, we need to select an **adapter**. The same host system may expose **multiple adapters** if it has access to multiple physical GPUs. It may also have an adapter that represents an emulated/virtual device.
12
+
Before getting our hands on a WebGPU **device**, we need to select an **adapter**.
13
+
14
+
```{tip}
15
+
This chapter is a bit dense because it is also the occasion to **introduce multiple key concepts** of the WebGPU API, in particular the **asynchronous functions** and the `WGPUStringView` (that represents **character strings**).
16
+
17
+
Take the time to understand these concepts, it is going to pay off later on!
18
+
```
19
+
20
+
Why do we need an adapter?
21
+
--------------------------
22
+
23
+
The same host system may expose **multiple adapters** if it has access to multiple physical GPUs. It may also have an adapter that represents an emulated/virtual device.
13
24
14
25
```{note}
15
26
It is common that high-end laptops have **two physical GPUs**, a **high performance** one (sometimes called *discrete*) and a **low energy** consumption one (that is usually integrated inside the CPU chip).
@@ -112,7 +123,7 @@ Here is a rough example to **illustrate the `userdata` mechanism**:
112
123
voidonAdapterRequestEnded(
113
124
WGPURequestAdapterStatus status, // a success status
void* userdata1, // custom user data, as provided when requesting the adapter
117
128
void* userdata2 // second custom user data
118
129
) {
@@ -316,7 +327,21 @@ std::cerr << "Error while requesting adapter: " << toStdStringView(message) << s
316
327
317
328
We know how to request the adpater, and how to handle the response. But we do not know yet **how to wait** for the request to end before returning to the main function.
318
329
319
-
**WIP line**
330
+
To keep track of ongoing asynchronous operations, each function that starts such an operation **returns a `WGPUFuture`**, which is some sort of internal ID that **identifies the operation**.
Although it is technically just an integer value, the `WGPUFuture` should be treated as an **opaque handle**, i.e., one should not try to deduce anything from the very value of this ID.
338
+
```
339
+
340
+
**WIP line***Maybe move this section up after Asynchronous function*
When using the **native** API (Dawn or `wgpu-native`), it is in practice **not needed**, we know that when the `wgpuInstanceRequestAdapter` function returns its callback has been called.
322
347
@@ -561,7 +586,11 @@ Conclusion
561
586
562
587
- The very first thing to do with WebGPU is to get the **adapter**.
563
588
- Once we have an adapter, we can inspect its **capabilities** (limits, features) and properties.
564
-
- We learned to use **asynchronous functions** and **double call** enumeration functions.
589
+
- We learned to use **asynchronous functions**.
565
590
- We have learned about `WGPUStringView`.
566
591
592
+
```{note}
593
+
For more information about asynchronous operations in WebGPU, you may consult the [official specification](https://webgpu-native.github.io/webgpu-headers/Asynchronous-Operations.html).
0 commit comments