Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ repository = "https://github.com/grovesNL/glyphon"
license = "MIT OR Apache-2.0 OR Zlib"

[dependencies]
wgpu = { version = "27.0.1", default-features = false, features = ["wgsl"] }
etagere = "0.2.10"
cosmic-text = "0.14"
lru = { version = "0.16", default-features = false }
wgpu = { version = "28.0.0", default-features = false, features = ["wgsl"] }
etagere = "0.2.15"
cosmic-text = "0.15"
lru = { version = "0.16.2", default-features = false }
rustc-hash = "2.1.1"

[dev-dependencies]
winit = "0.30.3"
wgpu = "27.0.1"
resvg = { version = "0.45", default-features = false }
winit = "0.30.12"
wgpu = "28.0.0"
resvg = { version = "0.45.1", default-features = false }
pollster = "0.4.0"
criterion = { version = "0.6", features = ["html_reports"] }
criterion = { version = "0.8.1", features = ["html_reports"] }

[[bench]]
name = "prepare"
Expand Down
5 changes: 3 additions & 2 deletions benches/prepare.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::hint;
use cosmic_text::{Attrs, Buffer, Color, Family, FontSystem, Metrics, Shaping, SwashCache};
use criterion::{criterion_group, criterion_main, Criterion};
use glyphon::{
Expand Down Expand Up @@ -70,7 +71,7 @@ fn run_bench(ctx: &mut Criterion) {
.map(|s| {
let mut text_buffer = Buffer::new(&mut font_system, Metrics::relative(1.0, 10.0));
text_buffer.set_size(&mut font_system, Some(20.0), None);
text_buffer.set_text(&mut font_system, s, &attrs, shaping);
text_buffer.set_text(&mut font_system, s, &attrs, shaping, None);
text_buffer.shape_until_scroll(&mut font_system, false);
text_buffer
})
Expand All @@ -96,7 +97,7 @@ fn run_bench(ctx: &mut Criterion) {
})
.collect();

criterion::black_box(
hint::black_box(
text_renderer
.prepare(
&state.device,
Expand Down
18 changes: 8 additions & 10 deletions benches/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@ impl State {
..Default::default()
},
..Default::default()
}
},
});

let adapter = block_on(wgpu::util::initialize_adapter_from_env_or_default(
&instance, None,
))
.unwrap();

let (device, queue) = block_on(adapter.request_device(
&wgpu::DeviceDescriptor {
label: Some("Benchmark Device"),
required_features: adapter.features(),
required_limits: adapter.limits(),
memory_hints: wgpu::MemoryHints::Performance,
..Default::default()
},
))
let (device, queue) = block_on(adapter.request_device(&wgpu::DeviceDescriptor {
label: Some("Benchmark Device"),
required_features: adapter.features(),
required_limits: adapter.limits(),
memory_hints: wgpu::MemoryHints::Performance,
..Default::default()
}))
.unwrap();

Self { device, queue }
Expand Down
2 changes: 2 additions & 0 deletions examples/custom-glyphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl WindowState {
"SVG icons! --->\n\nThe icons below should be partially clipped.",
&Attrs::new().family(Family::SansSerif),
Shaping::Advanced,
None,
);
text_buffer.shape_until_scroll(&mut font_system, false);

Expand Down Expand Up @@ -311,6 +312,7 @@ impl winit::application::ApplicationHandler for Application {
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});

text_renderer.render(atlas, viewport, &mut pass).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion examples/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ impl WindowState {
Some(physical_width),
Some(physical_height),
);
text_buffer.set_text(&mut font_system, "Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", &Attrs::new().family(Family::SansSerif), Shaping::Advanced);
text_buffer.set_text(&mut font_system, "Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", &Attrs::new().family(Family::SansSerif), Shaping::Advanced
,None,);
text_buffer.shape_until_scroll(&mut font_system, false);

Self {
Expand Down Expand Up @@ -211,6 +212,7 @@ impl winit::application::ApplicationHandler for Application {
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});

text_renderer.render(atlas, viewport, &mut pass).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions examples/text-sizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl WindowState {
&format!("size {s}: {TEXT}"),
&attrs,
shaping,
None,
);

text_buffer.shape_until_scroll(&mut font_system, false);
Expand Down Expand Up @@ -288,6 +289,7 @@ impl winit::application::ApplicationHandler for Application {
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
multiview_mask: None,
});

text_renderer.render(atlas, viewport, &mut pass).unwrap();
Expand Down
18 changes: 9 additions & 9 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ use std::{
use wgpu::{
BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutEntry,
BindingResource, BindingType, BlendState, Buffer, BufferBindingType, ColorTargetState,
ColorWrites, DepthStencilState, Device, FilterMode, FragmentState, MultisampleState,
PipelineCompilationOptions, PipelineLayout, PipelineLayoutDescriptor, PrimitiveState,
PrimitiveTopology, RenderPipeline, RenderPipelineDescriptor, Sampler, SamplerBindingType,
SamplerDescriptor, ShaderModule, ShaderModuleDescriptor, ShaderSource, ShaderStages,
TextureFormat, TextureSampleType, TextureView, TextureViewDimension, VertexFormat, VertexState,
ColorWrites, DepthStencilState, Device, FilterMode, FragmentState, MipmapFilterMode,
MultisampleState, PipelineCompilationOptions, PipelineLayout, PipelineLayoutDescriptor,
PrimitiveState, PrimitiveTopology, RenderPipeline, RenderPipelineDescriptor, Sampler,
SamplerBindingType, SamplerDescriptor, ShaderModule, ShaderModuleDescriptor, ShaderSource,
ShaderStages, TextureFormat, TextureSampleType, TextureView, TextureViewDimension,
VertexFormat, VertexState,
};

/// A cache to share common resources (e.g., pipelines, layouts, shaders) between multiple text
Expand Down Expand Up @@ -48,7 +49,7 @@ impl Cache {
label: Some("glyphon sampler"),
min_filter: FilterMode::Nearest,
mag_filter: FilterMode::Nearest,
mipmap_filter: FilterMode::Nearest,
mipmap_filter: MipmapFilterMode::Nearest,
lod_min_clamp: 0f32,
lod_max_clamp: 0f32,
..Default::default()
Expand Down Expand Up @@ -143,9 +144,8 @@ impl Cache {
});

let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&atlas_layout, &uniforms_layout],
push_constant_ranges: &[],
..Default::default()
});

Self(Arc::new(Inner {
Expand Down Expand Up @@ -243,8 +243,8 @@ impl Cache {
},
depth_stencil: depth_stencil.clone(),
multisample,
multiview: None,
cache: None,
multiview_mask: None,
});

cache.push((format, multisample, depth_stencil, pipeline.clone()));
Expand Down