Skip to content
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

Introduce Plugin API along with Raster Tiles #253

Merged
merged 82 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
3c9d546
Rebase with the new codebase
Nov 11, 2022
45fbec2
Fix raster
Drabble Nov 15, 2022
104ff8a
Use hashmap to manage the texture bind groups
Drabble Nov 17, 2022
45be8a2
Hiding the raster rendering behind a Cargo feature flag
Nov 23, 2022
bbeaab0
Addition of LinearLayerRaster for the web transferables
Nov 24, 2022
6296a8e
Minor cleanups
Nov 28, 2022
308d560
Store raster data as RgbaImage in the tile repository
Dec 2, 2022
a3e16ec
Merge branch 'main' into ft-branch-raster-tiles
maxammann Dec 12, 2022
7e34ebe
Fixes after merge
maxammann Dec 12, 2022
e0357f8
Fix web builds (multithreaded works already)
maxammann Dec 12, 2022
4b0f170
Fix APC implementation
maxammann Dec 12, 2022
e2bee64
Fix tests
maxammann Dec 13, 2022
85e9e4b
Merge branch 'main' into ft-branch-raster-tiles
maxammann Dec 15, 2022
716c8b4
Fixes after merge
maxammann Dec 15, 2022
eb40680
Replace buffer_pool changes with a more specific shader
maxammann Dec 21, 2022
a573a74
Refactor tile requests
maxammann Dec 22, 2022
74289d6
Fix vector tiles
maxammann Dec 22, 2022
279a5ad
Refactor RasterResources and request stage
maxammann Dec 22, 2022
27b8d7a
Move fns to HasTile
maxammann Dec 22, 2022
cdcaa64
Refactor
maxammann Jan 11, 2023
b0b83ff
Merge branch 'main' into ft-branch-raster-tiles
maxammann Jan 29, 2023
6aff8c0
Only upload raster tiles if needed
maxammann Jan 29, 2023
9148b6f
Add world
maxammann Feb 3, 2023
5e0de2b
Add ecs drawing
maxammann Feb 3, 2023
e388039
Migrate from specific stages to systems
maxammann Feb 4, 2023
a0a7b14
Remove global
maxammann Feb 4, 2023
115cd12
Fix the renderer such that it can run again
maxammann Feb 4, 2023
3e7a6cf
Add draw functions
maxammann Feb 7, 2023
eefaf58
First fully working version with a vector and raster plugin
maxammann Feb 7, 2023
0441c5c
Add feature gate for headless rendering to demo
maxammann Feb 8, 2023
a429d09
Remove tile_repository and integrate into world structures
maxammann Feb 8, 2023
dd21267
Update FIXMEs and also improve resource queries (HIGHLY UNSAFE!)
maxammann Feb 8, 2023
126017d
Simplify unsafe queries
maxammann Feb 9, 2023
7f97ced
Add a state
maxammann Feb 9, 2023
afd81c2
Remove unwraps
maxammann Feb 9, 2023
3e8be4a
Move buffer pool and raster resource helpers
maxammann Feb 9, 2023
58ad81b
Fix compilation
maxammann Feb 9, 2023
5fc4240
Add proper fixmes
maxammann Feb 9, 2023
5e61ab9
Remove inlines
maxammann Feb 9, 2023
0bdb679
Add safety to queries
maxammann Feb 9, 2023
6d59aad
Start work on transferables
maxammann Feb 9, 2023
4e3d6e5
Cleanup imports
maxammann Feb 9, 2023
1d0c3c8
Fix Optional
maxammann Feb 9, 2023
7aa18b1
Split request stage, also fix pipelines
maxammann Feb 10, 2023
4f22a08
Remove pipelines for simplicity
maxammann Feb 12, 2023
66168d1
Add message tags
maxammann Feb 14, 2023
e4737a3
Use labels for tagging messages
maxammann Feb 14, 2023
d26326a
Resolve quite a few fixmes
maxammann Feb 14, 2023
4a3e09d
Fix headless rendering
maxammann Feb 14, 2023
339dac9
Resolve a few fixmes
maxammann Feb 16, 2023
ac4953f
Fix tests
maxammann Feb 16, 2023
9bf9208
Add run config
maxammann Feb 16, 2023
17b635f
Fix benchmark compilation
maxammann Feb 16, 2023
9d0be99
Fix benchmarks
maxammann Feb 16, 2023
d7eeaa7
Remove unused imports
maxammann Feb 16, 2023
831042b
Remove unused imports
maxammann Feb 16, 2023
a41853c
Rename module to systems
maxammann Feb 16, 2023
521933d
Entangle tile_view_pattern
maxammann Feb 16, 2023
be13607
Add hint where package was found
maxammann Feb 16, 2023
63ab009
Log some output
maxammann Feb 16, 2023
345513d
Rever ls
maxammann Feb 16, 2023
d710664
Fix web builds
maxammann Feb 16, 2023
3bf21eb
Add show bash path
maxammann Feb 16, 2023
7005b41
Tests
maxammann Feb 17, 2023
ca6ee74
Fix CI
maxammann Feb 17, 2023
ef47452
Do not use symlinks
maxammann Feb 17, 2023
e0e3de0
Remove VectorLayersIndicesComponent to avoid inconsistent states
maxammann Feb 17, 2023
07943d2
Rename ecs to tcs
maxammann Feb 17, 2023
8e0c77c
Move things in world
maxammann Feb 17, 2023
64b3f8b
Extract debug plugin
maxammann Feb 17, 2023
fb58d67
Move tile_pipeline.rs
maxammann Feb 17, 2023
8eeddbd
Introduce RenderPlugin
maxammann Feb 17, 2023
ab4ff11
Introduce HeadlessPlugin
maxammann Feb 17, 2023
08c6c86
Adjust plugin initialization and cleanup
maxammann Feb 17, 2023
54fd90a
Run clippy
maxammann Feb 17, 2023
ace9fc8
Switch to unsafe cell
maxammann Feb 17, 2023
471329d
Clippy fixes
maxammann Feb 17, 2023
384e743
Fix rendering only rasters
maxammann Feb 17, 2023
5c6109f
Fix minor issues after reviewing changes
maxammann Feb 17, 2023
dcf4a8e
Fix benchmark
maxammann Feb 18, 2023
b49e9e5
Fix minor things
maxammann Feb 18, 2023
9f7a177
Add more layers to benchmark
maxammann Feb 18, 2023
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
12 changes: 8 additions & 4 deletions .github/actions/cargo-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
- name: Install binstall
run: |
if command -v cargo-binstall &> /dev/null; then
echo "binstall already found"
echo "binstall already found at $(command -v cargo-binstall)"
exit 0
fi

Expand Down Expand Up @@ -61,9 +61,13 @@ runs:
echo "Skipping binary install"
fi

# Upgrade
cargo binstall --no-confirm --force cargo-binstall
# Upgrade binstall to latest version
# Do not use symlinks because they behave weird on Windows(+Bash)
cargo binstall --no-confirm --force --no-symlinks cargo-binstall
# Use latest version to reinstall binstall
cargo binstall --no-confirm --force --no-symlinks cargo-binstall
shell: bash
- name: Install ${{ inputs.name }}
shell: bash
run: cargo binstall --no-confirm --force ${{ inputs.name }}
# Do not use symlinks because they behave weird on Windows(+Bash)
run: cargo binstall --no-confirm --force --no-symlinks ${{ inputs.name }}
3 changes: 3 additions & 0 deletions .github/workflows/demo-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- name: Show PATH
shell: powershell
run: Write-Host $env:path
- name: Show bash PATH
shell: bash
run: echo $PATH
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
Expand Down Expand Up @@ -28,4 +27,4 @@ perf.data*
*flamegraph.svg
*flamechart.svg

frame_*.png
frame_*.png
19 changes: 19 additions & 0 deletions .idea/runConfigurations/Build_maplibre.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 32 additions & 56 deletions benchmarks/benches/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,55 @@ use criterion::{criterion_group, criterion_main, Criterion};
use maplibre::{
benchmarking::io::static_tile_fetcher::StaticTileFetcher,
coords::{TileCoords, ZoomLevel},
io::{
pipeline::{PipelineContext, PipelineProcessor, Processable},
tile_pipelines::{ParseTile, TessellateLayer},
TileRequest,
},
io::apc::{Context, IntoMessage, SendError},
style::source::TileAddressingScheme,
vector::{
process_vector_tile, DefaultVectorTransferables, ProcessVectorContext, VectorTileRequest,
},
};

// https://tile.openstreetmap.org/15/17425/11365.png
const MUNICH_COORDS: TileCoords = TileCoords {
x: 17425,
y: 11365,
z: ZoomLevel::new(15u8),
};

pub struct DummyPipelineProcessor;

impl PipelineProcessor for DummyPipelineProcessor {}

