Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions wgpu-hal/src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ crate::impl_dyn_resource!(
TextureView
);

pub struct Instance {
managed_metal_layer_delegate: surface::HalManagedMetalLayerDelegate,
}
pub struct Instance {}

impl Instance {
pub fn create_surface_from_layer(&self, layer: &metal::MetalLayerRef) -> Surface {
Expand All @@ -113,9 +111,7 @@ impl crate::Instance for Instance {
profiling::scope!("Init Metal Backend");
// We do not enable metal validation based on the validation flags as it affects the entire
// process. Instead, we enable the validation inside the test harness itself in tests/src/native.rs.
Ok(Instance {
managed_metal_layer_delegate: surface::HalManagedMetalLayerDelegate::new(),
})
Ok(Instance {})
}

unsafe fn create_surface(
Expand All @@ -126,16 +122,12 @@ impl crate::Instance for Instance {
match window_handle {
#[cfg(target_os = "ios")]
raw_window_handle::RawWindowHandle::UiKit(handle) => {
let _ = &self.managed_metal_layer_delegate;
Ok(unsafe { Surface::from_view(handle.ui_view.as_ptr(), None) })
Ok(unsafe { Surface::from_view(handle.ui_view.cast()) })
}
#[cfg(target_os = "macos")]
raw_window_handle::RawWindowHandle::AppKit(handle) => Ok(unsafe {
Surface::from_view(
handle.ns_view.as_ptr(),
Some(&self.managed_metal_layer_delegate),
)
}),
raw_window_handle::RawWindowHandle::AppKit(handle) => {
Ok(unsafe { Surface::from_view(handle.ns_view.cast()) })
}
_ => Err(crate::InstanceError::new(format!(
"window handle {window_handle:?} is not a Metal-compatible handle"
))),
Expand Down Expand Up @@ -367,7 +359,6 @@ pub struct Device {
}

pub struct Surface {
view: Option<NonNull<objc::runtime::Object>>,
render_layer: Mutex<metal::MetalLayer>,
swapchain_format: RwLock<Option<wgt::TextureFormat>>,
extent: RwLock<wgt::Extent3d>,
Expand Down
Loading
Loading