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
Copy file name to clipboardExpand all lines: doc/articles/Asynchronous Operations.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ All asynchronous operations start when the application calls an asynchronous web
21
21
`void* userdata1`<br>
22
22
`void* userdata2`
23
23
24
-
The `callback` function pointer is called when the application _observes completion_ of the asynchronous operation. The `userdata1` and `userdata2` members are passed back to the application as the last two arguments in the callback function. Callbacks **might not** be called unless the application explicitly flushes them in order to _observe completion_. The point in time a callback is called depends on the @ref WGPUCallbackMode of the operation. webgpu.h provides three callback modes: `::WGPUCallbackMode_WaitAnyOnly`, `::WGPUCallbackMode_AllowProcessEvents`, and `::WGPUCallbackMode_AllowSpontaneous`.
24
+
The `callback` function pointer is called when the application _observes completion_ of the asynchronous operation. The `userdata1` and `userdata2` members are passed back to the application as the last two arguments in the callback function. Callbacks **might not** be called unless the application explicitly flushes them in order to _observe completion_. The point in time a callback is called depends on the @ref WGPUCallbackMode of the operation. webgpu.h provides three callback modes: @ref WGPUCallbackMode_WaitAnyOnly, @ref WGPUCallbackMode_AllowProcessEvents, and @ref WGPUCallbackMode_AllowSpontaneous.
25
25
26
26
> @copydoc ::WGPUCallbackMode_WaitAnyOnly
27
27
> @copydoc ::WGPUCallbackMode_AllowProcessEvents
@@ -32,13 +32,13 @@ The `callback` function pointer is called when the application _observes complet
32
32
33
33
Waits on any WGPUFuture in the list of `futures` to complete for `timeoutNS` nanoseconds. Returns when at least one `WGPUFuture` is completed or `timeoutNS` elapses, whichever is first. If `timeoutNS` is zero, all `futures` are polled once, without blocking.
34
34
35
-
Returns `::WGPUWaitStatus_Success` if at least one `WGPUFuture` completes. WGPUFutureWaitInfo::completed is set to true for all completed futures. See @ref WGPUWaitStatus for other status codes.
35
+
Returns @ref WGPUWaitStatus_Success if at least one `WGPUFuture` completes. WGPUFutureWaitInfo::completed is set to true for all completed futures. See @ref WGPUWaitStatus for other status codes.
36
36
37
37
Within this call, for any `WGPUFuture`s that completed, their respective callbacks will fire.
38
38
39
39
### Timed Wait {#Timed-Wait}
40
40
41
-
Use of _timed waits_ (`timeoutNS > 0`), must be enabled on the WGPUInstance in `::wgpuCreateInstance` with `WGPUInstanceFeatures::timedWaitAnyEnable`, and the number of futures waited on must be less than or equal to `WGPUInstanceFeatures::timedWaitAnyMaxCount`. Supported instance features may be queried using `::wgpuGetInstanceFeatures`.
41
+
Use of _timed waits_ (`timeoutNS > 0`), must be enabled on the WGPUInstance in @ref wgpuCreateInstance with `WGPUInstanceFeatures::timedWaitAnyEnable`, and the number of futures waited on must be less than or equal to `WGPUInstanceFeatures::timedWaitAnyMaxCount`. Supported instance features may be queried using @ref wgpuGetInstanceCapabilities.
42
42
43
43
### Mixed Sources {#Mixed-Sources}
44
44
@@ -59,13 +59,13 @@ Asynchronous operations may originate from different sources. There are CPU-time
59
59
## wgpuInstanceProcessEvents {#Process-Events}
60
60
`void wgpuInstanceProcessEvents(WGPUInstance)`
61
61
62
-
Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with `::WGPUCallbackMode_AllowProcessEvents` that have completed. This is a non-blocking operation.
62
+
Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with @ref WGPUCallbackMode_AllowProcessEvents that have completed. This is a non-blocking operation.
63
63
64
64
## Device Events
65
65
66
66
Device events are slightly different in that their callback info (`WGPUDeviceLostCallbackInfo` and `WGPUUncapturedErrorCallbackInfo`) are passed on the `WGPUDeviceDescriptor`, instead of in a function argument. There is no `WGPUFuture` returned for either callback.
67
67
@todo Add a getter for the device lost WGPUFuture. See discussion at https://github.com/webgpu-native/webgpu-headers/issues/199#issuecomment-1866850031.
68
68
69
-
The `WGPUUncapturedErrorCallbackInfo` _does not_ have a callback mode member. It is always as-if it were `::WGPUCallbackMode_AllowSpontaneous`. Note also that the uncaptured error callback is a _repeating_ callback that fires multiple times, unlike other callbacks in webgpu.h.
69
+
The `WGPUUncapturedErrorCallbackInfo` _does not_ have a callback mode member. It is always as-if it were @ref WGPUCallbackMode_AllowSpontaneous. Note also that the uncaptured error callback is a _repeating_ callback that fires multiple times, unlike other callbacks in webgpu.h.
70
70
71
71
The uncaptured error callback is guaranteed not to fire after the device becomes lost. When the device is lost, it is an appropriate time for the application to free userdata variables for the uncaptured error callback. Note that the device becomes lost _before_ the actual device lost callback fires. First the device state transitions to lost, then the device lost callback fires. The timing of the callback depends on the device lost callback mode.
Copy file name to clipboardExpand all lines: doc/articles/Errors.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ These behave similarly to the Promise-returning JavaScript APIs. Instead of ther
25
25
26
26
These errors include:
27
27
28
-
-@refSynchronousStructChainingError cases.
28
+
-@refStructChainingError cases.
29
29
-[Content-timeline](https://www.w3.org/TR/webgpu/#content-timeline) errors other than those which are surfaced as @ref DeviceError in `webgpu.h`. See specific documentation to determine how each error is exposed.
30
30
31
31
Generally these will return some kind of failure status (like \ref WGPUStatus_Error) or `NULL`, and produce an @ref ImplementationDefinedLogging message.
@@ -36,15 +36,15 @@ Entry points may also specify that they produce "implementation-defined logging"
36
36
These messages are logged in an implementation defined way (e.g. to an implementation-specific callback, or to a logging runtime).
37
37
They are intended to be intended to be read by humans, useful primarily for development and crash reporting.
38
38
39
-
## Struct-Chaining Errors {#StructChainingErrors}
39
+
## Struct-Chaining Error {#StructChainingError}
40
40
41
-
A struct-chaining error happens when the @refSType of a struct in a struct chain is not valid for that chain.
41
+
A struct-chaining error happens when the @refWGPUSType of a struct in a struct chain is not valid for that chain.
42
42
43
-
Struct chains which are used in device-timeline validation/operations (e.g. @ref WGPUBufferDescriptor in @refWGPUDeviceCreateBuffer) have their chain errors surfaced asynchronously, like any other validation error.
43
+
Struct chains which are used in device-timeline validation/operations (e.g. @ref WGPUBufferDescriptor in @refwgpuDeviceCreateBuffer) have their chain errors surfaced asynchronously, like any other validation error.
44
44
45
45
### Out-Struct-Chain Error {#OutStructChainError}
46
46
47
-
Operations which take out-struct-chains (e.g. @ref WGPULimits, in @refWGPUAdapterGetLimits/@refWGPUDeviceGetLimits, but not in @ref WGPUDeviceDescriptor) handle struct-chaining errors as follows:
47
+
Operations which take out-struct-chains (e.g. @ref WGPULimits, in @refwgpuAdapterGetLimits and @refwgpuDeviceGetLimits, but not in @ref WGPUDeviceDescriptor) handle struct-chaining errors as follows:
48
48
49
49
- The output struct and struct chain is not modified.
50
50
- The operation produces a @ref SynchronousError (return value and log message).
Copy file name to clipboardExpand all lines: doc/articles/Surfaces.md
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Sections below give more details about these operations, including the specifica
11
11
12
12
## Surface Creation {#Surface-Creation}
13
13
14
-
A @ref WGPUSurface is child object of a @ref WGPUInstance and created using `::wgpuInstanceCreateSurface`.
14
+
A @ref WGPUSurface is child object of a @ref WGPUInstance and created using @refwgpuInstanceCreateSurface.
15
15
The description of a @ref WGPUSurface is a @ref WGPUSurfaceDescriptor with a sub-descriptor chained containing the environment-specific objects used to identify the surface.
16
16
17
17
Surfaces that can be presented to using `webgpu.h` (but not necessarily by all implementations) are:
@@ -56,9 +56,9 @@ struct WGPUSurface {
56
56
};
57
57
```
58
58
59
-
The behavior of `::wgpuInstanceCreateSurface``(instance, descriptor)` is:
59
+
The behavior of <code>@ref wgpuInstanceCreateSurface</code><code>(instance, descriptor)</code> is:
60
60
61
-
- If any of these validation steps fails, return an error @ref WGPUSurface:
61
+
- If any of these validation steps fails, return an error @ref WGPUSurface object:
62
62
63
63
- Validate that all the sub-descriptors in the chain for `descriptor` are known to this implementation.
64
64
- Validate that `descriptor` contains information about exactly one OS surface.
@@ -70,16 +70,16 @@ The behavior of `::wgpuInstanceCreateSurface``(instance, descriptor)` is:
70
70
71
71
Depending on the OS, GPU used, backing API for WebGPU and other factors, different capabilities are available to render and present the @ref WGPUSurface.
72
72
For this reason, negotiation is done between the WebGPU implementation and the application to choose how to use the @ref WGPUSurface.
73
-
This first step of the negotiation is querying what capabilities are available using `::wgpuSurfaceGetCapabilities` that fills an @ref WGPUSurfaceCapabilities structure with the following information:
73
+
This first step of the negotiation is querying what capabilities are available using @ref wgpuSurfaceGetCapabilities that fills an @ref WGPUSurfaceCapabilities structure with the following information:
74
74
75
75
- A bit set of supported @ref WGPUTextureUsage that are guaranteed to contain @ref WGPUTextureUsage_RenderAttachment.
76
76
- A list of supported @ref WGPUTextureFormat values, in order of preference.
77
77
- A list of supported @ref WGPUPresentMode values (guaranteed to contain @ref WGPUPresentMode_Fifo).
78
78
- A list of supported @ref WGPUCompositeAlphaMode values (@ref WGPUCompositeAlphaMode_Auto is always supported but never listed in capabilities as it just lets the implementation decide what to use).
79
79
80
-
The call to `::wgpuSurfaceGetCapabilities` may allocate memory for pointers filled in the @ref WGPUSurfaceCapabilities structure so `::wgpuSurfaceCapabilitiesFreeMembers` must be called to avoid leaking memory once the capabilities are no longer needed.
80
+
The call to @ref wgpuSurfaceGetCapabilities may allocate memory for pointers filled in the @ref WGPUSurfaceCapabilities structure so @ref wgpuSurfaceCapabilitiesFreeMembers must be called to avoid leaking memory once the capabilities are no longer needed.
81
81
82
-
This is an example of how to query the capabilities or a @ref WGPUSurface:
82
+
This is an example of how to query the capabilities of a <code>@ref WGPUSurface</code>:
83
83
84
84
```c
85
85
// Get the capabilities
@@ -103,7 +103,7 @@ for (size_t i = 0; i < caps.presentModeCount; i++) {
103
103
wgpuSurfaceCapabilitiesFreeMembers(caps);
104
104
```
105
105
106
-
The behavior of `::wgpuSurfaceGetCapabilities``(surface, adapter, caps)` is:
106
+
The behavior of <code>@refwgpuSurfaceGetCapabilities</code><code>(surface, adapter, caps)</code> is:
107
107
108
108
- If any of these validation steps fails, return false. (TODO return an error WGPUStatus):
109
109
@@ -116,14 +116,14 @@ The behavior of `::wgpuSurfaceGetCapabilities``(surface, adapter, caps)` is:
116
116
## Surface Configuration {#Surface-Configuration}
117
117
118
118
Before it can use it for rendering, the application must configure the surface.
119
-
The configuration is the second step of the negotiation, done after analyzing the results of `::wgpuSurfaceGetCapabilities`.
119
+
The configuration is the second step of the negotiation, done after analyzing the results of @ref wgpuSurfaceGetCapabilities.
120
120
It contains the following kinds of parameters:
121
121
122
122
- The @ref WGPUDevice that will be used to render to the surface.
123
-
- Parameters for the textures returned by `::wgpuSurfaceGetCurrentTexture`.
123
+
- Parameters for the textures returned by @ref wgpuSurfaceGetCurrentTexture.
124
124
- @ref WGPUPresentMode and @ref WGPUCompositeAlphaMode parameters for how and when the surface will be presented to the user.
125
125
126
-
This is an example of how to configure a @ref WGPUSurface:
126
+
This is an example of how to configure a <code>@ref WGPUSurface</code>:
When a surface is successfully configured, the new configuration overrides any previous configuration and destroys the previous current texture (if any) so it can no longer be used.
165
165
166
-
The behavior of `::wgpuSurfaceConfigure``(surface, config)` is:
166
+
The behavior of <code>@refwgpuSurfaceConfigure</code><code>(surface, config)</code> is:
167
167
168
168
- If any of these validation steps fails, TODO: what should happen on failure?
169
169
170
170
- Validate that `surface` is not an error.
171
171
- Let `adapter` be the adapter used to create `device`.
172
-
- Let `caps` be the @ref WGPUSurfaceCapabilities filled with `::wgpuSurfaceGetCapabilities``(surface, adapter, &caps)`.
172
+
- Let `caps` be the @ref WGPUSurfaceCapabilities filled with <code>@refwgpuSurfaceGetCapabilities</code><code>(surface, adapter, &caps)</code>.
173
173
- Validate that all the sub-descriptors in the chain for `caps` are known to this implementation.
174
174
- Validate that `device` is alive.
175
175
- Validate that `config->presentMode` is in `caps->presentModes`.
@@ -182,23 +182,23 @@ The behavior of `::wgpuSurfaceConfigure``(surface, config)` is:
182
182
- Set `surface.config` to a deep copy of `config`.
183
183
- If `surface.currentFrame` is not `None`:
184
184
185
-
- Do as if `::wgpuTextureDestroy``(surface.currentFrame)` was called.
185
+
- Do as if <code>@refwgpuTextureDestroy</code><code>(surface.currentFrame)</code> was called.
186
186
- Set `surface.currentFrame` to `None`.
187
187
188
188
It can also be useful to remove the configuration of a @ref WGPUSurface without replacing it with a valid one.
189
189
Without removing the configuration, the @ref WGPUSurface will keep referencing the @ref WGPUDevice that cannot be totally reclaimed.
190
190
191
-
The behavior of `::wgpuSurfaceUnconfigure``()` is:
191
+
The behavior of <code>@refwgpuSurfaceUnconfigure</code><code>()</code> is:
192
192
193
193
- Set `surface.config` to `None`.
194
194
- If `surface.currentFrame` is not `None`:
195
195
196
-
- Do as if `::wgpuTextureDestroy``(surface.currentFrame)` was called.
196
+
- Do as if <code>@refwgpuTextureDestroy</code><code>(surface.currentFrame)</code> was called.
197
197
- Set `surface.currentFrame` to `None`.
198
198
199
199
## Presenting to Surface {#Surface-Presenting}
200
200
201
-
Each frame, the application retrieves the @ref WGPUTexture for the frame with `::wgpuSurfaceGetCurrentTexture`, renders to it and then presents it on the screen with `::wgpuSurfacePresent`.
201
+
Each frame, the application retrieves the @ref WGPUTexture for the frame with @refwgpuSurfaceGetCurrentTexture, renders to it and then presents it on the screen with @refwgpuSurfacePresent.
202
202
203
203
Issues can happen when trying to retrieve the frame's @ref WGPUTexture, so the application must check @ref WGPUSurfaceTexture `.status` to see if the surface or the device was lost, or some other windowing system issue caused a timeout.
204
204
The environment can also change the surface without breaking it, but making the current configuration suboptimal.
The behavior of `::wgpuSurfaceGetCurrentTexture``(surface, surfaceTexture)` is:
237
+
The behavior of <code>@ref wgpuSurfaceGetCurrentTexture</code><code>(surface, surfaceTexture)</code> is:
238
238
239
239
1. Set `surfaceTexture->texture` to `NULL`.
240
240
1. If any of these validation steps fails, set `surfaceTexture->status` to `WGPUSurfaceGetCurrentTextureStatus_Error` and return (TODO send error to device?).
@@ -255,13 +255,13 @@ The behavior of `::wgpuSurfaceGetCurrentTexture``(surface, surfaceTexture)` is:
255
255
1. Add a new reference to `t`.
256
256
1. Set `surfaceTexture->texture` to a new reference to `t`.
257
257
258
-
The behavior of `::wgpuSurfacePresent``(surface)` is:
258
+
The behavior of <code>@ref wgpuSurfacePresent</code><code>(surface)</code> is:
259
259
260
260
- If any of these validation steps fails, TODO send error to device?
261
261
262
262
- Validate that `surface` is not an error.
263
263
- Validate that `surface.currentFrame` is not `None`.
264
264
265
-
- Do as if `::wgpuTextureDestroy``(surface.currentFrame)` was called.
265
+
- Do as if <code>@ref wgpuTextureDestroy</code><code>(surface.currentFrame)</code> was called.
266
266
- Present `surface.currentFrame` to the `surface`.
0 commit comments