fn parse_tile(c: &mut Criterion) {
let fetcher = StaticTileFetcher::new();
pub struct DummyContext;

c.bench_function("parse", |b| {
b.iter(|| {
let request = TileRequest {
coords: MUNICH_COORDS
.into_world_tile(TileAddressingScheme::XYZ)
.unwrap(),
layers: HashSet::from(["boundary".to_owned(), "water".to_owned()]),
};
let data = fetcher
.sync_fetch_tile(&MUNICH_COORDS)
.unwrap()
.into_boxed_slice();
ParseTile::default()
.process(
(request, data),
&mut PipelineContext::new(DummyPipelineProcessor),
)
.unwrap();
})
});
impl Context for DummyContext {
fn send<T: IntoMessage>(&self, _message: T) -> Result<(), SendError> {
Ok(())
}
}

fn tessellate_tile(c: &mut Criterion) {
fn bench_process_vector_tile(c: &mut Criterion) {
let fetcher = StaticTileFetcher::new();
let request = TileRequest {
coords: MUNICH_COORDS
.into_world_tile(TileAddressingScheme::XYZ)
.unwrap(),
layers: HashSet::from(["boundary".to_owned(), "water".to_owned()]),
};
let data = fetcher
.sync_fetch_tile(&MUNICH_COORDS)
.unwrap()
.into_boxed_slice();
let parsed = ParseTile::default()
.process(
(request, data),
&mut PipelineContext::new(DummyPipelineProcessor),
)
.unwrap();

c.bench_function("tessselate", |b| {
c.bench_function("process_vector_tile", |b| {
let data = fetcher
.sync_fetch_tile(&MUNICH_COORDS)
.unwrap()
.into_boxed_slice();

b.iter(|| {
TessellateLayer::default()
.process(
parsed.clone(),
&mut PipelineContext::new(DummyPipelineProcessor),
)
.unwrap();
let _ = process_vector_tile(
&data,
VectorTileRequest {
coords: MUNICH_COORDS
.into_world_tile(TileAddressingScheme::XYZ)
.unwrap(),
layers: HashSet::from([
"transportation".to_owned(),
"water".to_owned(),
"building".to_owned(),
]),
},
&mut ProcessVectorContext::<DefaultVectorTransferables, _>::new(DummyContext),
);
})
});
}

criterion_group!(benches, parse_tile, tessellate_tile);
criterion_group!(benches, bench_process_vector_tile);
criterion_main!(benches);
23 changes: 15 additions & 8 deletions benchmarks/benches/render.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
use criterion::{criterion_group, criterion_main, Criterion};
use maplibre::{
coords::{WorldTileCoords, ZoomLevel},
headless::{create_headless_renderer, map::HeadlessMap},
headless::{create_headless_renderer, map::HeadlessMap, HeadlessPlugin},
platform::run_multithreaded,
plugin::Plugin,
render::RenderPlugin,
style::Style,
vector::{DefaultVectorTransferables, VectorPlugin},
};

fn headless_render(c: &mut Criterion) {
c.bench_function("headless_render", |b| {
let (mut map, tile) = run_multithreaded(async {
let (mut map, layer) = run_multithreaded(async {
let (kernel, renderer) = create_headless_renderer(1000, None).await;
let style = Style::default();
let map = HeadlessMap::new(style, renderer, kernel, false).unwrap();

let plugins: Vec<Box<dyn Plugin<_>>> = vec![
Box::new(RenderPlugin::default()),
Box::new(VectorPlugin::<DefaultVectorTransferables>::default()),
Box::new(HeadlessPlugin::new(false)),
];

let map = HeadlessMap::new(style, renderer, kernel, plugins).unwrap();

let tile = map
.fetch_tile(WorldTileCoords::from((0, 0, ZoomLevel::default())))
.await
.expect("Failed to fetch!");

let tile = map
.process_tile(tile, &["water"])
.await
.expect("Failed to process!");
let tile = map.process_tile(tile, &["water"]).await;

(map, tile)
});

b.iter(|| {
map.render_tile(tile.clone());
map.render_tile(layer.clone());
});
});
}
Expand Down
4 changes: 4 additions & 0 deletions docs/src/development-documents/ecs-design.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion maplibre-build-tools/src/wgsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl From<std::io::Error> for WgslError {
impl WgslError {
pub fn from_parse_err(err: ParseError, src: &str) -> Self {
let location = err.location(src);
let error = err.emit_to_string(src);
let error = err.message().to_string();
Self::ParserErr { error, location }
}
}
Expand Down
3 changes: 2 additions & 1 deletion maplibre-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ authors.workspace = true
[features]
web-webgl = ["maplibre/web-webgl"]
trace = ["maplibre/trace"]
headless = ["maplibre/headless"]

[dependencies]
env_logger = "0.10.0"
maplibre = { path = "../maplibre", version = "0.1.0", features = ["headless", "thread-safe-futures"] }
maplibre = { path = "../maplibre", version = "0.1.0", features = ["thread-safe-futures"] }
maplibre-winit = { path = "../maplibre-winit", version = "0.1.0" }

tile-grid = "0.3"
Expand Down
22 changes: 16 additions & 6 deletions maplibre-demo/src/headless.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use maplibre::{
coords::{LatLon, WorldTileCoords},
headless::{create_headless_renderer, map::HeadlessMap},
headless::{create_headless_renderer, map::HeadlessMap, HeadlessPlugin},
plugin::Plugin,
raster::{DefaultRasterTransferables, RasterPlugin},
render::RenderPlugin,
style::Style,
util::grid::google_mercator,
vector::{DefaultVectorTransferables, VectorPlugin},
};
use tile_grid::{extent_wgs84_to_merc, Extent, GridIterator};

Expand All @@ -17,7 +21,14 @@ pub async fn run_headless(tile_size: u32, min: LatLon, max: LatLon) {
.map(|layer| layer.source_layer.as_ref().unwrap().clone())
.collect::<Vec<_>>();

let mut map = HeadlessMap::new(style, renderer, kernel, true).unwrap();
let plugins: Vec<Box<dyn Plugin<_>>> = vec![
Box::new(RenderPlugin::default()),
Box::new(VectorPlugin::<DefaultVectorTransferables>::default()),
Box::new(RasterPlugin::<DefaultRasterTransferables>::default()),
Box::new(HeadlessPlugin::new(true)),
];

let mut map = HeadlessMap::new(style, renderer, kernel, plugins).unwrap();

let tile_limits = google_mercator().tile_limits(
extent_wgs84_to_merc(&Extent {
Expand All @@ -35,17 +46,16 @@ pub async fn run_headless(tile_size: u32, min: LatLon, max: LatLon) {

let tile = map.fetch_tile(coords).await.expect("Failed to fetch!");

let tile = map
let layers = map
.process_tile(
tile,
&requested_layers
.iter()
.map(|layer| layer.as_str())
.collect::<Vec<_>>(),
)
.await
.expect("Failed to process!");
.await;

map.render_tile(tile);
map.render_tile(layers);
}
}
17 changes: 10 additions & 7 deletions maplibre-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

use std::io::ErrorKind;

use clap::{builder::ValueParser, Parser, Subcommand};
use maplibre::{coords::LatLon, platform::run_multithreaded};
use clap::{Parser, Subcommand};
use maplibre::coords::LatLon;
use maplibre_winit::run_headed_map;

use crate::headless::run_headless;

#[cfg(feature = "headless")]
mod headless;

#[derive(Parser)]
Expand Down Expand Up @@ -36,16 +35,17 @@ fn parse_lat_long(env: &str) -> Result<LatLon, std::io::Error> {
#[derive(Subcommand)]
enum Commands {
Headed {},
#[cfg(feature = "headless")]
Headless {
#[clap(default_value_t = 400)]
tile_size: u32,
#[clap(
value_parser = ValueParser::new(parse_lat_long),
value_parser = clap::builder::ValueParser::new(parse_lat_long),
default_value_t = LatLon::new(48.0345697188, 11.3475219363)
)]
min: LatLon,
#[clap(
value_parser = ValueParser::new(parse_lat_long),
value_parser = clap::builder::ValueParser::new(parse_lat_long),
default_value_t = LatLon::new(48.255861, 11.7917815798)
)]
max: LatLon,
Expand All @@ -64,12 +64,15 @@ fn main() {
// matches just as you would the top level cmd
match &cli.command {
Commands::Headed {} => run_headed_map(None),
#[cfg(feature = "headless")]
Commands::Headless {
tile_size,
min,
max,
} => {
run_multithreaded(async { run_headless(*tile_size, *min, *max).await });
maplibre::platform::run_multithreaded(async {
headless::run_headless(*tile_size, *min, *max).await
});
}
}
}
11 changes: 2 additions & 9 deletions maplibre-winit/src/input/pan_handler.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use cgmath::{EuclideanSpace, Point3, Vector2, Vector3, Zero};
use maplibre::{context::MapContext, render::camera::Camera, world::World};
use maplibre::{context::MapContext, render::camera::Camera};
use winit::event::{ElementState, MouseButton};

use super::UpdateState;
Expand All @@ -15,14 +15,7 @@ pub struct PanHandler {
}

impl UpdateState for PanHandler {
fn update_state(
&mut self,
MapContext {
world: World { view_state, .. },
..
}: &mut MapContext,
_dt: Duration,
) {
fn update_state(&mut self, MapContext { view_state, .. }: &mut MapContext, _dt: Duration) {
if !self.is_panning {
return;
}
Expand Down
Loading