locum 0.1.4

Captures everything a Direct3D 11 game draws in a frame, to look at, query, change and replay: d3d11.dll and dxgi.dll beside the game that watch every call on its way to the real runtime.
Documentation
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
//! Generated by `cargo xtask gen` from the `windows` crate's `ID3D12PipelineLibrary1_Vtbl`; do not edit.

#![allow(
    non_snake_case,
    clippy::too_many_arguments,
    clippy::missing_safety_doc,
    dead_code
)]

use core::ffi::c_void;

/// Every method of `ID3D12PipelineLibrary1` in vtable order. The defaults forward to the wrapped object [`Library12Methods::inner`].
///
/// # Safety
/// The implementing type must be `#[repr(C)]` with a pointer to [`vtable`]'s table as its first field,
/// and `inner` must return a live `ID3D12PipelineLibrary1`.
pub unsafe trait Library12Methods: Sized {
    /// The wrapped object, an `ID3D12PipelineLibrary1`.
    fn inner(&self) -> *mut c_void;
    unsafe fn QueryInterface(
        &self,
        iid: *const windows::core::GUID,
        out: *mut *mut c_void,
    ) -> windows::core::HRESULT;
    unsafe fn AddRef(&self) -> u32;
    unsafe fn Release(&self) -> u32;
    unsafe fn GetPrivateData(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut u32,
        a2: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::GetPrivateData(self.inner(), a0, a1, a2) }
    }
    unsafe fn SetPrivateData(
        &self,
        a0: *const windows::core::GUID,
        a1: u32,
        a2: *const core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::SetPrivateData(self.inner(), a0, a1, a2) }
    }
    unsafe fn SetPrivateDataInterface(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::SetPrivateDataInterface(self.inner(), a0, a1) }
    }
    unsafe fn SetName(&self, a0: windows::core::PCWSTR) -> windows::core::HRESULT {
        unsafe { real::SetName(self.inner(), a0) }
    }
    unsafe fn GetDevice(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::GetDevice(self.inner(), a0, a1) }
    }
    unsafe fn StorePipeline(
        &self,
        a0: windows::core::PCWSTR,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::StorePipeline(self.inner(), a0, a1) }
    }
    unsafe fn LoadGraphicsPipeline(
        &self,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_GRAPHICS_PIPELINE_STATE_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::LoadGraphicsPipeline(self.inner(), a0, a1, a2, a3) }
    }
    unsafe fn LoadComputePipeline(
        &self,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_COMPUTE_PIPELINE_STATE_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::LoadComputePipeline(self.inner(), a0, a1, a2, a3) }
    }
    unsafe fn GetSerializedSize(&self) -> usize {
        unsafe { real::GetSerializedSize(self.inner()) }
    }
    unsafe fn Serialize(&self, a0: *mut core::ffi::c_void, a1: usize) -> windows::core::HRESULT {
        unsafe { real::Serialize(self.inner(), a0, a1) }
    }
    unsafe fn LoadPipeline(
        &self,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_PIPELINE_STATE_STREAM_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::LoadPipeline(self.inner(), a0, a1, a2, a3) }
    }
}

/// Each method called on the real (wrapped) object: the trait's defaults, and overrides that still want the
/// real behaviour.
pub mod real {
    use core::ffi::c_void;

