Skip to content

Remove use of std::time::Instant on WASM #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2024
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
8 changes: 5 additions & 3 deletions examples/with_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,8 @@ fn run(
renderers.resize_with(render_cx.devices.len(), || None);
let id = render_state.surface.dev_id;
renderers[id].get_or_insert_with(|| {
eprintln!("Creating renderer {id}");
Renderer::new(
let start = Instant::now();
let renderer = Renderer::new(
&render_cx.devices[id].device,
RendererOptions {
surface_format: Some(render_state.surface.format),
Expand All @@ -544,7 +544,9 @@ fn run(
num_init_threads: NonZeroUsize::new(args.num_init_threads)
},
)
.expect("Could create renderer")
.expect("Could create renderer");
eprintln!("Creating renderer {id} took {:?}", start.elapsed());
renderer
});
Some(render_state)
};
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod shaders;
#[cfg(feature = "wgpu")]
mod wgpu_engine;

use std::{num::NonZeroUsize, time::Instant};
use std::num::NonZeroUsize;

/// Styling and composition primitives.
pub use peniko;
Expand Down Expand Up @@ -151,11 +151,9 @@ impl Renderer {
#[cfg(not(target_arch = "wasm32"))]
engine.use_parallel_initialisation();
}
let start = Instant::now();
let shaders = shaders::full_shaders(device, &mut engine, &options)?;
#[cfg(not(target_arch = "wasm32"))]
engine.build_shaders_if_needed(device, options.num_init_threads);
eprintln!("Building shaders took {:?}", start.elapsed());
let blit = options
.surface_format
.map(|surface_format| BlitPipeline::new(device, surface_format));
Expand Down