Skip to content

Commit

Permalink
apply bind group only if entries are different
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Aug 30, 2024
1 parent 5c0a1c0 commit c82fdbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions sugarloaf/src/components/rich_text/image_cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use super::atlas::*;
use super::*;

pub struct ImageCache {
entries: Vec<Entry>,
atlases: Vec<Atlas>,
pub images: Vec<Standalone>,
pub entries: Vec<Entry>,
pub atlases: Vec<Atlas>,
images: Vec<Standalone>,
buffered_data: Vec<u8>,
events: Vec<Event>,
free_entries: u32,
Expand Down Expand Up @@ -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.
Expand All @@ -669,7 +669,7 @@ struct Entry {
height: u16,
}

struct Atlas {
pub struct Atlas {
format: PixelFormat,
alloc: AtlasAllocator,
buffer: Vec<u8>,
Expand All @@ -678,7 +678,7 @@ struct Atlas {
texture_id: TextureId,
}

pub struct Standalone {
struct Standalone {
texture_id: TextureId,
used: bool,
next: u32,
Expand Down
6 changes: 3 additions & 3 deletions sugarloaf/src/components/rich_text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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, &[]);
Expand Down

0 comments on commit c82fdbf

Please sign in to comment.