Reuse glyphon::Pipeline state in iced_wgpu

This commit is contained in:
Héctor Ramón Jiménez 2024-05-08 12:29:17 +02:00
parent e07b42ac96
commit 447f3a2d14
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 12 additions and 5 deletions

View file

@ -142,7 +142,7 @@ cosmic-text = "0.10"
dark-light = "1.0" dark-light = "1.0"
futures = "0.3" futures = "0.3"
glam = "0.25" glam = "0.25"
glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "ceed55403ce53e120ce9d1fae17dcfe388726118" } glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "cd66a24859cf30b0b8cabf06256dacad362ed44a" }
guillotiere = "0.6" guillotiere = "0.6"
half = "2.2" half = "2.2"
image = "0.24" image = "0.24"

View file

@ -115,6 +115,7 @@ impl Storage {
queue: &wgpu::Queue, queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder, encoder: &mut wgpu::CommandEncoder,
format: wgpu::TextureFormat, format: wgpu::TextureFormat,
pipeline: &glyphon::Pipeline,
cache: &Cache, cache: &Cache,
new_transformation: Transformation, new_transformation: Transformation,
bounds: Rectangle, bounds: Rectangle,
@ -131,7 +132,7 @@ impl Storage {
Group { Group {
atlas: glyphon::TextAtlas::with_color_mode( atlas: glyphon::TextAtlas::with_color_mode(
device, queue, format, COLOR_MODE, device, queue, pipeline, format, COLOR_MODE,
), ),
version: 0, version: 0,
should_trim: false, should_trim: false,
@ -259,6 +260,7 @@ impl Storage {
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct Pipeline { pub struct Pipeline {
state: glyphon::Pipeline,
format: wgpu::TextureFormat, format: wgpu::TextureFormat,
atlas: glyphon::TextAtlas, atlas: glyphon::TextAtlas,
renderers: Vec<glyphon::TextRenderer>, renderers: Vec<glyphon::TextRenderer>,
@ -272,12 +274,16 @@ impl Pipeline {
queue: &wgpu::Queue, queue: &wgpu::Queue,
format: wgpu::TextureFormat, format: wgpu::TextureFormat,
) -> Self { ) -> Self {
let state = glyphon::Pipeline::new(device);
let atlas = glyphon::TextAtlas::with_color_mode(
device, queue, &state, format, COLOR_MODE,
);
Pipeline { Pipeline {
state,
format, format,
renderers: Vec::new(), renderers: Vec::new(),
atlas: glyphon::TextAtlas::with_color_mode( atlas,
device, queue, format, COLOR_MODE,
),
prepare_layer: 0, prepare_layer: 0,
cache: BufferCache::new(), cache: BufferCache::new(),
} }
@ -343,6 +349,7 @@ impl Pipeline {
queue, queue,
encoder, encoder,
self.format, self.format,
&self.state,
cache, cache,
layer_transformation * *transformation, layer_transformation * *transformation,
layer_bounds * layer_transformation, layer_bounds * layer_transformation,