From 2bb53ad6e7ea2689f2f56662e5840a8d363b3108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 29 Mar 2024 04:02:24 +0100 Subject: [PATCH 1/7] Use a `StagingBelt` in `iced_wgpu` for regular buffer uploads --- Cargo.toml | 2 +- wgpu/src/backend.rs | 26 ++++++++++++++++++++----- wgpu/src/buffer.rs | 14 ++++++++++++-- wgpu/src/image.rs | 36 +++++++++++++++++++++++------------ wgpu/src/quad.rs | 28 +++++++++++++++++++-------- wgpu/src/quad/gradient.rs | 5 +++-- wgpu/src/quad/solid.rs | 5 +++-- wgpu/src/text.rs | 2 ++ wgpu/src/triangle.rs | 35 +++++++++++++++++++++++++--------- wgpu/src/window/compositor.rs | 1 + 10 files changed, 113 insertions(+), 41 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e2639944f9..74ff3b84dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -129,7 +129,7 @@ cosmic-text = "0.10" dark-light = "1.0" futures = "0.3" glam = "0.25" -glyphon = "0.5" +glyphon = { git = "https://github.com/hecrj/glyphon.git", branch = "use-staging-belt" } guillotiere = "0.6" half = "2.2" image = "0.24" diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index 5019191c33..129e9bca9b 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -30,6 +30,7 @@ pub struct Backend { pipeline_storage: pipeline::Storage, #[cfg(any(feature = "image", feature = "svg"))] image_pipeline: image::Pipeline, + staging_belt: wgpu::util::StagingBelt, } impl Backend { @@ -61,6 +62,11 @@ impl Backend { #[cfg(any(feature = "image", feature = "svg"))] image_pipeline, + + // TODO: Resize belt smartly (?) + // It would be great if the `StagingBelt` API exposed methods + // for introspection to detect when a resize may be worth it. + staging_belt: wgpu::util::StagingBelt::new(1024 * 100), } } @@ -105,6 +111,8 @@ impl Backend { &layers, ); + self.staging_belt.finish(); + self.render( device, encoder, @@ -123,12 +131,17 @@ impl Backend { self.image_pipeline.end_frame(); } + /// + pub fn recall(&mut self) { + self.staging_belt.recall(); + } + fn prepare( &mut self, device: &wgpu::Device, queue: &wgpu::Queue, format: wgpu::TextureFormat, - _encoder: &mut wgpu::CommandEncoder, + encoder: &mut wgpu::CommandEncoder, scale_factor: f32, target_size: Size, transformation: Transformation, @@ -144,7 +157,8 @@ impl Backend { if !layer.quads.is_empty() { self.quad_pipeline.prepare( device, - queue, + encoder, + &mut self.staging_belt, &layer.quads, transformation, scale_factor, @@ -157,7 +171,8 @@ impl Backend { self.triangle_pipeline.prepare( device, - queue, + encoder, + &mut self.staging_belt, &layer.meshes, scaled, ); @@ -171,8 +186,8 @@ impl Backend { self.image_pipeline.prepare( device, - queue, - _encoder, + encoder, + &mut self.staging_belt, &layer.images, scaled, scale_factor, @@ -184,6 +199,7 @@ impl Backend { self.text_pipeline.prepare( device, queue, + encoder, &layer.text, layer.bounds, scale_factor, diff --git a/wgpu/src/buffer.rs b/wgpu/src/buffer.rs index ef00c58f4a..f8828d4656 100644 --- a/wgpu/src/buffer.rs +++ b/wgpu/src/buffer.rs @@ -61,12 +61,22 @@ impl Buffer { /// Returns the size of the written bytes. pub fn write( &mut self, - queue: &wgpu::Queue, + device: &wgpu::Device, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, offset: usize, contents: &[T], ) -> usize { let bytes: &[u8] = bytemuck::cast_slice(contents); - queue.write_buffer(&self.raw, offset as u64, bytes); + + belt.write_buffer( + encoder, + &self.raw, + offset as u64, + (bytes.len() as u64).try_into().expect("Non-empty write"), + device, + ) + .copy_from_slice(bytes); self.offsets.push(offset as u64); diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 067b77ab80..d0bf1182a7 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -83,21 +83,31 @@ impl Layer { fn prepare( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, nearest_instances: &[Instance], linear_instances: &[Instance], transformation: Transformation, ) { - queue.write_buffer( + let uniforms = Uniforms { + transform: transformation.into(), + }; + + let bytes = bytemuck::bytes_of(&uniforms); + + belt.write_buffer( + encoder, &self.uniforms, 0, - bytemuck::bytes_of(&Uniforms { - transform: transformation.into(), - }), - ); + (bytes.len() as u64).try_into().expect("Sized uniforms"), + device, + ) + .copy_from_slice(bytes); + + self.nearest + .upload(device, encoder, belt, nearest_instances); - self.nearest.upload(device, queue, nearest_instances); - self.linear.upload(device, queue, linear_instances); + self.linear.upload(device, encoder, belt, linear_instances); } fn render<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) { @@ -158,7 +168,8 @@ impl Data { fn upload( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, instances: &[Instance], ) { self.instance_count = instances.len(); @@ -168,7 +179,7 @@ impl Data { } let _ = self.instances.resize(device, instances.len()); - let _ = self.instances.write(queue, 0, instances); + let _ = self.instances.write(device, encoder, belt, 0, instances); } fn render<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) { @@ -383,8 +394,8 @@ impl Pipeline { pub fn prepare( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, images: &[layer::Image], transformation: Transformation, _scale: f32, @@ -501,7 +512,8 @@ impl Pipeline { layer.prepare( device, - queue, + encoder, + belt, nearest_instances, linear_instances, transformation, diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index b932f54f9e..0717a03175 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -57,7 +57,8 @@ impl Pipeline { pub fn prepare( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, quads: &Batch, transformation: Transformation, scale: f32, @@ -67,7 +68,7 @@ impl Pipeline { } let layer = &mut self.layers[self.prepare_layer]; - layer.prepare(device, queue, quads, transformation, scale); + layer.prepare(device, encoder, belt, quads, transformation, scale); self.prepare_layer += 1; } @@ -162,7 +163,8 @@ impl Layer { pub fn prepare( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, quads: &Batch, transformation: Transformation, scale: f32, @@ -171,15 +173,25 @@ impl Layer { let _ = info_span!("Wgpu::Quad", "PREPARE").entered(); let uniforms = Uniforms::new(transformation, scale); + let bytes = bytemuck::bytes_of(&uniforms); - queue.write_buffer( + belt.write_buffer( + encoder, &self.constants_buffer, 0, - bytemuck::bytes_of(&uniforms), - ); + (bytes.len() as u64).try_into().expect("Sized uniforms"), + device, + ) + .copy_from_slice(bytes); - self.solid.prepare(device, queue, &quads.solids); - self.gradient.prepare(device, queue, &quads.gradients); + if !quads.solids.is_empty() { + self.solid.prepare(device, encoder, belt, &quads.solids); + } + + if !quads.gradients.is_empty() { + self.gradient + .prepare(device, encoder, belt, &quads.gradients); + } } } diff --git a/wgpu/src/quad/gradient.rs b/wgpu/src/quad/gradient.rs index 560fcad22f..5b32c52a76 100644 --- a/wgpu/src/quad/gradient.rs +++ b/wgpu/src/quad/gradient.rs @@ -46,11 +46,12 @@ impl Layer { pub fn prepare( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, instances: &[Gradient], ) { let _ = self.instances.resize(device, instances.len()); - let _ = self.instances.write(queue, 0, instances); + let _ = self.instances.write(device, encoder, belt, 0, instances); self.instance_count = instances.len(); } diff --git a/wgpu/src/quad/solid.rs b/wgpu/src/quad/solid.rs index 771eee34fb..1cead3678f 100644 --- a/wgpu/src/quad/solid.rs +++ b/wgpu/src/quad/solid.rs @@ -40,11 +40,12 @@ impl Layer { pub fn prepare( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, instances: &[Solid], ) { let _ = self.instances.resize(device, instances.len()); - let _ = self.instances.write(queue, 0, instances); + let _ = self.instances.write(device, encoder, belt, 0, instances); self.instance_count = instances.len(); } diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 6fa1922d43..97ff77f504 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -53,6 +53,7 @@ impl Pipeline { &mut self, device: &wgpu::Device, queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, sections: &[Text<'_>], layer_bounds: Rectangle, scale_factor: f32, @@ -262,6 +263,7 @@ impl Pipeline { let result = renderer.prepare( device, queue, + encoder, font_system, &mut self.atlas, glyphon::Resolution { diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index 2bb6f307fa..b6be54d4c4 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -48,7 +48,8 @@ impl Layer { fn prepare( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, solid: &solid::Pipeline, gradient: &gradient::Pipeline, meshes: &[Mesh<'_>], @@ -103,33 +104,47 @@ impl Layer { let uniforms = Uniforms::new(transformation * mesh.transformation()); - index_offset += - self.index_buffer.write(queue, index_offset, indices); + index_offset += self.index_buffer.write( + device, + encoder, + belt, + index_offset, + indices, + ); + self.index_strides.push(indices.len() as u32); match mesh { Mesh::Solid { buffers, .. } => { solid_vertex_offset += self.solid.vertices.write( - queue, + device, + encoder, + belt, solid_vertex_offset, &buffers.vertices, ); solid_uniform_offset += self.solid.uniforms.write( - queue, + device, + encoder, + belt, solid_uniform_offset, &[uniforms], ); } Mesh::Gradient { buffers, .. } => { gradient_vertex_offset += self.gradient.vertices.write( - queue, + device, + encoder, + belt, gradient_vertex_offset, &buffers.vertices, ); gradient_uniform_offset += self.gradient.uniforms.write( - queue, + device, + encoder, + belt, gradient_uniform_offset, &[uniforms], ); @@ -237,7 +252,8 @@ impl Pipeline { pub fn prepare( &mut self, device: &wgpu::Device, - queue: &wgpu::Queue, + encoder: &mut wgpu::CommandEncoder, + belt: &mut wgpu::util::StagingBelt, meshes: &[Mesh<'_>], transformation: Transformation, ) { @@ -252,7 +268,8 @@ impl Pipeline { let layer = &mut self.layers[self.prepare_layer]; layer.prepare( device, - queue, + encoder, + belt, &self.solid, &self.gradient, meshes, diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 9a3e3b34b3..482d705bbd 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -243,6 +243,7 @@ pub fn present>( // Submit work let _submission = compositor.queue.submit(Some(encoder.finish())); + backend.recall(); frame.present(); Ok(()) From 0a97b9e37ae115bb0db33193c8a6b62590a3cd2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 29 Mar 2024 09:57:11 +0100 Subject: [PATCH 2/7] Add documentation to `Backend::recall` in `iced_wgpu` --- wgpu/src/backend.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index 129e9bca9b..208093736e 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -131,7 +131,10 @@ impl Backend { self.image_pipeline.end_frame(); } + /// Recalls staging memory for future uploads. /// + /// This method should be called after the command encoder + /// has been submitted. pub fn recall(&mut self) { self.staging_belt.recall(); } From 5f1eb43161d70b4ef157aae1ebc2b5fb25eb5b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 29 Mar 2024 14:29:31 +0100 Subject: [PATCH 3/7] Split big `Buffer` writes into multiple chunks --- wgpu/src/backend.rs | 5 ++++- wgpu/src/buffer.rs | 42 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index 208093736e..6ccf4111d8 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -1,3 +1,4 @@ +use crate::buffer; use crate::core::{Color, Size, Transformation}; use crate::graphics::backend; use crate::graphics::color; @@ -66,7 +67,9 @@ impl Backend { // TODO: Resize belt smartly (?) // It would be great if the `StagingBelt` API exposed methods // for introspection to detect when a resize may be worth it. - staging_belt: wgpu::util::StagingBelt::new(1024 * 100), + staging_belt: wgpu::util::StagingBelt::new( + buffer::MAX_WRITE_SIZE as u64, + ), } } diff --git a/wgpu/src/buffer.rs b/wgpu/src/buffer.rs index f8828d4656..c9d6b82864 100644 --- a/wgpu/src/buffer.rs +++ b/wgpu/src/buffer.rs @@ -1,6 +1,8 @@ use std::marker::PhantomData; use std::ops::RangeBounds; +pub const MAX_WRITE_SIZE: usize = 1024 * 100; + #[derive(Debug)] pub struct Buffer { label: &'static str, @@ -69,14 +71,38 @@ impl Buffer { ) -> usize { let bytes: &[u8] = bytemuck::cast_slice(contents); - belt.write_buffer( - encoder, - &self.raw, - offset as u64, - (bytes.len() as u64).try_into().expect("Non-empty write"), - device, - ) - .copy_from_slice(bytes); + if bytes.len() <= MAX_WRITE_SIZE { + belt.write_buffer( + encoder, + &self.raw, + offset as u64, + (bytes.len() as u64).try_into().expect("Non-empty write"), + device, + ) + .copy_from_slice(bytes); + } else { + let mut bytes_written = 0; + + let bytes_per_chunk = (bytes.len().min(MAX_WRITE_SIZE) as u64) + .try_into() + .expect("Non-empty write"); + + while bytes_written < bytes.len() { + belt.write_buffer( + encoder, + &self.raw, + (offset + bytes_written) as u64, + bytes_per_chunk, + device, + ) + .copy_from_slice( + &bytes[bytes_written + ..bytes_written + bytes_per_chunk.get() as usize], + ); + + bytes_written += bytes_per_chunk.get() as usize; + } + } self.offsets.push(offset as u64); From d11e271d262056523f3f644bce3144a7d1a490c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sat, 30 Mar 2024 00:17:06 +0100 Subject: [PATCH 4/7] Update `glyphon` with more performance improvements See: - https://github.com/grovesNL/glyphon/pull/90 - https://github.com/grovesNL/glyphon/pull/91 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 74ff3b84dd..8a6246c854 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -129,7 +129,7 @@ cosmic-text = "0.10" dark-light = "1.0" futures = "0.3" glam = "0.25" -glyphon = { git = "https://github.com/hecrj/glyphon.git", branch = "use-staging-belt" } +glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "6412ac86d63f048d17022fa100db7be6686db728" } guillotiere = "0.6" half = "2.2" image = "0.24" From 35af0aa84f76daddbb6d6959f9746bd09e306278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sat, 30 Mar 2024 13:50:40 +0100 Subject: [PATCH 5/7] Fix batched writes logic in `iced_wgpu::buffer` --- wgpu/src/buffer.rs | 59 +++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/wgpu/src/buffer.rs b/wgpu/src/buffer.rs index c9d6b82864..463ea24a1d 100644 --- a/wgpu/src/buffer.rs +++ b/wgpu/src/buffer.rs @@ -1,7 +1,12 @@ use std::marker::PhantomData; +use std::num::NonZeroU64; use std::ops::RangeBounds; -pub const MAX_WRITE_SIZE: usize = 1024 * 100; +pub const MAX_WRITE_SIZE: usize = 100 * 1024; + +#[allow(unsafe_code)] +const MAX_WRITE_SIZE_U64: NonZeroU64 = + unsafe { NonZeroU64::new_unchecked(MAX_WRITE_SIZE as u64) }; #[derive(Debug)] pub struct Buffer { @@ -70,40 +75,40 @@ impl Buffer { contents: &[T], ) -> usize { let bytes: &[u8] = bytemuck::cast_slice(contents); + let mut bytes_written = 0; - if bytes.len() <= MAX_WRITE_SIZE { + // Split write into multiple chunks if necessary + while bytes_written + MAX_WRITE_SIZE < bytes.len() { belt.write_buffer( encoder, &self.raw, - offset as u64, - (bytes.len() as u64).try_into().expect("Non-empty write"), + (offset + bytes_written) as u64, + MAX_WRITE_SIZE_U64, device, ) - .copy_from_slice(bytes); - } else { - let mut bytes_written = 0; - - let bytes_per_chunk = (bytes.len().min(MAX_WRITE_SIZE) as u64) - .try_into() - .expect("Non-empty write"); - - while bytes_written < bytes.len() { - belt.write_buffer( - encoder, - &self.raw, - (offset + bytes_written) as u64, - bytes_per_chunk, - device, - ) - .copy_from_slice( - &bytes[bytes_written - ..bytes_written + bytes_per_chunk.get() as usize], - ); - - bytes_written += bytes_per_chunk.get() as usize; - } + .copy_from_slice( + &bytes[bytes_written..bytes_written + MAX_WRITE_SIZE], + ); + + bytes_written += MAX_WRITE_SIZE; } + // There will always be some bytes left, since the previous + // loop guarantees `bytes_written < bytes.len()` + let bytes_left = ((bytes.len() - bytes_written) as u64) + .try_into() + .expect("non-empty write"); + + // Write them + belt.write_buffer( + encoder, + &self.raw, + (offset + bytes_written) as u64, + bytes_left, + device, + ) + .copy_from_slice(&bytes[bytes_written..]); + self.offsets.push(offset as u64); bytes.len() From faa53647cc83577e1ecb81a450c948b3fa4203e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sat, 30 Mar 2024 15:57:12 +0100 Subject: [PATCH 6/7] Replace `xxhash-rust` with `rustc-hash` --- Cargo.toml | 1 - core/Cargo.toml | 2 +- core/src/hasher.rs | 2 +- graphics/Cargo.toml | 1 - graphics/src/text/cache.rs | 11 ++++------- tiny_skia/Cargo.toml | 1 - 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8a6246c854..bf05ed1d04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,7 +155,6 @@ thiserror = "1.0" tiny-skia = "0.11" tokio = "1.0" tracing = "0.1" -xxhash-rust = { version = "0.8", features = ["xxh3"] } unicode-segmentation = "1.0" wasm-bindgen-futures = "0.4" wasm-timer = "0.2" diff --git a/core/Cargo.toml b/core/Cargo.toml index 32d233ee3b..d3529d98ea 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -21,10 +21,10 @@ log.workspace = true num-traits.workspace = true once_cell.workspace = true palette.workspace = true +rustc-hash.workspace = true smol_str.workspace = true thiserror.workspace = true web-time.workspace = true -xxhash-rust.workspace = true dark-light.workspace = true dark-light.optional = true diff --git a/core/src/hasher.rs b/core/src/hasher.rs index a13d78afcd..13180e4188 100644 --- a/core/src/hasher.rs +++ b/core/src/hasher.rs @@ -1,7 +1,7 @@ /// The hasher used to compare layouts. #[allow(missing_debug_implementations)] // Doesn't really make sense to have debug on the hasher state anyways. #[derive(Default)] -pub struct Hasher(xxhash_rust::xxh3::Xxh3); +pub struct Hasher(rustc_hash::FxHasher); impl core::hash::Hasher for Hasher { fn write(&mut self, bytes: &[u8]) { diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index 0ee6ff47de..a42ed477ed 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -34,7 +34,6 @@ raw-window-handle.workspace = true rustc-hash.workspace = true thiserror.workspace = true unicode-segmentation.workspace = true -xxhash-rust.workspace = true image.workspace = true image.optional = true diff --git a/graphics/src/text/cache.rs b/graphics/src/text/cache.rs index 7fb335678d..b6473f851d 100644 --- a/graphics/src/text/cache.rs +++ b/graphics/src/text/cache.rs @@ -2,9 +2,9 @@ use crate::core::{Font, Size}; use crate::text; -use rustc_hash::{FxHashMap, FxHashSet}; +use rustc_hash::{FxHashMap, FxHashSet, FxHasher}; use std::collections::hash_map; -use std::hash::{BuildHasher, Hash, Hasher}; +use std::hash::{Hash, Hasher}; /// A store of recently used sections of text. #[allow(missing_debug_implementations)] @@ -13,11 +13,8 @@ pub struct Cache { entries: FxHashMap, aliases: FxHashMap, recently_used: FxHashSet, - hasher: HashBuilder, } -type HashBuilder = xxhash_rust::xxh3::Xxh3Builder; - impl Cache { /// Creates a new empty [`Cache`]. pub fn new() -> Self { @@ -35,7 +32,7 @@ impl Cache { font_system: &mut cosmic_text::FontSystem, key: Key<'_>, ) -> (KeyHash, &mut Entry) { - let hash = key.hash(self.hasher.build_hasher()); + let hash = key.hash(FxHasher::default()); if let Some(hash) = self.aliases.get(&hash) { let _ = self.recently_used.insert(*hash); @@ -77,7 +74,7 @@ impl Cache { ] { if key.bounds != bounds { let _ = self.aliases.insert( - Key { bounds, ..key }.hash(self.hasher.build_hasher()), + Key { bounds, ..key }.hash(FxHasher::default()), hash, ); } diff --git a/tiny_skia/Cargo.toml b/tiny_skia/Cargo.toml index 68b2a03ac8..44a894a1d8 100644 --- a/tiny_skia/Cargo.toml +++ b/tiny_skia/Cargo.toml @@ -25,7 +25,6 @@ log.workspace = true rustc-hash.workspace = true softbuffer.workspace = true tiny-skia.workspace = true -xxhash-rust.workspace = true resvg.workspace = true resvg.optional = true From 4c74bebc708f960f77d53526e7da4187f56967c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sat, 30 Mar 2024 16:02:38 +0100 Subject: [PATCH 7/7] Update `glyphon` for instanced rendering --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index bf05ed1d04..b033cf33fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -129,7 +129,7 @@ cosmic-text = "0.10" dark-light = "1.0" futures = "0.3" glam = "0.25" -glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "6412ac86d63f048d17022fa100db7be6686db728" } +glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "ceed55403ce53e120ce9d1fae17dcfe388726118" } guillotiere = "0.6" half = "2.2" image = "0.24"