diff --git a/Cargo.toml b/Cargo.toml index 01b8bb8d0..105516476 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,7 +88,7 @@ winit = "0.27.1" # Metal dependencies block = "0.1" foreign-types = "0.3" -mtl = { package = "metal", version = "0.24.0" } +metal = "0.24.0" objc = "0.2.5" core-graphics-types = "0.1" diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 79f228be3..30c9436e4 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -102,7 +102,7 @@ native = { package = "d3d12", version = "0.6.0", git = "https://github.com/gfx-r block = { version = "0.1", optional = true } foreign-types = { version = "0.3", optional = true } -mtl = { package = "metal", version = "0.24.0" } +metal = "0.24.0" objc = "0.2.5" core-graphics-types = "0.1" diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index e1ac0eae5..b19b66d68 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -1,4 +1,4 @@ -use mtl::{MTLFeatureSet, MTLGPUFamily, MTLLanguageVersion, MTLReadWriteTextureTier}; +use metal::{MTLFeatureSet, MTLGPUFamily, MTLLanguageVersion, MTLReadWriteTextureTier}; use objc::{class, msg_send, sel, sel_impl}; use parking_lot::Mutex; use wgt::{AstcBlock, AstcChannel}; @@ -50,9 +50,9 @@ impl crate::Adapter for super::Adapter { // https://developer.apple.com/documentation/metal/mtlreadwritetexturetier/mtlreadwritetexturetier1?language=objc // https://developer.apple.com/documentation/metal/mtlreadwritetexturetier/mtlreadwritetexturetier2?language=objc let (read_write_tier1_if, read_write_tier2_if) = match pc.read_write_texture_tier { - mtl::MTLReadWriteTextureTier::TierNone => (Tfc::empty(), Tfc::empty()), - mtl::MTLReadWriteTextureTier::Tier1 => (Tfc::STORAGE_READ_WRITE, Tfc::empty()), - mtl::MTLReadWriteTextureTier::Tier2 => { + metal::MTLReadWriteTextureTier::TierNone => (Tfc::empty(), Tfc::empty()), + metal::MTLReadWriteTextureTier::Tier1 => (Tfc::STORAGE_READ_WRITE, Tfc::empty()), + metal::MTLReadWriteTextureTier::Tier2 => { (Tfc::STORAGE_READ_WRITE, Tfc::STORAGE_READ_WRITE) } }; @@ -437,14 +437,14 @@ const DEPTH_CLIP_MODE: &[MTLFeatureSet] = &[ const OS_NOT_SUPPORT: (usize, usize) = (10000, 0); impl super::PrivateCapabilities { - fn supports_any(raw: &mtl::DeviceRef, features_sets: &[MTLFeatureSet]) -> bool { + fn supports_any(raw: &metal::DeviceRef, features_sets: &[MTLFeatureSet]) -> bool { features_sets .iter() .cloned() .any(|x| raw.supports_feature_set(x)) } - pub fn new(device: &mtl::Device) -> Self { + pub fn new(device: &metal::Device) -> Self { #[repr(C)] #[derive(Clone, Copy, Debug)] #[allow(clippy::upper_case_acronyms)] @@ -628,7 +628,7 @@ impl super::PrivateCapabilities { buffer_alignment: if os_is_mac { 256 } else { 64 }, max_buffer_size: if version.at_least((10, 14), (12, 0)) { // maxBufferLength available on macOS 10.14+ and iOS 12.0+ - let buffer_size: mtl::NSInteger = + let buffer_size: metal::NSInteger = unsafe { msg_send![device.as_ref(), maxBufferLength] }; buffer_size as _ } else if os_is_mac { @@ -863,8 +863,8 @@ impl super::PrivateCapabilities { } } - pub fn map_format(&self, format: wgt::TextureFormat) -> mtl::MTLPixelFormat { - use mtl::MTLPixelFormat::*; + pub fn map_format(&self, format: wgt::TextureFormat) -> metal::MTLPixelFormat { + use metal::MTLPixelFormat::*; use wgt::TextureFormat as Tf; match format { Tf::R8Unorm => R8Unorm, @@ -1008,9 +1008,9 @@ impl super::PrivateCapabilities { &self, format: wgt::TextureFormat, aspects: crate::FormatAspects, - ) -> mtl::MTLPixelFormat { + ) -> metal::MTLPixelFormat { use crate::FormatAspects as Fa; - use mtl::MTLPixelFormat::*; + use metal::MTLPixelFormat::*; use wgt::TextureFormat as Tf; match (format, aspects) { // map combined depth-stencil format to their stencil-only format @@ -1030,7 +1030,7 @@ impl super::PrivateCapabilities { } impl super::PrivateDisabilities { - pub fn new(device: &mtl::Device) -> Self { + pub fn new(device: &metal::Device) -> Self { let is_intel = device.name().starts_with("Intel"); Self { broken_viewport_near_depth: is_intel diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index e94c8dae4..25e355a32 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -10,9 +10,9 @@ impl Default for super::CommandState { blit: None, render: None, compute: None, - raw_primitive_type: mtl::MTLPrimitiveType::Point, + raw_primitive_type: metal::MTLPrimitiveType::Point, index: None, - raw_wg_size: mtl::MTLSize::new(0, 0, 0), + raw_wg_size: metal::MTLSize::new(0, 0, 0), stage_infos: Default::default(), storage_buffer_length_map: Default::default(), work_group_memory_sizes: Vec::new(), @@ -22,7 +22,7 @@ impl Default for super::CommandState { } impl super::CommandEncoder { - fn enter_blit(&mut self) -> &mtl::BlitCommandEncoderRef { + fn enter_blit(&mut self) -> &metal::BlitCommandEncoderRef { if self.state.blit.is_none() { debug_assert!(self.state.render.is_none() && self.state.compute.is_none()); objc::rc::autoreleasepool(|| { @@ -39,7 +39,7 @@ impl super::CommandEncoder { } } - fn enter_any(&mut self) -> Option<&mtl::CommandEncoderRef> { + fn enter_any(&mut self) -> Option<&metal::CommandEncoderRef> { if let Some(ref encoder) = self.state.render { Some(encoder) } else if let Some(ref encoder) = self.state.compute { @@ -300,7 +300,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .as_ref() .unwrap() .set_visibility_result_mode( - mtl::MTLVisibilityResultMode::Boolean, + metal::MTLVisibilityResultMode::Boolean, index as u64 * crate::QUERY_SIZE, ); } @@ -314,7 +314,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .render .as_ref() .unwrap() - .set_visibility_result_mode(mtl::MTLVisibilityResultMode::Disabled, 0); + .set_visibility_result_mode(metal::MTLVisibilityResultMode::Disabled, 0); } _ => {} } @@ -322,7 +322,7 @@ impl crate::CommandEncoder for super::CommandEncoder { unsafe fn write_timestamp(&mut self, _set: &super::QuerySet, _index: u32) {} unsafe fn reset_queries(&mut self, set: &super::QuerySet, range: Range) { let encoder = self.enter_blit(); - let raw_range = mtl::NSRange { + let raw_range = metal::NSRange { location: range.start as u64 * crate::QUERY_SIZE, length: (range.end - range.start) as u64 * crate::QUERY_SIZE, }; @@ -354,7 +354,7 @@ impl crate::CommandEncoder for super::CommandEncoder { self.state.index = None; objc::rc::autoreleasepool(|| { - let descriptor = mtl::RenderPassDescriptor::new(); + let descriptor = metal::RenderPassDescriptor::new(); //TODO: set visibility results buffer for (i, at) in desc.color_attachments.iter().enumerate() { @@ -366,10 +366,10 @@ impl crate::CommandEncoder for super::CommandEncoder { at_descriptor.set_resolve_texture(Some(&resolve.view.raw)); } let load_action = if at.ops.contains(crate::AttachmentOps::LOAD) { - mtl::MTLLoadAction::Load + metal::MTLLoadAction::Load } else { at_descriptor.set_clear_color(conv::map_clear_color(&at.clear_value)); - mtl::MTLLoadAction::Clear + metal::MTLLoadAction::Clear }; let store_action = conv::map_store_action( at.ops.contains(crate::AttachmentOps::STORE), @@ -386,15 +386,15 @@ impl crate::CommandEncoder for super::CommandEncoder { at_descriptor.set_texture(Some(&at.target.view.raw)); let load_action = if at.depth_ops.contains(crate::AttachmentOps::LOAD) { - mtl::MTLLoadAction::Load + metal::MTLLoadAction::Load } else { at_descriptor.set_clear_depth(at.clear_value.0 as f64); - mtl::MTLLoadAction::Clear + metal::MTLLoadAction::Clear }; let store_action = if at.depth_ops.contains(crate::AttachmentOps::STORE) { - mtl::MTLStoreAction::Store + metal::MTLStoreAction::Store } else { - mtl::MTLStoreAction::DontCare + metal::MTLStoreAction::DontCare }; at_descriptor.set_load_action(load_action); at_descriptor.set_store_action(store_action); @@ -409,15 +409,15 @@ impl crate::CommandEncoder for super::CommandEncoder { at_descriptor.set_texture(Some(&at.target.view.raw)); let load_action = if at.stencil_ops.contains(crate::AttachmentOps::LOAD) { - mtl::MTLLoadAction::Load + metal::MTLLoadAction::Load } else { at_descriptor.set_clear_stencil(at.clear_value.1); - mtl::MTLLoadAction::Clear + metal::MTLLoadAction::Clear }; let store_action = if at.stencil_ops.contains(crate::AttachmentOps::STORE) { - mtl::MTLStoreAction::Store + metal::MTLStoreAction::Store } else { - mtl::MTLStoreAction::DontCare + metal::MTLStoreAction::DontCare }; at_descriptor.set_load_action(load_action); at_descriptor.set_store_action(store_action); @@ -713,8 +713,8 @@ impl crate::CommandEncoder for super::CommandEncoder { format: wgt::IndexFormat, ) { let (stride, raw_type) = match format { - wgt::IndexFormat::Uint16 => (2, mtl::MTLIndexType::UInt16), - wgt::IndexFormat::Uint32 => (4, mtl::MTLIndexType::UInt32), + wgt::IndexFormat::Uint16 => (2, metal::MTLIndexType::UInt16), + wgt::IndexFormat::Uint32 => (4, metal::MTLIndexType::UInt32), }; self.state.index = Some(super::IndexState { buffer_ptr: AsNative::from(binding.buffer.raw.as_ref()), @@ -741,7 +741,7 @@ impl crate::CommandEncoder for super::CommandEncoder { depth_range.end }; let encoder = self.state.render.as_ref().unwrap(); - encoder.set_viewport(mtl::MTLViewport { + encoder.set_viewport(metal::MTLViewport { originX: rect.x as _, originY: rect.y as _, width: rect.w as _, @@ -752,7 +752,7 @@ impl crate::CommandEncoder for super::CommandEncoder { } unsafe fn set_scissor_rect(&mut self, rect: &crate::Rect) { //TODO: support empty scissors by modifying the viewport - let scissor = mtl::MTLScissorRect { + let scissor = metal::MTLScissorRect { x: rect.x as _, y: rect.y as _, width: rect.w as _, @@ -957,7 +957,7 @@ impl crate::CommandEncoder for super::CommandEncoder { unsafe fn dispatch(&mut self, count: [u32; 3]) { let encoder = self.state.compute.as_ref().unwrap(); - let raw_count = mtl::MTLSize { + let raw_count = metal::MTLSize { width: count[0] as u64, height: count[1] as u64, depth: count[2] as u64, diff --git a/wgpu-hal/src/metal/conv.rs b/wgpu-hal/src/metal/conv.rs index 3ffffc31b..a1ceb287a 100644 --- a/wgpu-hal/src/metal/conv.rs +++ b/wgpu-hal/src/metal/conv.rs @@ -1,37 +1,37 @@ pub fn map_texture_usage( format: wgt::TextureFormat, usage: crate::TextureUses, -) -> mtl::MTLTextureUsage { +) -> metal::MTLTextureUsage { use crate::TextureUses as Tu; - let mut mtl_usage = mtl::MTLTextureUsage::Unknown; + let mut mtl_usage = metal::MTLTextureUsage::Unknown; mtl_usage.set( - mtl::MTLTextureUsage::RenderTarget, + metal::MTLTextureUsage::RenderTarget, usage.intersects(Tu::COLOR_TARGET | Tu::DEPTH_STENCIL_READ | Tu::DEPTH_STENCIL_WRITE), ); mtl_usage.set( - mtl::MTLTextureUsage::ShaderRead, + metal::MTLTextureUsage::ShaderRead, usage.intersects( Tu::RESOURCE | Tu::DEPTH_STENCIL_READ | Tu::STORAGE_READ | Tu::STORAGE_READ_WRITE, ), ); mtl_usage.set( - mtl::MTLTextureUsage::ShaderWrite, + metal::MTLTextureUsage::ShaderWrite, usage.intersects(Tu::STORAGE_READ_WRITE), ); // needed for combined depth/stencil formats since we might // create a stencil-only view from them mtl_usage.set( - mtl::MTLTextureUsage::PixelFormatView, + metal::MTLTextureUsage::PixelFormatView, format.is_combined_depth_stencil_format(), ); mtl_usage } -pub fn map_texture_view_dimension(dim: wgt::TextureViewDimension) -> mtl::MTLTextureType { - use mtl::MTLTextureType::*; +pub fn map_texture_view_dimension(dim: wgt::TextureViewDimension) -> metal::MTLTextureType { + use metal::MTLTextureType::*; use wgt::TextureViewDimension as Tvd; match dim { Tvd::D1 => D1, @@ -43,8 +43,8 @@ pub fn map_texture_view_dimension(dim: wgt::TextureViewDimension) -> mtl::MTLTex } } -pub fn map_compare_function(fun: wgt::CompareFunction) -> mtl::MTLCompareFunction { - use mtl::MTLCompareFunction::*; +pub fn map_compare_function(fun: wgt::CompareFunction) -> metal::MTLCompareFunction { + use metal::MTLCompareFunction::*; use wgt::CompareFunction as Cf; match fun { Cf::Never => Never, @@ -58,16 +58,16 @@ pub fn map_compare_function(fun: wgt::CompareFunction) -> mtl::MTLCompareFunctio } } -pub fn map_filter_mode(filter: wgt::FilterMode) -> mtl::MTLSamplerMinMagFilter { - use mtl::MTLSamplerMinMagFilter::*; +pub fn map_filter_mode(filter: wgt::FilterMode) -> metal::MTLSamplerMinMagFilter { + use metal::MTLSamplerMinMagFilter::*; match filter { wgt::FilterMode::Nearest => Nearest, wgt::FilterMode::Linear => Linear, } } -pub fn map_address_mode(address: wgt::AddressMode) -> mtl::MTLSamplerAddressMode { - use mtl::MTLSamplerAddressMode::*; +pub fn map_address_mode(address: wgt::AddressMode) -> metal::MTLSamplerAddressMode { + use metal::MTLSamplerAddressMode::*; use wgt::AddressMode as Fm; match address { Fm::Repeat => Repeat, @@ -78,8 +78,8 @@ pub fn map_address_mode(address: wgt::AddressMode) -> mtl::MTLSamplerAddressMode } } -pub fn map_border_color(border_color: wgt::SamplerBorderColor) -> mtl::MTLSamplerBorderColor { - use mtl::MTLSamplerBorderColor::*; +pub fn map_border_color(border_color: wgt::SamplerBorderColor) -> metal::MTLSamplerBorderColor { + use metal::MTLSamplerBorderColor::*; match border_color { wgt::SamplerBorderColor::TransparentBlack => TransparentBlack, wgt::SamplerBorderColor::OpaqueBlack => OpaqueBlack, @@ -90,53 +90,53 @@ pub fn map_border_color(border_color: wgt::SamplerBorderColor) -> mtl::MTLSample pub fn map_primitive_topology( topology: wgt::PrimitiveTopology, -) -> (mtl::MTLPrimitiveTopologyClass, mtl::MTLPrimitiveType) { +) -> (metal::MTLPrimitiveTopologyClass, metal::MTLPrimitiveType) { use wgt::PrimitiveTopology as Pt; match topology { Pt::PointList => ( - mtl::MTLPrimitiveTopologyClass::Point, - mtl::MTLPrimitiveType::Point, + metal::MTLPrimitiveTopologyClass::Point, + metal::MTLPrimitiveType::Point, ), Pt::LineList => ( - mtl::MTLPrimitiveTopologyClass::Line, - mtl::MTLPrimitiveType::Line, + metal::MTLPrimitiveTopologyClass::Line, + metal::MTLPrimitiveType::Line, ), Pt::LineStrip => ( - mtl::MTLPrimitiveTopologyClass::Line, - mtl::MTLPrimitiveType::LineStrip, + metal::MTLPrimitiveTopologyClass::Line, + metal::MTLPrimitiveType::LineStrip, ), Pt::TriangleList => ( - mtl::MTLPrimitiveTopologyClass::Triangle, - mtl::MTLPrimitiveType::Triangle, + metal::MTLPrimitiveTopologyClass::Triangle, + metal::MTLPrimitiveType::Triangle, ), Pt::TriangleStrip => ( - mtl::MTLPrimitiveTopologyClass::Triangle, - mtl::MTLPrimitiveType::TriangleStrip, + metal::MTLPrimitiveTopologyClass::Triangle, + metal::MTLPrimitiveType::TriangleStrip, ), } } -pub fn map_color_write(mask: wgt::ColorWrites) -> mtl::MTLColorWriteMask { - let mut raw_mask = mtl::MTLColorWriteMask::empty(); +pub fn map_color_write(mask: wgt::ColorWrites) -> metal::MTLColorWriteMask { + let mut raw_mask = metal::MTLColorWriteMask::empty(); if mask.contains(wgt::ColorWrites::RED) { - raw_mask |= mtl::MTLColorWriteMask::Red; + raw_mask |= metal::MTLColorWriteMask::Red; } if mask.contains(wgt::ColorWrites::GREEN) { - raw_mask |= mtl::MTLColorWriteMask::Green; + raw_mask |= metal::MTLColorWriteMask::Green; } if mask.contains(wgt::ColorWrites::BLUE) { - raw_mask |= mtl::MTLColorWriteMask::Blue; + raw_mask |= metal::MTLColorWriteMask::Blue; } if mask.contains(wgt::ColorWrites::ALPHA) { - raw_mask |= mtl::MTLColorWriteMask::Alpha; + raw_mask |= metal::MTLColorWriteMask::Alpha; } raw_mask } -pub fn map_blend_factor(factor: wgt::BlendFactor) -> mtl::MTLBlendFactor { - use mtl::MTLBlendFactor::*; +pub fn map_blend_factor(factor: wgt::BlendFactor) -> metal::MTLBlendFactor { + use metal::MTLBlendFactor::*; use wgt::BlendFactor as Bf; match factor { @@ -162,8 +162,8 @@ pub fn map_blend_factor(factor: wgt::BlendFactor) -> mtl::MTLBlendFactor { } } -pub fn map_blend_op(operation: wgt::BlendOperation) -> mtl::MTLBlendOperation { - use mtl::MTLBlendOperation::*; +pub fn map_blend_op(operation: wgt::BlendOperation) -> metal::MTLBlendOperation { + use metal::MTLBlendOperation::*; use wgt::BlendOperation as Bo; match operation { @@ -178,9 +178,9 @@ pub fn map_blend_op(operation: wgt::BlendOperation) -> mtl::MTLBlendOperation { pub fn map_blend_component( component: &wgt::BlendComponent, ) -> ( - mtl::MTLBlendOperation, - mtl::MTLBlendFactor, - mtl::MTLBlendFactor, + metal::MTLBlendOperation, + metal::MTLBlendFactor, + metal::MTLBlendFactor, ) { ( map_blend_op(component.operation), @@ -189,8 +189,8 @@ pub fn map_blend_component( ) } -pub fn map_vertex_format(format: wgt::VertexFormat) -> mtl::MTLVertexFormat { - use mtl::MTLVertexFormat::*; +pub fn map_vertex_format(format: wgt::VertexFormat) -> metal::MTLVertexFormat { + use metal::MTLVertexFormat::*; use wgt::VertexFormat as Vf; match format { @@ -228,15 +228,15 @@ pub fn map_vertex_format(format: wgt::VertexFormat) -> mtl::MTLVertexFormat { } } -pub fn map_step_mode(mode: wgt::VertexStepMode) -> mtl::MTLVertexStepFunction { +pub fn map_step_mode(mode: wgt::VertexStepMode) -> metal::MTLVertexStepFunction { match mode { - wgt::VertexStepMode::Vertex => mtl::MTLVertexStepFunction::PerVertex, - wgt::VertexStepMode::Instance => mtl::MTLVertexStepFunction::PerInstance, + wgt::VertexStepMode::Vertex => metal::MTLVertexStepFunction::PerVertex, + wgt::VertexStepMode::Instance => metal::MTLVertexStepFunction::PerInstance, } } -pub fn map_stencil_op(op: wgt::StencilOperation) -> mtl::MTLStencilOperation { - use mtl::MTLStencilOperation::*; +pub fn map_stencil_op(op: wgt::StencilOperation) -> metal::MTLStencilOperation { + use metal::MTLStencilOperation::*; use wgt::StencilOperation as So; match op { @@ -251,46 +251,46 @@ pub fn map_stencil_op(op: wgt::StencilOperation) -> mtl::MTLStencilOperation { } } -pub fn map_winding(winding: wgt::FrontFace) -> mtl::MTLWinding { +pub fn map_winding(winding: wgt::FrontFace) -> metal::MTLWinding { match winding { - wgt::FrontFace::Cw => mtl::MTLWinding::Clockwise, - wgt::FrontFace::Ccw => mtl::MTLWinding::CounterClockwise, + wgt::FrontFace::Cw => metal::MTLWinding::Clockwise, + wgt::FrontFace::Ccw => metal::MTLWinding::CounterClockwise, } } -pub fn map_cull_mode(face: Option) -> mtl::MTLCullMode { +pub fn map_cull_mode(face: Option) -> metal::MTLCullMode { match face { - None => mtl::MTLCullMode::None, - Some(wgt::Face::Front) => mtl::MTLCullMode::Front, - Some(wgt::Face::Back) => mtl::MTLCullMode::Back, + None => metal::MTLCullMode::None, + Some(wgt::Face::Front) => metal::MTLCullMode::Front, + Some(wgt::Face::Back) => metal::MTLCullMode::Back, } } -pub fn map_range(range: &crate::MemoryRange) -> mtl::NSRange { - mtl::NSRange { +pub fn map_range(range: &crate::MemoryRange) -> metal::NSRange { + metal::NSRange { location: range.start, length: range.end - range.start, } } -pub fn map_copy_extent(extent: &crate::CopyExtent) -> mtl::MTLSize { - mtl::MTLSize { +pub fn map_copy_extent(extent: &crate::CopyExtent) -> metal::MTLSize { + metal::MTLSize { width: extent.width as u64, height: extent.height as u64, depth: extent.depth as u64, } } -pub fn map_origin(origin: &wgt::Origin3d) -> mtl::MTLOrigin { - mtl::MTLOrigin { +pub fn map_origin(origin: &wgt::Origin3d) -> metal::MTLOrigin { + metal::MTLOrigin { x: origin.x as u64, y: origin.y as u64, z: origin.z as u64, } } -pub fn map_store_action(store: bool, resolve: bool) -> mtl::MTLStoreAction { - use mtl::MTLStoreAction::*; +pub fn map_store_action(store: bool, resolve: bool) -> metal::MTLStoreAction { + use metal::MTLStoreAction::*; match (store, resolve) { (true, true) => StoreAndMultisampleResolve, (false, true) => MultisampleResolve, @@ -299,8 +299,8 @@ pub fn map_store_action(store: bool, resolve: bool) -> mtl::MTLStoreAction { } } -pub fn map_clear_color(color: &wgt::Color) -> mtl::MTLClearColor { - mtl::MTLClearColor { +pub fn map_clear_color(color: &wgt::Color) -> metal::MTLClearColor { + metal::MTLClearColor { red: color.r, green: color.g, blue: color.b, @@ -311,14 +311,14 @@ pub fn map_clear_color(color: &wgt::Color) -> mtl::MTLClearColor { pub fn get_blit_option( format: wgt::TextureFormat, aspect: crate::FormatAspects, -) -> mtl::MTLBlitOption { +) -> metal::MTLBlitOption { if format.is_combined_depth_stencil_format() { match aspect { - crate::FormatAspects::DEPTH => mtl::MTLBlitOption::DepthFromDepthStencil, - crate::FormatAspects::STENCIL => mtl::MTLBlitOption::StencilFromDepthStencil, + crate::FormatAspects::DEPTH => metal::MTLBlitOption::DepthFromDepthStencil, + crate::FormatAspects::STENCIL => metal::MTLBlitOption::StencilFromDepthStencil, _ => unreachable!(), } } else { - mtl::MTLBlitOption::None + metal::MTLBlitOption::None } } diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index 4a4e19fa2..c80fec2b9 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -12,9 +12,9 @@ use crate::auxil::map_naga_stage; type DeviceResult = Result; struct CompiledShader { - library: mtl::Library, - function: mtl::Function, - wg_size: mtl::MTLSize, + library: metal::Library, + function: metal::Function, + wg_size: metal::MTLSize, wg_memory_sizes: Vec, /// Bindings of WGSL `storage` globals that contain variable-sized arrays. @@ -34,8 +34,8 @@ fn create_stencil_desc( face: &wgt::StencilFaceState, read_mask: u32, write_mask: u32, -) -> mtl::StencilDescriptor { - let desc = mtl::StencilDescriptor::new(); +) -> metal::StencilDescriptor { + let desc = metal::StencilDescriptor::new(); desc.set_stencil_compare_function(conv::map_compare_function(face.compare)); desc.set_read_mask(read_mask); desc.set_write_mask(write_mask); @@ -45,8 +45,8 @@ fn create_stencil_desc( desc } -fn create_depth_stencil_desc(state: &wgt::DepthStencilState) -> mtl::DepthStencilDescriptor { - let desc = mtl::DepthStencilDescriptor::new(); +fn create_depth_stencil_desc(state: &wgt::DepthStencilState) -> metal::DepthStencilDescriptor { + let desc = metal::DepthStencilDescriptor::new(); desc.set_depth_compare_function(conv::map_compare_function(state.depth_compare)); desc.set_depth_write_enabled(state.depth_write_enabled); let s = &state.stencil; @@ -64,13 +64,13 @@ impl super::Device { &self, stage: &crate::ProgrammableStage, layout: &super::PipelineLayout, - primitive_class: mtl::MTLPrimitiveTopologyClass, + primitive_class: metal::MTLPrimitiveTopologyClass, naga_stage: naga::ShaderStage, ) -> Result { let stage_bit = map_naga_stage(naga_stage); let pipeline_options = naga::back::msl::PipelineOptions { allow_point_size: match primitive_class { - mtl::MTLPrimitiveTopologyClass::Point => true, + metal::MTLPrimitiveTopologyClass::Point => true, _ => false, }, }; @@ -91,7 +91,7 @@ impl super::Device { &source ); - let options = mtl::CompileOptions::new(); + let options = metal::CompileOptions::new(); options.set_language_version(self.shared.private_caps.msl_version); if self.shared.private_caps.supports_preserve_invariance { @@ -117,7 +117,7 @@ impl super::Device { let name = info.entry_point_names[ep_index] .as_ref() .map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("{}", e)))?; - let wg_size = mtl::MTLSize { + let wg_size = metal::MTLSize { width: ep.workgroup_size[0] as _, height: ep.workgroup_size[1] as _, depth: ep.workgroup_size[2] as _, @@ -188,7 +188,7 @@ impl super::Device { } fn set_buffers_mutability( - buffers: &mtl::PipelineBufferDescriptorArrayRef, + buffers: &metal::PipelineBufferDescriptorArrayRef, mut immutable_mask: usize, ) { while immutable_mask != 0 { @@ -197,14 +197,14 @@ impl super::Device { buffers .object_at(slot as u64) .unwrap() - .set_mutability(mtl::MTLMutability::Immutable); + .set_mutability(metal::MTLMutability::Immutable); } } pub unsafe fn texture_from_raw( - raw: mtl::Texture, + raw: metal::Texture, format: wgt::TextureFormat, - raw_type: mtl::MTLTextureType, + raw_type: metal::MTLTextureType, array_layers: u32, mip_levels: u32, copy_size: crate::CopyExtent, @@ -219,14 +219,14 @@ impl super::Device { } } - pub unsafe fn device_from_raw(raw: mtl::Device, features: wgt::Features) -> super::Device { + pub unsafe fn device_from_raw(raw: metal::Device, features: wgt::Features) -> super::Device { super::Device { shared: Arc::new(super::AdapterShared::new(raw)), features, } } - pub fn raw_device(&self) -> &Mutex { + pub fn raw_device(&self) -> &Mutex { &self.shared.device } } @@ -238,15 +238,15 @@ impl crate::Device for super::Device { let map_read = desc.usage.contains(crate::BufferUses::MAP_READ); let map_write = desc.usage.contains(crate::BufferUses::MAP_WRITE); - let mut options = mtl::MTLResourceOptions::empty(); + let mut options = metal::MTLResourceOptions::empty(); options |= if map_read || map_write { // `crate::MemoryFlags::PREFER_COHERENT` is ignored here - mtl::MTLResourceOptions::StorageModeShared + metal::MTLResourceOptions::StorageModeShared } else { - mtl::MTLResourceOptions::StorageModePrivate + metal::MTLResourceOptions::StorageModePrivate }; options.set( - mtl::MTLResourceOptions::CPUCacheModeWriteCombined, + metal::MTLResourceOptions::CPUCacheModeWriteCombined, map_write, ); @@ -291,24 +291,24 @@ impl crate::Device for super::Device { let mtl_format = self.shared.private_caps.map_format(desc.format); objc::rc::autoreleasepool(|| { - let descriptor = mtl::TextureDescriptor::new(); + let descriptor = metal::TextureDescriptor::new(); let mtl_type = match desc.dimension { - wgt::TextureDimension::D1 => mtl::MTLTextureType::D1, + wgt::TextureDimension::D1 => metal::MTLTextureType::D1, wgt::TextureDimension::D2 => { if desc.sample_count > 1 { descriptor.set_sample_count(desc.sample_count as u64); - mtl::MTLTextureType::D2Multisample + metal::MTLTextureType::D2Multisample } else if desc.size.depth_or_array_layers > 1 { descriptor.set_array_length(desc.size.depth_or_array_layers as u64); - mtl::MTLTextureType::D2Array + metal::MTLTextureType::D2Array } else { - mtl::MTLTextureType::D2 + metal::MTLTextureType::D2 } } wgt::TextureDimension::D3 => { descriptor.set_depth(desc.size.depth_or_array_layers as u64); - mtl::MTLTextureType::D3 + metal::MTLTextureType::D3 } }; @@ -318,7 +318,7 @@ impl crate::Device for super::Device { descriptor.set_mipmap_level_count(desc.mip_level_count as u64); descriptor.set_pixel_format(mtl_format); descriptor.set_usage(conv::map_texture_usage(desc.format, desc.usage)); - descriptor.set_storage_mode(mtl::MTLStorageMode::Private); + descriptor.set_storage_mode(metal::MTLStorageMode::Private); let raw = self.shared.device.lock().new_texture(&descriptor); if let Some(label) = desc.label { @@ -343,7 +343,7 @@ impl crate::Device for super::Device { texture: &super::Texture, desc: &crate::TextureViewDescriptor, ) -> DeviceResult { - let raw_type = if texture.raw_type == mtl::MTLTextureType::D2Multisample { + let raw_type = if texture.raw_type == metal::MTLTextureType::D2Multisample { texture.raw_type } else { conv::map_texture_view_dimension(desc.dimension) @@ -380,11 +380,11 @@ impl crate::Device for super::Device { let raw = texture.raw.new_texture_view_from_slice( raw_format, raw_type, - mtl::NSRange { + metal::NSRange { location: desc.range.base_mip_level as _, length: mip_level_count as _, }, - mtl::NSRange { + metal::NSRange { location: desc.range.base_array_layer as _, length: array_layer_count as _, }, @@ -406,16 +406,16 @@ impl crate::Device for super::Device { ) -> DeviceResult { let caps = &self.shared.private_caps; objc::rc::autoreleasepool(|| { - let descriptor = mtl::SamplerDescriptor::new(); + let descriptor = metal::SamplerDescriptor::new(); descriptor.set_min_filter(conv::map_filter_mode(desc.min_filter)); descriptor.set_mag_filter(conv::map_filter_mode(desc.mag_filter)); descriptor.set_mip_filter(match desc.mipmap_filter { wgt::FilterMode::Nearest if desc.lod_clamp.is_none() => { - mtl::MTLSamplerMipFilter::NotMipmapped + metal::MTLSamplerMipFilter::NotMipmapped } - wgt::FilterMode::Nearest => mtl::MTLSamplerMipFilter::Nearest, - wgt::FilterMode::Linear => mtl::MTLSamplerMipFilter::Linear, + wgt::FilterMode::Nearest => metal::MTLSamplerMipFilter::Nearest, + wgt::FilterMode::Linear => metal::MTLSamplerMipFilter::Linear, }); let [s, t, r] = desc.address_modes; @@ -443,15 +443,15 @@ impl crate::Device for super::Device { if let Some(border_color) = desc.border_color { if let wgt::SamplerBorderColor::Zero = border_color { if s == wgt::AddressMode::ClampToBorder { - descriptor.set_address_mode_s(mtl::MTLSamplerAddressMode::ClampToZero); + descriptor.set_address_mode_s(metal::MTLSamplerAddressMode::ClampToZero); } if t == wgt::AddressMode::ClampToBorder { - descriptor.set_address_mode_t(mtl::MTLSamplerAddressMode::ClampToZero); + descriptor.set_address_mode_t(metal::MTLSamplerAddressMode::ClampToZero); } if r == wgt::AddressMode::ClampToBorder { - descriptor.set_address_mode_r(mtl::MTLSamplerAddressMode::ClampToZero); + descriptor.set_address_mode_r(metal::MTLSamplerAddressMode::ClampToZero); } } else { descriptor.set_border_color(conv::map_border_color(border_color)); @@ -650,14 +650,14 @@ impl crate::Device for super::Device { total_counters: stage_data.map(|info| info.counters.clone()), naga_options: naga::back::msl::Options { lang_version: match self.shared.private_caps.msl_version { - mtl::MTLLanguageVersion::V1_0 => (1, 0), - mtl::MTLLanguageVersion::V1_1 => (1, 1), - mtl::MTLLanguageVersion::V1_2 => (1, 2), - mtl::MTLLanguageVersion::V2_0 => (2, 0), - mtl::MTLLanguageVersion::V2_1 => (2, 1), - mtl::MTLLanguageVersion::V2_2 => (2, 2), - mtl::MTLLanguageVersion::V2_3 => (2, 3), - mtl::MTLLanguageVersion::V2_4 => (2, 4), + metal::MTLLanguageVersion::V1_0 => (1, 0), + metal::MTLLanguageVersion::V1_1 => (1, 1), + metal::MTLLanguageVersion::V1_2 => (1, 2), + metal::MTLLanguageVersion::V2_0 => (2, 0), + metal::MTLLanguageVersion::V2_1 => (2, 1), + metal::MTLLanguageVersion::V2_2 => (2, 2), + metal::MTLLanguageVersion::V2_3 => (2, 3), + metal::MTLLanguageVersion::V2_4 => (2, 4), }, inline_samplers: Default::default(), spirv_cross_compatibility: false, @@ -789,11 +789,11 @@ impl crate::Device for super::Device { desc: &crate::RenderPipelineDescriptor, ) -> Result { objc::rc::autoreleasepool(|| { - let descriptor = mtl::RenderPipelineDescriptor::new(); + let descriptor = metal::RenderPipelineDescriptor::new(); let raw_triangle_fill_mode = match desc.primitive.polygon_mode { - wgt::PolygonMode::Fill => mtl::MTLTriangleFillMode::Fill, - wgt::PolygonMode::Line => mtl::MTLTriangleFillMode::Lines, + wgt::PolygonMode::Fill => metal::MTLTriangleFillMode::Fill, + wgt::PolygonMode::Line => metal::MTLTriangleFillMode::Lines, wgt::PolygonMode::Point => panic!( "{:?} is not enabled for this backend", wgt::Features::POLYGON_MODE_POINT @@ -841,7 +841,7 @@ impl crate::Device for super::Device { // A pixel format is required even though no attachments are provided if desc.color_targets.is_empty() && desc.depth_stencil.is_none() { descriptor - .set_depth_attachment_pixel_format(mtl::MTLPixelFormat::Depth32Float); + .set_depth_attachment_pixel_format(metal::MTLPixelFormat::Depth32Float); } (None, Vec::new()) } @@ -852,7 +852,7 @@ impl crate::Device for super::Device { let ct = if let Some(color_target) = ct.as_ref() { color_target } else { - at_descriptor.set_pixel_format(mtl::MTLPixelFormat::Invalid); + at_descriptor.set_pixel_format(metal::MTLPixelFormat::Invalid); continue; }; @@ -912,7 +912,7 @@ impl crate::Device for super::Device { } if !desc.vertex_buffers.is_empty() { - let vertex_descriptor = mtl::VertexDescriptor::new(); + let vertex_descriptor = metal::VertexDescriptor::new(); for (i, vb) in desc.vertex_buffers.iter().enumerate() { let buffer_index = self.shared.private_caps.max_vertex_buffers as u64 - 1 - i as u64; @@ -978,9 +978,9 @@ impl crate::Device for super::Device { raw_cull_mode: conv::map_cull_mode(desc.primitive.cull_mode), raw_depth_clip_mode: if self.features.contains(wgt::Features::DEPTH_CLIP_CONTROL) { Some(if desc.primitive.unclipped_depth { - mtl::MTLDepthClipMode::Clamp + metal::MTLDepthClipMode::Clamp } else { - mtl::MTLDepthClipMode::Clip + metal::MTLDepthClipMode::Clip }) } else { None @@ -996,12 +996,12 @@ impl crate::Device for super::Device { desc: &crate::ComputePipelineDescriptor, ) -> Result { objc::rc::autoreleasepool(|| { - let descriptor = mtl::ComputePipelineDescriptor::new(); + let descriptor = metal::ComputePipelineDescriptor::new(); let cs = self.load_shader( &desc.stage, desc.layout, - mtl::MTLPrimitiveTopologyClass::Unspecified, + metal::MTLPrimitiveTopologyClass::Unspecified, naga::ShaderStage::Compute, )?; descriptor.set_compute_function(Some(&cs.function)); @@ -1052,7 +1052,7 @@ impl crate::Device for super::Device { match desc.ty { wgt::QueryType::Occlusion => { let size = desc.count as u64 * crate::QUERY_SIZE; - let options = mtl::MTLResourceOptions::empty(); + let options = metal::MTLResourceOptions::empty(); //TODO: HazardTrackingModeUntracked let raw_buffer = self.shared.device.lock().new_buffer(size, options); if let Some(label) = desc.label { @@ -1081,7 +1081,7 @@ impl crate::Device for super::Device { unsafe fn get_fence_value(&self, fence: &super::Fence) -> DeviceResult { let mut max_value = fence.completed_value.load(atomic::Ordering::Acquire); for &(value, ref cmd_buf) in fence.pending_command_buffers.iter() { - if cmd_buf.status() == mtl::MTLCommandBufferStatus::Completed { + if cmd_buf.status() == metal::MTLCommandBufferStatus::Completed { max_value = value; } } @@ -1111,7 +1111,7 @@ impl crate::Device for super::Device { let start = time::Instant::now(); loop { - if let mtl::MTLCommandBufferStatus::Completed = cmd_buf.status() { + if let metal::MTLCommandBufferStatus::Completed = cmd_buf.status() { return Ok(true); } if start.elapsed().as_millis() >= timeout_ms as u128 { @@ -1126,7 +1126,7 @@ impl crate::Device for super::Device { return false; } let device = self.shared.device.lock(); - let shared_capture_manager = mtl::CaptureManager::shared(); + let shared_capture_manager = metal::CaptureManager::shared(); let default_capture_scope = shared_capture_manager.new_capture_scope_with_device(&device); shared_capture_manager.set_default_capture_scope(&default_capture_scope); shared_capture_manager.start_capture_with_scope(&default_capture_scope); @@ -1134,7 +1134,7 @@ impl crate::Device for super::Device { true } unsafe fn stop_capture(&self) { - let shared_capture_manager = mtl::CaptureManager::shared(); + let shared_capture_manager = metal::CaptureManager::shared(); if let Some(default_capture_scope) = shared_capture_manager.default_capture_scope() { default_capture_scope.end_scope(); } diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index 83aeb02de..639fda97c 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -67,7 +67,7 @@ pub struct Instance { } impl Instance { - pub fn create_surface_from_layer(&self, layer: &mtl::MetalLayerRef) -> Surface { + pub fn create_surface_from_layer(&self, layer: &metal::MetalLayerRef) -> Surface { unsafe { Surface::from_layer(layer) } } } @@ -104,7 +104,7 @@ impl crate::Instance for Instance { } unsafe fn enumerate_adapters(&self) -> Vec> { - let devices = mtl::Device::all(); + let devices = metal::Device::all(); let mut adapters: Vec> = devices .into_iter() .map(|dev| { @@ -140,9 +140,9 @@ impl crate::Instance for Instance { #[derive(Clone, Debug)] struct PrivateCapabilities { family_check: bool, - msl_version: mtl::MTLLanguageVersion, + msl_version: metal::MTLLanguageVersion, fragment_rw_storage: bool, - read_write_texture_tier: mtl::MTLReadWriteTextureTier, + read_write_texture_tier: metal::MTLReadWriteTextureTier, msaa_desktop: bool, msaa_apple3: bool, msaa_apple7: bool, @@ -250,7 +250,7 @@ struct Settings { } struct AdapterShared { - device: Mutex, + device: Mutex, disabilities: PrivateDisabilities, private_caps: PrivateCapabilities, settings: Settings, @@ -261,7 +261,7 @@ unsafe impl Send for AdapterShared {} unsafe impl Sync for AdapterShared {} impl AdapterShared { - fn new(device: mtl::Device) -> Self { + fn new(device: metal::Device) -> Self { let private_caps = PrivateCapabilities::new(&device); log::debug!("{:#?}", private_caps); @@ -280,14 +280,14 @@ pub struct Adapter { } pub struct Queue { - raw: Arc>, + raw: Arc>, } unsafe impl Send for Queue {} unsafe impl Sync for Queue {} impl Queue { - pub unsafe fn queue_from_raw(raw: mtl::CommandQueue) -> Self { + pub unsafe fn queue_from_raw(raw: metal::CommandQueue) -> Self { Self { raw: Arc::new(Mutex::new(raw)), } @@ -300,7 +300,7 @@ pub struct Device { pub struct Surface { view: Option>, - render_layer: Mutex, + render_layer: Mutex, swapchain_format: Option, extent: wgt::Extent3d, main_thread_id: thread::ThreadId, @@ -315,7 +315,7 @@ unsafe impl Sync for Surface {} #[derive(Debug)] pub struct SurfaceTexture { texture: Texture, - drawable: mtl::MetalDrawable, + drawable: metal::MetalDrawable, present_with_transaction: bool, } @@ -409,7 +409,7 @@ impl crate::Queue for Queue { #[derive(Debug)] pub struct Buffer { - raw: mtl::Buffer, + raw: metal::Buffer, size: wgt::BufferAddress, } @@ -424,9 +424,9 @@ impl Buffer { #[derive(Debug)] pub struct Texture { - raw: mtl::Texture, + raw: metal::Texture, format: wgt::TextureFormat, - raw_type: mtl::MTLTextureType, + raw_type: metal::MTLTextureType, array_layers: u32, mip_levels: u32, copy_size: crate::CopyExtent, @@ -437,7 +437,7 @@ unsafe impl Sync for Texture {} #[derive(Debug)] pub struct TextureView { - raw: mtl::Texture, + raw: metal::Texture, aspects: crate::FormatAspects, } @@ -452,7 +452,7 @@ impl TextureView { #[derive(Debug)] pub struct Sampler { - raw: mtl::SamplerState, + raw: metal::SamplerState, } unsafe impl Send for Sampler {} @@ -549,12 +549,12 @@ trait AsNative { fn as_native(&self) -> &Self::Native; } -type BufferPtr = NonNull; -type TexturePtr = NonNull; -type SamplerPtr = NonNull; +type BufferPtr = NonNull; +type TexturePtr = NonNull; +type SamplerPtr = NonNull; impl AsNative for BufferPtr { - type Native = mtl::BufferRef; + type Native = metal::BufferRef; #[inline] fn from(native: &Self::Native) -> Self { unsafe { NonNull::new_unchecked(native.as_ptr()) } @@ -566,7 +566,7 @@ impl AsNative for BufferPtr { } impl AsNative for TexturePtr { - type Native = mtl::TextureRef; + type Native = metal::TextureRef; #[inline] fn from(native: &Self::Native) -> Self { unsafe { NonNull::new_unchecked(native.as_ptr()) } @@ -578,7 +578,7 @@ impl AsNative for TexturePtr { } impl AsNative for SamplerPtr { - type Native = mtl::SamplerStateRef; + type Native = metal::SamplerStateRef; #[inline] fn from(native: &Self::Native) -> Self { unsafe { NonNull::new_unchecked(native.as_ptr()) } @@ -655,30 +655,30 @@ impl PipelineStageInfo { } pub struct RenderPipeline { - raw: mtl::RenderPipelineState, + raw: metal::RenderPipelineState, #[allow(dead_code)] - vs_lib: mtl::Library, + vs_lib: metal::Library, #[allow(dead_code)] - fs_lib: Option, + fs_lib: Option, vs_info: PipelineStageInfo, fs_info: PipelineStageInfo, - raw_primitive_type: mtl::MTLPrimitiveType, - raw_triangle_fill_mode: mtl::MTLTriangleFillMode, - raw_front_winding: mtl::MTLWinding, - raw_cull_mode: mtl::MTLCullMode, - raw_depth_clip_mode: Option, - depth_stencil: Option<(mtl::DepthStencilState, wgt::DepthBiasState)>, + raw_primitive_type: metal::MTLPrimitiveType, + raw_triangle_fill_mode: metal::MTLTriangleFillMode, + raw_front_winding: metal::MTLWinding, + raw_cull_mode: metal::MTLCullMode, + raw_depth_clip_mode: Option, + depth_stencil: Option<(metal::DepthStencilState, wgt::DepthBiasState)>, } unsafe impl Send for RenderPipeline {} unsafe impl Sync for RenderPipeline {} pub struct ComputePipeline { - raw: mtl::ComputePipelineState, + raw: metal::ComputePipelineState, #[allow(dead_code)] - cs_lib: mtl::Library, + cs_lib: metal::Library, cs_info: PipelineStageInfo, - work_group_size: mtl::MTLSize, + work_group_size: metal::MTLSize, work_group_memory_sizes: Vec, } @@ -687,7 +687,7 @@ unsafe impl Sync for ComputePipeline {} #[derive(Debug)] pub struct QuerySet { - raw_buffer: mtl::Buffer, + raw_buffer: metal::Buffer, ty: wgt::QueryType, } @@ -698,7 +698,7 @@ unsafe impl Sync for QuerySet {} pub struct Fence { completed_value: Arc, /// The pending fence values have to be ascending. - pending_command_buffers: Vec<(crate::FenceValue, mtl::CommandBuffer)>, + pending_command_buffers: Vec<(crate::FenceValue, metal::CommandBuffer)>, } unsafe impl Send for Fence {} @@ -708,7 +708,7 @@ impl Fence { fn get_latest(&self) -> crate::FenceValue { let mut max_value = self.completed_value.load(atomic::Ordering::Acquire); for &(value, ref cmd_buf) in self.pending_command_buffers.iter() { - if cmd_buf.status() == mtl::MTLCommandBufferStatus::Completed { + if cmd_buf.status() == metal::MTLCommandBufferStatus::Completed { max_value = value; } } @@ -726,7 +726,7 @@ struct IndexState { buffer_ptr: BufferPtr, offset: wgt::BufferAddress, stride: wgt::BufferAddress, - raw_type: mtl::MTLIndexType, + raw_type: metal::MTLIndexType, } #[derive(Default)] @@ -735,12 +735,12 @@ struct Temp { } struct CommandState { - blit: Option, - render: Option, - compute: Option, - raw_primitive_type: mtl::MTLPrimitiveType, + blit: Option, + render: Option, + compute: Option, + raw_primitive_type: metal::MTLPrimitiveType, index: Option, - raw_wg_size: mtl::MTLSize, + raw_wg_size: metal::MTLSize, stage_infos: MultiStageData, /// Sizes of currently bound [`wgt::BufferBindingType::Storage`] buffers. @@ -770,8 +770,8 @@ struct CommandState { pub struct CommandEncoder { shared: Arc, - raw_queue: Arc>, - raw_cmd_buf: Option, + raw_queue: Arc>, + raw_cmd_buf: Option, state: CommandState, temp: Temp, } @@ -790,7 +790,7 @@ unsafe impl Sync for CommandEncoder {} #[derive(Debug)] pub struct CommandBuffer { - raw: mtl::CommandBuffer, + raw: metal::CommandBuffer, } unsafe impl Send for CommandBuffer {} diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index c68e0d952..8101d5296 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -59,7 +59,7 @@ impl HalManagedMetalLayerDelegate { } impl super::Surface { - fn new(view: Option>, layer: mtl::MetalLayer) -> Self { + fn new(view: Option>, layer: metal::MetalLayer) -> Self { Self { view, render_layer: Mutex::new(layer), @@ -85,14 +85,14 @@ impl super::Surface { let view = view as *mut Object; let render_layer = { let layer = unsafe { Self::get_metal_layer(view, delegate) }; - unsafe { mem::transmute::<_, &mtl::MetalLayerRef>(layer) } + unsafe { mem::transmute::<_, &metal::MetalLayerRef>(layer) } } .to_owned(); let _: *mut c_void = msg_send![view, retain]; Self::new(NonNull::new(view), render_layer) } - pub unsafe fn from_layer(layer: &mtl::MetalLayerRef) -> Self { + pub unsafe fn from_layer(layer: &metal::MetalLayerRef) -> Self { let class = class!(CAMetalLayer); let proper_kind: BOOL = msg_send![layer, isKindOfClass: class]; assert_eq!(proper_kind, YES); @@ -255,7 +255,7 @@ impl crate::Surface for super::Surface { texture: super::Texture { raw: texture, format: self.swapchain_format.unwrap(), - raw_type: mtl::MTLTextureType::D2, + raw_type: metal::MTLTextureType::D2, array_layers: 1, mip_levels: 1, copy_size: crate::CopyExtent {