From 860de97b420e7bb603d70e2e190a337bedf79dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 19:12:28 +0100 Subject: [PATCH 01/11] Update `env_logger` in `tour` and `integration` examples --- examples/integration/Cargo.toml | 2 +- examples/tour/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/integration/Cargo.toml b/examples/integration/Cargo.toml index afc2c791..4515502f 100644 --- a/examples/integration/Cargo.toml +++ b/examples/integration/Cargo.toml @@ -8,4 +8,4 @@ publish = false [dependencies] iced_winit = { path = "../../winit" } iced_wgpu = { path = "../../wgpu" } -env_logger = "0.7" +env_logger = "0.8" diff --git a/examples/tour/Cargo.toml b/examples/tour/Cargo.toml index 96749e90..bc7fac11 100644 --- a/examples/tour/Cargo.toml +++ b/examples/tour/Cargo.toml @@ -7,4 +7,4 @@ publish = false [dependencies] iced = { path = "../..", features = ["image", "debug"] } -env_logger = "0.7" +env_logger = "0.8" From 17a4647fce8dbd4c916715351b2d4178b0f942a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 19:13:40 +0100 Subject: [PATCH 02/11] Update `directories` dependency in `todos` example --- examples/todos/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml index b236cc0d..327a0ef1 100644 --- a/examples/todos/Cargo.toml +++ b/examples/todos/Cargo.toml @@ -12,7 +12,7 @@ serde_json = "1.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] async-std = "1.0" -directories = "2.0" +directories = "3.0" [target.'cfg(target_arch = "wasm32")'.dependencies] web-sys = { version = "0.3", features = ["Window", "Storage"] } From 0c2787eada0b69e0e98edc2bf2b6c2414b767f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 19:15:07 +0100 Subject: [PATCH 03/11] Update `euclid` dependency in `iced_glow` --- glow/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glow/Cargo.toml b/glow/Cargo.toml index 11ca80e2..78392282 100644 --- a/glow/Cargo.toml +++ b/glow/Cargo.toml @@ -18,7 +18,7 @@ svg = [] glow = "0.5" glow_glyph = "0.3" glyph_brush = "0.7" -euclid = "0.20" +euclid = "0.22" bytemuck = "1.2" log = "0.4" From fb3cd68dde11856111c8e1812fa0eea9e530820e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 19:48:40 +0100 Subject: [PATCH 04/11] Update `glow` and `glow_glyph` dependencies in `iced_glow` --- glow/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glow/Cargo.toml b/glow/Cargo.toml index 78392282..2deacea9 100644 --- a/glow/Cargo.toml +++ b/glow/Cargo.toml @@ -15,8 +15,8 @@ image = [] svg = [] [dependencies] -glow = "0.5" -glow_glyph = "0.3" +glow = "0.6" +glow_glyph = "0.4" glyph_brush = "0.7" euclid = "0.22" bytemuck = "1.2" From b86accfe1cdc0a4404416eb3c68aa3cf9c242f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 19:52:43 +0100 Subject: [PATCH 05/11] Update `bytemuck` dependency in `iced_glow` --- glow/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glow/Cargo.toml b/glow/Cargo.toml index 2deacea9..8c15be04 100644 --- a/glow/Cargo.toml +++ b/glow/Cargo.toml @@ -19,7 +19,7 @@ glow = "0.6" glow_glyph = "0.4" glyph_brush = "0.7" euclid = "0.22" -bytemuck = "1.2" +bytemuck = "1.4" log = "0.4" [dependencies.iced_native] From 9d4f664c946e6475eaf2e8719ba56beee84a8fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 20:06:24 +0100 Subject: [PATCH 06/11] Update `bytemuck` and remove `zerocopy` in `iced_wgpu` --- wgpu/Cargo.toml | 6 ++++-- wgpu/src/image.rs | 27 +++++++++++++-------------- wgpu/src/image/vector.rs | 4 +--- wgpu/src/quad.rs | 12 ++++++------ wgpu/src/triangle.rs | 7 ++++--- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index c07081fd..01fd720b 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -16,13 +16,15 @@ default_system_font = ["iced_graphics/font-source"] wgpu = "0.6" wgpu_glyph = "0.10" glyph_brush = "0.7" -zerocopy = "0.3" -bytemuck = "1.2" raw-window-handle = "0.3" log = "0.4" guillotiere = "0.6" futures = "0.3" +[dependencies.bytemuck] +version = "1.4" +features = ["derive"] + [dependencies.iced_native] version = "0.2" path = "../native" diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 891dba1e..c256ca7e 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -13,7 +13,8 @@ use iced_graphics::layer; use iced_native::Rectangle; use std::cell::RefCell; use std::mem; -use zerocopy::AsBytes; + +use bytemuck::{Pod, Zeroable}; #[cfg(feature = "image")] use iced_native::image; @@ -219,14 +220,14 @@ impl Pipeline { let vertices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("iced_wgpu::image vertex buffer"), - contents: QUAD_VERTS.as_bytes(), + contents: bytemuck::cast_slice(&QUAD_VERTS), usage: wgpu::BufferUsage::VERTEX, }); let indices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("iced_wgpu::image index buffer"), - contents: QUAD_INDICES.as_bytes(), + contents: bytemuck::cast_slice(&QUAD_INDICES), usage: wgpu::BufferUsage::INDEX, }); @@ -385,12 +386,9 @@ impl Pipeline { device, ); - uniforms_buffer.copy_from_slice( - Uniforms { - transform: transformation.into(), - } - .as_bytes(), - ); + uniforms_buffer.copy_from_slice(bytemuck::bytes_of(&Uniforms { + transform: transformation.into(), + })); } let mut i = 0; @@ -411,8 +409,9 @@ impl Pipeline { device, ); - instances_buffer - .copy_from_slice(instances[i..i + amount].as_bytes()); + instances_buffer.copy_from_slice(bytemuck::cast_slice( + &instances[i..i + amount], + )); let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { @@ -463,7 +462,7 @@ impl Pipeline { } #[repr(C)] -#[derive(Clone, Copy, AsBytes)] +#[derive(Clone, Copy, Zeroable, Pod)] pub struct Vertex { _position: [f32; 2], } @@ -486,7 +485,7 @@ const QUAD_VERTS: [Vertex; 4] = [ ]; #[repr(C)] -#[derive(Debug, Clone, Copy, AsBytes)] +#[derive(Debug, Clone, Copy, Zeroable, Pod)] struct Instance { _position: [f32; 2], _size: [f32; 2], @@ -500,7 +499,7 @@ impl Instance { } #[repr(C)] -#[derive(Debug, Clone, Copy, AsBytes)] +#[derive(Debug, Clone, Copy, Zeroable, Pod)] struct Uniforms { transform: [f32; 16], } diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs index 7648aa7e..95df2e99 100644 --- a/wgpu/src/image/vector.rs +++ b/wgpu/src/image/vector.rs @@ -2,8 +2,6 @@ use crate::image::atlas::{self, Atlas}; use iced_native::svg; use std::collections::{HashMap, HashSet}; -use zerocopy::AsBytes; - pub enum Svg { Loaded(resvg::usvg::Tree), NotFound, @@ -119,7 +117,7 @@ impl Cache { let allocation = texture_atlas.upload( width, height, - canvas.get_data().as_bytes(), + bytemuck::cast_slice(canvas.get_data()), device, encoder, )?; diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index d54f2577..24d20cfa 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -2,9 +2,9 @@ use crate::Transformation; use iced_graphics::layer; use iced_native::Rectangle; +use bytemuck::{Pod, Zeroable}; use std::mem; use wgpu::util::DeviceExt; -use zerocopy::AsBytes; #[derive(Debug)] pub struct Pipeline { @@ -156,14 +156,14 @@ impl Pipeline { let vertices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("iced_wgpu::quad vertex buffer"), - contents: QUAD_VERTS.as_bytes(), + contents: bytemuck::cast_slice(&QUAD_VERTS), usage: wgpu::BufferUsage::VERTEX, }); let indices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("iced_wgpu::quad index buffer"), - contents: QUAD_INDICES.as_bytes(), + contents: bytemuck::cast_slice(&QUAD_INDICES), usage: wgpu::BufferUsage::INDEX, }); @@ -207,7 +207,7 @@ impl Pipeline { device, ); - constants_buffer.copy_from_slice(uniforms.as_bytes()); + constants_buffer.copy_from_slice(bytemuck::bytes_of(&uniforms)); } let mut i = 0; @@ -271,7 +271,7 @@ impl Pipeline { } #[repr(C)] -#[derive(Clone, Copy, AsBytes)] +#[derive(Clone, Copy, Zeroable, Pod)] pub struct Vertex { _position: [f32; 2], } @@ -296,7 +296,7 @@ const QUAD_VERTS: [Vertex; 4] = [ const MAX_INSTANCES: usize = 100_000; #[repr(C)] -#[derive(Debug, Clone, Copy, AsBytes)] +#[derive(Debug, Clone, Copy, Zeroable, Pod)] struct Uniforms { transform: [f32; 16], scale: f32, diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index 53ce454b..61a771d8 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -1,8 +1,9 @@ //! Draw meshes of triangles. use crate::{settings, Transformation}; use iced_graphics::layer; + +use bytemuck::{Pod, Zeroable}; use std::mem; -use zerocopy::AsBytes; pub use iced_graphics::triangle::{Mesh2D, Vertex2D}; @@ -322,7 +323,7 @@ impl Pipeline { } } - let uniforms = uniforms.as_bytes(); + let uniforms = bytemuck::cast_slice(&uniforms); if let Some(uniforms_size) = wgpu::BufferSize::new(uniforms.len() as u64) @@ -409,7 +410,7 @@ impl Pipeline { } #[repr(C)] -#[derive(Debug, Clone, Copy, AsBytes)] +#[derive(Debug, Clone, Copy, Zeroable, Pod)] struct Uniforms { transform: [f32; 16], // We need to align this to 256 bytes to please `wgpu`... From 45c749f28c8690ce0aaa6521f40e827281b8a7d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 20:11:23 +0100 Subject: [PATCH 07/11] Update `bytemuck` dependency in `iced_graphics` --- graphics/Cargo.toml | 5 ++++- graphics/src/triangle.rs | 9 ++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index dec24c59..5fe8b63e 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -12,11 +12,14 @@ font-icons = [] opengl = [] [dependencies] -bytemuck = "1.2" glam = "0.9" raw-window-handle = "0.3" thiserror = "1.0" +[dependencies.bytemuck] +version = "1.4" +features = ["derive"] + [dependencies.iced_native] version = "0.2" path = "../native" diff --git a/graphics/src/triangle.rs b/graphics/src/triangle.rs index ce879ffc..eb1494b1 100644 --- a/graphics/src/triangle.rs +++ b/graphics/src/triangle.rs @@ -1,4 +1,5 @@ //! Draw geometry using meshes of triangles. +use bytemuck::{Pod, Zeroable}; /// A set of [`Vertex2D`] and indices representing a list of triangles. /// @@ -16,7 +17,7 @@ pub struct Mesh2D { } /// A two-dimensional vertex with some color in __linear__ RGBA. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Zeroable, Pod)] #[repr(C)] pub struct Vertex2D { /// The vertex position @@ -24,9 +25,3 @@ pub struct Vertex2D { /// The vertex color in __linear__ RGBA. pub color: [f32; 4], } - -#[allow(unsafe_code)] -unsafe impl bytemuck::Zeroable for Vertex2D {} - -#[allow(unsafe_code)] -unsafe impl bytemuck::Pod for Vertex2D {} From fa98dbad1685c92584994fc9d9448ae52d92e416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 20:12:15 +0100 Subject: [PATCH 08/11] Update `glam` dependency in `iced_graphics` --- graphics/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index 5fe8b63e..4f9c5e99 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -12,7 +12,7 @@ font-icons = [] opengl = [] [dependencies] -glam = "0.9" +glam = "0.10" raw-window-handle = "0.3" thiserror = "1.0" From 6f52eb4d3a99565a6261eca3263fa8a5e2c3f63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 20:13:47 +0100 Subject: [PATCH 09/11] Update `lyon` dependency in `iced_graphics` --- graphics/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index 4f9c5e99..1e2df1fd 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -29,7 +29,7 @@ version = "0.1" path = "../style" [dependencies.lyon] -version = "0.15" +version = "0.16" optional = true [dependencies.font-kit] From 1475b10dfff23ea30ad7e90c9964bafbd48e84c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 10 Nov 2020 20:33:45 +0100 Subject: [PATCH 10/11] Update `font-kit` dependency in `iced_graphics` --- graphics/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index 1e2df1fd..1511f8b0 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -33,7 +33,7 @@ version = "0.16" optional = true [dependencies.font-kit] -version = "0.6" +version = "0.8" optional = true [package.metadata.docs.rs] From 0400f6716bfb7bcae7d7e464e79e400f3ccc2368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Wed, 11 Nov 2020 02:34:17 +0100 Subject: [PATCH 11/11] Use `directories-next` in `todos` example --- examples/todos/Cargo.toml | 2 +- examples/todos/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml index 327a0ef1..c8926c33 100644 --- a/examples/todos/Cargo.toml +++ b/examples/todos/Cargo.toml @@ -12,7 +12,7 @@ serde_json = "1.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] async-std = "1.0" -directories = "3.0" +directories-next = "2.0" [target.'cfg(target_arch = "wasm32")'.dependencies] web-sys = { version = "0.3", features = ["Window", "Storage"] } diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 7a546815..f88e9869 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -499,7 +499,7 @@ enum SaveError { impl SavedState { fn path() -> std::path::PathBuf { let mut path = if let Some(project_dirs) = - directories::ProjectDirs::from("rs", "Iced", "Todos") + directories_next::ProjectDirs::from("rs", "Iced", "Todos") { project_dirs.data_dir().into() } else {