Commit c0ff4bf
Implement transparent pass-throughs for the remaining audit-layer stubs
Turns the ~113 todo!() stubs across Device, Queue, CommandEncoder, and
the rest of Adapter/Surface into calls that forward to `inner`,
allocating a fresh audit `Id` for each newly created resource. No new
safety checking is added here — this just makes the wrapper functionally
complete (usable end to end) instead of panicking on first use of
anything beyond instance creation and adapter enumeration.
Since `Audited<T>::inner` is already stored as the erased `Box<dyn
DynX>` the real backend expects, converting an audited-wrapper
descriptor into its `dyn` equivalent needs no downcasting — just `&self
.inner`. Added two small helpers to make that idiomatic:
`Audited::wrap` (allocate an id, wrap a freshly created inner resource)
and `Audited::as_dyn` (deref `inner` to its erased type). Descriptors
that are themselves generic over other resource types (BindGroupDescriptor,
RenderPipelineDescriptor, RenderPassDescriptor, BuildAccelerationStructureDescriptor,
etc.) get reconstructed field-by-field against their `dyn` equivalents,
mirroring the existing reverse-direction conversions in
wgpu-hal/src/dynamic/*.rs (which do the same job the other way, backend
-> dyn, complete with real downcasts since they don't have the luxury
of already holding the erased type).
Two methods are left as todo!(), each with a comment explaining why:
- `Surface::acquire_texture` needs to cache an owned `audit::Texture` so
`Borrow<audit::Texture>` has something to point to, but the only
texture available is a *borrowed* view of the inner surface texture.
Manufacturing an owned `Box<dyn DynTexture>` from that borrow would
need either downcasting to a concrete backend type (this layer is
backend-agnostic) or aliasing `inner`'s allocation (double-free once
both boxes drop). Needs an actual design change, not a mechanical fix.
- `CommandEncoder::set_acceleration_structure_dependencies` is declared
as a receiverless associated function in the static `CommandEncoder`
trait, so there is no `self.inner` to forward to.
Added wgpu-hal/examples/audit_smoke.rs, a standalone example that drives
a real Vulkan instance through the auditing wrapper end to end (create
instance, enumerate adapters, open a device, write to a mapped buffer,
record+submit+wait on a command buffer) to exercise this. Verified with
`WGPU_AUDIT_HAL_USAGE=1 cargo run -p wgpu-hal --example audit_smoke
--features vulkan`, comparing against the same run with the env var
unset. `cargo check --workspace --features vulkan` and `cargo clippy -p
wgpu-hal --features vulkan --all-targets` are both clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent abdb954 commit c0ff4bf
8 files changed
Lines changed: 737 additions & 123 deletions
File tree
- wgpu-hal
- examples
- src/audit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | 15 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 16 | + | |
| 17 | + | |
28 | 18 | | |
29 | 19 | | |
30 | 20 | | |
31 | 21 | | |
32 | 22 | | |
33 | 23 | | |
34 | 24 | | |
35 | | - | |
| 25 | + | |
36 | 26 | | |
37 | 27 | | |
38 | 28 | | |
39 | 29 | | |
40 | 30 | | |
41 | 31 | | |
42 | | - | |
| 32 | + | |
43 | 33 | | |
44 | 34 | | |
45 | 35 | | |
46 | | - | |
| 36 | + | |
47 | 37 | | |
48 | 38 | | |
49 | 39 | | |
50 | | - | |
| 40 | + | |
51 | 41 | | |
52 | 42 | | |
53 | 43 | | |
54 | | - | |
| 44 | + | |
55 | 45 | | |
56 | 46 | | |
0 commit comments