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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-metal")]
use objc2_metal::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_drawable_render_context?language=objc)
#[repr(C)]
#[derive(Debug)]
pub struct cp_drawable_render_context {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
unsafe impl RefEncode for cp_drawable_render_context {
const ENCODING_REF: Encoding =
Encoding::Pointer(&Encoding::Struct("cp_drawable_render_context", &[]));
}
/// An object that can render any effects associated with a drawable
/// This is required for applications that want to render using the
/// Progressive Immersion Style
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_drawable_render_context_t?language=objc)
pub type cp_drawable_render_context_t = *mut cp_drawable_render_context;
impl cp_drawable_render_context {
/// Store the `value` parameter in the stencil texture in the pixels that Compositor
/// will display on the screen.
///
/// - Parameters:
/// - render_context: The render context to use to present the drawable.
/// - command_encoder: The command encoder to use to render the Compositor effects
/// and present the drawable.
/// - value: The value to use when updating the stencil texture in the command_encoder.
///
/// - Note: In Full and Mixed immersion style, this will be the full texture.
///
/// - Note: The command encoder used in the render context has the following constraints:
/// - stencil texture: should have the same pixel format as
/// ``cp_layer_renderer_configuration_get_drawable_render_context_stencil_format``
/// - renderTargetArrayLength: should be the same as the number of views
/// in the drawable.
/// - rasterizationRateMap: should be the one provided by the drawable.
/// - layer renderer layout: Dedicated and Shared layout is not supported.
///
/// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
/// to true to avoid Metal API validation errors.
/// This API is not available on simulator; as a workaround, either disable API validation or separate
/// the rendering into multiple render encoders for other color attachments.
///
/// - Note: This function will modify the depth stencil state, the viewports, the vertex amplification count
/// and some of the texture bindings in the render command encoder passed to the function.
/// Make sure to set those values again to the ones expected in your application.
///
/// # Safety
///
/// `render_context` must be a valid pointer.
#[doc(alias = "cp_drawable_render_context_draw_mask_on_stencil_attachment")]
#[cfg(feature = "objc2-metal")]
#[inline]
pub unsafe fn draw_mask_on_stencil_attachment(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
value: u8,
) {
extern "C-unwind" {
fn cp_drawable_render_context_draw_mask_on_stencil_attachment(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
value: u8,
);
}
unsafe {
cp_drawable_render_context_draw_mask_on_stencil_attachment(
render_context,
command_encoder,
value,
)
}
}
/// Finish encoding the render context.
///
/// - Parameters:
/// - render_context: The render context to use to present the drawable.
/// - command_encoder: The command encoder to use to render the Compositor effects
/// and present the drawable.
///
/// - Note: The ownership of the command encoder is passed to the drawable render context, which will
/// call endEncoding on the command encoder.
///
/// - Note: The command encoder used in the render context has the following constraints:
/// - color texture: colorAttachment[0] should contain the color texture
/// provided by the drawable.
/// - depth texture: depthAttachment should contain the depth texture provided
/// by the drawable.
/// - renderTargetArrayLength: should be the same as the number of views
/// in the drawable.
/// - rasterizationRateMap: should be the one provided by the drawable.
/// - layer renderer layout: Dedicated and Shared layout is not supported.
///
/// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
/// to true to avoid Metal API validation errors.
/// This API is not available on simulator; as a workaround, either disable API validation or separate
/// the rendering into multiple render encoders for other color attachments.
///
/// # Safety
///
/// `render_context` must be a valid pointer.
#[doc(alias = "cp_drawable_render_context_end_encoding")]
#[cfg(feature = "objc2-metal")]
#[inline]
pub unsafe fn end_encoding(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
) {
extern "C-unwind" {
fn cp_drawable_render_context_end_encoding(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
);
}
unsafe { cp_drawable_render_context_end_encoding(render_context, command_encoder) }
}
/// Store the `value` parameter in the stencil texture in the pixels that Compositor
/// will display on the screen.
///
/// - Parameters:
/// - render_context: The render context to use to present the drawable.
/// - command_encoder: The command encoder to use to render the Compositor effects
/// and present the drawable.
/// - value: The value to use when updating the stencil texture in the command_encoder.
///
/// - Note: In Full and Mixed immersion style, this will be the full texture.
///
/// - Note: The command encoder used in the render context has the following constraints:
/// - stencil texture: should have the same pixel format as
/// ``cp_layer_renderer_configuration_get_drawable_render_context_stencil_format``
/// - renderTargetArrayLength: should be the same as the number of views
/// in the drawable.
/// - rasterizationRateMap: should be the one provided by the drawable.
/// - layer renderer layout: Dedicated and Shared layout is not supported.
///
/// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
/// to true to avoid Metal API validation errors.
/// This API is not available on simulator; as a workaround, either disable API validation or separate
/// the rendering into multiple render encoders for other color attachments.
///
/// - Note: This function will modify the depth stencil state, the viewports, the vertex amplification count
/// and some of the texture bindings in the render command encoder passed to the function.
/// Make sure to set those values again to the ones expected in your application.
///
/// # Safety
///
/// `render_context` must be a valid pointer.
#[doc(alias = "cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment")]
#[cfg(feature = "objc2-metal")]
#[inline]
pub unsafe fn mtl4_draw_mask_on_stencil_attachment(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
value: u8,
) {
extern "C-unwind" {
fn cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
value: u8,
);
}
unsafe {
cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
render_context,
command_encoder,
value,
)
}
}
/// Finish encoding the render context.
///
/// - Parameters:
/// - render_context: The render context to use to present the drawable.
/// - command_encoder: The command encoder to use to render the Compositor effects
/// and present the drawable.
///
/// - Note: The ownership of the command encoder is passed to the drawable render context, which will
/// call endEncoding on the command encoder.
///
/// - Note: The command encoder used in the render context has the following constraints:
/// - color texture: colorAttachment[0] should contain the color texture
/// provided by the drawable.
/// - depth texture: depthAttachment should contain the depth texture provided
/// by the drawable.
/// - renderTargetArrayLength: should be the same as the number of views
/// in the drawable.
/// - rasterizationRateMap: should be the one provided by the drawable.
/// - layer renderer layout: Dedicated and Shared layout is not supported.
///
/// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
/// to true to avoid Metal API validation errors.
/// This API is not available on simulator; as a workaround, either disable API validation or separate
/// the rendering into multiple render encoders for other color attachments.
///
/// # Safety
///
/// `render_context` must be a valid pointer.
#[doc(alias = "cp_drawable_render_context_mtl4_end_encoding")]
#[cfg(feature = "objc2-metal")]
#[inline]
pub unsafe fn mtl4_end_encoding(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
) {
extern "C-unwind" {
fn cp_drawable_render_context_mtl4_end_encoding(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
);
}
unsafe { cp_drawable_render_context_mtl4_end_encoding(render_context, command_encoder) }
}
}
extern "C-unwind" {
#[cfg(feature = "objc2-metal")]
#[deprecated = "renamed to `cp_drawable_render_context::draw_mask_on_stencil_attachment`"]
pub fn cp_drawable_render_context_draw_mask_on_stencil_attachment(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
value: u8,
);
}
extern "C-unwind" {
#[cfg(feature = "objc2-metal")]
#[deprecated = "renamed to `cp_drawable_render_context::end_encoding`"]
pub fn cp_drawable_render_context_end_encoding(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
);
}
extern "C-unwind" {
#[cfg(feature = "objc2-metal")]
#[deprecated = "renamed to `cp_drawable_render_context::mtl4_draw_mask_on_stencil_attachment`"]
pub fn cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
value: u8,
);
}
extern "C-unwind" {
#[cfg(feature = "objc2-metal")]
#[deprecated = "renamed to `cp_drawable_render_context::mtl4_end_encoding`"]
pub fn cp_drawable_render_context_mtl4_end_encoding(
render_context: cp_drawable_render_context_t,
command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
);
}