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
//! Viewport filter trait for post-processing rendered frames.
//!
//! Plugins that implement [`ViewportFilter`] can transform the viewport image
//! after the main render pipeline (tile compositing, adjustments, stain norm)
//! has produced a frame. Filters are applied in registration order.
//!
//! Two rendering paths are supported:
//!
//! - **CPU**: The filter receives and returns an RGBA8 pixel buffer.
//! - **GPU**: The filter receives raw Vulkan handles for zero-copy access
//! to GPU memory. In-process (FFI) plugins get the VkDevice and VkImage
//! directly, and may also import exported DMA-BUF handles when needed.
//!
//! In-process Rust plugins implement this trait directly via `abi_stable`.
use RawFd;
type RawFd = c_int;
/// Describes what an RGBA8 pixel buffer looks like in memory.
/// Raw Vulkan handles for GPU filter execution (in-process FFI path).
///
/// The host populates this with the Vulkan device and a VkImage backed by
/// exportable memory. The plugin creates its own pipeline on the shared
/// device and submits commands that operate on `vk_image`. The plugin must
/// signal `vk_done_fence` when its GPU work is complete so the host can
/// safely read the result.
/// DMA-BUF descriptor for cross-process GPU memory sharing.
///
/// The host exports the filter texture's backing memory as a DMA-BUF file
/// descriptor and passes it (along with a sync fence fd) to the plugin
/// process over a Unix domain socket. The plugin imports the DMA-BUF,
/// wraps it as a Vulkan image, runs its shader, and signals completion
/// by writing to the done-fence fd.
/// Trait for viewport post-processing filters.
///
/// A filter can support CPU processing, GPU processing, or both. The host
/// calls whichever variant matches the active render backend.