feat: add text cache size debug display, increase max texture size
This commit is contained in:
parent
3282bcc4ae
commit
c374ba0fc8
2 changed files with 15 additions and 2 deletions
|
|
@ -562,7 +562,12 @@ impl eframe::App for TemplateApp {
|
||||||
|
|
||||||
if let Some(ref cache) = self.text_cache {
|
if let Some(ref cache) = self.text_cache {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.label(format!("Text cache: {} entries", cache.cache_size()));
|
let bytes = cache.cache_memory_bytes();
|
||||||
|
let mb = bytes as f32 / (1024.0 * 1024.0);
|
||||||
|
ui.label(format!(
|
||||||
|
"Text cache: {} entries (~{mb:.2} MB)",
|
||||||
|
cache.cache_size()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const TEXTURE_OPTIONS: TextureOptions = TextureOptions {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Maximum texture dimension to prevent memory issues.
|
/// Maximum texture dimension to prevent memory issues.
|
||||||
const MAX_TEXTURE_DIM: u32 = 4096;
|
const MAX_TEXTURE_DIM: u32 = 8192;
|
||||||
|
|
||||||
/// Maximum pixel count (16M pixels = 64MB for RGBA).
|
/// Maximum pixel count (16M pixels = 64MB for RGBA).
|
||||||
const MAX_PIXEL_COUNT: usize = 16 * 1024 * 1024;
|
const MAX_PIXEL_COUNT: usize = 16 * 1024 * 1024;
|
||||||
|
|
@ -74,6 +74,14 @@ impl TextCache {
|
||||||
self.cache.len()
|
self.cache.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns approximate GPU memory used by cached text textures (bytes).
|
||||||
|
pub fn cache_memory_bytes(&self) -> usize {
|
||||||
|
self.cache
|
||||||
|
.values()
|
||||||
|
.map(|cached| cached.width as usize * cached.height as usize * 4)
|
||||||
|
.sum()
|
||||||
|
}
|
||||||
|
|
||||||
/// Get or create a cached texture for the given text.
|
/// Get or create a cached texture for the given text.
|
||||||
///
|
///
|
||||||
/// The texture is rendered at the smallest available render scale that can
|
/// The texture is rendered at the smallest available render scale that can
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue