Support sharing Pipeline
state between TextAtlas
(#95)
* Support sharing `Pipeline` state between `TextAtlas` * Keep using `Vec` for pipeline cache * Use `OnceCell` to keep `Pipeline` private * Revert "Use `OnceCell` to keep `Pipeline` private" This reverts commit 4112732b1734a3bb6b915d2103e699ef549b77c1. * Rename `Pipeline` type to `Cache`
This commit is contained in:
parent
670140e2a1
commit
5aed9e1477
6 changed files with 295 additions and 237 deletions
|
@ -1,6 +1,6 @@
|
|||
use glyphon::{
|
||||
Attrs, Buffer, Color, Family, FontSystem, Metrics, Resolution, Shaping, SwashCache, TextArea,
|
||||
TextAtlas, TextBounds, TextRenderer,
|
||||
Attrs, Buffer, Cache, Color, Family, FontSystem, Metrics, Resolution, Shaping, SwashCache,
|
||||
TextArea, TextAtlas, TextBounds, TextRenderer,
|
||||
};
|
||||
use wgpu::{
|
||||
CommandEncoderDescriptor, CompositeAlphaMode, DeviceDescriptor, Features, Instance,
|
||||
|
@ -71,8 +71,9 @@ async fn run() {
|
|||
|
||||
// Set up text renderer
|
||||
let mut font_system = FontSystem::new();
|
||||
let mut cache = SwashCache::new();
|
||||
let mut atlas = TextAtlas::new(&device, &queue, swapchain_format);
|
||||
let mut swash_cache = SwashCache::new();
|
||||
let cache = Cache::new(&device);
|
||||
let mut atlas = TextAtlas::new(&device, &queue, &cache, swapchain_format);
|
||||
let mut text_renderer =
|
||||
TextRenderer::new(&mut atlas, &device, MultisampleState::default(), None);
|
||||
let mut buffer = Buffer::new(&mut font_system, Metrics::new(30.0, 42.0));
|
||||
|
@ -122,7 +123,7 @@ async fn run() {
|
|||
},
|
||||
default_color: Color::rgb(255, 255, 255),
|
||||
}],
|
||||
&mut cache,
|
||||
&mut swash_cache,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue