From c82fdbfc54c0eea2d81748f3741b6ac794dd4165 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Fri, 30 Aug 2024 22:17:08 +0200 Subject: [PATCH] apply bind group only if entries are different --- .../src/components/rich_text/image_cache/cache.rs | 12 ++++++------ sugarloaf/src/components/rich_text/mod.rs | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sugarloaf/src/components/rich_text/image_cache/cache.rs b/sugarloaf/src/components/rich_text/image_cache/cache.rs index 53a3a2785d..cfe2655217 100644 --- a/sugarloaf/src/components/rich_text/image_cache/cache.rs +++ b/sugarloaf/src/components/rich_text/image_cache/cache.rs @@ -8,9 +8,9 @@ use super::atlas::*; use super::*; pub struct ImageCache { - entries: Vec, - atlases: Vec, - pub images: Vec, + pub entries: Vec, + pub atlases: Vec, + images: Vec, buffered_data: Vec, events: Vec, free_entries: u32, @@ -651,7 +651,7 @@ impl ImageCache { } #[derive(Default)] -struct Entry { +pub struct Entry { /// Zero if the entry is free. flags: u8, /// Generation of this entry. Used to detect stale handles. @@ -669,7 +669,7 @@ struct Entry { height: u16, } -struct Atlas { +pub struct Atlas { format: PixelFormat, alloc: AtlasAllocator, buffer: Vec, @@ -678,7 +678,7 @@ struct Atlas { texture_id: TextureId, } -pub struct Standalone { +struct Standalone { texture_id: TextureId, used: bool, next: u32, diff --git a/sugarloaf/src/components/rich_text/mod.rs b/sugarloaf/src/components/rich_text/mod.rs index 72efd8689f..fb5207091d 100644 --- a/sugarloaf/src/components/rich_text/mod.rs +++ b/sugarloaf/src/components/rich_text/mod.rs @@ -445,8 +445,8 @@ impl RichTextBrush { self.index_buffer_size = size; } - // if self.textures_version != self.images.images.len() { - // println!("oi"); + if self.textures_version != self.images.entries.len() { + self.textures_version = self.images.entries.len(); self.layout_bind_group = ctx.device.create_bind_group(&wgpu::BindGroupDescriptor { layout: &self.layout_bind_group_layout, @@ -460,7 +460,7 @@ impl RichTextBrush { ], label: Some("rich_text::Pipeline uniforms"), }); - // } + } rpass.set_pipeline(&self.pipeline); rpass.set_bind_group(0, &self.constant_bind_group, &[]);