Minor cleanup

This commit is contained in:
Maximilian Ammann 2022-01-08 22:53:31 +01:00
parent 6744382b32
commit c00ca2d280
10 changed files with 19 additions and 42 deletions

View File

@ -1,6 +1,5 @@
use mapr::io::cache::Cache;
use mapr::main_loop;
use pollster::FutureExt;
use tokio::task;
use winit::event_loop::EventLoop;
@ -21,5 +20,5 @@ async fn main() {
let join_handle = task::spawn(async move { cache_io.run_loop().await });
main_loop::setup(window, event_loop, Box::new(cache_main)).await;
join_handle.await;
join_handle.await.unwrap();
}

View File

@ -206,7 +206,7 @@ impl Decode<Geometry> for ProtoFeature {
/// Decode a Feature
// FIXME: Decoding is very slow right now on development builds of wasm: (Development: 15s, Production: 60ms)
impl Decode<Feature> for (&mut ProtoLayer, ProtoFeature) {
fn decode(mut self) -> Feature {
fn decode(self) -> Feature {
let (layer, feature) = self;
let mut properties = HashMap::with_capacity(feature.tags.len());

View File

@ -1,9 +1,7 @@
use std::collections::HashMap;
use crate::geometry::Geometry;
use crate::protos::vector_tile::{
Tile as ProtoTile, Tile_Feature as ProtoFeature, Tile_Layer as ProtoLayer,
};
use crate::protos::vector_tile::{Tile as ProtoTile, Tile_Layer as ProtoLayer};
#[derive(Debug)]
pub struct Tile {

View File

@ -68,13 +68,13 @@ pub fn validate_project_wgsl() {
Err(err) => {
let path = path.strip_prefix(&root_dir).unwrap_or(path);
println!(
"cargo:warning={}: {}",
"cargo:warning={}{}",
path.to_str().unwrap(),
match err {
WgslError::ValidationErr(error) => format!("{:?}", error),
WgslError::ValidationErr(error) => format!(": {:?}", error),
WgslError::ParserErr { error, line, pos } =>
format!("{}", error),
WgslError::IoErr(error) => format!("{:?}", error),
format!(":{}:{} {}", line, pos, error),
WgslError::IoErr(error) => format!(": {:?}", error),
}
);
exit(1);

View File

@ -5,7 +5,6 @@ use log::info;
use crate::platform::Instant;
pub struct FPSMeter {
start: Instant,
next_report: Instant,
frame_count: u32,
}
@ -14,7 +13,6 @@ impl FPSMeter {
pub fn new() -> Self {
let start = Instant::now();
Self {
start,
next_report: start + Duration::from_secs(1),
frame_count: 0,
}

View File

@ -98,11 +98,6 @@ impl<T: Send> WorkQueue<T> {
result
}
fn try_pop(&self) -> Option<T> {
let mut queue = self.inner.try_lock().ok()?;
queue.pop_front()
}
fn pop(&self) -> Option<T> {
if let Ok(mut queue) = self.inner.lock() {
loop {

View File

@ -3,7 +3,7 @@ use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn create_cache() -> *mut Cache {
let mut cache = Box::new(Cache::new());
let cache = Box::new(Cache::new());
let ptr = Box::into_raw(cache);
return ptr;
}

View File

@ -1,26 +1,20 @@
mod cache;
mod fetch;
use std::cell::RefCell;
use std::panic;
use std::rc::Rc;
use log::{info, warn, Level};
use winit::dpi::{LogicalSize, Size};
use log::Level;
use winit::dpi::LogicalSize;
use winit::event_loop::EventLoop;
use winit::platform::web::WindowBuilderExtWebSys;
use winit::window::{Window, WindowBuilder};
use crate::error::Error;
use crate::io::cache::Cache;
use console_error_panic_hook;
pub use instant::Instant;
use js_sys::Array;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen_futures::JsFuture;
use web_sys::{MessageEvent, Window as WebSysWindow};
use web_sys::Window as WebSysWindow;
// WebGPU
#[cfg(not(feature = "web-webgl"))]

View File

@ -8,7 +8,6 @@ use std::ops::Range;
use wgpu::BufferAddress;
use crate::coords::TileCoords;
use crate::tesselation::OverAlignedVertexBuffer;
/// Buffer and its size
@ -49,8 +48,14 @@ impl<Q: Queue<B>, B, V: bytemuck::Pod, I: bytemuck::Pod> BufferPool<Q, B, V, I>
}
}
#[cfg(test)]
fn available_space(&self, vertices: bool) -> wgpu::BufferAddress {
let gap = self.vertices.find_largest_gap(&self.index, vertices);
let gap = if vertices {
&self.vertices
} else {
&self.indices
}
.find_largest_gap(&self.index, vertices);
gap.end - gap.start
}
@ -106,7 +111,6 @@ impl<Q: Queue<B>, B, V: bytemuck::Pod, I: bytemuck::Pod> BufferPool<Q, B, V, I>
let maybe_entry = IndexEntry {
id,
coords,
indices_stride: indices_stride as wgpu::BufferAddress,
buffer_vertices: self
.vertices
.make_room(vertices_bytes, &mut self.index, true),
@ -151,17 +155,11 @@ struct BackingBuffer<B> {
inner: B,
/// The size of the `inner` buffer
inner_size: wgpu::BufferAddress,
/// The offset within `inner`
inner_offset: wgpu::BufferAddress,
}
impl<B> BackingBuffer<B> {
fn new(inner: B, inner_size: wgpu::BufferAddress) -> Self {
Self {
inner,
inner_size,
inner_offset: 0,
}
Self { inner, inner_size }
}
fn make_room(
@ -240,7 +238,6 @@ impl<B> BackingBuffer<B> {
pub struct IndexEntry {
pub id: u32,
pub coords: TileCoords,
indices_stride: wgpu::BufferAddress,
// Range of bytes within the backing buffer for vertices
buffer_vertices: Range<wgpu::BufferAddress>,
// Range of bytes within the backing buffer for indices

View File

@ -502,10 +502,6 @@ impl State {
Ok(())
}
pub fn is_suspended(&self) -> bool {
self.suspended
}
pub fn suspend(&mut self) {
self.suspended = true;
}