1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
//! Submission and cross-queue synchronisation.
//!
//! # The sync model, and where the line is
//!
//! The HAL rule in `docs/notes/backends.md` says "explicit sync **at the graph level**".
//! That splits into two halves, and this crate owns only the lower one:
//!
//! | Concern | Owner |
//! | --- | --- |
//! | *Where* a barrier goes, and between which states | `crcbl-render`'s graph |
//! | *How* a barrier is expressed to the driver | this seam, backends |
//! | Resource state tracking across passes | `crcbl-render`'s graph |
//! | Transient aliasing, frames-in-flight, deletion queues | `crcbl-render` |
//! | Semaphore objects and submit-level waits/signals | this seam |
//!
//! **The HAL is stateless with respect to resource states.** It never infers a
//! barrier, never tracks a layout, and never reorders a command. If the graph
//! forgets a transition, the backend's validation layer says so — that is the
//! intended failure mode, and it is why stage 2 demanded
//! zero validation warnings as a P1 exit criterion.
//!
//! # Timeline semaphores are the primitive
//!
//! One synchronisation object, not the Vulkan trio of fence, binary semaphore
//! and event. A [`SemaphoreKind::Timeline`] semaphore is a monotonically
//! increasing `u64` that both the GPU and the CPU can wait on. It replaces
//! fences for frame pacing, replaces separate upload-tracking objects for the
//! staging ring (topic 03 §3.1 waits on a timeline value before consuming a
//! mesh), and maps directly onto DX12's `ID3D12Fence` and Metal's
//! `MTLSharedEvent`. Vulkan 1.3 with `timelineSemaphore` is a hard requirement
//! for `crcbl-vk`, so there is no fallback path to design around.
//!
//! [`SemaphoreKind::Binary`] exists only because WSI acquire/present still uses
//! binary semaphores on Vulkan. Nothing above the seam creates one: the
//! swapchain owns them and hands them out through
//! [`AcquiredFrame`](crate::AcquiredFrame).
//!
//! P0's seam review asked whether "semaphore" is Vulkan-only vocabulary, since
//! DX12 has fences and Metal has `MTLSharedEvent`. The answer recorded here so
//! it is not re-litigated: **the name describes the thing.** `Timeline` maps
//! one-for-one onto both of those, and `Binary` names a real object that WSI
//! acquire genuinely needs — a one-shot GPU-only signal with no value to read.
//! Renaming it "fence" would import DX12's noun for a concept DX12 does not
//! have in this shape, which is the same mistake in the other direction.
//!
//! # WebGPU has no semaphores at all
//!
//! WebGPU expresses cross-submit ordering **implicitly**: one queue, command
//! buffers executed in submission order, and hazards between them tracked by the
//! browser. There is no object to signal and nothing to wait on, and the only
//! completion signal it offers — `GPUQueue.onSubmittedWorkDone()` — resolves for
//! *everything* submitted so far and carries no value, so it cannot answer "has
//! the timeline reached N".
//!
//! A backend on it therefore **refuses** the timeline half rather than
//! implementing it as a no-op: [`Device::create_semaphore`](crate::Device::create_semaphore)
//! answers [`HalError::Unsupported`](crate::HalError::Unsupported) for
//! [`SemaphoreKind::Timeline`], and so do
//! [`Device::semaphore_value`](crate::Device::semaphore_value),
//! [`Device::signal_semaphore`](crate::Device::signal_semaphore) and
//! [`Device::wait_semaphores`](crate::Device::wait_semaphores). The
//! [`SemaphoreKind::Binary`] half is still handed out, because WSI acquire is
//! where binary semaphores come from and every device must have one to give.
//!
//! **A no-op that returns `Ok` is the wrong shape here**, and `crcbl-webgpu`
//! shipped it: a caller got a handle, polled its value, and read `0` for ever
//! with nothing in any return code to say why. The engine is unaffected either
//! way — `crcbl::engine`'s `GpuContext` and `crcbl_render::MeshPool` both check
//! [`Features::TIMELINE_SEMAPHORE`](crate::Features::TIMELINE_SEMAPHORE) before
//! creating one and take their documented `wait_idle` fallback when it is
//! absent, which it always is on a browser — so refusing costs nothing and buys
//! a caller that does *not* check the flag an immediate answer instead of a
//! silent one.
use Handle;
use crateCommandBufferHandle;
/// Marker type for semaphore handles. Uninhabited.
/// A semaphore.
pub type SemaphoreHandle = ;
/// What kind of semaphore to create.
/// Creation parameters for a semaphore.
/// A wait a submission performs before executing.
/// A signal a submission performs when it completes.
/// One queue submission.
///
/// Waits happen before any command buffer runs; signals happen after all of
/// them complete. Finer-grained per-stage wait masks (Vulkan's
/// `pWaitDstStageMask`) are deliberately **not** exposed: they buy overlap only
/// when a submission's first work is unrelated to what it waited on, which the
/// graph already arranges by splitting submissions, and Metal cannot express
/// them at all.