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

Tile source fixes #236

Merged
merged 6 commits into from
Jan 11, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/actions/install-driver/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ runs:
# On Ubuntu 22.04 (currently used) using the PPA introduces SEGVs.
#- name: Use oibaf PPA for drivers
# shell: bash
# run: |
# sudo apt-get update -y -qq
# sudo add-apt-repository ppa:oibaf/graphics-drivers -y
# run: sudo apt-get update -y -qq && sudo add-apt-repository ppa:oibaf/graphics-drivers -y
- name: Install Mesa Dependencies
shell: bash
run: sudo apt-get install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
run: sudo apt-get update -y -qq && sudo apt-get install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: Install wgpu-info
shell: bash
# Rev is for 0.14.1: https://github.com/gfx-rs/wgpu/tree/v0.14.1
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/install-system-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get install -y \
sudo apt-get update -y -qq && sudo apt-get install -y \
protobuf-compiler \
libwayland-dev libxkbcommon-dev # Required for winit
- name: Install System Dependencies (macOS)
Expand Down
4 changes: 2 additions & 2 deletions maplibre/src/io/source_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ where
}

pub async fn fetch(&self, coords: &WorldTileCoords) -> Result<Vec<u8>, SourceFetchError> {
let tile_coords = coords.into_tile(TileAddressingScheme::TMS).unwrap();
let tile_coords = coords.into_tile(TileAddressingScheme::XYZ).unwrap();
self.inner_client
.fetch(
format!(
"https://maps.tuerantuer.org/europe_germany/{z}/{x}/{y}.pbf",
"https://maps.tuerantuer.org/europe_germany/{z}/{x}/{y}",
x = tile_coords.x,
y = tile_coords.y,
z = tile_coords.z
Expand Down
6 changes: 6 additions & 0 deletions maplibre/src/io/transferables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub trait LayerTessellated: Send {

fn coords(&self) -> WorldTileCoords;

fn is_empty(&self) -> bool;

fn to_stored_layer(self) -> StoredLayer;
}

Expand Down Expand Up @@ -119,6 +121,10 @@ impl LayerTessellated for DefaultLayerTesselated {
self.coords
}

fn is_empty(&self) -> bool {
self.buffer.usable_indices == 0
}

fn to_stored_layer(self) -> StoredLayer {
StoredLayer::TessellatedLayer {
coords: self.coords,
Expand Down
13 changes: 9 additions & 4 deletions maplibre/src/render/render_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,16 @@ impl RenderCommand<(IndexEntry, TileShape)> for DrawTile {
&entry.coords
);

let index_range = entry.indices_buffer_range();

if index_range.is_empty() {
tracing::error!("Tried to draw a vector tile without any vertices");
return RenderCommandResult::Failure;
}

pass.set_stencil_reference(reference);
pass.set_index_buffer(
buffer_pool.indices().slice(entry.indices_buffer_range()),
INDEX_FORMAT,
);

pass.set_index_buffer(buffer_pool.indices().slice(index_range), INDEX_FORMAT);
pass.set_vertex_buffer(
0,
buffer_pool.vertices().slice(entry.vertices_buffer_range()),
Expand Down
5 changes: 5 additions & 0 deletions maplibre/src/stages/populate_tile_store_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ impl<E: Environment> Stage for PopulateTileStore<E> {
tile_repository.put_layer(layer);
}
Message::LayerTessellated(message) => {
// TODO: Is it fine to ignore layers without any vertices?
if message.is_empty() {
continue;
}

let layer: StoredLayer = message.to_stored_layer();

tracing::debug!(
Expand Down
5 changes: 5 additions & 0 deletions web/src/platform/singlethreaded/transferables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ impl LayerTessellated for FlatBufferTransferable {
data.coords().unwrap().into()
}

fn is_empty(&self) -> bool {
let data = unsafe { root_as_flat_layer_tessellated_unchecked(&self.data[self.start..]) };
data.usable_indices() == 0
}

fn to_stored_layer(self) -> StoredLayer {
let data = unsafe { root_as_flat_layer_tessellated_unchecked(&self.data[self.start..]) };
let vertices = data
Expand Down