Merge pull request #914 from yusdacra/feat/expose_draw_cache_multithread
feat: expose draw_cache_multithread as a feature
This commit is contained in:
commit
a2b1ba522a
8 changed files with 55 additions and 11 deletions
|
|
@ -31,8 +31,13 @@ pub struct Backend {
|
|||
impl Backend {
|
||||
/// Creates a new [`Backend`].
|
||||
pub fn new(device: &wgpu::Device, settings: Settings) -> Self {
|
||||
let text_pipeline =
|
||||
text::Pipeline::new(device, settings.format, settings.default_font);
|
||||
let text_pipeline = text::Pipeline::new(
|
||||
device,
|
||||
settings.format,
|
||||
settings.default_font,
|
||||
settings.text_multithreading,
|
||||
);
|
||||
|
||||
let quad_pipeline = quad::Pipeline::new(device, settings.format);
|
||||
let triangle_pipeline = triangle::Pipeline::new(
|
||||
device,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,15 @@ pub struct Settings {
|
|||
/// By default, it will be set to 20.
|
||||
pub default_text_size: u16,
|
||||
|
||||
/// If enabled, spread text workload in multiple threads when multiple cores
|
||||
/// are available.
|
||||
///
|
||||
/// By default, it is disabled.
|
||||
pub text_multithreading: bool,
|
||||
|
||||
/// The antialiasing strategy that will be used for triangle primitives.
|
||||
///
|
||||
/// By default, it is `None`.
|
||||
pub antialiasing: Option<Antialiasing>,
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +73,7 @@ impl Default for Settings {
|
|||
internal_backend: wgpu::BackendBit::PRIMARY,
|
||||
default_font: None,
|
||||
default_text_size: 20,
|
||||
text_multithreading: false,
|
||||
antialiasing: None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ impl Pipeline {
|
|||
device: &wgpu::Device,
|
||||
format: wgpu::TextureFormat,
|
||||
default_font: Option<&[u8]>,
|
||||
multithreading: bool,
|
||||
) -> Self {
|
||||
let default_font = default_font.map(|slice| slice.to_vec());
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ impl Pipeline {
|
|||
let draw_brush =
|
||||
wgpu_glyph::GlyphBrushBuilder::using_font(font.clone())
|
||||
.initial_cache_size((2048, 2048))
|
||||
.draw_cache_multithread(false) // TODO: Expose as a configuration flag
|
||||
.draw_cache_multithread(multithreading)
|
||||
.build(device, format);
|
||||
|
||||
let measure_brush =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue