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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Naga now infers the correct binding layout when a resource appears only in an as

- Get `vertex_index` & `instance_index` builtins working for indirect draws. By @teoxoy in [#7535](https://github.com/gfx-rs/wgpu/pull/7535)

#### Metal

- Remove extraneous main thread warning in `fn surface_capabilities()`. By @jamesordner in [#7692](https://github.com/gfx-rs/wgpu/pull/7692)

### Changes

- Loosen Viewport validation requirements to match the [new specs](https://github.com/gpuweb/gpuweb/pull/5025). By @ebbdrop in [#7564](https://github.com/gfx-rs/wgpu/pull/7564)
Expand Down
10 changes: 1 addition & 9 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use parking_lot::Mutex;
use wgt::{AstcBlock, AstcChannel};

use alloc::sync::Arc;
use std::thread;

use super::TimestampQuerySupport;

Expand Down Expand Up @@ -342,13 +341,6 @@ impl crate::Adapter for super::Adapter {
&self,
surface: &super::Surface,
) -> Option<crate::SurfaceCapabilities> {
let current_extent = if surface.main_thread_id == thread::current().id() {
Some(surface.dimensions())
} else {
log::warn!("Unable to get the current view dimensions on a non-main thread");
None
};

let mut formats = vec![
wgt::TextureFormat::Bgra8Unorm,
wgt::TextureFormat::Bgra8UnormSrgb,
Expand Down Expand Up @@ -380,7 +372,7 @@ impl crate::Adapter for super::Adapter {
wgt::CompositeAlphaMode::PostMultiplied,
],

current_extent,
current_extent: Some(surface.dimensions()),
usage: wgt::TextureUses::COLOR_TARGET
| wgt::TextureUses::COPY_SRC
| wgt::TextureUses::COPY_DST
Expand Down
2 changes: 0 additions & 2 deletions wgpu-hal/src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ mod time;

use alloc::{borrow::ToOwned as _, string::String, sync::Arc, vec::Vec};
use core::{fmt, iter, ops, ptr::NonNull, sync::atomic};
use std::thread;

use arrayvec::ArrayVec;
use bitflags::bitflags;
Expand Down Expand Up @@ -376,7 +375,6 @@ pub struct Surface {
render_layer: Mutex<metal::MetalLayer>,
swapchain_format: RwLock<Option<wgt::TextureFormat>>,
extent: RwLock<wgt::Extent3d>,
main_thread_id: thread::ThreadId,
// Useful for UI-intensive applications that are sensitive to
// window resizing.
pub present_with_transaction: bool,
Expand Down
9 changes: 7 additions & 2 deletions wgpu-hal/src/metal/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use alloc::borrow::ToOwned as _;
use core::mem::ManuallyDrop;
use core::ptr::NonNull;
use std::thread;

use core_graphics_types::{
base::CGFloat,
Expand All @@ -29,7 +28,6 @@ impl super::Surface {
render_layer: Mutex::new(layer),
swapchain_format: RwLock::new(None),
extent: RwLock::new(wgt::Extent3d::default()),
main_thread_id: thread::current().id(),
present_with_transaction: false,
}
}
Expand Down Expand Up @@ -109,6 +107,13 @@ impl super::Surface {
}
}

/// Gets the current dimensions of the `Surface`.
///
/// This function is safe to call off of the main thread. However, note that
/// `bounds` and `contentsScale` may be modified by the main thread while
/// this function is running, possibly resulting in the two values being out
/// of sync. This is sound, as these properties are accessed atomically.
/// See: <https://github.com/gfx-rs/wgpu/pull/7692>
pub(super) fn dimensions(&self) -> wgt::Extent3d {
let (size, scale): (CGSize, CGFloat) = unsafe {
let render_layer_borrow = self.render_layer.lock();
Expand Down