| 1 |
// Copyright 2016 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 |
/// See <https://developer.apple.com/documentation/metal/mtlbuffer> |
| 11 |
pub enum MTLBuffer {} |
| 12 |
|
| 13 |
foreign_obj_type! { |
| 14 |
type CType = MTLBuffer; |
| 15 |
pub struct Buffer; |
| 16 |
type ParentType = Resource; |
| 17 |
} |
| 18 |
|
| 19 |
impl BufferRef { |
| 20 |
pub fn length(&self) -> u64 { |
| 21 |
unsafe { msg_send![self, length] } |
| 22 |
} |
| 23 |
|
| 24 |
pub fn contents(&self) -> *mut std::ffi::c_void { |
| 25 |
unsafe { msg_send![self, contents] } |
| 26 |
} |
| 27 |
|
| 28 |
pub fn did_modify_range(&self, range: crate::NSRange) { |
| 29 |
unsafe { msg_send![self, didModifyRange: range] } |
| 30 |
} |
| 31 |
|
| 32 |
pub fn new_texture_with_descriptor( |
| 33 |
&self, |
| 34 |
descriptor: &TextureDescriptorRef, |
| 35 |
offset: u64, |
| 36 |
bytes_per_row: u64, |
| 37 |
) -> Texture { |
| 38 |
unsafe { |
| 39 |
msg_send![self, |
| 40 |
newTextureWithDescriptor:descriptor |
| 41 |
offset:offset |
| 42 |
bytesPerRow:bytes_per_row |
| 43 |
] |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
/// Only available on macos(10.15), NOT available on (ios) |
| 48 |
pub fn remote_storage_buffer(&self) -> &BufferRef { |
| 49 |
unsafe { msg_send![self, remoteStorageBuffer] } |
| 50 |
} |
| 51 |
|
| 52 |
/// Only available on (macos(10.15), NOT available on (ios) |
| 53 |
pub fn new_remote_buffer_view_for_device(&self, device: &DeviceRef) -> Buffer { |
| 54 |
unsafe { msg_send![self, newRemoteBufferViewForDevice: device] } |
| 55 |
} |
| 56 |
|
| 57 |
pub fn add_debug_marker(&self, name: &str, range: crate::NSRange) { |
| 58 |
unsafe { |
| 59 |
let name = crate::nsstring_from_str(name); |
| 60 |
msg_send![self, addDebugMarker:name range:range] |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
pub fn remove_all_debug_markers(&self) { |
| 65 |
unsafe { msg_send![self, removeAllDebugMarkers] } |
| 66 |
} |
| 67 |
|
| 68 |
pub fn gpu_address(&self) -> u64 { |
| 69 |
unsafe { msg_send![self, gpuAddress] } |
| 70 |
} |
| 71 |
} |