From ad7d76a6cebd94f2b750558267a83472dacb844d Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 1 Sep 2022 17:27:25 +0200 Subject: [PATCH] Use common types from objc2::foundation NSUInteger is now usize, so a bunch of `as u64` casts were removed --- Cargo.toml | 2 -- examples/bindless/main.rs | 1 + examples/circle/main.rs | 4 +-- examples/compute/compute-argument-buffer.rs | 6 ++-- examples/compute/main.rs | 6 ++-- examples/headless-render/main.rs | 8 +++--- examples/mps/main.rs | 16 +++++------ examples/shader-dylib/main.rs | 2 +- examples/texture/Cargo.toml | 2 -- examples/texture/src/main.rs | 16 +++++------ examples/window/main.rs | 14 ++++----- src/argument.rs | 3 +- src/buffer.rs | 5 ++-- src/device.rs | 3 +- src/drawable.rs | 2 +- src/encoder.rs | 3 +- src/heap.rs | 1 + src/indirect_encoder.rs | 4 ++- src/lib.rs | 32 ++------------------- src/library.rs | 1 + src/mps.rs | 1 + src/pipeline/compute.rs | 1 + src/pipeline/mod.rs | 1 + src/pipeline/render.rs | 1 + src/renderpass.rs | 1 + src/resource.rs | 3 +- src/sampler.rs | 3 +- src/sync.rs | 1 + src/texture.rs | 7 +++-- src/types.rs | 2 +- src/vertexdescriptor.rs | 3 +- 31 files changed, 70 insertions(+), 85 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c85488b6..09913706 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,8 +21,6 @@ private = [] mps = [] [dependencies] -# Branch: objc2. TODO: Remove this -core-graphics-types = { git = "https://github.com/madsmtm/core-foundation-rs.git", rev = "8e6c4854de2408ed1e3e614dbe6f9f2762bde7c3" } bitflags = "1" log = "0.4" block2 = "=0.2.0-alpha.6" diff --git a/examples/bindless/main.rs b/examples/bindless/main.rs index e7e90ed1..27c91a8d 100644 --- a/examples/bindless/main.rs +++ b/examples/bindless/main.rs @@ -6,6 +6,7 @@ // copied, modified, or distributed except according to those terms. use metal::*; +use objc2::foundation::NSUInteger; use objc2::rc::autoreleasepool; const BINDLESS_TEXTURE_COUNT: NSUInteger = 100_000; // ~25Mb diff --git a/examples/circle/main.rs b/examples/circle/main.rs index f0d8e29f..e4cdc236 100644 --- a/examples/circle/main.rs +++ b/examples/circle/main.rs @@ -7,8 +7,8 @@ use winit::{ }; use cocoa::{appkit::NSView, base::id as cocoa_id}; -use core_graphics_types::geometry::CGSize; +use objc2::foundation::CGSize; use objc2::rc::autoreleasepool; use objc2::runtime::Bool; @@ -103,7 +103,7 @@ fn main() { device.new_buffer_with_data( vertex_data.as_ptr() as *const _, - (vertex_data.len() * mem::size_of::()) as u64, + vertex_data.len() * mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache | MTLResourceOptions::StorageModeManaged, ) }; diff --git a/examples/compute/compute-argument-buffer.rs b/examples/compute/compute-argument-buffer.rs index cc4535fb..1fdae43d 100644 --- a/examples/compute/compute-argument-buffer.rs +++ b/examples/compute/compute-argument-buffer.rs @@ -23,7 +23,7 @@ fn main() { let buffer = device.new_buffer_with_data( unsafe { mem::transmute(data.as_ptr()) }, - (data.len() * mem::size_of::()) as u64, + data.len() * mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache, ); @@ -31,7 +31,7 @@ fn main() { let data = [0u32]; device.new_buffer_with_data( unsafe { mem::transmute(data.as_ptr()) }, - (data.len() * mem::size_of::()) as u64, + data.len() * mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache, ) }; @@ -77,7 +77,7 @@ fn main() { }; let thread_group_size = MTLSize { - width: (data.len() as u64 + width) / width, + width: (data.len() + width) / width, height: 1, depth: 1, }; diff --git a/examples/compute/main.rs b/examples/compute/main.rs index 1a1df0a5..ba91c65f 100644 --- a/examples/compute/main.rs +++ b/examples/compute/main.rs @@ -21,7 +21,7 @@ fn main() { let buffer = device.new_buffer_with_data( unsafe { mem::transmute(data.as_ptr()) }, - (data.len() * mem::size_of::()) as u64, + data.len() * mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache, ); @@ -29,7 +29,7 @@ fn main() { let data = [0u32]; device.new_buffer_with_data( unsafe { mem::transmute(data.as_ptr()) }, - (data.len() * mem::size_of::()) as u64, + data.len() * mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache, ) }; @@ -73,7 +73,7 @@ fn main() { }; let thread_group_size = MTLSize { - width: (data.len() as u64 + width) / width, + width: (data.len() + width) / width, height: 1, depth: 1, }; diff --git a/examples/headless-render/main.rs b/examples/headless-render/main.rs index 44917025..f9603e39 100644 --- a/examples/headless-render/main.rs +++ b/examples/headless-render/main.rs @@ -12,9 +12,9 @@ use metal::{ }; use png::ColorType; -const VIEW_WIDTH: u64 = 512; -const VIEW_HEIGHT: u64 = 512; -const TOTAL_BYTES: usize = (VIEW_WIDTH * VIEW_HEIGHT * 4) as usize; +const VIEW_WIDTH: usize = 512; +const VIEW_HEIGHT: usize = 512; +const TOTAL_BYTES: usize = VIEW_WIDTH * VIEW_HEIGHT * 4; const VERTEX_SHADER: &'static str = "triangle_vertex"; const FRAGMENT_SHADER: &'static str = "triangle_fragment"; @@ -144,7 +144,7 @@ fn prepare_pipeline_state(device: &DeviceRef, library: &LibraryRef) -> RenderPip fn create_vertex_buffer(device: &DeviceRef) -> Buffer { device.new_buffer_with_data( VERTEX_ATTRIBS.as_ptr() as *const _, - (VERTEX_ATTRIBS.len() * mem::size_of::()) as u64, + VERTEX_ATTRIBS.len() * mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache | MTLResourceOptions::StorageModeManaged, ) } diff --git a/examples/mps/main.rs b/examples/mps/main.rs index efff9f4e..485c0bbd 100644 --- a/examples/mps/main.rs +++ b/examples/mps/main.rs @@ -50,13 +50,13 @@ fn main() { let vertex_buffer = device.new_buffer_with_data( vertices.as_ptr() as *const c_void, - (vertex_stride * vertices.len()) as u64, + vertex_stride * vertices.len(), buffer_opts, ); let index_buffer = device.new_buffer_with_data( indices.as_ptr() as *const c_void, - (mem::size_of::() * indices.len()) as u64, + mem::size_of::() * indices.len(), buffer_opts, ); @@ -65,7 +65,7 @@ fn main() { .expect("Failed to create acceleration structure"); acceleration_structure.set_vertex_buffer(Some(&vertex_buffer)); - acceleration_structure.set_vertex_stride(vertex_stride as u64); + acceleration_structure.set_vertex_stride(vertex_stride); acceleration_structure.set_index_buffer(Some(&index_buffer)); acceleration_structure.set_index_type(MPSDataType::UInt32); acceleration_structure.set_triangle_count(1); @@ -75,21 +75,21 @@ fn main() { let ray_intersector = RayIntersector::from_device(&device).expect("Failed to create ray intersector"); - ray_intersector.set_ray_stride(mem::size_of::() as u64); + ray_intersector.set_ray_stride(mem::size_of::()); ray_intersector.set_ray_data_type(MPSRayDataType::OriginMinDistanceDirectionMaxDistance); - ray_intersector.set_intersection_stride(mem::size_of::() as u64); + ray_intersector.set_intersection_stride(mem::size_of::()); ray_intersector .set_intersection_data_type(MPSIntersectionDataType::DistancePrimitiveIndexCoordinates); // Create a buffer to hold generated rays and intersection results let ray_count = 1024; let ray_buffer = device.new_buffer( - (mem::size_of::() * ray_count) as u64, + mem::size_of::() * ray_count, MTLResourceOptions::StorageModePrivate, ); let intersection_buffer = device.new_buffer( - (mem::size_of::() * ray_count) as u64, + mem::size_of::() * ray_count, MTLResourceOptions::StorageModePrivate, ); @@ -119,7 +119,7 @@ fn main() { 0, &intersection_buffer, 0, - ray_count as u64, + ray_count, &acceleration_structure, ); diff --git a/examples/shader-dylib/main.rs b/examples/shader-dylib/main.rs index b9f52372..e7b096d3 100644 --- a/examples/shader-dylib/main.rs +++ b/examples/shader-dylib/main.rs @@ -1,7 +1,7 @@ use cocoa::{appkit::NSView, base::id as cocoa_id}; -use core_graphics_types::geometry::CGSize; use metal::*; +use objc2::foundation::CGSize; use objc2::rc::autoreleasepool; use objc2::runtime::Bool; diff --git a/examples/texture/Cargo.toml b/examples/texture/Cargo.toml index 34950f4c..7b201e25 100644 --- a/examples/texture/Cargo.toml +++ b/examples/texture/Cargo.toml @@ -9,8 +9,6 @@ edition = "2018" bindgen = { version = "0.60", default-features = false, features = ["logging", "runtime", "which-rustfmt"] } [dependencies] -# Branch: objc2. TODO: Remove this -core-graphics-types = { git = "https://github.com/madsmtm/core-foundation-rs.git", rev = "8e6c4854de2408ed1e3e614dbe6f9f2762bde7c3" } cocoa = "0.24" png = "0.17" metal = { path = "../../" } diff --git a/examples/texture/src/main.rs b/examples/texture/src/main.rs index 406b4652..fb75f79f 100644 --- a/examples/texture/src/main.rs +++ b/examples/texture/src/main.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use cocoa::{appkit::NSView, base::id as cocoa_id}; -use core_graphics_types::geometry::CGSize; +use objc2::foundation::{CGSize, NSRange}; use objc2::rc::autoreleasepool; use winit::dpi::LogicalSize; use winit::event_loop::{ControlFlow, EventLoop}; @@ -40,7 +40,7 @@ fn main() { let vertex_data = vertices(); let vertex_buffer = device.new_buffer_with_data( vertex_data.as_ptr() as *const _, - (vertex_data.len() * std::mem::size_of::()) as u64, + vertex_data.len() * std::mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache | MTLResourceOptions::StorageModeManaged, ); @@ -113,7 +113,7 @@ fn create_texture_to_display(device: &Device) -> Texture { let mut reader = decoder.read_info().unwrap(); let info = reader.info(); - let (width, height) = (info.width as u64, info.height as u64); + let (width, height) = (info.width as usize, info.height as usize); let mut buf = vec![0; reader.output_buffer_size()]; reader.next_frame(&mut buf).unwrap(); @@ -226,12 +226,12 @@ fn handle_window_event( fn update_viewport_size_buffer(viewport_size_buffer: &Buffer, size: (u32, u32)) { let contents = viewport_size_buffer.contents(); let viewport_size: [u32; 2] = [size.0, size.1]; - let byte_count = (viewport_size.len() * std::mem::size_of::()) as usize; + let byte_count = viewport_size.len() * std::mem::size_of::(); unsafe { std::ptr::copy(viewport_size.as_ptr(), contents as *mut u32, byte_count); } - viewport_size_buffer.did_modify_range(metal::NSRange::new(0, byte_count as u64)); + viewport_size_buffer.did_modify_range(NSRange::new(0, byte_count)); } fn redraw( @@ -255,9 +255,9 @@ fn redraw( let encoder = command_buffer.new_render_command_encoder(&render_pass_descriptor); encoder.set_render_pipeline_state(&pipeline_state); - encoder.set_vertex_buffer(VerticesBufferIdx as u64, Some(vertex_buffer), 0); - encoder.set_vertex_buffer(ViewportSizeBufferIdx as u64, Some(viewport_size_buffer), 0); - encoder.set_fragment_texture(TextureBaseColorIdx as u64, Some(texture_to_render)); + encoder.set_vertex_buffer(VerticesBufferIdx as usize, Some(vertex_buffer), 0); + encoder.set_vertex_buffer(ViewportSizeBufferIdx as usize, Some(viewport_size_buffer), 0); + encoder.set_fragment_texture(TextureBaseColorIdx as usize, Some(texture_to_render)); encoder.draw_primitives(MTLPrimitiveType::Triangle, 0, 6); encoder.end_encoding(); diff --git a/examples/window/main.rs b/examples/window/main.rs index ba439a3a..f11564ad 100644 --- a/examples/window/main.rs +++ b/examples/window/main.rs @@ -6,9 +6,9 @@ // copied, modified, or distributed except according to those terms. use cocoa::{appkit::NSView, base::id as cocoa_id}; -use core_graphics_types::geometry::CGSize; use metal::*; +use objc2::foundation::{CGSize, NSRange}; use objc2::rc::autoreleasepool; use objc2::runtime::Bool; use std::mem; @@ -132,7 +132,7 @@ fn main() { device.new_buffer_with_data( vertex_data.as_ptr() as *const _, - (vertex_data.len() * mem::size_of::()) as u64, + vertex_data.len() * mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache | MTLResourceOptions::StorageModeManaged, ) }; @@ -156,7 +156,7 @@ fn main() { let clear_rect_buffer = device.new_buffer_with_data( clear_rect.as_ptr() as *const _, - mem::size_of::() as u64, + mem::size_of::(), MTLResourceOptions::CPUCacheModeDefaultCache | MTLResourceOptions::StorageModeManaged, ); @@ -199,13 +199,13 @@ fn main() { std::ptr::copy( vertex_data.as_ptr(), p as *mut f32, - (vertex_data.len() * mem::size_of::()) as usize, + vertex_data.len() * mem::size_of::(), ); } - vbuf.did_modify_range(crate::NSRange::new( - 0 as u64, - (vertex_data.len() * mem::size_of::()) as u64, + vbuf.did_modify_range(NSRange::new( + 0, + vertex_data.len() * mem::size_of::(), )); let drawable = match layer.next_drawable() { diff --git a/src/argument.rs b/src/argument.rs index 8474c686..18ff87ad 100644 --- a/src/argument.rs +++ b/src/argument.rs @@ -5,7 +5,8 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use super::{MTLTextureType, NSUInteger}; +use super::MTLTextureType; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(u64)] diff --git a/src/buffer.rs b/src/buffer.rs index e334c54e..dfadeffd 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -6,6 +6,7 @@ // copied, modified, or distributed except according to those terms. use super::*; +use objc2::foundation::NSRange; pub enum MTLBuffer {} @@ -25,7 +26,7 @@ impl BufferRef { unsafe { msg_send![self, contents] } } - pub fn did_modify_range(&self, range: crate::NSRange) { + pub fn did_modify_range(&self, range: NSRange) { unsafe { msg_send![self, didModifyRange: range] } } @@ -54,7 +55,7 @@ impl BufferRef { unsafe { msg_send![self, newRemoteBufferViewForDevice: device] } } - pub fn add_debug_marker(&self, name: &str, range: crate::NSRange) { + pub fn add_debug_marker(&self, name: &str, range: NSRange) { unsafe { let name = crate::nsstring_from_str(name); msg_send![self, addDebugMarker:name range:range] diff --git a/src/device.rs b/src/device.rs index 1708a74a..d40e2f65 100644 --- a/src/device.rs +++ b/src/device.rs @@ -9,6 +9,7 @@ use super::*; use block2::{Block, ConcreteBlock}; use foreign_types::ForeignType; +use objc2::foundation::NSUInteger; use objc2::runtime::Object; use objc2::{Encode, Encoding}; @@ -1880,7 +1881,7 @@ impl DeviceRef { } } - pub fn new_buffer(&self, length: u64, options: MTLResourceOptions) -> Buffer { + pub fn new_buffer(&self, length: NSUInteger, options: MTLResourceOptions) -> Buffer { unsafe { msg_send![self, newBufferWithLength:length options:options] diff --git a/src/drawable.rs b/src/drawable.rs index a1ab789b..4e19a5e4 100644 --- a/src/drawable.rs +++ b/src/drawable.rs @@ -5,7 +5,7 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use super::NSUInteger; +use objc2::foundation::NSUInteger; pub enum MTLDrawable {} diff --git a/src/encoder.rs b/src/encoder.rs index ace17c68..11673772 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -9,6 +9,7 @@ use super::*; use std::ops::Range; +use objc2::foundation::{NSInteger, NSRange, NSUInteger}; use objc2::{Encode, Encoding}; #[repr(u64)] @@ -904,7 +905,7 @@ impl BlitCommandEncoderRef { unsafe { msg_send![self, synchronizeResource: resource] } } - pub fn fill_buffer(&self, destination_buffer: &BufferRef, range: crate::NSRange, value: u8) { + pub fn fill_buffer(&self, destination_buffer: &BufferRef, range: NSRange, value: u8) { unsafe { msg_send![self, fillBuffer: destination_buffer diff --git a/src/heap.rs b/src/heap.rs index 1276b490..98e06f08 100644 --- a/src/heap.rs +++ b/src/heap.rs @@ -7,6 +7,7 @@ use super::*; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; /// Only available on macos(10.15), ios(13.0) diff --git a/src/indirect_encoder.rs b/src/indirect_encoder.rs index 49ae90d2..505a0aa7 100644 --- a/src/indirect_encoder.rs +++ b/src/indirect_encoder.rs @@ -1,5 +1,7 @@ use super::*; +use objc2::foundation::{NSRange, NSUInteger}; + bitflags! { #[allow(non_upper_case_globals)] pub struct MTLIndirectCommandType: NSUInteger { @@ -99,7 +101,7 @@ impl IndirectCommandBufferRef { unsafe { msg_send![self, indirectComputeCommandAtIndex: index] } } - pub fn reset_with_range(&self, range: crate::NSRange) { + pub fn reset_with_range(&self, range: NSRange) { unsafe { msg_send![self, resetWithRange: range] } } } diff --git a/src/lib.rs b/src/lib.rs index c8d57159..284d2da4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,39 +25,11 @@ use std::{ os::raw::c_void, }; -use core_graphics_types::{base::CGFloat, geometry::CGSize}; use foreign_types::ForeignType; +use objc2::foundation::{CGFloat, CGSize, NSUInteger}; use objc2::runtime::Object; use objc2::{Encode, Encoding, RefEncode}; -#[cfg(target_pointer_width = "64")] -pub type NSInteger = i64; -#[cfg(not(target_pointer_width = "64"))] -pub type NSInteger = i32; -#[cfg(target_pointer_width = "64")] -pub type NSUInteger = u64; -#[cfg(target_pointer_width = "32")] -pub type NSUInteger = u32; - -#[repr(C)] -#[derive(Copy, Clone)] -pub struct NSRange { - pub location: NSUInteger, - pub length: NSUInteger, -} - -unsafe impl objc2::Encode for NSRange { - const ENCODING: objc2::Encoding = - objc2::Encoding::Struct("_NSRange", &[NSUInteger::ENCODING, NSUInteger::ENCODING]); -} - -impl NSRange { - #[inline] - pub fn new(location: NSUInteger, length: NSUInteger) -> NSRange { - NSRange { location, length } - } -} - fn nsstring_as_str(nsstr: &objc2::runtime::Object) -> &str { let bytes = unsafe { let bytes: *const std::os::raw::c_char = msg_send![nsstr, UTF8String]; @@ -65,7 +37,7 @@ fn nsstring_as_str(nsstr: &objc2::runtime::Object) -> &str { }; let len: NSUInteger = unsafe { msg_send![nsstr, length] }; unsafe { - let bytes = std::slice::from_raw_parts(bytes, len as usize); + let bytes = std::slice::from_raw_parts(bytes, len); std::str::from_utf8(bytes).unwrap() } } diff --git a/src/library.rs b/src/library.rs index 7a38ef56..51a25572 100644 --- a/src/library.rs +++ b/src/library.rs @@ -8,6 +8,7 @@ use super::*; use foreign_types::ForeignType; +use objc2::foundation::{NSRange, NSUInteger}; use objc2::runtime::Object; use objc2::{Encode, Encoding}; diff --git a/src/mps.rs b/src/mps.rs index 97de1246..0fd62617 100644 --- a/src/mps.rs +++ b/src/mps.rs @@ -7,6 +7,7 @@ use super::*; +use objc2::foundation::NSUInteger; use objc2::runtime::Bool; use objc2::{Encode, Encoding}; diff --git a/src/pipeline/compute.rs b/src/pipeline/compute.rs index 0fb486ed..c8d24fc5 100644 --- a/src/pipeline/compute.rs +++ b/src/pipeline/compute.rs @@ -7,6 +7,7 @@ use super::*; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(u64)] diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs index 9fdffe8f..2d4084ba 100644 --- a/src/pipeline/mod.rs +++ b/src/pipeline/mod.rs @@ -13,6 +13,7 @@ mod render; pub use self::compute::*; pub use self::render::*; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(u64)] diff --git a/src/pipeline/render.rs b/src/pipeline/render.rs index 8233bc81..3a312f99 100644 --- a/src/pipeline/render.rs +++ b/src/pipeline/render.rs @@ -7,6 +7,7 @@ use super::*; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(u64)] diff --git a/src/renderpass.rs b/src/renderpass.rs index 96233169..6b4f571f 100644 --- a/src/renderpass.rs +++ b/src/renderpass.rs @@ -7,6 +7,7 @@ use super::*; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(u64)] diff --git a/src/resource.rs b/src/resource.rs index b7fa192f..14cb0345 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -5,7 +5,8 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use super::{DeviceRef, HeapRef, NSUInteger}; +use super::{DeviceRef, HeapRef}; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(u64)] diff --git a/src/sampler.rs b/src/sampler.rs index c49ded44..be076fc0 100644 --- a/src/sampler.rs +++ b/src/sampler.rs @@ -5,8 +5,9 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use super::{depthstencil::MTLCompareFunction, DeviceRef, NSUInteger}; +use super::{depthstencil::MTLCompareFunction, DeviceRef}; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(u64)] diff --git a/src/sync.rs b/src/sync.rs index 01ee9a0a..7e03d84f 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -7,6 +7,7 @@ use super::*; use block2::{Block, RcBlock}; +use objc2::foundation::NSUInteger; use objc2::{Encode, EncodeArguments, Encoding}; use std::mem; diff --git a/src/texture.rs b/src/texture.rs index 776fd3fb..c9432525 100644 --- a/src/texture.rs +++ b/src/texture.rs @@ -7,6 +7,7 @@ use super::*; +use objc2::foundation::{NSRange, NSUInteger}; use objc2::{Encode, Encoding}; #[repr(u64)] @@ -124,7 +125,7 @@ impl TextureDescriptorRef { height, depth, } = size; - let count = (width.max(height).max(depth) as f64).log2().ceil() as u64; + let count = (width.max(height).max(depth) as f64).log2().ceil() as NSUInteger; self.set_mipmap_level_count(count); } @@ -341,8 +342,8 @@ impl TextureRef { &self, pixel_format: MTLPixelFormat, texture_type: MTLTextureType, - mipmap_levels: crate::NSRange, - slices: crate::NSRange, + mipmap_levels: NSRange, + slices: NSRange, ) -> Texture { unsafe { msg_send![self, newTextureViewWithPixelFormat:pixel_format diff --git a/src/types.rs b/src/types.rs index 90b3e76b..5d0a591a 100644 --- a/src/types.rs +++ b/src/types.rs @@ -5,9 +5,9 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use super::NSUInteger; use std::default::Default; +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(C)] diff --git a/src/vertexdescriptor.rs b/src/vertexdescriptor.rs index b66dae75..61b37122 100644 --- a/src/vertexdescriptor.rs +++ b/src/vertexdescriptor.rs @@ -5,8 +5,7 @@ // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. -use super::NSUInteger; - +use objc2::foundation::NSUInteger; use objc2::{Encode, Encoding}; #[repr(u64)]