Skip to content

Commit f8b74b8

Browse files
committed
Merge branch 'main' into vertex-buffer-hole
2 parents b95830e + dbc9baf commit f8b74b8

File tree

13 files changed

+259
-266
lines changed

13 files changed

+259
-266
lines changed

Doxyfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ OUTPUT_DIRECTORY = doc/generated
2727

2828
OPTIMIZE_OUTPUT_FOR_C = YES
2929

30+
EXTRACT_ALL = YES
31+
EXTRACT_STATIC = YES
32+
WARN_AS_ERROR = FAIL_ON_WARNINGS
33+
WARN_IF_INCOMPLETE_DOC = NO
34+
# Note EXTRACT_ALL bypasses these, but keep them in case we disable it.
35+
WARN_IF_UNDOC_ENUM_VAL = YES
36+
WARN_NO_PARAMDOC = NO
37+
WARN_IF_UNDOCUMENTED = YES
38+
3039
#---------------------------------------------------------------------------
3140
# Build related configuration options
3241
#---------------------------------------------------------------------------

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ gen-check: fix gen
2424

2525
doc: webgpu.h Doxyfile
2626
doxygen Doxyfile
27+
# Verify that no ` or :: made it through into the final docs
28+
! grep -RE '`|>::' doc/generated/**/*.html

doc/articles/Asynchronous Operations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ All asynchronous operations start when the application calls an asynchronous web
2121
`void* userdata1`<br>
2222
`void* userdata2`
2323
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.
2525
2626
> @copydoc ::WGPUCallbackMode_WaitAnyOnly
2727
> @copydoc ::WGPUCallbackMode_AllowProcessEvents
@@ -32,13 +32,13 @@ The `callback` function pointer is called when the application _observes complet
3232
3333
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.
3434
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.
3636
3737
Within this call, for any `WGPUFuture`s that completed, their respective callbacks will fire.
3838
3939
### Timed Wait {#Timed-Wait}
4040
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.
4242
4343
### Mixed Sources {#Mixed-Sources}
4444
@@ -59,13 +59,13 @@ Asynchronous operations may originate from different sources. There are CPU-time
5959
## wgpuInstanceProcessEvents {#Process-Events}
6060
`void wgpuInstanceProcessEvents(WGPUInstance)`
6161
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.
6363
6464
## Device Events
6565
6666
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.
6767
@todo Add a getter for the device lost WGPUFuture. See discussion at https://github.com/webgpu-native/webgpu-headers/issues/199#issuecomment-1866850031.
6868
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.
7070
7171
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.

doc/articles/Errors.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ These behave similarly to the Promise-returning JavaScript APIs. Instead of ther
2525

2626
These errors include:
2727

28-
- @ref SynchronousStructChainingError cases.
28+
- @ref StructChainingError cases.
2929
- [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.
3030

3131
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"
3636
These messages are logged in an implementation defined way (e.g. to an implementation-specific callback, or to a logging runtime).
3737
They are intended to be intended to be read by humans, useful primarily for development and crash reporting.
3838

39-
## Struct-Chaining Errors {#StructChainingErrors}
39+
## Struct-Chaining Error {#StructChainingError}
4040

41-
A struct-chaining error happens when the @ref SType of a struct in a struct chain is not valid for that chain.
41+
A struct-chaining error happens when the @ref WGPUSType of a struct in a struct chain is not valid for that chain.
4242

43-
Struct chains which are used in device-timeline validation/operations (e.g. @ref WGPUBufferDescriptor in @ref WGPUDeviceCreateBuffer) 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 @ref wgpuDeviceCreateBuffer) have their chain errors surfaced asynchronously, like any other validation error.
4444

4545
### Out-Struct-Chain Error {#OutStructChainError}
4646

47-
Operations which take out-struct-chains (e.g. @ref WGPULimits, in @ref WGPUAdapterGetLimits/@ref WGPUDeviceGetLimits, but not in @ref WGPUDeviceDescriptor) handle struct-chaining errors as follows:
47+
Operations which take out-struct-chains (e.g. @ref WGPULimits, in @ref wgpuAdapterGetLimits and @ref wgpuDeviceGetLimits, but not in @ref WGPUDeviceDescriptor) handle struct-chaining errors as follows:
4848

4949
- The output struct and struct chain is not modified.
5050
- The operation produces a @ref SynchronousError (return value and log message).