    /// `GetPrivateData` on the real object.
    pub unsafe fn GetPrivateData(
        inner: *mut c_void,
        a0: *const windows::core::GUID,
        a1: *mut u32,
        a2: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .base__
                .base__
                .GetPrivateData)(inner, a0, a1, a2)
        }
    }
    /// `SetPrivateData` on the real object.
    pub unsafe fn SetPrivateData(
        inner: *mut c_void,
        a0: *const windows::core::GUID,
        a1: u32,
        a2: *const core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .base__
                .base__
                .SetPrivateData)(inner, a0, a1, a2)
        }
    }
    /// `SetPrivateDataInterface` on the real object.
    pub unsafe fn SetPrivateDataInterface(
        inner: *mut c_void,
        a0: *const windows::core::GUID,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .base__
                .base__
                .SetPrivateDataInterface)(inner, a0, a1)
        }
    }
    /// `SetName` on the real object.
    pub unsafe fn SetName(inner: *mut c_void, a0: windows::core::PCWSTR) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .base__
                .base__
                .SetName)(inner, a0)
        }
    }
    /// `GetDevice` on the real object.
    pub unsafe fn GetDevice(
        inner: *mut c_void,
        a0: *const windows::core::GUID,
        a1: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .base__
                .GetDevice)(inner, a0, a1)
        }
    }
    /// `StorePipeline` on the real object.
    pub unsafe fn StorePipeline(
        inner: *mut c_void,
        a0: windows::core::PCWSTR,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .StorePipeline)(inner, a0, a1)
        }
    }
    /// `LoadGraphicsPipeline` on the real object.
    pub unsafe fn LoadGraphicsPipeline(
        inner: *mut c_void,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_GRAPHICS_PIPELINE_STATE_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .LoadGraphicsPipeline)(inner, a0, a1, a2, a3)
        }
    }
    /// `LoadComputePipeline` on the real object.
    pub unsafe fn LoadComputePipeline(
        inner: *mut c_void,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_COMPUTE_PIPELINE_STATE_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .LoadComputePipeline)(inner, a0, a1, a2, a3)
        }
    }
    /// `GetSerializedSize` on the real object.
    pub unsafe fn GetSerializedSize(inner: *mut c_void) -> usize {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .GetSerializedSize)(inner)
        }
    }
    /// `Serialize` on the real object.
    pub unsafe fn Serialize(
        inner: *mut c_void,
        a0: *mut core::ffi::c_void,
        a1: usize,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .base__
                .Serialize)(inner, a0, a1)
        }
    }
    /// `LoadPipeline` on the real object.
    pub unsafe fn LoadPipeline(
        inner: *mut c_void,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_PIPELINE_STATE_STREAM_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner as *const *const windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl)))
                .LoadPipeline)(inner, a0, a1, a2, a3)
        }
    }
}

