1use std::ffi::c_void;
6
7use mtl_foundation::{Referencing, UInteger};
8use mtl_sys::sel;
9
10use crate::Buffer;
11use crate::Texture;
12
13use super::RenderCommandEncoder;
14
15impl RenderCommandEncoder {
16 #[inline]
24 pub fn set_object_buffer(&self, buffer: &Buffer, offset: UInteger, index: UInteger) {
25 unsafe {
26 mtl_sys::msg_send_3::<(), *const c_void, UInteger, UInteger>(
27 self.as_ptr(),
28 sel!(setObjectBuffer: offset: atIndex:),
29 buffer.as_ptr(),
30 offset,
31 index,
32 );
33 }
34 }
35
36 #[inline]
40 pub fn set_object_texture(&self, texture: &Texture, index: UInteger) {
41 unsafe {
42 mtl_sys::msg_send_2::<(), *const c_void, UInteger>(
43 self.as_ptr(),
44 sel!(setObjectTexture: atIndex:),
45 texture.as_ptr(),
46 index,
47 );
48 }
49 }
50
51 #[inline]
55 pub fn set_object_sampler_state(&self, sampler: &crate::SamplerState, index: UInteger) {
56 unsafe {
57 mtl_sys::msg_send_2::<(), *const c_void, UInteger>(
58 self.as_ptr(),
59 sel!(setObjectSamplerState: atIndex:),
60 sampler.as_ptr(),
61 index,
62 );
63 }
64 }
65
66 #[inline]
70 pub fn set_object_threadgroup_memory_length(&self, length: UInteger, index: UInteger) {
71 unsafe {
72 mtl_sys::msg_send_2::<(), UInteger, UInteger>(
73 self.as_ptr(),
74 sel!(setObjectThreadgroupMemoryLength: atIndex:),
75 length,
76 index,
77 );
78 }
79 }
80
81 #[inline]
85 pub fn set_object_buffer_offset(&self, offset: UInteger, index: UInteger) {
86 unsafe {
87 mtl_sys::msg_send_2::<(), UInteger, UInteger>(
88 self.as_ptr(),
89 sel!(setObjectBufferOffset: atIndex:),
90 offset,
91 index,
92 );
93 }
94 }
95
96 #[inline]
100 pub fn set_object_bytes(&self, bytes: &[u8], index: UInteger) {
101 unsafe {
102 mtl_sys::msg_send_3::<(), *const c_void, UInteger, UInteger>(
103 self.as_ptr(),
104 sel!(setObjectBytes: length: atIndex:),
105 bytes.as_ptr() as *const c_void,
106 bytes.len() as UInteger,
107 index,
108 );
109 }
110 }
111
112 #[inline]
120 pub unsafe fn set_object_buffers_ptr(
121 &self,
122 buffers: *const *const c_void,
123 offsets: *const UInteger,
124 range_location: UInteger,
125 range_length: UInteger,
126 ) {
127 let range = mtl_foundation::Range::new(range_location, range_length);
128 unsafe {
129 mtl_sys::msg_send_3::<
130 (),
131 *const *const c_void,
132 *const UInteger,
133 mtl_foundation::Range,
134 >(
135 self.as_ptr(),
136 sel!(setObjectBuffers: offsets: withRange:),
137 buffers,
138 offsets,
139 range,
140 );
141 }
142 }
143
144 #[inline]
152 pub unsafe fn set_object_textures_ptr(
153 &self,
154 textures: *const *const c_void,
155 range_location: UInteger,
156 range_length: UInteger,
157 ) {
158 let range = mtl_foundation::Range::new(range_location, range_length);
159 unsafe {
160 mtl_sys::msg_send_2::<(), *const *const c_void, mtl_foundation::Range>(
161 self.as_ptr(),
162 sel!(setObjectTextures: withRange:),
163 textures,
164 range,
165 );
166 }
167 }
168
169 #[inline]
173 pub fn set_object_sampler_state_with_lod_clamps(
174 &self,
175 sampler: &crate::SamplerState,
176 lod_min_clamp: f32,
177 lod_max_clamp: f32,
178 index: UInteger,
179 ) {
180 unsafe {
181 mtl_sys::msg_send_4::<(), *const c_void, f32, f32, UInteger>(
182 self.as_ptr(),
183 sel!(setObjectSamplerState: lodMinClamp: lodMaxClamp: atIndex:),
184 sampler.as_ptr(),
185 lod_min_clamp,
186 lod_max_clamp,
187 index,
188 );
189 }
190 }
191
192 #[inline]
200 pub unsafe fn set_object_sampler_states_ptr(
201 &self,
202 samplers: *const *const c_void,
203 range_location: UInteger,
204 range_length: UInteger,
205 ) {
206 let range = mtl_foundation::Range::new(range_location, range_length);
207 unsafe {
208 mtl_sys::msg_send_2::<(), *const *const c_void, mtl_foundation::Range>(
209 self.as_ptr(),
210 sel!(setObjectSamplerStates: withRange:),
211 samplers,
212 range,
213 );
214 }
215 }
216
217 #[inline]
225 pub unsafe fn set_object_sampler_states_with_lod_clamps_ptr(
226 &self,
227 samplers: *const *const c_void,
228 lod_min_clamps: *const f32,
229 lod_max_clamps: *const f32,
230 range_location: UInteger,
231 range_length: UInteger,
232 ) {
233 let range = mtl_foundation::Range::new(range_location, range_length);
234 unsafe {
235 mtl_sys::msg_send_4::<
236 (),
237 *const *const c_void,
238 *const f32,
239 *const f32,
240 mtl_foundation::Range,
241 >(
242 self.as_ptr(),
243 sel!(setObjectSamplerStates: lodMinClamps: lodMaxClamps: withRange:),
244 samplers,
245 lod_min_clamps,
246 lod_max_clamps,
247 range,
248 );
249 }
250 }
251
252 #[inline]
260 pub fn set_mesh_buffer(&self, buffer: &Buffer, offset: UInteger, index: UInteger) {
261 unsafe {
262 mtl_sys::msg_send_3::<(), *const c_void, UInteger, UInteger>(
263 self.as_ptr(),
264 sel!(setMeshBuffer: offset: atIndex:),
265 buffer.as_ptr(),
266 offset,
267 index,
268 );
269 }
270 }
271
272 #[inline]
276 pub fn set_mesh_texture(&self, texture: &Texture, index: UInteger) {
277 unsafe {
278 mtl_sys::msg_send_2::<(), *const c_void, UInteger>(
279 self.as_ptr(),
280 sel!(setMeshTexture: atIndex:),
281 texture.as_ptr(),
282 index,
283 );
284 }
285 }
286
287 #[inline]
291 pub fn set_mesh_sampler_state(&self, sampler: &crate::SamplerState, index: UInteger) {
292 unsafe {
293 mtl_sys::msg_send_2::<(), *const c_void, UInteger>(
294 self.as_ptr(),
295 sel!(setMeshSamplerState: atIndex:),
296 sampler.as_ptr(),
297 index,
298 );
299 }
300 }
301
302 #[inline]
306 pub fn set_mesh_buffer_offset(&self, offset: UInteger, index: UInteger) {
307 unsafe {
308 mtl_sys::msg_send_2::<(), UInteger, UInteger>(
309 self.as_ptr(),
310 sel!(setMeshBufferOffset: atIndex:),
311 offset,
312 index,
313 );
314 }
315 }
316
317 #[inline]
321 pub fn set_mesh_bytes(&self, bytes: &[u8], index: UInteger) {
322 unsafe {
323 mtl_sys::msg_send_3::<(), *const c_void, UInteger, UInteger>(
324 self.as_ptr(),
325 sel!(setMeshBytes: length: atIndex:),
326 bytes.as_ptr() as *const c_void,
327 bytes.len() as UInteger,
328 index,
329 );
330 }
331 }
332
333 #[inline]
341 pub unsafe fn set_mesh_buffers_ptr(
342 &self,
343 buffers: *const *const c_void,
344 offsets: *const UInteger,
345 range_location: UInteger,
346 range_length: UInteger,
347 ) {
348 let range = mtl_foundation::Range::new(range_location, range_length);
349 unsafe {
350 mtl_sys::msg_send_3::<
351 (),
352 *const *const c_void,
353 *const UInteger,
354 mtl_foundation::Range,
355 >(
356 self.as_ptr(),
357 sel!(setMeshBuffers: offsets: withRange:),
358 buffers,
359 offsets,
360 range,
361 );
362 }
363 }
364
365 #[inline]
373 pub unsafe fn set_mesh_textures_ptr(
374 &self,
375 textures: *const *const c_void,
376 range_location: UInteger,
377 range_length: UInteger,
378 ) {
379 let range = mtl_foundation::Range::new(range_location, range_length);
380 unsafe {
381 mtl_sys::msg_send_2::<(), *const *const c_void, mtl_foundation::Range>(
382 self.as_ptr(),
383 sel!(setMeshTextures: withRange:),
384 textures,
385 range,
386 );
387 }
388 }
389
390 #[inline]
394 pub fn set_mesh_sampler_state_with_lod_clamps(
395 &self,
396 sampler: &crate::SamplerState,
397 lod_min_clamp: f32,
398 lod_max_clamp: f32,
399 index: UInteger,
400 ) {
401 unsafe {
402 mtl_sys::msg_send_4::<(), *const c_void, f32, f32, UInteger>(
403 self.as_ptr(),
404 sel!(setMeshSamplerState: lodMinClamp: lodMaxClamp: atIndex:),
405 sampler.as_ptr(),
406 lod_min_clamp,
407 lod_max_clamp,
408 index,
409 );
410 }
411 }
412
413 #[inline]
421 pub unsafe fn set_mesh_sampler_states_ptr(
422 &self,
423 samplers: *const *const c_void,
424 range_location: UInteger,
425 range_length: UInteger,
426 ) {
427 let range = mtl_foundation::Range::new(range_location, range_length);
428 unsafe {
429 mtl_sys::msg_send_2::<(), *const *const c_void, mtl_foundation::Range>(
430 self.as_ptr(),
431 sel!(setMeshSamplerStates: withRange:),
432 samplers,
433 range,
434 );
435 }
436 }
437
438 #[inline]
446 pub unsafe fn set_mesh_sampler_states_with_lod_clamps_ptr(
447 &self,
448 samplers: *const *const c_void,
449 lod_min_clamps: *const f32,
450 lod_max_clamps: *const f32,
451 range_location: UInteger,
452 range_length: UInteger,
453 ) {
454 let range = mtl_foundation::Range::new(range_location, range_length);
455 unsafe {
456 mtl_sys::msg_send_4::<
457 (),
458 *const *const c_void,
459 *const f32,
460 *const f32,
461 mtl_foundation::Range,
462 >(
463 self.as_ptr(),
464 sel!(setMeshSamplerStates: lodMinClamps: lodMaxClamps: withRange:),
465 samplers,
466 lod_min_clamps,
467 lod_max_clamps,
468 range,
469 );
470 }
471 }
472}