@bloomengine/engine 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/native/tvos/metal-patched/Cargo.toml +178 -0
- package/native/tvos/metal-patched/LICENSE-APACHE +201 -0
- package/native/tvos/metal-patched/LICENSE-MIT +25 -0
- package/native/tvos/metal-patched/src/acceleration_structure.rs +667 -0
- package/native/tvos/metal-patched/src/acceleration_structure_pass.rs +108 -0
- package/native/tvos/metal-patched/src/argument.rs +366 -0
- package/native/tvos/metal-patched/src/blitpass.rs +102 -0
- package/native/tvos/metal-patched/src/buffer.rs +71 -0
- package/native/tvos/metal-patched/src/capturedescriptor.rs +76 -0
- package/native/tvos/metal-patched/src/capturemanager.rs +113 -0
- package/native/tvos/metal-patched/src/commandbuffer.rs +192 -0
- package/native/tvos/metal-patched/src/commandqueue.rs +44 -0
- package/native/tvos/metal-patched/src/computepass.rs +107 -0
- package/native/tvos/metal-patched/src/constants.rs +152 -0
- package/native/tvos/metal-patched/src/counters.rs +119 -0
- package/native/tvos/metal-patched/src/depthstencil.rs +190 -0
- package/native/tvos/metal-patched/src/device.rs +2134 -0
- package/native/tvos/metal-patched/src/drawable.rs +39 -0
- package/native/tvos/metal-patched/src/encoder.rs +2041 -0
- package/native/tvos/metal-patched/src/heap.rs +281 -0
- package/native/tvos/metal-patched/src/indirect_encoder.rs +344 -0
- package/native/tvos/metal-patched/src/lib.rs +657 -0
- package/native/tvos/metal-patched/src/library.rs +902 -0
- package/native/tvos/metal-patched/src/mps.rs +575 -0
- package/native/tvos/metal-patched/src/pipeline/compute.rs +475 -0
- package/native/tvos/metal-patched/src/pipeline/mod.rs +71 -0
- package/native/tvos/metal-patched/src/pipeline/render.rs +762 -0
- package/native/tvos/metal-patched/src/renderpass.rs +443 -0
- package/native/tvos/metal-patched/src/resource.rs +182 -0
- package/native/tvos/metal-patched/src/sampler.rs +165 -0
- package/native/tvos/metal-patched/src/sync.rs +178 -0
- package/native/tvos/metal-patched/src/texture.rs +352 -0
- package/native/tvos/metal-patched/src/types.rs +90 -0
- package/native/tvos/metal-patched/src/vertexdescriptor.rs +250 -0
- package/package.json +5 -1
|
@@ -0,0 +1,2041 @@
|
|
|
1
|
+
// Copyright 2017 GFX developers
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
|
|
4
|
+
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
|
|
5
|
+
// http://opensource.org/licenses/MIT>, at your option. This file may not be
|
|
6
|
+
// copied, modified, or distributed except according to those terms.
|
|
7
|
+
|
|
8
|
+
use super::*;
|
|
9
|
+
|
|
10
|
+
use std::ops::Range;
|
|
11
|
+
|
|
12
|
+
/// See <https://developer.apple.com/documentation/metal/mtlcounterdontsample>
|
|
13
|
+
pub const COUNTER_DONT_SAMPLE: NSUInteger = NSUInteger::MAX; // #define MTLCounterDontSample ((NSUInteger)-1)
|
|
14
|
+
|
|
15
|
+
/// See <https://developer.apple.com/documentation/metal/mtlprimitivetype>
|
|
16
|
+
#[repr(u64)]
|
|
17
|
+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
|
18
|
+
pub enum MTLPrimitiveType {
|
|
19
|
+
Point = 0,
|
|
20
|
+
Line = 1,
|
|
21
|
+
LineStrip = 2,
|
|
22
|
+
Triangle = 3,
|
|
23
|
+
TriangleStrip = 4,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// See <https://developer.apple.com/documentation/metal/mtlindextype>
|
|
27
|
+
#[repr(u64)]
|
|
28
|
+
#[allow(non_camel_case_types)]
|
|
29
|
+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
|
30
|
+
pub enum MTLIndexType {
|
|
31
|
+
UInt16 = 0,
|
|
32
|
+
UInt32 = 1,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// See <https://developer.apple.com/documentation/metal/mtlvisibilityresultmode>
|
|
36
|
+
#[repr(u64)]
|
|
37
|
+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
|
38
|
+
pub enum MTLVisibilityResultMode {
|
|
39
|
+
Disabled = 0,
|
|
40
|
+
Boolean = 1,
|
|
41
|
+
Counting = 2,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// See <https://developer.apple.com/documentation/metal/mtlcullmode>
|
|
45
|
+
#[repr(u64)]
|
|
46
|
+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
|
47
|
+
pub enum MTLCullMode {
|
|
48
|
+
None = 0,
|
|
49
|
+
Front = 1,
|
|
50
|
+
Back = 2,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/// See <https://developer.apple.com/documentation/metal/mtlwinding>
|
|
54
|
+
#[repr(u64)]
|
|
55
|
+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
|
56
|
+
pub enum MTLWinding {
|
|
57
|
+
Clockwise = 0,
|
|
58
|
+
CounterClockwise = 1,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// See <https://developer.apple.com/documentation/metal/mtldepthclipmode>
|
|
62
|
+
#[repr(u64)]
|
|
63
|
+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
|
64
|
+
pub enum MTLDepthClipMode {
|
|
65
|
+
Clip = 0,
|
|
66
|
+
Clamp = 1,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// See <https://developer.apple.com/documentation/metal/mtltrianglefillmode>
|
|
70
|
+
#[repr(u64)]
|
|
71
|
+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
|
72
|
+
pub enum MTLTriangleFillMode {
|
|
73
|
+
Fill = 0,
|
|
74
|
+
Lines = 1,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
bitflags::bitflags! {
|
|
78
|
+
/// https://developer.apple.com/documentation/metal/mtlblitoption
|
|
79
|
+
#[allow(non_upper_case_globals)]
|
|
80
|
+
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
|
81
|
+
pub struct MTLBlitOption: NSUInteger {
|
|
82
|
+
/// https://developer.apple.com/documentation/metal/mtlblitoption/mtlblitoptionnone
|
|
83
|
+
const None = 0;
|
|
84
|
+
/// https://developer.apple.com/documentation/metal/mtlblitoption/mtlblitoptiondepthfromdepthstencil
|
|
85
|
+
const DepthFromDepthStencil = 1 << 0;
|
|
86
|
+
/// https://developer.apple.com/documentation/metal/mtlblitoption/mtlblitoptionstencilfromdepthstencil
|
|
87
|
+
const StencilFromDepthStencil = 1 << 1;
|
|
88
|
+
/// https://developer.apple.com/documentation/metal/mtlblitoption/mtlblitoptionrowlinearpvrtc
|
|
89
|
+
const RowLinearPVRTC = 1 << 2;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// See <https://developer.apple.com/documentation/metal/mtlscissorrect>
|
|
94
|
+
#[repr(C)]
|
|
95
|
+
#[derive(Copy, Clone, Debug)]
|
|
96
|
+
pub struct MTLScissorRect {
|
|
97
|
+
pub x: NSUInteger,
|
|
98
|
+
pub y: NSUInteger,
|
|
99
|
+
pub width: NSUInteger,
|
|
100
|
+
pub height: NSUInteger,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// See <https://developer.apple.com/documentation/metal/mtlviewport>
|
|
104
|
+
#[repr(C)]
|
|
105
|
+
#[derive(Copy, Clone, Debug)]
|
|
106
|
+
pub struct MTLViewport {
|
|
107
|
+
pub originX: f64,
|
|
108
|
+
pub originY: f64,
|
|
109
|
+
pub width: f64,
|
|
110
|
+
pub height: f64,
|
|
111
|
+
pub znear: f64,
|
|
112
|
+
pub zfar: f64,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/// See <https://developer.apple.com/documentation/metal/mtldrawprimitivesindirectarguments>
|
|
116
|
+
#[repr(C)]
|
|
117
|
+
#[derive(Copy, Clone, Debug)]
|
|
118
|
+
pub struct MTLDrawPrimitivesIndirectArguments {
|
|
119
|
+
pub vertexCount: u32,
|
|
120
|
+
pub instanceCount: u32,
|
|
121
|
+
pub vertexStart: u32,
|
|
122
|
+
pub baseInstance: u32,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/// See <https://developer.apple.com/documentation/metal/mtldrawindexedprimitivesindirectarguments>
|
|
126
|
+
#[repr(C)]
|
|
127
|
+
#[derive(Copy, Clone, Debug)]
|
|
128
|
+
pub struct MTLDrawIndexedPrimitivesIndirectArguments {
|
|
129
|
+
pub indexCount: u32,
|
|
130
|
+
pub instanceCount: u32,
|
|
131
|
+
pub indexStart: u32,
|
|
132
|
+
pub baseVertex: i32,
|
|
133
|
+
pub baseInstance: u32,
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/// See <https://developer.apple.com/documentation/metal/mtlvertexamplificationviewmapping>
|
|
137
|
+
#[repr(C)]
|
|
138
|
+
#[derive(Copy, Clone, Debug)]
|
|
139
|
+
pub struct VertexAmplificationViewMapping {
|
|
140
|
+
pub renderTargetArrayIndexOffset: u32,
|
|
141
|
+
pub viewportArrayIndexOffset: u32,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
#[allow(dead_code)]
|
|
145
|
+
type MTLVertexAmplicationViewMapping = VertexAmplificationViewMapping;
|
|
146
|
+
|
|
147
|
+
/// See <https://developer.apple.com/documentation/metal/mtlcommandencoder>
|
|
148
|
+
pub enum MTLCommandEncoder {}
|
|
149
|
+
|
|
150
|
+
foreign_obj_type! {
|
|
151
|
+
type CType = MTLCommandEncoder;
|
|
152
|
+
pub struct CommandEncoder;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
impl CommandEncoderRef {
|
|
156
|
+
pub fn label(&self) -> &str {
|
|
157
|
+
unsafe {
|
|
158
|
+
let label = msg_send![self, label];
|
|
159
|
+
crate::nsstring_as_str(label)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
pub fn set_label(&self, label: &str) {
|
|
164
|
+
unsafe {
|
|
165
|
+
let nslabel = crate::nsstring_from_str(label);
|
|
166
|
+
msg_send![self, setLabel: nslabel]
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
pub fn end_encoding(&self) {
|
|
171
|
+
unsafe { msg_send![self, endEncoding] }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
pub fn insert_debug_signpost(&self, name: &str) {
|
|
175
|
+
unsafe {
|
|
176
|
+
let nslabel = crate::nsstring_from_str(name);
|
|
177
|
+
msg_send![self, insertDebugSignpost: nslabel]
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
pub fn push_debug_group(&self, name: &str) {
|
|
182
|
+
unsafe {
|
|
183
|
+
let nslabel = crate::nsstring_from_str(name);
|
|
184
|
+
msg_send![self, pushDebugGroup: nslabel]
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
pub fn pop_debug_group(&self) {
|
|
189
|
+
unsafe { msg_send![self, popDebugGroup] }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/// See <https://developer.apple.com/documentation/metal/mtlparallelrendercommandencoder>
|
|
194
|
+
pub enum MTLParallelRenderCommandEncoder {}
|
|
195
|
+
|
|
196
|
+
foreign_obj_type! {
|
|
197
|
+
type CType = MTLParallelRenderCommandEncoder;
|
|
198
|
+
pub struct ParallelRenderCommandEncoder;
|
|
199
|
+
type ParentType = CommandEncoder;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
impl ParallelRenderCommandEncoderRef {
|
|
203
|
+
pub fn render_command_encoder(&self) -> &RenderCommandEncoderRef {
|
|
204
|
+
unsafe { msg_send![self, renderCommandEncoder] }
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/// See <https://developer.apple.com/documentation/metal/mtlrendercommandencoder/>
|
|
209
|
+
pub enum MTLRenderCommandEncoder {}
|
|
210
|
+
|
|
211
|
+
foreign_obj_type! {
|
|
212
|
+
type CType = MTLRenderCommandEncoder;
|
|
213
|
+
pub struct RenderCommandEncoder;
|
|
214
|
+
type ParentType = CommandEncoder;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
impl RenderCommandEncoderRef {
|
|
218
|
+
pub fn set_render_pipeline_state(&self, pipeline_state: &RenderPipelineStateRef) {
|
|
219
|
+
unsafe { msg_send![self, setRenderPipelineState: pipeline_state] }
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
pub fn set_viewport(&self, viewport: MTLViewport) {
|
|
223
|
+
unsafe { msg_send![self, setViewport: viewport] }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
pub fn set_front_facing_winding(&self, winding: MTLWinding) {
|
|
227
|
+
unsafe { msg_send![self, setFrontFacingWinding: winding] }
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
pub fn set_cull_mode(&self, mode: MTLCullMode) {
|
|
231
|
+
unsafe { msg_send![self, setCullMode: mode] }
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
pub fn set_depth_clip_mode(&self, mode: MTLDepthClipMode) {
|
|
235
|
+
unsafe { msg_send![self, setDepthClipMode: mode] }
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
pub fn set_depth_bias(&self, bias: f32, scale: f32, clamp: f32) {
|
|
239
|
+
unsafe {
|
|
240
|
+
msg_send![self, setDepthBias:bias
|
|
241
|
+
slopeScale:scale
|
|
242
|
+
clamp:clamp]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
pub fn set_scissor_rect(&self, rect: MTLScissorRect) {
|
|
247
|
+
unsafe { msg_send![self, setScissorRect: rect] }
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
pub fn set_triangle_fill_mode(&self, mode: MTLTriangleFillMode) {
|
|
251
|
+
unsafe { msg_send![self, setTriangleFillMode: mode] }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
pub fn set_blend_color(&self, red: f32, green: f32, blue: f32, alpha: f32) {
|
|
255
|
+
unsafe {
|
|
256
|
+
msg_send![self, setBlendColorRed:red
|
|
257
|
+
green:green
|
|
258
|
+
blue:blue
|
|
259
|
+
alpha:alpha]
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
pub fn set_depth_stencil_state(&self, depth_stencil_state: &DepthStencilStateRef) {
|
|
264
|
+
unsafe { msg_send![self, setDepthStencilState: depth_stencil_state] }
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
pub fn set_stencil_reference_value(&self, value: u32) {
|
|
268
|
+
unsafe { msg_send![self, setStencilReferenceValue: value] }
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
pub fn set_stencil_front_back_reference_value(&self, front: u32, back: u32) {
|
|
272
|
+
unsafe {
|
|
273
|
+
msg_send![self, setStencilFrontReferenceValue:front
|
|
274
|
+
backReferenceValue:back]
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
pub fn set_visibility_result_mode(&self, mode: MTLVisibilityResultMode, offset: NSUInteger) {
|
|
279
|
+
unsafe {
|
|
280
|
+
msg_send![self, setVisibilityResultMode:mode
|
|
281
|
+
offset:offset]
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
pub fn set_vertex_amplification_count(
|
|
286
|
+
&self,
|
|
287
|
+
count: NSUInteger,
|
|
288
|
+
view_mappings: Option<&[VertexAmplificationViewMapping]>,
|
|
289
|
+
) {
|
|
290
|
+
unsafe {
|
|
291
|
+
msg_send! [self, setVertexAmplificationCount: count viewMappings: view_mappings.map_or(std::ptr::null(), |vm| vm.as_ptr())]
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Specifying Resources for a Vertex Shader Function
|
|
296
|
+
|
|
297
|
+
pub fn set_vertex_bytes(
|
|
298
|
+
&self,
|
|
299
|
+
index: NSUInteger,
|
|
300
|
+
length: NSUInteger,
|
|
301
|
+
bytes: *const std::ffi::c_void,
|
|
302
|
+
) {
|
|
303
|
+
unsafe {
|
|
304
|
+
msg_send![self,
|
|
305
|
+
setVertexBytes:bytes
|
|
306
|
+
length:length
|
|
307
|
+
atIndex:index
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
pub fn set_vertex_buffer(
|
|
313
|
+
&self,
|
|
314
|
+
index: NSUInteger,
|
|
315
|
+
buffer: Option<&BufferRef>,
|
|
316
|
+
offset: NSUInteger,
|
|
317
|
+
) {
|
|
318
|
+
unsafe {
|
|
319
|
+
msg_send![self,
|
|
320
|
+
setVertexBuffer:buffer
|
|
321
|
+
offset:offset
|
|
322
|
+
atIndex:index
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
pub fn set_vertex_buffer_offset(&self, index: NSUInteger, offset: NSUInteger) {
|
|
328
|
+
unsafe {
|
|
329
|
+
msg_send![self,
|
|
330
|
+
setVertexBufferOffset:offset
|
|
331
|
+
atIndex:index
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
pub fn set_vertex_buffers(
|
|
337
|
+
&self,
|
|
338
|
+
start_index: NSUInteger,
|
|
339
|
+
data: &[Option<&BufferRef>],
|
|
340
|
+
offsets: &[NSUInteger],
|
|
341
|
+
) {
|
|
342
|
+
debug_assert_eq!(offsets.len(), data.len());
|
|
343
|
+
unsafe {
|
|
344
|
+
msg_send![self,
|
|
345
|
+
setVertexBuffers: data.as_ptr()
|
|
346
|
+
offsets: offsets.as_ptr()
|
|
347
|
+
withRange: NSRange {
|
|
348
|
+
location: start_index,
|
|
349
|
+
length: data.len() as _,
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
pub fn set_vertex_texture(&self, index: NSUInteger, texture: Option<&TextureRef>) {
|
|
356
|
+
unsafe {
|
|
357
|
+
msg_send![self,
|
|
358
|
+
setVertexTexture:texture
|
|
359
|
+
atIndex:index
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
pub fn set_vertex_textures(&self, start_index: NSUInteger, data: &[Option<&TextureRef>]) {
|
|
365
|
+
unsafe {
|
|
366
|
+
msg_send![self,
|
|
367
|
+
setVertexTextures: data.as_ptr()
|
|
368
|
+
withRange: NSRange {
|
|
369
|
+
location: start_index,
|
|
370
|
+
length: data.len() as _,
|
|
371
|
+
}
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
pub fn set_vertex_sampler_state(&self, index: NSUInteger, sampler: Option<&SamplerStateRef>) {
|
|
377
|
+
unsafe {
|
|
378
|
+
msg_send![self,
|
|
379
|
+
setVertexSamplerState:sampler
|
|
380
|
+
atIndex:index
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
pub fn set_vertex_sampler_states(
|
|
386
|
+
&self,
|
|
387
|
+
start_index: NSUInteger,
|
|
388
|
+
data: &[Option<&SamplerStateRef>],
|
|
389
|
+
) {
|
|
390
|
+
unsafe {
|
|
391
|
+
msg_send![self,
|
|
392
|
+
setVertexSamplerStates: data.as_ptr()
|
|
393
|
+
withRange: NSRange {
|
|
394
|
+
location: start_index,
|
|
395
|
+
length: data.len() as _,
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
pub fn set_vertex_sampler_state_with_lod(
|
|
402
|
+
&self,
|
|
403
|
+
index: NSUInteger,
|
|
404
|
+
sampler: Option<&SamplerStateRef>,
|
|
405
|
+
lod_clamp: Range<f32>,
|
|
406
|
+
) {
|
|
407
|
+
unsafe {
|
|
408
|
+
msg_send![self,
|
|
409
|
+
setVertexSamplerState:sampler
|
|
410
|
+
lodMinClamp:lod_clamp.start
|
|
411
|
+
lodMaxClamp:lod_clamp.end
|
|
412
|
+
atIndex:index
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/// Only available in (macos(12.0), ios(15.0))
|
|
418
|
+
pub fn set_vertex_acceleration_structure(
|
|
419
|
+
&self,
|
|
420
|
+
index: NSUInteger,
|
|
421
|
+
accel: Option<&AccelerationStructureRef>,
|
|
422
|
+
) {
|
|
423
|
+
unsafe {
|
|
424
|
+
msg_send![
|
|
425
|
+
self,
|
|
426
|
+
setVertexAccelerationStructure: accel
|
|
427
|
+
atBufferIndex: index
|
|
428
|
+
]
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/// Only available in (macos(12.0), ios(15.0))
|
|
433
|
+
pub fn set_vertex_intersection_function_table(
|
|
434
|
+
&self,
|
|
435
|
+
index: NSUInteger,
|
|
436
|
+
table: Option<&IntersectionFunctionTableRef>,
|
|
437
|
+
) {
|
|
438
|
+
unsafe {
|
|
439
|
+
msg_send![
|
|
440
|
+
self,
|
|
441
|
+
setVertexIntersectionFunctionTable: table
|
|
442
|
+
atBufferIndex: index
|
|
443
|
+
]
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
pub fn set_vertex_visible_function_table(
|
|
448
|
+
&self,
|
|
449
|
+
buffer_index: NSUInteger,
|
|
450
|
+
visible_function_table: Option<&VisibleFunctionTableRef>,
|
|
451
|
+
) {
|
|
452
|
+
unsafe {
|
|
453
|
+
msg_send![self,
|
|
454
|
+
setVertexVisibleFunctionTable:visible_function_table
|
|
455
|
+
atBufferIndex:buffer_index]
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
pub fn set_vertex_visible_function_tables(
|
|
460
|
+
&self,
|
|
461
|
+
buffer_start_index: NSUInteger,
|
|
462
|
+
visible_function_tables: &[&VisibleFunctionTableRef],
|
|
463
|
+
) {
|
|
464
|
+
unsafe {
|
|
465
|
+
msg_send![self,
|
|
466
|
+
setVertexVisibleFunctionTables:visible_function_tables.as_ptr()
|
|
467
|
+
withBufferRange: NSRange {
|
|
468
|
+
location: buffer_start_index,
|
|
469
|
+
length: visible_function_tables.len() as _,
|
|
470
|
+
}
|
|
471
|
+
]
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Specifying Resources for a Object Shader Function
|
|
476
|
+
|
|
477
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
478
|
+
pub fn set_object_buffer(
|
|
479
|
+
&self,
|
|
480
|
+
index: NSUInteger,
|
|
481
|
+
buffer: Option<&BufferRef>,
|
|
482
|
+
offset: NSUInteger,
|
|
483
|
+
) {
|
|
484
|
+
unsafe {
|
|
485
|
+
msg_send![self,
|
|
486
|
+
setObjectBuffer:buffer
|
|
487
|
+
offset:offset
|
|
488
|
+
atIndex:index
|
|
489
|
+
]
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
494
|
+
pub fn set_object_buffer_offset(&self, index: NSUInteger, offset: NSUInteger) {
|
|
495
|
+
unsafe {
|
|
496
|
+
msg_send![self,
|
|
497
|
+
setObjectBufferOffset:offset
|
|
498
|
+
atIndex:index
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
504
|
+
pub fn set_object_bytes(
|
|
505
|
+
&self,
|
|
506
|
+
index: NSUInteger,
|
|
507
|
+
length: NSUInteger,
|
|
508
|
+
bytes: *const std::ffi::c_void,
|
|
509
|
+
) {
|
|
510
|
+
unsafe {
|
|
511
|
+
msg_send![self,
|
|
512
|
+
setObjectBytes:bytes
|
|
513
|
+
length:length
|
|
514
|
+
atIndex:index
|
|
515
|
+
]
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
520
|
+
pub fn set_object_sampler_state(&self, index: NSUInteger, sampler: Option<&SamplerStateRef>) {
|
|
521
|
+
unsafe {
|
|
522
|
+
msg_send![self,
|
|
523
|
+
setObjectSamplerState:sampler
|
|
524
|
+
atIndex:index
|
|
525
|
+
]
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
530
|
+
pub fn set_object_sampler_state_with_lod(
|
|
531
|
+
&self,
|
|
532
|
+
index: NSUInteger,
|
|
533
|
+
sampler: Option<&SamplerStateRef>,
|
|
534
|
+
lod_clamp: Range<f32>,
|
|
535
|
+
) {
|
|
536
|
+
unsafe {
|
|
537
|
+
msg_send![self,
|
|
538
|
+
setObjectSamplerState:sampler
|
|
539
|
+
lodMinClamp:lod_clamp.start
|
|
540
|
+
lodMaxClamp:lod_clamp.end
|
|
541
|
+
atIndex:index
|
|
542
|
+
]
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
547
|
+
pub fn set_object_texture(&self, index: NSUInteger, texture: Option<&TextureRef>) {
|
|
548
|
+
unsafe {
|
|
549
|
+
msg_send![self,
|
|
550
|
+
setObjectTexture:texture
|
|
551
|
+
atIndex:index
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
557
|
+
pub fn set_object_threadgroup_memory_length(&self, index: NSUInteger, length: NSUInteger) {
|
|
558
|
+
unsafe {
|
|
559
|
+
msg_send![self,
|
|
560
|
+
setObjectThreadgroupMemoryLength: length
|
|
561
|
+
atIndex: index
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
567
|
+
pub fn set_object_buffers(
|
|
568
|
+
&self,
|
|
569
|
+
start_index: NSUInteger,
|
|
570
|
+
data: &[Option<&BufferRef>],
|
|
571
|
+
offsets: &[NSUInteger],
|
|
572
|
+
) {
|
|
573
|
+
debug_assert_eq!(offsets.len(), data.len());
|
|
574
|
+
unsafe {
|
|
575
|
+
msg_send![self,
|
|
576
|
+
setObjectBuffers: data.as_ptr()
|
|
577
|
+
offsets: offsets.as_ptr()
|
|
578
|
+
withRange: NSRange {
|
|
579
|
+
location: start_index,
|
|
580
|
+
length: data.len() as _,
|
|
581
|
+
}
|
|
582
|
+
]
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
587
|
+
pub fn set_object_sampler_states(
|
|
588
|
+
&self,
|
|
589
|
+
start_index: NSUInteger,
|
|
590
|
+
data: &[Option<&SamplerStateRef>],
|
|
591
|
+
) {
|
|
592
|
+
unsafe {
|
|
593
|
+
msg_send![self,
|
|
594
|
+
setObjectSamplerStates: data.as_ptr()
|
|
595
|
+
withRange: NSRange {
|
|
596
|
+
location: start_index,
|
|
597
|
+
length: data.len() as _,
|
|
598
|
+
}
|
|
599
|
+
]
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
604
|
+
pub fn set_object_textures(&self, start_index: NSUInteger, data: &[Option<&TextureRef>]) {
|
|
605
|
+
unsafe {
|
|
606
|
+
msg_send![self,
|
|
607
|
+
setObjectTextures: data.as_ptr()
|
|
608
|
+
withRange: NSRange {
|
|
609
|
+
location: start_index,
|
|
610
|
+
length: data.len() as _,
|
|
611
|
+
}
|
|
612
|
+
]
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Specifying Resources for a Mesh Shader
|
|
617
|
+
|
|
618
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
619
|
+
pub fn set_mesh_buffer(
|
|
620
|
+
&self,
|
|
621
|
+
index: NSUInteger,
|
|
622
|
+
buffer: Option<&BufferRef>,
|
|
623
|
+
offset: NSUInteger,
|
|
624
|
+
) {
|
|
625
|
+
unsafe {
|
|
626
|
+
msg_send![self,
|
|
627
|
+
setMeshBuffer:buffer
|
|
628
|
+
offset:offset
|
|
629
|
+
atIndex:index
|
|
630
|
+
]
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
635
|
+
pub fn set_mesh_buffer_offset(&self, index: NSUInteger, offset: NSUInteger) {
|
|
636
|
+
unsafe {
|
|
637
|
+
msg_send![self,
|
|
638
|
+
setMeshBufferOffset:offset
|
|
639
|
+
atIndex:index
|
|
640
|
+
]
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
645
|
+
pub fn set_mesh_bytes(
|
|
646
|
+
&self,
|
|
647
|
+
index: NSUInteger,
|
|
648
|
+
length: NSUInteger,
|
|
649
|
+
bytes: *const std::ffi::c_void,
|
|
650
|
+
) {
|
|
651
|
+
unsafe {
|
|
652
|
+
msg_send![self,
|
|
653
|
+
setMeshBytes:bytes
|
|
654
|
+
length:length
|
|
655
|
+
atIndex:index
|
|
656
|
+
]
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
661
|
+
pub fn set_mesh_sampler_state(&self, index: NSUInteger, sampler: Option<&SamplerStateRef>) {
|
|
662
|
+
unsafe {
|
|
663
|
+
msg_send![self,
|
|
664
|
+
setMeshSamplerState:sampler
|
|
665
|
+
atIndex:index
|
|
666
|
+
]
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
671
|
+
pub fn set_mesh_sampler_state_with_lod(
|
|
672
|
+
&self,
|
|
673
|
+
index: NSUInteger,
|
|
674
|
+
sampler: Option<&SamplerStateRef>,
|
|
675
|
+
lod_clamp: Range<f32>,
|
|
676
|
+
) {
|
|
677
|
+
unsafe {
|
|
678
|
+
msg_send![self,
|
|
679
|
+
setMeshSamplerState:sampler
|
|
680
|
+
lodMinClamp:lod_clamp.start
|
|
681
|
+
lodMaxClamp:lod_clamp.end
|
|
682
|
+
atIndex:index
|
|
683
|
+
]
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
688
|
+
pub fn set_mesh_texture(&self, index: NSUInteger, texture: Option<&TextureRef>) {
|
|
689
|
+
unsafe {
|
|
690
|
+
msg_send![self,
|
|
691
|
+
setMeshTexture:texture
|
|
692
|
+
atIndex:index
|
|
693
|
+
]
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
698
|
+
pub fn set_mesh_buffers(
|
|
699
|
+
&self,
|
|
700
|
+
start_index: NSUInteger,
|
|
701
|
+
data: &[Option<&BufferRef>],
|
|
702
|
+
offsets: &[NSUInteger],
|
|
703
|
+
) {
|
|
704
|
+
debug_assert_eq!(offsets.len(), data.len());
|
|
705
|
+
unsafe {
|
|
706
|
+
msg_send![self,
|
|
707
|
+
setMeshBuffers: data.as_ptr()
|
|
708
|
+
offsets: offsets.as_ptr()
|
|
709
|
+
withRange: NSRange {
|
|
710
|
+
location: start_index,
|
|
711
|
+
length: data.len() as _,
|
|
712
|
+
}
|
|
713
|
+
]
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
718
|
+
pub fn set_mesh_sampler_states(
|
|
719
|
+
&self,
|
|
720
|
+
start_index: NSUInteger,
|
|
721
|
+
data: &[Option<&SamplerStateRef>],
|
|
722
|
+
) {
|
|
723
|
+
unsafe {
|
|
724
|
+
msg_send![self,
|
|
725
|
+
setMeshSamplerStates: data.as_ptr()
|
|
726
|
+
withRange: NSRange {
|
|
727
|
+
location: start_index,
|
|
728
|
+
length: data.len() as _,
|
|
729
|
+
}
|
|
730
|
+
]
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
735
|
+
pub fn set_mesh_textures(&self, start_index: NSUInteger, data: &[Option<&TextureRef>]) {
|
|
736
|
+
unsafe {
|
|
737
|
+
msg_send![self,
|
|
738
|
+
setMeshTextures: data.as_ptr()
|
|
739
|
+
withRange: NSRange {
|
|
740
|
+
location: start_index,
|
|
741
|
+
length: data.len() as _,
|
|
742
|
+
}
|
|
743
|
+
]
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// Specifying Resources for a Fragment Shader Function
|
|
748
|
+
|
|
749
|
+
pub fn set_fragment_bytes(
|
|
750
|
+
&self,
|
|
751
|
+
index: NSUInteger,
|
|
752
|
+
length: NSUInteger,
|
|
753
|
+
bytes: *const std::ffi::c_void,
|
|
754
|
+
) {
|
|
755
|
+
unsafe {
|
|
756
|
+
msg_send![self,
|
|
757
|
+
setFragmentBytes:bytes
|
|
758
|
+
length:length
|
|
759
|
+
atIndex:index
|
|
760
|
+
]
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
pub fn set_fragment_buffer(
|
|
765
|
+
&self,
|
|
766
|
+
index: NSUInteger,
|
|
767
|
+
buffer: Option<&BufferRef>,
|
|
768
|
+
offset: NSUInteger,
|
|
769
|
+
) {
|
|
770
|
+
unsafe {
|
|
771
|
+
msg_send![self,
|
|
772
|
+
setFragmentBuffer:buffer
|
|
773
|
+
offset:offset
|
|
774
|
+
atIndex:index
|
|
775
|
+
]
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
pub fn set_fragment_buffer_offset(&self, index: NSUInteger, offset: NSUInteger) {
|
|
780
|
+
unsafe {
|
|
781
|
+
msg_send![self,
|
|
782
|
+
setFragmentBufferOffset:offset
|
|
783
|
+
atIndex:index
|
|
784
|
+
]
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
pub fn set_fragment_buffers(
|
|
789
|
+
&self,
|
|
790
|
+
start_index: NSUInteger,
|
|
791
|
+
data: &[Option<&BufferRef>],
|
|
792
|
+
offsets: &[NSUInteger],
|
|
793
|
+
) {
|
|
794
|
+
debug_assert_eq!(offsets.len(), data.len());
|
|
795
|
+
unsafe {
|
|
796
|
+
msg_send![self,
|
|
797
|
+
setFragmentBuffers: data.as_ptr()
|
|
798
|
+
offsets: offsets.as_ptr()
|
|
799
|
+
withRange: NSRange {
|
|
800
|
+
location: start_index,
|
|
801
|
+
length: data.len() as _,
|
|
802
|
+
}
|
|
803
|
+
]
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
pub fn set_fragment_texture(&self, index: NSUInteger, texture: Option<&TextureRef>) {
|
|
808
|
+
unsafe {
|
|
809
|
+
msg_send![self,
|
|
810
|
+
setFragmentTexture:texture
|
|
811
|
+
atIndex:index
|
|
812
|
+
]
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
pub fn set_fragment_textures(&self, start_index: NSUInteger, data: &[Option<&TextureRef>]) {
|
|
817
|
+
unsafe {
|
|
818
|
+
msg_send![self,
|
|
819
|
+
setFragmentTextures: data.as_ptr()
|
|
820
|
+
withRange: NSRange {
|
|
821
|
+
location: start_index,
|
|
822
|
+
length: data.len() as _,
|
|
823
|
+
}
|
|
824
|
+
]
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
pub fn set_fragment_sampler_state(&self, index: NSUInteger, sampler: Option<&SamplerStateRef>) {
|
|
829
|
+
unsafe {
|
|
830
|
+
msg_send![self, setFragmentSamplerState:sampler
|
|
831
|
+
atIndex:index]
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
pub fn set_fragment_sampler_states(
|
|
836
|
+
&self,
|
|
837
|
+
start_index: NSUInteger,
|
|
838
|
+
data: &[Option<&SamplerStateRef>],
|
|
839
|
+
) {
|
|
840
|
+
unsafe {
|
|
841
|
+
msg_send![self,
|
|
842
|
+
setFragmentSamplerStates: data.as_ptr()
|
|
843
|
+
withRange: NSRange {
|
|
844
|
+
location: start_index,
|
|
845
|
+
length: data.len() as _,
|
|
846
|
+
}
|
|
847
|
+
]
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
pub fn set_fragment_sampler_state_with_lod(
|
|
852
|
+
&self,
|
|
853
|
+
index: NSUInteger,
|
|
854
|
+
sampler: Option<&SamplerStateRef>,
|
|
855
|
+
lod_clamp: Range<f32>,
|
|
856
|
+
) {
|
|
857
|
+
unsafe {
|
|
858
|
+
msg_send![self,
|
|
859
|
+
setFragmentSamplerState:sampler
|
|
860
|
+
lodMinClamp:lod_clamp.start
|
|
861
|
+
lodMaxClamp:lod_clamp.end
|
|
862
|
+
atIndex:index
|
|
863
|
+
]
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/// Only available in (macos(12.0), ios(15.0))
|
|
868
|
+
pub fn set_fragment_acceleration_structure(
|
|
869
|
+
&self,
|
|
870
|
+
index: NSUInteger,
|
|
871
|
+
accel: Option<&AccelerationStructureRef>,
|
|
872
|
+
) {
|
|
873
|
+
unsafe {
|
|
874
|
+
msg_send![
|
|
875
|
+
self,
|
|
876
|
+
setFragmentAccelerationStructure: accel
|
|
877
|
+
atBufferIndex: index
|
|
878
|
+
]
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/// Only available in (macos(12.0), ios(15.0))
|
|
883
|
+
pub fn set_fragment_intersection_function_table(
|
|
884
|
+
&self,
|
|
885
|
+
index: NSUInteger,
|
|
886
|
+
table: Option<&IntersectionFunctionTableRef>,
|
|
887
|
+
) {
|
|
888
|
+
unsafe {
|
|
889
|
+
msg_send![
|
|
890
|
+
self,
|
|
891
|
+
setFragmentIntersectionFunctionTable: table
|
|
892
|
+
atBufferIndex: index
|
|
893
|
+
]
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
pub fn set_fragment_visible_function_table(
|
|
898
|
+
&self,
|
|
899
|
+
buffer_index: NSUInteger,
|
|
900
|
+
visible_function_table: Option<&VisibleFunctionTableRef>,
|
|
901
|
+
) {
|
|
902
|
+
unsafe {
|
|
903
|
+
msg_send![self,
|
|
904
|
+
setFragmentVisibleFunctionTable:visible_function_table
|
|
905
|
+
atBufferIndex:buffer_index]
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
pub fn set_fragment_visible_function_tables(
|
|
910
|
+
&self,
|
|
911
|
+
buffer_start_index: NSUInteger,
|
|
912
|
+
visible_function_tables: &[&VisibleFunctionTableRef],
|
|
913
|
+
) {
|
|
914
|
+
unsafe {
|
|
915
|
+
msg_send![self,
|
|
916
|
+
setFragmentVisibleFunctionTables:visible_function_tables.as_ptr()
|
|
917
|
+
withBufferRange: NSRange {
|
|
918
|
+
location: buffer_start_index,
|
|
919
|
+
length: visible_function_tables.len() as _,
|
|
920
|
+
}
|
|
921
|
+
]
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// Drawing Geometric Primitives
|
|
926
|
+
|
|
927
|
+
pub fn draw_primitives(
|
|
928
|
+
&self,
|
|
929
|
+
primitive_type: MTLPrimitiveType,
|
|
930
|
+
vertex_start: NSUInteger,
|
|
931
|
+
vertex_count: NSUInteger,
|
|
932
|
+
) {
|
|
933
|
+
unsafe {
|
|
934
|
+
msg_send![self,
|
|
935
|
+
drawPrimitives: primitive_type
|
|
936
|
+
vertexStart: vertex_start
|
|
937
|
+
vertexCount: vertex_count
|
|
938
|
+
]
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
pub fn draw_primitives_instanced(
|
|
943
|
+
&self,
|
|
944
|
+
primitive_type: MTLPrimitiveType,
|
|
945
|
+
vertex_start: NSUInteger,
|
|
946
|
+
vertex_count: NSUInteger,
|
|
947
|
+
instance_count: NSUInteger,
|
|
948
|
+
) {
|
|
949
|
+
unsafe {
|
|
950
|
+
msg_send![self,
|
|
951
|
+
drawPrimitives: primitive_type
|
|
952
|
+
vertexStart: vertex_start
|
|
953
|
+
vertexCount: vertex_count
|
|
954
|
+
instanceCount: instance_count
|
|
955
|
+
]
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
pub fn draw_primitives_instanced_base_instance(
|
|
960
|
+
&self,
|
|
961
|
+
primitive_type: MTLPrimitiveType,
|
|
962
|
+
vertex_start: NSUInteger,
|
|
963
|
+
vertex_count: NSUInteger,
|
|
964
|
+
instance_count: NSUInteger,
|
|
965
|
+
base_instance: NSUInteger,
|
|
966
|
+
) {
|
|
967
|
+
unsafe {
|
|
968
|
+
msg_send![self,
|
|
969
|
+
drawPrimitives: primitive_type
|
|
970
|
+
vertexStart: vertex_start
|
|
971
|
+
vertexCount: vertex_count
|
|
972
|
+
instanceCount: instance_count
|
|
973
|
+
baseInstance: base_instance
|
|
974
|
+
]
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
pub fn draw_primitives_indirect(
|
|
979
|
+
&self,
|
|
980
|
+
primitive_type: MTLPrimitiveType,
|
|
981
|
+
indirect_buffer: &BufferRef,
|
|
982
|
+
indirect_buffer_offset: NSUInteger,
|
|
983
|
+
) {
|
|
984
|
+
unsafe {
|
|
985
|
+
msg_send![self,
|
|
986
|
+
drawPrimitives: primitive_type
|
|
987
|
+
indirectBuffer: indirect_buffer
|
|
988
|
+
indirectBufferOffset: indirect_buffer_offset
|
|
989
|
+
]
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
pub fn draw_indexed_primitives(
|
|
994
|
+
&self,
|
|
995
|
+
primitive_type: MTLPrimitiveType,
|
|
996
|
+
index_count: NSUInteger,
|
|
997
|
+
index_type: MTLIndexType,
|
|
998
|
+
index_buffer: &BufferRef,
|
|
999
|
+
index_buffer_offset: NSUInteger,
|
|
1000
|
+
) {
|
|
1001
|
+
unsafe {
|
|
1002
|
+
msg_send![self,
|
|
1003
|
+
drawIndexedPrimitives: primitive_type
|
|
1004
|
+
indexCount: index_count
|
|
1005
|
+
indexType: index_type
|
|
1006
|
+
indexBuffer: index_buffer
|
|
1007
|
+
indexBufferOffset: index_buffer_offset
|
|
1008
|
+
]
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
pub fn draw_indexed_primitives_instanced(
|
|
1013
|
+
&self,
|
|
1014
|
+
primitive_type: MTLPrimitiveType,
|
|
1015
|
+
index_count: NSUInteger,
|
|
1016
|
+
index_type: MTLIndexType,
|
|
1017
|
+
index_buffer: &BufferRef,
|
|
1018
|
+
index_buffer_offset: NSUInteger,
|
|
1019
|
+
instance_count: NSUInteger,
|
|
1020
|
+
) {
|
|
1021
|
+
unsafe {
|
|
1022
|
+
msg_send![self,
|
|
1023
|
+
drawIndexedPrimitives: primitive_type
|
|
1024
|
+
indexCount: index_count
|
|
1025
|
+
indexType: index_type
|
|
1026
|
+
indexBuffer: index_buffer
|
|
1027
|
+
indexBufferOffset: index_buffer_offset
|
|
1028
|
+
instanceCount: instance_count
|
|
1029
|
+
]
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
pub fn draw_indexed_primitives_instanced_base_instance(
|
|
1034
|
+
&self,
|
|
1035
|
+
primitive_type: MTLPrimitiveType,
|
|
1036
|
+
index_count: NSUInteger,
|
|
1037
|
+
index_type: MTLIndexType,
|
|
1038
|
+
index_buffer: &BufferRef,
|
|
1039
|
+
index_buffer_offset: NSUInteger,
|
|
1040
|
+
instance_count: NSUInteger,
|
|
1041
|
+
base_vertex: NSInteger,
|
|
1042
|
+
base_instance: NSUInteger,
|
|
1043
|
+
) {
|
|
1044
|
+
unsafe {
|
|
1045
|
+
msg_send![self,
|
|
1046
|
+
drawIndexedPrimitives: primitive_type
|
|
1047
|
+
indexCount: index_count
|
|
1048
|
+
indexType: index_type
|
|
1049
|
+
indexBuffer: index_buffer
|
|
1050
|
+
indexBufferOffset: index_buffer_offset
|
|
1051
|
+
instanceCount: instance_count
|
|
1052
|
+
baseVertex: base_vertex
|
|
1053
|
+
baseInstance: base_instance
|
|
1054
|
+
]
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
pub fn draw_indexed_primitives_indirect(
|
|
1059
|
+
&self,
|
|
1060
|
+
primitive_type: MTLPrimitiveType,
|
|
1061
|
+
index_type: MTLIndexType,
|
|
1062
|
+
index_buffer: &BufferRef,
|
|
1063
|
+
index_buffer_offset: NSUInteger,
|
|
1064
|
+
indirect_buffer: &BufferRef,
|
|
1065
|
+
indirect_buffer_offset: NSUInteger,
|
|
1066
|
+
) {
|
|
1067
|
+
unsafe {
|
|
1068
|
+
msg_send![self,
|
|
1069
|
+
drawIndexedPrimitives: primitive_type
|
|
1070
|
+
indexType: index_type
|
|
1071
|
+
indexBuffer: index_buffer
|
|
1072
|
+
indexBufferOffset: index_buffer_offset
|
|
1073
|
+
indirectBuffer: indirect_buffer
|
|
1074
|
+
indirectBufferOffset: indirect_buffer_offset
|
|
1075
|
+
]
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// TODO: more draws
|
|
1080
|
+
// fn setVertexBufferOffset_atIndex(self, offset: NSUInteger, index: NSUInteger);
|
|
1081
|
+
// fn setVertexBuffers_offsets_withRange(self, buffers: *const id, offsets: *const NSUInteger, range: NSRange);
|
|
1082
|
+
// fn setVertexSamplerStates_lodMinClamps_lodMaxClamps_withRange(self, samplers: *const id, lodMinClamps: *const f32, lodMaxClamps: *const f32, range: NSRange);
|
|
1083
|
+
|
|
1084
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
1085
|
+
pub fn draw_mesh_threadgroups(
|
|
1086
|
+
&self,
|
|
1087
|
+
threadgroups_per_grid: MTLSize,
|
|
1088
|
+
threads_per_object_threadgroup: MTLSize,
|
|
1089
|
+
threads_per_mesh_threadgroup: MTLSize,
|
|
1090
|
+
) {
|
|
1091
|
+
unsafe {
|
|
1092
|
+
msg_send![self,
|
|
1093
|
+
drawMeshThreadgroups: threadgroups_per_grid
|
|
1094
|
+
threadsPerObjectThreadgroup: threads_per_object_threadgroup
|
|
1095
|
+
threadsPerMeshThreadgroup: threads_per_mesh_threadgroup
|
|
1096
|
+
]
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
1101
|
+
pub fn draw_mesh_threadgroups_with_indirect_buffer(
|
|
1102
|
+
&self,
|
|
1103
|
+
indirect_buffer: &BufferRef,
|
|
1104
|
+
indirect_buffer_offset: NSUInteger,
|
|
1105
|
+
threads_per_object_threadgroup: MTLSize,
|
|
1106
|
+
threads_per_mesh_threadgroup: MTLSize,
|
|
1107
|
+
) {
|
|
1108
|
+
unsafe {
|
|
1109
|
+
msg_send![self,
|
|
1110
|
+
drawMeshThreadgroupsWithIndirectBuffer: indirect_buffer
|
|
1111
|
+
indirectBufferOffset: indirect_buffer_offset
|
|
1112
|
+
threadsPerObjectThreadgroup: threads_per_object_threadgroup
|
|
1113
|
+
threadsPerMeshThreadgroup: threads_per_mesh_threadgroup
|
|
1114
|
+
]
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/// Only available in (macos(13.0), ios(16.0))
|
|
1119
|
+
pub fn draw_mesh_threads(
|
|
1120
|
+
&self,
|
|
1121
|
+
threads_per_grid: MTLSize,
|
|
1122
|
+
threads_per_object_threadgroup: MTLSize,
|
|
1123
|
+
threads_per_mesh_threadgroup: MTLSize,
|
|
1124
|
+
) {
|
|
1125
|
+
unsafe {
|
|
1126
|
+
msg_send![self,
|
|
1127
|
+
drawMeshThreads: threads_per_grid
|
|
1128
|
+
threadsPerObjectThreadgroup: threads_per_object_threadgroup
|
|
1129
|
+
threadsPerMeshThreadgroup: threads_per_mesh_threadgroup
|
|
1130
|
+
]
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/// Adds an untracked resource to the render pass.
|
|
1135
|
+
///
|
|
1136
|
+
/// Availability: iOS 11.0+, macOS 10.13+
|
|
1137
|
+
///
|
|
1138
|
+
/// # Arguments
|
|
1139
|
+
/// * `resource`: A resource within an argument buffer.
|
|
1140
|
+
/// * `usage`: Options for describing how a graphics function uses the resource.
|
|
1141
|
+
///
|
|
1142
|
+
/// See <https://developer.apple.com/documentation/metal/mtlrendercommandencoder/2866168-useresource?language=objc>
|
|
1143
|
+
#[deprecated(note = "Use use_resource_at instead")]
|
|
1144
|
+
pub fn use_resource(&self, resource: &ResourceRef, usage: MTLResourceUsage) {
|
|
1145
|
+
unsafe {
|
|
1146
|
+
msg_send![self,
|
|
1147
|
+
useResource:resource
|
|
1148
|
+
usage:usage
|
|
1149
|
+
]
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/// Adds an untracked resource to the render pass, specifying which render stages need it.
|
|
1154
|
+
///
|
|
1155
|
+
/// Availability: iOS 13.0+, macOS 10.15+
|
|
1156
|
+
///
|
|
1157
|
+
/// # Arguments
|
|
1158
|
+
/// * `resource`: A resource within an argument buffer.
|
|
1159
|
+
/// * `usage`: Options for describing how a graphics function uses the resource.
|
|
1160
|
+
/// * `stages`: The render stages where the resource must be resident.
|
|
1161
|
+
///
|
|
1162
|
+
/// See <https://developer.apple.com/documentation/metal/mtlrendercommandencoder/3043404-useresource>
|
|
1163
|
+
pub fn use_resource_at(
|
|
1164
|
+
&self,
|
|
1165
|
+
resource: &ResourceRef,
|
|
1166
|
+
usage: MTLResourceUsage,
|
|
1167
|
+
stages: MTLRenderStages,
|
|
1168
|
+
) {
|
|
1169
|
+
unsafe {
|
|
1170
|
+
msg_send![self,
|
|
1171
|
+
useResource: resource
|
|
1172
|
+
usage: usage
|
|
1173
|
+
stages: stages
|
|
1174
|
+
]
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/// Adds an array of untracked resources to the render pass, specifying which stages need them.
|
|
1179
|
+
///
|
|
1180
|
+
/// When working with color render targets, call this method as late as possible to improve performance.
|
|
1181
|
+
///
|
|
1182
|
+
/// Availability: iOS 13.0+, macOS 10.15+
|
|
1183
|
+
///
|
|
1184
|
+
/// # Arguments
|
|
1185
|
+
/// * `resources`: A slice of resources within an argument buffer.
|
|
1186
|
+
/// * `usage`: Options for describing how a graphics function uses the resources.
|
|
1187
|
+
/// * `stages`: The render stages where the resources must be resident.
|
|
1188
|
+
pub fn use_resources(
|
|
1189
|
+
&self,
|
|
1190
|
+
resources: &[&ResourceRef],
|
|
1191
|
+
usage: MTLResourceUsage,
|
|
1192
|
+
stages: MTLRenderStages,
|
|
1193
|
+
) {
|
|
1194
|
+
unsafe {
|
|
1195
|
+
msg_send![self,
|
|
1196
|
+
useResources: resources.as_ptr()
|
|
1197
|
+
count: resources.len() as NSUInteger
|
|
1198
|
+
usage: usage
|
|
1199
|
+
stages: stages
|
|
1200
|
+
]
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/// Adds the resources in a heap to the render pass.
|
|
1205
|
+
///
|
|
1206
|
+
/// Availability: iOS 11.0+, macOS 10.13+
|
|
1207
|
+
///
|
|
1208
|
+
/// # Arguments:
|
|
1209
|
+
/// * `heap`: A heap that contains resources within an argument buffer.
|
|
1210
|
+
///
|
|
1211
|
+
/// See <https://developer.apple.com/documentation/metal/mtlrendercommandencoder/2866163-useheap?language=objc>
|
|
1212
|
+
#[deprecated(note = "Use use_heap_at instead")]
|
|
1213
|
+
pub fn use_heap(&self, heap: &HeapRef) {
|
|
1214
|
+
unsafe { msg_send![self, useHeap: heap] }
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
/// Adds the resources in a heap to the render pass, specifying which render stages need them.
|
|
1218
|
+
///
|
|
1219
|
+
/// Availability: iOS 13.0+, macOS 10.15+
|
|
1220
|
+
///
|
|
1221
|
+
/// # Arguments
|
|
1222
|
+
/// * `heap`: A heap that contains resources within an argument buffer.
|
|
1223
|
+
/// * `stages`: The render stages where the resources must be resident.
|
|
1224
|
+
///
|
|
1225
|
+
pub fn use_heap_at(&self, heap: &HeapRef, stages: MTLRenderStages) {
|
|
1226
|
+
unsafe {
|
|
1227
|
+
msg_send![self,
|
|
1228
|
+
useHeap: heap
|
|
1229
|
+
stages: stages
|
|
1230
|
+
]
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/// Adds the resources in an array of heaps to the render pass, specifying which render stages need them.
|
|
1235
|
+
///
|
|
1236
|
+
/// Availability: iOS 13.0+, macOS 10.15+
|
|
1237
|
+
///
|
|
1238
|
+
/// # Arguments
|
|
1239
|
+
///
|
|
1240
|
+
/// * `heaps`: A slice of heaps that contains resources within an argument buffer.
|
|
1241
|
+
/// * `stages`: The render stages where the resources must be resident.
|
|
1242
|
+
pub fn use_heaps(&self, heaps: &[&HeapRef], stages: MTLRenderStages) {
|
|
1243
|
+
unsafe {
|
|
1244
|
+
msg_send![self,
|
|
1245
|
+
useHeaps: heaps.as_ptr()
|
|
1246
|
+
count: heaps.len() as NSUInteger
|
|
1247
|
+
stages: stages
|
|
1248
|
+
]
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
pub fn execute_commands_in_buffer(
|
|
1253
|
+
&self,
|
|
1254
|
+
buffer: &IndirectCommandBufferRef,
|
|
1255
|
+
with_range: NSRange,
|
|
1256
|
+
) {
|
|
1257
|
+
unsafe { msg_send![self, executeCommandsInBuffer:buffer withRange:with_range] }
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
pub fn update_fence(&self, fence: &FenceRef, after_stages: MTLRenderStages) {
|
|
1261
|
+
unsafe {
|
|
1262
|
+
msg_send![self,
|
|
1263
|
+
updateFence: fence
|
|
1264
|
+
afterStages: after_stages
|
|
1265
|
+
]
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
pub fn wait_for_fence(&self, fence: &FenceRef, before_stages: MTLRenderStages) {
|
|
1270
|
+
unsafe {
|
|
1271
|
+
msg_send![self,
|
|
1272
|
+
waitForFence: fence
|
|
1273
|
+
beforeStages: before_stages
|
|
1274
|
+
]
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/// See: <https://developer.apple.com/documentation/metal/mtlrendercommandencoder/3194379-samplecountersinbuffer>
|
|
1279
|
+
pub fn sample_counters_in_buffer(
|
|
1280
|
+
&self,
|
|
1281
|
+
sample_buffer: &CounterSampleBufferRef,
|
|
1282
|
+
sample_index: NSUInteger,
|
|
1283
|
+
with_barrier: bool,
|
|
1284
|
+
) {
|
|
1285
|
+
unsafe {
|
|
1286
|
+
msg_send![self,
|
|
1287
|
+
sampleCountersInBuffer: sample_buffer
|
|
1288
|
+
atSampleIndex: sample_index
|
|
1289
|
+
withBarrier: with_barrier
|
|
1290
|
+
]
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
/// See <https://developer.apple.com/documentation/metal/mtlblitcommandencoder/>
|
|
1296
|
+
pub enum MTLBlitCommandEncoder {}
|
|
1297
|
+
|
|
1298
|
+
foreign_obj_type! {
|
|
1299
|
+
type CType = MTLBlitCommandEncoder;
|
|
1300
|
+
pub struct BlitCommandEncoder;
|
|
1301
|
+
type ParentType = CommandEncoder;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
impl BlitCommandEncoderRef {
|
|
1305
|
+
pub fn synchronize_resource(&self, resource: &ResourceRef) {
|
|
1306
|
+
unsafe { msg_send![self, synchronizeResource: resource] }
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
pub fn fill_buffer(&self, destination_buffer: &BufferRef, range: crate::NSRange, value: u8) {
|
|
1310
|
+
unsafe {
|
|
1311
|
+
msg_send![self,
|
|
1312
|
+
fillBuffer: destination_buffer
|
|
1313
|
+
range: range
|
|
1314
|
+
value: value
|
|
1315
|
+
]
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
pub fn generate_mipmaps(&self, texture: &TextureRef) {
|
|
1320
|
+
unsafe { msg_send![self, generateMipmapsForTexture: texture] }
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
pub fn copy_from_buffer(
|
|
1324
|
+
&self,
|
|
1325
|
+
source_buffer: &BufferRef,
|
|
1326
|
+
source_offset: NSUInteger,
|
|
1327
|
+
destination_buffer: &BufferRef,
|
|
1328
|
+
destination_offset: NSUInteger,
|
|
1329
|
+
size: NSUInteger,
|
|
1330
|
+
) {
|
|
1331
|
+
unsafe {
|
|
1332
|
+
msg_send![self,
|
|
1333
|
+
copyFromBuffer: source_buffer
|
|
1334
|
+
sourceOffset: source_offset
|
|
1335
|
+
toBuffer: destination_buffer
|
|
1336
|
+
destinationOffset: destination_offset
|
|
1337
|
+
size: size
|
|
1338
|
+
]
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
pub fn copy_from_texture(
|
|
1343
|
+
&self,
|
|
1344
|
+
source_texture: &TextureRef,
|
|
1345
|
+
source_slice: NSUInteger,
|
|
1346
|
+
source_level: NSUInteger,
|
|
1347
|
+
source_origin: MTLOrigin,
|
|
1348
|
+
source_size: MTLSize,
|
|
1349
|
+
destination_texture: &TextureRef,
|
|
1350
|
+
destination_slice: NSUInteger,
|
|
1351
|
+
destination_level: NSUInteger,
|
|
1352
|
+
destination_origin: MTLOrigin,
|
|
1353
|
+
) {
|
|
1354
|
+
unsafe {
|
|
1355
|
+
msg_send![self,
|
|
1356
|
+
copyFromTexture: source_texture
|
|
1357
|
+
sourceSlice: source_slice
|
|
1358
|
+
sourceLevel: source_level
|
|
1359
|
+
sourceOrigin: source_origin
|
|
1360
|
+
sourceSize: source_size
|
|
1361
|
+
toTexture: destination_texture
|
|
1362
|
+
destinationSlice: destination_slice
|
|
1363
|
+
destinationLevel: destination_level
|
|
1364
|
+
destinationOrigin: destination_origin
|
|
1365
|
+
]
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
pub fn copy_from_buffer_to_texture(
|
|
1370
|
+
&self,
|
|
1371
|
+
source_buffer: &BufferRef,
|
|
1372
|
+
source_offset: NSUInteger,
|
|
1373
|
+
source_bytes_per_row: NSUInteger,
|
|
1374
|
+
source_bytes_per_image: NSUInteger,
|
|
1375
|
+
source_size: MTLSize,
|
|
1376
|
+
destination_texture: &TextureRef,
|
|
1377
|
+
destination_slice: NSUInteger,
|
|
1378
|
+
destination_level: NSUInteger,
|
|
1379
|
+
destination_origin: MTLOrigin,
|
|
1380
|
+
options: MTLBlitOption,
|
|
1381
|
+
) {
|
|
1382
|
+
unsafe {
|
|
1383
|
+
msg_send![self,
|
|
1384
|
+
copyFromBuffer: source_buffer
|
|
1385
|
+
sourceOffset: source_offset
|
|
1386
|
+
sourceBytesPerRow: source_bytes_per_row
|
|
1387
|
+
sourceBytesPerImage: source_bytes_per_image
|
|
1388
|
+
sourceSize: source_size
|
|
1389
|
+
toTexture: destination_texture
|
|
1390
|
+
destinationSlice: destination_slice
|
|
1391
|
+
destinationLevel: destination_level
|
|
1392
|
+
destinationOrigin: destination_origin
|
|
1393
|
+
options: options
|
|
1394
|
+
]
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/// See <https://developer.apple.com/documentation/metal/mtlblitcommandencoder/1400756-copy>
|
|
1399
|
+
pub fn copy_from_texture_to_buffer(
|
|
1400
|
+
&self,
|
|
1401
|
+
source_texture: &TextureRef,
|
|
1402
|
+
source_slice: NSUInteger,
|
|
1403
|
+
source_level: NSUInteger,
|
|
1404
|
+
source_origin: MTLOrigin,
|
|
1405
|
+
source_size: MTLSize,
|
|
1406
|
+
destination_buffer: &BufferRef,
|
|
1407
|
+
destination_offset: NSUInteger,
|
|
1408
|
+
destination_bytes_per_row: NSUInteger,
|
|
1409
|
+
destination_bytes_per_image: NSUInteger,
|
|
1410
|
+
options: MTLBlitOption,
|
|
1411
|
+
) {
|
|
1412
|
+
unsafe {
|
|
1413
|
+
msg_send![self,
|
|
1414
|
+
copyFromTexture: source_texture
|
|
1415
|
+
sourceSlice: source_slice
|
|
1416
|
+
sourceLevel: source_level
|
|
1417
|
+
sourceOrigin: source_origin
|
|
1418
|
+
sourceSize: source_size
|
|
1419
|
+
toBuffer: destination_buffer
|
|
1420
|
+
destinationOffset: destination_offset
|
|
1421
|
+
destinationBytesPerRow: destination_bytes_per_row
|
|
1422
|
+
destinationBytesPerImage: destination_bytes_per_image
|
|
1423
|
+
options: options
|
|
1424
|
+
]
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
pub fn optimize_contents_for_gpu_access(&self, texture: &TextureRef) {
|
|
1429
|
+
unsafe { msg_send![self, optimizeContentsForGPUAccess: texture] }
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
pub fn optimize_contents_for_gpu_access_slice_level(
|
|
1433
|
+
&self,
|
|
1434
|
+
texture: &TextureRef,
|
|
1435
|
+
slice: NSUInteger,
|
|
1436
|
+
level: NSUInteger,
|
|
1437
|
+
) {
|
|
1438
|
+
unsafe {
|
|
1439
|
+
msg_send![self,
|
|
1440
|
+
optimizeContentsForGPUAccess: texture
|
|
1441
|
+
slice: slice
|
|
1442
|
+
level: level
|
|
1443
|
+
]
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
pub fn optimize_contents_for_cpu_access(&self, texture: &TextureRef) {
|
|
1448
|
+
unsafe { msg_send![self, optimizeContentsForCPUAccess: texture] }
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
pub fn optimize_contents_for_cpu_access_slice_level(
|
|
1452
|
+
&self,
|
|
1453
|
+
texture: &TextureRef,
|
|
1454
|
+
slice: NSUInteger,
|
|
1455
|
+
level: NSUInteger,
|
|
1456
|
+
) {
|
|
1457
|
+
unsafe {
|
|
1458
|
+
msg_send![self,
|
|
1459
|
+
optimizeContentsForCPUAccess: texture
|
|
1460
|
+
slice: slice
|
|
1461
|
+
level: level
|
|
1462
|
+
]
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
pub fn update_fence(&self, fence: &FenceRef) {
|
|
1467
|
+
unsafe { msg_send![self, updateFence: fence] }
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
pub fn wait_for_fence(&self, fence: &FenceRef) {
|
|
1471
|
+
unsafe { msg_send![self, waitForFence: fence] }
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
pub fn copy_indirect_command_buffer(
|
|
1475
|
+
&self,
|
|
1476
|
+
source: &IndirectCommandBufferRef,
|
|
1477
|
+
source_range: NSRange,
|
|
1478
|
+
destination: &IndirectCommandBufferRef,
|
|
1479
|
+
destination_index: NSUInteger,
|
|
1480
|
+
) {
|
|
1481
|
+
unsafe {
|
|
1482
|
+
msg_send![self,
|
|
1483
|
+
copyIndirectCommandBuffer: source
|
|
1484
|
+
sourceRange: source_range
|
|
1485
|
+
destination: destination
|
|
1486
|
+
destinationIndex: destination_index
|
|
1487
|
+
]
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
pub fn reset_commands_in_buffer(&self, buffer: &IndirectCommandBufferRef, range: NSRange) {
|
|
1492
|
+
unsafe {
|
|
1493
|
+
msg_send![self,
|
|
1494
|
+
resetCommandsInBuffer: buffer
|
|
1495
|
+
withRange: range
|
|
1496
|
+
]
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
pub fn optimize_indirect_command_buffer(
|
|
1501
|
+
&self,
|
|
1502
|
+
buffer: &IndirectCommandBufferRef,
|
|
1503
|
+
range: NSRange,
|
|
1504
|
+
) {
|
|
1505
|
+
unsafe {
|
|
1506
|
+
msg_send![self,
|
|
1507
|
+
optimizeIndirectCommandBuffer: buffer
|
|
1508
|
+
withRange: range
|
|
1509
|
+
]
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
/// See: <https://developer.apple.com/documentation/metal/mtlblitcommandencoder/3194348-samplecountersinbuffer>
|
|
1514
|
+
pub fn sample_counters_in_buffer(
|
|
1515
|
+
&self,
|
|
1516
|
+
sample_buffer: &CounterSampleBufferRef,
|
|
1517
|
+
sample_index: NSUInteger,
|
|
1518
|
+
with_barrier: bool,
|
|
1519
|
+
) {
|
|
1520
|
+
unsafe {
|
|
1521
|
+
msg_send![self,
|
|
1522
|
+
sampleCountersInBuffer: sample_buffer
|
|
1523
|
+
atSampleIndex: sample_index
|
|
1524
|
+
withBarrier: with_barrier
|
|
1525
|
+
]
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/// See: <https://developer.apple.com/documentation/metal/mtlblitcommandencoder/3194347-resolvecounters>
|
|
1530
|
+
pub fn resolve_counters(
|
|
1531
|
+
&self,
|
|
1532
|
+
sample_buffer: &CounterSampleBufferRef,
|
|
1533
|
+
range: crate::NSRange,
|
|
1534
|
+
destination_buffer: &BufferRef,
|
|
1535
|
+
destination_offset: NSUInteger,
|
|
1536
|
+
) {
|
|
1537
|
+
unsafe {
|
|
1538
|
+
msg_send![self,
|
|
1539
|
+
resolveCounters: sample_buffer
|
|
1540
|
+
inRange: range
|
|
1541
|
+
destinationBuffer: destination_buffer
|
|
1542
|
+
destinationOffset: destination_offset
|
|
1543
|
+
]
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/// See <https://developer.apple.com/documentation/metal/mtlcomputecommandencoder/>
|
|
1549
|
+
pub enum MTLComputeCommandEncoder {}
|
|
1550
|
+
|
|
1551
|
+
foreign_obj_type! {
|
|
1552
|
+
type CType = MTLComputeCommandEncoder;
|
|
1553
|
+
pub struct ComputeCommandEncoder;
|
|
1554
|
+
type ParentType = CommandEncoder;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
impl ComputeCommandEncoderRef {
|
|
1558
|
+
pub fn set_compute_pipeline_state(&self, state: &ComputePipelineStateRef) {
|
|
1559
|
+
unsafe { msg_send![self, setComputePipelineState: state] }
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
pub fn set_buffer(&self, index: NSUInteger, buffer: Option<&BufferRef>, offset: NSUInteger) {
|
|
1563
|
+
unsafe { msg_send![self, setBuffer:buffer offset:offset atIndex:index] }
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
pub fn set_buffers(
|
|
1567
|
+
&self,
|
|
1568
|
+
start_index: NSUInteger,
|
|
1569
|
+
data: &[Option<&BufferRef>],
|
|
1570
|
+
offsets: &[NSUInteger],
|
|
1571
|
+
) {
|
|
1572
|
+
debug_assert_eq!(offsets.len(), data.len());
|
|
1573
|
+
unsafe {
|
|
1574
|
+
msg_send![self,
|
|
1575
|
+
setBuffers: data.as_ptr()
|
|
1576
|
+
offsets: offsets.as_ptr()
|
|
1577
|
+
withRange: NSRange {
|
|
1578
|
+
location: start_index,
|
|
1579
|
+
length: data.len() as _,
|
|
1580
|
+
}
|
|
1581
|
+
]
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
pub fn set_texture(&self, index: NSUInteger, texture: Option<&TextureRef>) {
|
|
1586
|
+
unsafe {
|
|
1587
|
+
msg_send![self,
|
|
1588
|
+
setTexture:texture
|
|
1589
|
+
atIndex:index
|
|
1590
|
+
]
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
pub fn set_textures(&self, start_index: NSUInteger, data: &[Option<&TextureRef>]) {
|
|
1595
|
+
unsafe {
|
|
1596
|
+
msg_send![self,
|
|
1597
|
+
setTextures: data.as_ptr()
|
|
1598
|
+
withRange: NSRange {
|
|
1599
|
+
location: start_index,
|
|
1600
|
+
length: data.len() as _,
|
|
1601
|
+
}
|
|
1602
|
+
]
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
pub fn set_sampler_state(&self, index: NSUInteger, sampler: Option<&SamplerStateRef>) {
|
|
1607
|
+
unsafe {
|
|
1608
|
+
msg_send![self,
|
|
1609
|
+
setSamplerState:sampler
|
|
1610
|
+
atIndex:index
|
|
1611
|
+
]
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
pub fn set_sampler_states(&self, start_index: NSUInteger, data: &[Option<&SamplerStateRef>]) {
|
|
1616
|
+
unsafe {
|
|
1617
|
+
msg_send![self,
|
|
1618
|
+
setSamplerStates: data.as_ptr()
|
|
1619
|
+
withRange: NSRange {
|
|
1620
|
+
location: start_index,
|
|
1621
|
+
length: data.len() as _,
|
|
1622
|
+
}
|
|
1623
|
+
]
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
pub fn set_sampler_state_with_lod(
|
|
1628
|
+
&self,
|
|
1629
|
+
index: NSUInteger,
|
|
1630
|
+
sampler: Option<&SamplerStateRef>,
|
|
1631
|
+
lod_clamp: Range<f32>,
|
|
1632
|
+
) {
|
|
1633
|
+
unsafe {
|
|
1634
|
+
msg_send![self,
|
|
1635
|
+
setSamplerState:sampler
|
|
1636
|
+
lodMinClamp:lod_clamp.start
|
|
1637
|
+
lodMaxClamp:lod_clamp.end
|
|
1638
|
+
atIndex:index
|
|
1639
|
+
]
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
pub fn set_bytes(&self, index: NSUInteger, length: NSUInteger, bytes: *const std::ffi::c_void) {
|
|
1644
|
+
unsafe {
|
|
1645
|
+
msg_send![self,
|
|
1646
|
+
setBytes: bytes
|
|
1647
|
+
length: length
|
|
1648
|
+
atIndex: index
|
|
1649
|
+
]
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
pub fn set_visible_function_table(
|
|
1654
|
+
&self,
|
|
1655
|
+
buffer_index: NSUInteger,
|
|
1656
|
+
visible_function_table: Option<&VisibleFunctionTableRef>,
|
|
1657
|
+
) {
|
|
1658
|
+
unsafe {
|
|
1659
|
+
msg_send![self,
|
|
1660
|
+
setVisibleFunctionTable:visible_function_table
|
|
1661
|
+
atBufferIndex:buffer_index]
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
pub fn set_visible_function_tables(
|
|
1666
|
+
&self,
|
|
1667
|
+
buffer_start_index: NSUInteger,
|
|
1668
|
+
visible_function_tables: &[&VisibleFunctionTableRef],
|
|
1669
|
+
) {
|
|
1670
|
+
unsafe {
|
|
1671
|
+
msg_send![self,
|
|
1672
|
+
setVisibleFunctionTables:visible_function_tables.as_ptr()
|
|
1673
|
+
withBufferRange: NSRange {
|
|
1674
|
+
location: buffer_start_index,
|
|
1675
|
+
length: visible_function_tables.len() as _,
|
|
1676
|
+
}
|
|
1677
|
+
]
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
pub fn dispatch_thread_groups(
|
|
1682
|
+
&self,
|
|
1683
|
+
thread_groups_count: MTLSize,
|
|
1684
|
+
threads_per_threadgroup: MTLSize,
|
|
1685
|
+
) {
|
|
1686
|
+
unsafe {
|
|
1687
|
+
msg_send![self,
|
|
1688
|
+
dispatchThreadgroups:thread_groups_count
|
|
1689
|
+
threadsPerThreadgroup:threads_per_threadgroup
|
|
1690
|
+
]
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
pub fn dispatch_threads(&self, threads_per_grid: MTLSize, threads_per_thread_group: MTLSize) {
|
|
1695
|
+
unsafe {
|
|
1696
|
+
msg_send![self,
|
|
1697
|
+
dispatchThreads:threads_per_grid
|
|
1698
|
+
threadsPerThreadgroup:threads_per_thread_group
|
|
1699
|
+
]
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
pub fn dispatch_thread_groups_indirect(
|
|
1704
|
+
&self,
|
|
1705
|
+
buffer: &BufferRef,
|
|
1706
|
+
offset: NSUInteger,
|
|
1707
|
+
threads_per_threadgroup: MTLSize,
|
|
1708
|
+
) {
|
|
1709
|
+
unsafe {
|
|
1710
|
+
msg_send![self,
|
|
1711
|
+
dispatchThreadgroupsWithIndirectBuffer:buffer
|
|
1712
|
+
indirectBufferOffset:offset
|
|
1713
|
+
threadsPerThreadgroup:threads_per_threadgroup
|
|
1714
|
+
]
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
pub fn set_threadgroup_memory_length(&self, at_index: NSUInteger, size: NSUInteger) {
|
|
1719
|
+
unsafe {
|
|
1720
|
+
msg_send![self,
|
|
1721
|
+
setThreadgroupMemoryLength:size
|
|
1722
|
+
atIndex: at_index
|
|
1723
|
+
]
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
/// Encodes a barrier so that changes to a set of resources made by commands encoded before the
|
|
1728
|
+
/// barrier are completed before further commands are executed.
|
|
1729
|
+
///
|
|
1730
|
+
/// Availability: iOS 12.0+, macOS 10.14+
|
|
1731
|
+
///
|
|
1732
|
+
/// # Arguments
|
|
1733
|
+
/// * `resources`: A slice of resources.
|
|
1734
|
+
pub fn memory_barrier_with_resources(&self, resources: &[&ResourceRef]) {
|
|
1735
|
+
unsafe {
|
|
1736
|
+
msg_send![self,
|
|
1737
|
+
memoryBarrierWithResources: resources.as_ptr()
|
|
1738
|
+
count: resources.len() as NSUInteger
|
|
1739
|
+
]
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
/// Specifies that a resource in an argument buffer can be safely used by a compute pass.
|
|
1744
|
+
///
|
|
1745
|
+
/// Availability: iOS 11.0+, macOS 10.13+
|
|
1746
|
+
///
|
|
1747
|
+
/// # Arguments
|
|
1748
|
+
/// * `resource`: A specific resource within an argument buffer.
|
|
1749
|
+
/// * `usage`: The options that describe how the resource will be used by a compute function.
|
|
1750
|
+
pub fn use_resource(&self, resource: &ResourceRef, usage: MTLResourceUsage) {
|
|
1751
|
+
unsafe {
|
|
1752
|
+
msg_send![self,
|
|
1753
|
+
useResource: resource
|
|
1754
|
+
usage: usage
|
|
1755
|
+
]
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
/// Specifies that an array of resources in an argument buffer can be safely used by a compute pass.
|
|
1760
|
+
///
|
|
1761
|
+
/// Availability: iOS 11.0+, macOS 10.13+
|
|
1762
|
+
///
|
|
1763
|
+
/// See <https://developer.apple.com/documentation/metal/mtlcomputecommandencoder/2866561-useresources>
|
|
1764
|
+
///
|
|
1765
|
+
/// # Arguments
|
|
1766
|
+
/// * `resources`: A slice of resources within an argument buffer.
|
|
1767
|
+
/// * `usage`: The options that describe how the array of resources will be used by a compute function.
|
|
1768
|
+
pub fn use_resources(&self, resources: &[&ResourceRef], usage: MTLResourceUsage) {
|
|
1769
|
+
unsafe {
|
|
1770
|
+
msg_send![self,
|
|
1771
|
+
useResources: resources.as_ptr()
|
|
1772
|
+
count: resources.len() as NSUInteger
|
|
1773
|
+
usage: usage
|
|
1774
|
+
]
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/// Specifies that a heap containing resources in an argument buffer can be safely used by a compute pass.
|
|
1779
|
+
///
|
|
1780
|
+
/// Availability: iOS 11.0+, macOS 10.13+
|
|
1781
|
+
///
|
|
1782
|
+
/// See <https://developer.apple.com/documentation/metal/mtlcomputecommandencoder/2866530-useheap>
|
|
1783
|
+
///
|
|
1784
|
+
/// # Arguments
|
|
1785
|
+
/// * `heap`: A heap that contains resources within an argument buffer.
|
|
1786
|
+
pub fn use_heap(&self, heap: &HeapRef) {
|
|
1787
|
+
unsafe { msg_send![self, useHeap: heap] }
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
/// Specifies that an array of heaps containing resources in an argument buffer can be safely
|
|
1791
|
+
/// used by a compute pass.
|
|
1792
|
+
///
|
|
1793
|
+
/// Availability: iOS 11.0+, macOS 10.13+
|
|
1794
|
+
///
|
|
1795
|
+
/// # Arguments
|
|
1796
|
+
/// * `heaps`: A slice of heaps that contains resources within an argument buffer.
|
|
1797
|
+
pub fn use_heaps(&self, heaps: &[&HeapRef]) {
|
|
1798
|
+
unsafe {
|
|
1799
|
+
msg_send![self,
|
|
1800
|
+
useHeaps: heaps.as_ptr()
|
|
1801
|
+
count: heaps.len() as NSUInteger
|
|
1802
|
+
]
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
pub fn update_fence(&self, fence: &FenceRef) {
|
|
1807
|
+
unsafe { msg_send![self, updateFence: fence] }
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
pub fn wait_for_fence(&self, fence: &FenceRef) {
|
|
1811
|
+
unsafe { msg_send![self, waitForFence: fence] }
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
/// Only available in (macos(11.0), ios(14.0))
|
|
1815
|
+
pub fn set_acceleration_structure(
|
|
1816
|
+
&self,
|
|
1817
|
+
index: NSUInteger,
|
|
1818
|
+
accel: Option<&AccelerationStructureRef>,
|
|
1819
|
+
) {
|
|
1820
|
+
unsafe {
|
|
1821
|
+
msg_send![
|
|
1822
|
+
self,
|
|
1823
|
+
setAccelerationStructure: accel
|
|
1824
|
+
atBufferIndex: index
|
|
1825
|
+
]
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
/// Only available in (macos(11.0), ios(14.0))
|
|
1830
|
+
pub fn set_intersection_function_table(
|
|
1831
|
+
&self,
|
|
1832
|
+
index: NSUInteger,
|
|
1833
|
+
table: Option<&IntersectionFunctionTableRef>,
|
|
1834
|
+
) {
|
|
1835
|
+
unsafe {
|
|
1836
|
+
msg_send![
|
|
1837
|
+
self,
|
|
1838
|
+
setIntersectionFunctionTable: table
|
|
1839
|
+
atBufferIndex: index
|
|
1840
|
+
]
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
/// See: <https://developer.apple.com/documentation/metal/mtlcomputecommandencoder/3194349-samplecountersinbuffer>
|
|
1845
|
+
pub fn sample_counters_in_buffer(
|
|
1846
|
+
&self,
|
|
1847
|
+
sample_buffer: &CounterSampleBufferRef,
|
|
1848
|
+
sample_index: NSUInteger,
|
|
1849
|
+
with_barrier: bool,
|
|
1850
|
+
) {
|
|
1851
|
+
unsafe {
|
|
1852
|
+
msg_send![self,
|
|
1853
|
+
sampleCountersInBuffer: sample_buffer
|
|
1854
|
+
atSampleIndex: sample_index
|
|
1855
|
+
withBarrier: with_barrier
|
|
1856
|
+
]
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
/// See <https://developer.apple.com/documentation/metal/mtlargumentencoder/>
|
|
1862
|
+
pub enum MTLArgumentEncoder {}
|
|
1863
|
+
|
|
1864
|
+
foreign_obj_type! {
|
|
1865
|
+
type CType = MTLArgumentEncoder;
|
|
1866
|
+
pub struct ArgumentEncoder;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
impl ArgumentEncoderRef {
|
|
1870
|
+
pub fn encoded_length(&self) -> NSUInteger {
|
|
1871
|
+
unsafe { msg_send![self, encodedLength] }
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
pub fn alignment(&self) -> NSUInteger {
|
|
1875
|
+
unsafe { msg_send![self, alignment] }
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
pub fn set_argument_buffer(&self, buffer: &BufferRef, offset: NSUInteger) {
|
|
1879
|
+
unsafe {
|
|
1880
|
+
msg_send![self,
|
|
1881
|
+
setArgumentBuffer: buffer
|
|
1882
|
+
offset: offset
|
|
1883
|
+
]
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
pub fn set_argument_buffer_to_element(
|
|
1888
|
+
&self,
|
|
1889
|
+
array_element: NSUInteger,
|
|
1890
|
+
buffer: &BufferRef,
|
|
1891
|
+
offset: NSUInteger,
|
|
1892
|
+
) {
|
|
1893
|
+
unsafe {
|
|
1894
|
+
msg_send![self,
|
|
1895
|
+
setArgumentBuffer: buffer
|
|
1896
|
+
startOffset: offset
|
|
1897
|
+
arrayElement: array_element
|
|
1898
|
+
]
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
pub fn set_buffer(&self, at_index: NSUInteger, buffer: &BufferRef, offset: NSUInteger) {
|
|
1903
|
+
unsafe {
|
|
1904
|
+
msg_send![self,
|
|
1905
|
+
setBuffer: buffer
|
|
1906
|
+
offset: offset
|
|
1907
|
+
atIndex: at_index
|
|
1908
|
+
]
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
pub fn set_buffers(
|
|
1913
|
+
&self,
|
|
1914
|
+
start_index: NSUInteger,
|
|
1915
|
+
data: &[&BufferRef],
|
|
1916
|
+
offsets: &[NSUInteger],
|
|
1917
|
+
) {
|
|
1918
|
+
assert_eq!(offsets.len(), data.len());
|
|
1919
|
+
unsafe {
|
|
1920
|
+
msg_send![self,
|
|
1921
|
+
setBuffers: data.as_ptr()
|
|
1922
|
+
offsets: offsets.as_ptr()
|
|
1923
|
+
withRange: NSRange {
|
|
1924
|
+
location: start_index,
|
|
1925
|
+
length: data.len() as _,
|
|
1926
|
+
}
|
|
1927
|
+
]
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
pub fn set_texture(&self, at_index: NSUInteger, texture: &TextureRef) {
|
|
1932
|
+
unsafe {
|
|
1933
|
+
msg_send![self,
|
|
1934
|
+
setTexture: texture
|
|
1935
|
+
atIndex: at_index
|
|
1936
|
+
]
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
pub fn set_textures(&self, start_index: NSUInteger, data: &[&TextureRef]) {
|
|
1941
|
+
unsafe {
|
|
1942
|
+
msg_send![self,
|
|
1943
|
+
setTextures: data.as_ptr()
|
|
1944
|
+
withRange: NSRange {
|
|
1945
|
+
location: start_index,
|
|
1946
|
+
length: data.len() as _,
|
|
1947
|
+
}
|
|
1948
|
+
]
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
pub fn set_sampler_state(&self, at_index: NSUInteger, sampler_state: &SamplerStateRef) {
|
|
1953
|
+
unsafe {
|
|
1954
|
+
msg_send![self,
|
|
1955
|
+
setSamplerState: sampler_state
|
|
1956
|
+
atIndex: at_index
|
|
1957
|
+
]
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
pub fn set_sampler_states(&self, start_index: NSUInteger, data: &[&SamplerStateRef]) {
|
|
1962
|
+
unsafe {
|
|
1963
|
+
msg_send![self,
|
|
1964
|
+
setSamplerStates: data.as_ptr()
|
|
1965
|
+
withRange: NSRange {
|
|
1966
|
+
location: start_index,
|
|
1967
|
+
length: data.len() as _,
|
|
1968
|
+
}
|
|
1969
|
+
]
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
pub fn set_render_pipeline_state(
|
|
1974
|
+
&self,
|
|
1975
|
+
at_index: NSUInteger,
|
|
1976
|
+
pipeline: &RenderPipelineStateRef,
|
|
1977
|
+
) {
|
|
1978
|
+
unsafe {
|
|
1979
|
+
msg_send![self,
|
|
1980
|
+
setRenderPipelineState: pipeline
|
|
1981
|
+
atIndex: at_index
|
|
1982
|
+
]
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
pub fn set_render_pipeline_states(
|
|
1987
|
+
&self,
|
|
1988
|
+
start_index: NSUInteger,
|
|
1989
|
+
pipelines: &[&RenderPipelineStateRef],
|
|
1990
|
+
) {
|
|
1991
|
+
unsafe {
|
|
1992
|
+
msg_send![self,
|
|
1993
|
+
setRenderPipelineStates: pipelines.as_ptr()
|
|
1994
|
+
withRange: NSRange {
|
|
1995
|
+
location: start_index,
|
|
1996
|
+
length: pipelines.len() as _,
|
|
1997
|
+
}
|
|
1998
|
+
]
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
pub fn constant_data(&self, at_index: NSUInteger) -> *mut std::ffi::c_void {
|
|
2003
|
+
unsafe { msg_send![self, constantDataAtIndex: at_index] }
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
pub fn set_indirect_command_buffer(
|
|
2007
|
+
&self,
|
|
2008
|
+
at_index: NSUInteger,
|
|
2009
|
+
buffer: &IndirectCommandBufferRef,
|
|
2010
|
+
) {
|
|
2011
|
+
unsafe {
|
|
2012
|
+
msg_send![self,
|
|
2013
|
+
setIndirectCommandBuffer: buffer
|
|
2014
|
+
atIndex: at_index
|
|
2015
|
+
]
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
pub fn set_indirect_command_buffers(
|
|
2020
|
+
&self,
|
|
2021
|
+
start_index: NSUInteger,
|
|
2022
|
+
data: &[&IndirectCommandBufferRef],
|
|
2023
|
+
) {
|
|
2024
|
+
unsafe {
|
|
2025
|
+
msg_send![self,
|
|
2026
|
+
setIndirectCommandBuffers: data.as_ptr()
|
|
2027
|
+
withRange: NSRange {
|
|
2028
|
+
location: start_index,
|
|
2029
|
+
length: data.len() as _,
|
|
2030
|
+
}
|
|
2031
|
+
]
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
pub fn new_argument_encoder_for_buffer(&self, index: NSUInteger) -> ArgumentEncoder {
|
|
2036
|
+
unsafe {
|
|
2037
|
+
let ptr = msg_send![self, newArgumentEncoderForBufferAtIndex: index];
|
|
2038
|
+
ArgumentEncoder::from_ptr(ptr)
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
}
|