unsafe extern "system" fn QueryInterface<T: Library12Methods>(
    this: *mut c_void,
    iid: *const windows::core::GUID,
    out: *mut *mut c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).QueryInterface(iid, out) }
}
unsafe extern "system" fn AddRef<T: Library12Methods>(this: *mut c_void) -> u32 {
    unsafe { (*(this as *const T)).AddRef() }
}
unsafe extern "system" fn Release<T: Library12Methods>(this: *mut c_void) -> u32 {
    unsafe { (*(this as *const T)).Release() }
}
unsafe extern "system" fn GetPrivateData<T: Library12Methods>(
    this: *mut c_void,
    a0: *const windows::core::GUID,
    a1: *mut u32,
    a2: *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).GetPrivateData(a0, a1, a2) }
}
unsafe extern "system" fn SetPrivateData<T: Library12Methods>(
    this: *mut c_void,
    a0: *const windows::core::GUID,
    a1: u32,
    a2: *const core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).SetPrivateData(a0, a1, a2) }
}
unsafe extern "system" fn SetPrivateDataInterface<T: Library12Methods>(
    this: *mut c_void,
    a0: *const windows::core::GUID,
    a1: *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).SetPrivateDataInterface(a0, a1) }
}
unsafe extern "system" fn SetName<T: Library12Methods>(
    this: *mut c_void,
    a0: windows::core::PCWSTR,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).SetName(a0) }
}
unsafe extern "system" fn GetDevice<T: Library12Methods>(
    this: *mut c_void,
    a0: *const windows::core::GUID,
    a1: *mut *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).GetDevice(a0, a1) }
}
unsafe extern "system" fn StorePipeline<T: Library12Methods>(
    this: *mut c_void,
    a0: windows::core::PCWSTR,
    a1: *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).StorePipeline(a0, a1) }
}
unsafe extern "system" fn LoadGraphicsPipeline<T: Library12Methods>(
    this: *mut c_void,
    a0: windows::core::PCWSTR,
    a1: *const windows::Win32::Graphics::Direct3D12::D3D12_GRAPHICS_PIPELINE_STATE_DESC,
    a2: *const windows::core::GUID,
    a3: *mut *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).LoadGraphicsPipeline(a0, a1, a2, a3) }
}
unsafe extern "system" fn LoadComputePipeline<T: Library12Methods>(
    this: *mut c_void,
    a0: windows::core::PCWSTR,
    a1: *const windows::Win32::Graphics::Direct3D12::D3D12_COMPUTE_PIPELINE_STATE_DESC,
    a2: *const windows::core::GUID,
    a3: *mut *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).LoadComputePipeline(a0, a1, a2, a3) }
}
unsafe extern "system" fn GetSerializedSize<T: Library12Methods>(this: *mut c_void) -> usize {
    unsafe { (*(this as *const T)).GetSerializedSize() }
}
unsafe extern "system" fn Serialize<T: Library12Methods>(
    this: *mut c_void,
    a0: *mut core::ffi::c_void,
    a1: usize,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).Serialize(a0, a1) }
}
unsafe extern "system" fn LoadPipeline<T: Library12Methods>(
    this: *mut c_void,
    a0: windows::core::PCWSTR,
    a1: *const windows::Win32::Graphics::Direct3D12::D3D12_PIPELINE_STATE_STREAM_DESC,
    a2: *const windows::core::GUID,
    a3: *mut *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).LoadPipeline(a0, a1, a2, a3) }
}

