summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-01-19 20:28:45 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-19 20:28:45 +0100
commit7ae7fcb89855002519bab752fd3686106ce448db (patch)
treeac717dbd031e243519b446ab45e5008adef4f5dc /wgpu
parent61e3d8502fec7e83c584218e598fa20c79363be3 (diff)
parent9df7bf8ec30ca76016018bc758b4323760e231b0 (diff)
downloadiced-7ae7fcb89855002519bab752fd3686106ce448db.tar.gz
iced-7ae7fcb89855002519bab752fd3686106ce448db.tar.bz2
iced-7ae7fcb89855002519bab752fd3686106ce448db.zip
Merge pull request #2191 from ids1024/raw-window-handle-0.6
Update `wgpu` to `0.19`, `glyphon` to `0.5`, `softbuffer` to `0.4`, `window-clipboard` to `0.4`, and `raw-window-handle` to `0.6`
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/Cargo.toml1
-rw-r--r--wgpu/src/window/compositor.rs43
2 files changed, 22 insertions, 22 deletions
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml
index a460c127..1d3b57a7 100644
--- a/wgpu/Cargo.toml
+++ b/wgpu/Cargo.toml
@@ -32,7 +32,6 @@ glyphon.workspace = true
guillotiere.workspace = true
log.workspace = true
once_cell.workspace = true
-raw-window-handle.workspace = true
wgpu.workspace = true
lyon.workspace = true
diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs
index 090e0e9f..31cf3819 100644
--- a/wgpu/src/window/compositor.rs
+++ b/wgpu/src/window/compositor.rs
@@ -6,8 +6,6 @@ use crate::graphics::compositor;
use crate::graphics::{Error, Viewport};
use crate::{Backend, Primitive, Renderer, Settings};
-use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
-
use std::marker::PhantomData;
/// A window graphics backend for iced powered by `wgpu`.
@@ -26,9 +24,9 @@ impl<Theme> Compositor<Theme> {
/// Requests a new [`Compositor`] with the given [`Settings`].
///
/// Returns `None` if no compatible graphics adapter could be found.
- pub async fn request<W: HasRawWindowHandle + HasRawDisplayHandle>(
+ pub async fn request<W: compositor::Window>(
settings: Settings,
- compatible_window: Option<&W>,
+ compatible_window: Option<W>,
) -> Option<Self> {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: settings.internal_backend,
@@ -41,14 +39,15 @@ impl<Theme> Compositor<Theme> {
if log::max_level() >= log::LevelFilter::Info {
let available_adapters: Vec<_> = instance
.enumerate_adapters(settings.internal_backend)
- .map(|adapter| adapter.get_info())
+ .iter()
+ .map(wgpu::Adapter::get_info)
.collect();
log::info!("Available adapters: {available_adapters:#?}");
}
#[allow(unsafe_code)]
let compatible_surface = compatible_window
- .and_then(|window| unsafe { instance.create_surface(window).ok() });
+ .and_then(|window| instance.create_surface(window).ok());
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
@@ -100,14 +99,14 @@ impl<Theme> Compositor<Theme> {
let (device, queue) =
loop {
- let limits = limits.next()?;
+ let required_limits = limits.next()?;
let device = adapter.request_device(
&wgpu::DeviceDescriptor {
label: Some(
"iced_wgpu::window::compositor device descriptor",
),
- features: wgpu::Features::empty(),
- limits,
+ required_features: wgpu::Features::empty(),
+ required_limits,
},
None,
).await.ok();
@@ -136,13 +135,13 @@ impl<Theme> Compositor<Theme> {
/// Creates a [`Compositor`] and its [`Backend`] for the given [`Settings`] and
/// window.
-pub fn new<Theme, W: HasRawWindowHandle + HasRawDisplayHandle>(
+pub fn new<W: compositor::Window, Theme>(
settings: Settings,
- compatible_window: Option<&W>,
+ compatible_window: W,
) -> Result<Compositor<Theme>, Error> {
let compositor = futures::executor::block_on(Compositor::request(
settings,
- compatible_window,
+ Some(compatible_window),
))
.ok_or(Error::GraphicsAdapterNotFound)?;
@@ -153,7 +152,7 @@ pub fn new<Theme, W: HasRawWindowHandle + HasRawDisplayHandle>(
pub fn present<Theme, T: AsRef<str>>(
compositor: &mut Compositor<Theme>,
backend: &mut Backend,
- surface: &mut wgpu::Surface,
+ surface: &mut wgpu::Surface<'static>,
primitives: &[Primitive],
viewport: &Viewport,
background_color: Color,
@@ -207,11 +206,11 @@ pub fn present<Theme, T: AsRef<str>>(
impl<Theme> graphics::Compositor for Compositor<Theme> {
type Settings = Settings;
type Renderer = Renderer<Theme>;
- type Surface = wgpu::Surface;
+ type Surface = wgpu::Surface<'static>;
- fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(
+ fn new<W: compositor::Window>(
settings: Self::Settings,
- compatible_window: Option<&W>,
+ compatible_window: W,
) -> Result<Self, Error> {
new(settings, compatible_window)
}
@@ -224,14 +223,15 @@ impl<Theme> graphics::Compositor for Compositor<Theme> {
)
}
- fn create_surface<W: HasRawWindowHandle + HasRawDisplayHandle>(
+ fn create_surface<W: compositor::Window>(
&mut self,
- window: &W,
+ window: W,
width: u32,
height: u32,
- ) -> wgpu::Surface {
- #[allow(unsafe_code)]
- let mut surface = unsafe { self.instance.create_surface(window) }
+ ) -> Self::Surface {
+ let mut surface = self
+ .instance
+ .create_surface(window)
.expect("Create surface");
self.configure_surface(&mut surface, width, height);
@@ -255,6 +255,7 @@ impl<Theme> graphics::Compositor for Compositor<Theme> {
height,
alpha_mode: wgpu::CompositeAlphaMode::Auto,
view_formats: vec![],
+ desired_maximum_frame_latency: 2,
},
);
}