doc/articles/SentinelValues.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sentinel Values {#SentinelValues}
22

3-
## Undefined
3+
## Undefined and Null
44

55
Since WebGPU is defined first as a JavaScript API, it uses the JavaScript value
66
`undefined` in many places to indicate the lack of a value.
@@ -14,7 +14,8 @@ It may also be used in functions/methods. For example, `GPUBuffer`'s
1414
can be called equivalently as `b.getMappedRange()`, `b.getMappedRange(0)`,
1515
`b.getMappedRange(undefined)`, or `b.getMappedRange(undefined, undefined)`.
1616

17-
To represent `undefined` in C, `webgpu.h` uses `*_UNDEFINED` sentinel numeric values
17+
To represent `undefined` in C, `webgpu.h` uses `NULL` where possible (anything
18+
behind a pointer, including objects), `*_UNDEFINED` sentinel numeric values
1819
(generally `UINT32_MAX`, etc.) and `*_Undefined` enum values (generally `0`).
1920

2021
The place that uses the type will define what to do with an undefined value.
@@ -26,13 +27,19 @@ It may be:
2627
(usually this is either a special value or it has more complex defaulting,
2728
for example depending on other values).
2829

29-
## Other sentinel values
30-
31-
Undefined values are also be used in C-specific ways in place of WebIDL's
32-
more flexible typing:
33-
34-
- \ref WGPUVertexBufferLayout::stepMode = \ref WGPUVertexStepMode_Undefined with \ref WGPUVertexBufferLayout::attributeCount
35-
- \ref WGPUBufferBindingType_BindingNotUsed
36-
- \ref WGPUSamplerBindingType_BindingNotUsed
37-
- \ref WGPUTextureSampleType_BindingNotUsed
38-
- \ref WGPUStorageTextureAccess_BindingNotUsed
30+
## C-Specific Sentinel Values
31+
32+
Undefined and null values are also used in C-specific ways in place of
33+
WebIDL's more flexible typing:
34+
35+
- \ref WGPUStringView has a special null value
36+
- \ref WGPUFuture has a special null value
37+
- Special cases to indicate the parent struct is null, avoiding extra layers of
38+
pointers just for nullability:
39+
- \ref WGPUVertexBufferLayout::stepMode = \ref WGPUVertexStepMode_Undefined with \ref WGPUVertexBufferLayout::attributeCount
40+
- \ref WGPUBufferBindingLayout::type = \ref WGPUBufferBindingType_BindingNotUsed
41+
- \ref WGPUSamplerBindingLayout::type = \ref WGPUSamplerBindingType_BindingNotUsed
42+
- \ref WGPUTextureBindingLayout::sampleType = \ref WGPUTextureSampleType_BindingNotUsed
43+
- \ref WGPUStorageTextureBindingLayout::access = \ref WGPUStorageTextureAccess_BindingNotUsed
44+
- \ref WGPURenderPassColorAttachment::view = `NULL`
45+
- \ref WGPUColorTargetState::format = \ref WGPUTextureFormat_Undefined

doc/articles/Surfaces.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Sections below give more details about these operations, including the specifica
1111

1212
## Surface Creation {#Surface-Creation}
1313

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 @ref wgpuInstanceCreateSurface.
1515
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.
1616

1717
Surfaces that can be presented to using `webgpu.h` (but not necessarily by all implementations) are:
@@ -56,9 +56,9 @@ struct WGPUSurface {
5656
};
5757
```
5858
59-
The behavior of `::wgpuInstanceCreateSurface``(instance, descriptor)` is:
59+
The behavior of <code>@ref wgpuInstanceCreateSurface</code><code>(instance, descriptor)</code> is:
6060
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:
6262
6363
- Validate that all the sub-descriptors in the chain for `descriptor` are known to this implementation.
6464
- Validate that `descriptor` contains information about exactly one OS surface.
@@ -70,16 +70,16 @@ The behavior of `::wgpuInstanceCreateSurface``(instance, descriptor)` is:
7070
7171
Depending on the OS, GPU used, backing API for WebGPU and other factors, different capabilities are available to render and present the @ref WGPUSurface.
7272
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:
7474
7575
- A bit set of supported @ref WGPUTextureUsage that are guaranteed to contain @ref WGPUTextureUsage_RenderAttachment.
7676
- A list of supported @ref WGPUTextureFormat values, in order of preference.
7777
- A list of supported @ref WGPUPresentMode values (guaranteed to contain @ref WGPUPresentMode_Fifo).
7878
- 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).
7979
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.
8181
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>:
8383
8484
```c
8585
// Get the capabilities
@@ -103,7 +103,7 @@ for (size_t i = 0; i < caps.presentModeCount; i++) {
103103
wgpuSurfaceCapabilitiesFreeMembers(caps);
104104
```
105105

106-
The behavior of `::wgpuSurfaceGetCapabilities``(surface, adapter, caps)` is:
106+
The behavior of <code>@ref wgpuSurfaceGetCapabilities</code><code>(surface, adapter, caps)</code> is:
107107

108108
- If any of these validation steps fails, return false. (TODO return an error WGPUStatus):
109109

@@ -116,14 +116,14 @@ The behavior of `::wgpuSurfaceGetCapabilities``(surface, adapter, caps)` is:
116116
## Surface Configuration {#Surface-Configuration}
117117

118118
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.
120120
It contains the following kinds of parameters:
121121

122122
- 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.
124124
- @ref WGPUPresentMode and @ref WGPUCompositeAlphaMode parameters for how and when the surface will be presented to the user.
125125

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>:
127127

128128
```c
129129
WGPUSurfaceConfiguration config = {
@@ -163,13 +163,13 @@ WGPUTextureDescriptor GetSurfaceEquivalentTextureDescriptor(const WGPUSurfaceCon
163163

164164
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.
165165

166-
The behavior of `::wgpuSurfaceConfigure``(surface, config)` is:
166+
The behavior of <code>@ref wgpuSurfaceConfigure</code><code>(surface, config)</code> is:
167167

168168
- If any of these validation steps fails, TODO: what should happen on failure?
169169

170170
- Validate that `surface` is not an error.
171171
- 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>@ref wgpuSurfaceGetCapabilities</code><code>(surface, adapter, &caps)</code>.
173173
- Validate that all the sub-descriptors in the chain for `caps` are known to this implementation.
174174
- Validate that `device` is alive.
175175
- Validate that `config->presentMode` is in `caps->presentModes`.
@@ -182,23 +182,23 @@ The behavior of `::wgpuSurfaceConfigure``(surface, config)` is:
182182
- Set `surface.config` to a deep copy of `config`.
183183
- If `surface.currentFrame` is not `None`:
184184

185-
- Do as if `::wgpuTextureDestroy``(surface.currentFrame)` was called.
185+
- Do as if <code>@ref wgpuTextureDestroy</code><code>(surface.currentFrame)</code> was called.
186186
- Set `surface.currentFrame` to `None`.
187187

188188
It can also be useful to remove the configuration of a @ref WGPUSurface without replacing it with a valid one.
189189
Without removing the configuration, the @ref WGPUSurface will keep referencing the @ref WGPUDevice that cannot be totally reclaimed.
190190

191-
The behavior of `::wgpuSurfaceUnconfigure``()` is:
191+
The behavior of <code>@ref wgpuSurfaceUnconfigure</code><code>()</code> is:
192192

193193
- Set `surface.config` to `None`.
194194
- If `surface.currentFrame` is not `None`:
195195

196-
- Do as if `::wgpuTextureDestroy``(surface.currentFrame)` was called.
196+
- Do as if <code>@ref wgpuTextureDestroy</code><code>(surface.currentFrame)</code> was called.
197197
- Set `surface.currentFrame` to `None`.
198198

199199
## Presenting to Surface {#Surface-Presenting}
200200

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 @ref wgpuSurfaceGetCurrentTexture, renders to it and then presents it on the screen with @ref wgpuSurfacePresent.
202202

203203
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.
204204
The environment can also change the surface without breaking it, but making the current configuration suboptimal.
@@ -234,7 +234,7 @@ wgpuTextureRelease(surfaceTexture.texture);
234234

235235
```
236236
237-
The behavior of `::wgpuSurfaceGetCurrentTexture``(surface, surfaceTexture)` is:
237+
The behavior of <code>@ref wgpuSurfaceGetCurrentTexture</code><code>(surface, surfaceTexture)</code> is:
238238
239239
1. Set `surfaceTexture->texture` to `NULL`.
240240
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:
255255
1. Add a new reference to `t`.
256256
1. Set `surfaceTexture->texture` to a new reference to `t`.
257257
258-
The behavior of `::wgpuSurfacePresent``(surface)` is:
258+
The behavior of <code>@ref wgpuSurfacePresent</code><code>(surface)</code> is:
259259
260260
- If any of these validation steps fails, TODO send error to device?
261261
262262
- Validate that `surface` is not an error.
263263
- Validate that `surface.currentFrame` is not `None`.
264264
265-
- Do as if `::wgpuTextureDestroy``(surface.currentFrame)` was called.
265+
- Do as if <code>@ref wgpuTextureDestroy</code><code>(surface.currentFrame)</code> was called.
266266
- Present `surface.currentFrame` to the `surface`.
267267
- Set `surface.currentFrame` to `None`.

0 commit comments

Comments
 (0)