#[allow(clippy::let_and_return)] // Uniform post-call interception in generated methods.
unsafe impl Library12Methods for crate::d3d12::Object {
    fn inner(&self) -> *mut c_void {
        self.real()
    }
    unsafe fn QueryInterface(
        &self,
        iid: *const windows::core::GUID,
        out: *mut *mut c_void,
    ) -> windows::core::HRESULT {
        unsafe { self.query(iid, out) }
    }
    unsafe fn AddRef(&self) -> u32 {
        self.add_ref()
    }
    unsafe fn Release(&self) -> u32 {
        unsafe { self.release() }
    }
    unsafe fn GetPrivateData(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut u32,
        a2: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::GetPrivateData(self.real(), a0, a1, a2);
            self.private_output(result, a0, a1, a2);
            result
        }
    }
    unsafe fn SetPrivateData(
        &self,
        a0: *const windows::core::GUID,
        a1: u32,
        a2: *const core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::SetPrivateData(self.real(), a0, a1, a2);
            if result.is_ok() {
                self.private_interface(a0, false);
            }
            result
        }
    }
    unsafe fn SetPrivateDataInterface(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::SetPrivateDataInterface(self.real(), a0, crate::d3d12::unwrap(a1));
            if result.is_ok() {
                self.private_interface(a0, !a1.is_null());
            }
            result
        }
    }
    unsafe fn SetName(&self, a0: windows::core::PCWSTR) -> windows::core::HRESULT {
        unsafe {
            let result = real::SetName(self.real(), a0);
            result
        }
    }
    unsafe fn GetDevice(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::GetDevice(self.real(), a0, a1);
            crate::d3d12::wrap_output(result, a0, a1);
            result
        }
    }
    unsafe fn StorePipeline(
        &self,
        a0: windows::core::PCWSTR,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::StorePipeline(self.real(), a0, crate::d3d12::unwrap(a1));
            result
        }
    }
    unsafe fn LoadGraphicsPipeline(
        &self,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_GRAPHICS_PIPELINE_STATE_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let mapped1 = crate::d3d12::inputs::graphics(a1);
            self.called("LoadGraphicsPipeline");
            let result = real::LoadGraphicsPipeline(self.real(), a0, mapped1.ptr(), a2, a3);
            crate::d3d12::wrap_output(result, a2, a3);
            if result.is_ok() {
                crate::d3d12::shaders::graphics(a1);
                crate::d3d12::pipelines::created(
                    crate::d3d12::journal::owner_device(self.data.id),
                    a3,
                    || crate::d3d12::pipelines::graphics(a1),
                );
            }
            result
        }
    }
    unsafe fn LoadComputePipeline(
        &self,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_COMPUTE_PIPELINE_STATE_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let mapped1 = crate::d3d12::inputs::compute(a1);
            self.called("LoadComputePipeline");
            let result = real::LoadComputePipeline(self.real(), a0, mapped1.ptr(), a2, a3);
            crate::d3d12::wrap_output(result, a2, a3);
            if result.is_ok() {
                crate::d3d12::shaders::compute(a1);
                crate::d3d12::pipelines::created(
                    crate::d3d12::journal::owner_device(self.data.id),
                    a3,
                    || crate::d3d12::pipelines::compute(a1),
                );
            }
            result
        }
    }
    unsafe fn GetSerializedSize(&self) -> usize {
        unsafe {
            let result = real::GetSerializedSize(self.real());
            result
        }
    }
    unsafe fn Serialize(&self, a0: *mut core::ffi::c_void, a1: usize) -> windows::core::HRESULT {
        unsafe {
            let result = real::Serialize(self.real(), a0, a1);
            crate::log::log!("D3D12 Serialize: library={} capacity={}", self.data.id, a1);
            result
        }
    }
    unsafe fn LoadPipeline(
        &self,
        a0: windows::core::PCWSTR,
        a1: *const windows::Win32::Graphics::Direct3D12::D3D12_PIPELINE_STATE_STREAM_DESC,
        a2: *const windows::core::GUID,
        a3: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let mapped1 = crate::d3d12::inputs::stream(a1);
            self.called("LoadPipeline");
            let result = real::LoadPipeline(self.real(), a0, mapped1.ptr(), a2, a3);
            crate::d3d12::wrap_output(result, a2, a3);
            if result.is_ok() {
                crate::d3d12::shaders::stream(a1);
                crate::d3d12::pipelines::created(
                    crate::d3d12::journal::owner_device(self.data.id),
                    a3,
                    || crate::d3d12::pipelines::stream(a1),
                );
            }
            result
        }
    }
}

/// The `ID3D12PipelineLibrary1` vtable whose entries call `T`'s methods.
pub const fn vtable<T: Library12Methods>() -> windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl
{
    windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary1_Vtbl {
        base__: windows::Win32::Graphics::Direct3D12::ID3D12PipelineLibrary_Vtbl {
            base__: windows::Win32::Graphics::Direct3D12::ID3D12DeviceChild_Vtbl {
                base__: windows::Win32::Graphics::Direct3D12::ID3D12Object_Vtbl {
                    base__: windows::core::IUnknown_Vtbl {
                        QueryInterface: QueryInterface::<T>,
                        AddRef: AddRef::<T>,
                        Release: Release::<T>,
                    },
                    GetPrivateData: GetPrivateData::<T>,
                    SetPrivateData: SetPrivateData::<T>,
                    SetPrivateDataInterface: SetPrivateDataInterface::<T>,
                    SetName: SetName::<T>,
                },
                GetDevice: GetDevice::<T>,
            },
            StorePipeline: StorePipeline::<T>,
            LoadGraphicsPipeline: LoadGraphicsPipeline::<T>,
            LoadComputePipeline: LoadComputePipeline::<T>,
            GetSerializedSize: GetSerializedSize::<T>,
            Serialize: Serialize::<T>,
        },
        LoadPipeline: LoadPipeline::<T>,
    }
}