Skip to content

Commit

Permalink
Merge #38
Browse files Browse the repository at this point in the history
38: Add functions from gfx r=kvark a=grovesNL

Moved some functions from gfx (for gfx-rs/gfx#1972)

This isn't comprehensive yet – I've just moved the functions that were mostly straightforward. The remaining cases probably need more discussion (i.e. what to do with `ConcreteBlock` and `IOSurface` dependencies).

Co-authored-by: Joshua Groves <[email protected]>
  • Loading branch information
bors[bot] and grovesNL committed Apr 26, 2018
2 parents 15a3bd2 + 1795fdd commit 83c8e5b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "metal-rs"
version = "0.8.0"
version = "0.8.1"
description = "Rust bindings for Metal"
documentation = "https://docs.rs/crate/metal-rs"
homepage = "https://github.com/gfx-rs/metal-rs"
Expand Down
4 changes: 4 additions & 0 deletions src/capturemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ impl CaptureManagerRef {
unsafe { msg_send![self, defaultCaptureScope] }
}

pub fn set_default_capture_scope(&self, scope: &CaptureScopeRef) {
unsafe { msg_send![self, setDefaultCaptureScope:scope] }
}

pub fn start_capture_with_device(&self, device: &DeviceRef) {
unsafe {
msg_send![self, startCaptureWithDevice: device];
Expand Down
6 changes: 6 additions & 0 deletions src/commandqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ impl CommandQueueRef {
msg_send![self, commandBufferWithUnretainedReferences]
}
}

pub fn device(&self) -> &DeviceRef {
unsafe {
msg_send![self, device]
}
}
}
49 changes: 49 additions & 0 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@ impl RenderCommandEncoderRef {
}
}

pub fn draw_primitives_instanced_base_instance(&self, primitive_type: MTLPrimitiveType, vertex_start: NSUInteger, vertex_count: NSUInteger, instance_count: NSUInteger, base_instance: NSUInteger) {
unsafe {
msg_send![self, drawPrimitives:primitive_type
vertexStart:vertex_start
vertexCount:vertex_count
instanceCount:instance_count
baseInstance:base_instance]
}
}

pub fn draw_indexed_primitives(&self, primitive_type: MTLPrimitiveType, index_count: NSUInteger, index_type: MTLIndexType, index_buffer: &BufferRef, index_buffer_offset: NSUInteger) {
unsafe {
msg_send![self, drawIndexedPrimitives:primitive_type
Expand Down Expand Up @@ -414,6 +424,45 @@ impl BlitCommandEncoderRef {
}
}

pub fn copy_from_buffer(&self, source_buffer: &BufferRef, source_offset: NSUInteger, destination_buffer: &BufferRef, destination_offset: NSUInteger, size: NSUInteger) {
unsafe {
msg_send![self, copyFromBuffer:source_buffer
sourceOffset:source_offset
toBuffer:destination_buffer
destinationOffset:destination_offset
size:size]
}
}

pub fn copy_from_buffer_to_texture(&self, source_buffer: &BufferRef, source_offset: NSUInteger, source_bytes_per_row: NSUInteger, source_bytes_per_image: NSUInteger, source_size: MTLSize, destination_texture: &TextureRef, destination_slice: NSUInteger, destination_level: NSUInteger, destination_origin: MTLOrigin) {
unsafe {
msg_send![self, copyFromBuffer:source_buffer
sourceOffset:source_offset
sourceBytesPerRow:source_bytes_per_row
sourceBytesPerImage:source_bytes_per_image
sourceSize:source_size
toTexture:destination_texture
destinationSlice:destination_slice
destinationLevel:destination_level
destinationOrigin:destination_origin
]
}
}

pub fn copy_from_texture_to_buffer(&self, source_texture: &TextureRef, source_slice: NSUInteger, source_level: NSUInteger, source_origin: MTLOrigin, source_size: MTLSize, destination_buffer: &BufferRef, destination_offset: NSUInteger, destination_bytes_per_row: NSUInteger, destination_bytes_per_image: NSUInteger) {
unsafe {
msg_send![self, copyFromTexture:source_texture
sourceSlice:source_slice
sourceLevel:source_level
sourceOrigin:source_origin
sourceSize:source_size
toBuffer:destination_buffer
destinationOffset:destination_offset
destinationBytesPerRow:destination_bytes_per_row
destinationBytesPerImage:destination_bytes_per_image
]
}
}
}

pub enum MTLComputeCommandEncoder {}
Expand Down
6 changes: 6 additions & 0 deletions src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ impl FunctionRef {
ArgumentEncoder::from_ptr(ptr)
}
}

pub fn function_constants_dictionary(&self) -> *mut Object {
unsafe {
msg_send![self, functionConstantsDictionary]
}
}
}

#[repr(u64)]
Expand Down
6 changes: 6 additions & 0 deletions src/renderpass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,10 @@ impl RenderPassDescriptorRef {
msg_send![self, renderTargetArrayLength]
}
}

pub fn set_render_target_array_length(&self, length: NSUInteger) {
unsafe {
msg_send![self, setRenderTargetArrayLength:length]
}
}
}

0 comments on commit 83c8e5b

Please sign in to comment.