Skip to content

Commit

Permalink
Fix builds (#301)
Browse files Browse the repository at this point in the history
* Update and fix nix shell

* Upgrade NDK to a version available on GitHub Actions

* Fix web wasm-bindgen script

* Update nightly version aswell

* Fix wasm-bindgen version and lint

* Fix imports

* Upgrade wgpu to be compatible with new web-sys version, which was required due to the bump in the rust version which was required due to clap

* Fix tests
  • Loading branch information
maxammann authored Mar 14, 2024
1 parent a8be3cf commit c974e22
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/library-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
ANDROID_ROOT=/usr/local/lib/android
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
ln -sfn $ANDROID_SDK_ROOT/ndk/23.2.8568313 $ANDROID_NDK_ROOT
ln -sfn $ANDROID_SDK_ROOT/ndk/25.2.9519653 $ANDROID_NDK_ROOT
- name: Build
shell: bash
run: just build-android
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/library-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ jobs:
- name: Install wasm-bindgen
uses: ./.github/actions/cargo-install
# Install wasm-bindgen with test runner
# We want the latest version, as Cargo uses the latest version of wasm-bindgen
# We want a specific, as Cargo uses a pinned version of wasm-bindgen as dependency of the web crate
with:
name: wasm-bindgen-cli
name: wasm-bindgen-cli@0.2.92
- name: Build lib
shell: bash
run: just web-lib build --release ${{ inputs.webgl && '--webgl' || '' }} ${{ inputs.multithreaded && '--multithreaded' || '' }}
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ tracing-subscriber = "0.3.17"
tracing-tracy = "0.10"
tracing-wasm = "0.2.1" # TODO: Low quality dependency (remove in a separate PR!)
walkdir = "2.4.0"
wasm-bindgen = "=0.2.87"
wasm-bindgen = "=0.2.92"
wasm-bindgen-futures = "0.4"
wasm-bindgen-test = "0.3"
web-sys = "0.3" # Individual features are customized in each crate
wgpu = "0.17.0"
wgpu = "0.18.0"

[profile.release]
lto = true
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
apply plugin: 'kotlin-android'

android {
ndkVersion "23.2.8568313"
ndkVersion "25.2.9519653"

compileSdkVersion 31

Expand Down Expand Up @@ -35,7 +35,7 @@ cargo {
targetDirectory = "${module}/../target"
profile = "debug"
// This should be in sync with the justfile
rustupChannel = "nightly-2023-09-23"
rustupChannel = "nightly-2024-03-12"


features {
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set shell := ["bash", "-c"]

# Keep this in sync with `android/gradle/lib/build.gradle`

export NIGHTLY_TOOLCHAIN := "nightly-2023-09-23"
export NIGHTLY_TOOLCHAIN := "nightly-2024-03-12"

# Keep this in sync with `rust-toolchain.toml` and `Cargo.toml`.
# Make sure the above is newer than this.
Expand Down
6 changes: 5 additions & 1 deletion maplibre/src/debug/debug_pass.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::ops::Deref;

use wgpu::StoreOp;

use crate::{
debug::TileDebugItem,
render::{
Expand Down Expand Up @@ -44,7 +46,7 @@ impl Node for DebugPassNode {
ops: wgpu::Operations {
// Draws on-top of previously rendered data
load: wgpu::LoadOp::Load,
store: true,
store: StoreOp::Store,
},
resolve_target: None,
};
Expand All @@ -56,6 +58,8 @@ impl Node for DebugPassNode {
label: Some("debug_pass"),
color_attachments: &[Some(color_attachment)],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});

let mut tracked_pass = TrackedRenderPass::new(render_pass);
Expand Down
2 changes: 0 additions & 2 deletions maplibre/src/render/camera.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Main camera

use std::convert::Into;

use cgmath::{num_traits::clamp, prelude::*, *};

use crate::util::SignificantlyDifferent;
Expand Down
2 changes: 2 additions & 0 deletions maplibre/src/render/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub enum RenderError {
Graph(#[from] RenderGraphError),
#[error("error while requesting device")]
RequestDevice(#[from] wgpu::RequestDeviceError),
#[error("error while requesting adaptor")]
RequestAdaptor,
}

impl RenderError {
Expand Down
12 changes: 8 additions & 4 deletions maplibre/src/render/main_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

use std::ops::Deref;

use wgpu::StoreOp;

use crate::{
render::{
draw_graph,
Expand Down Expand Up @@ -54,7 +56,7 @@ impl Node for MainPassNode {
view: &texture.view,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::WHITE),
store: true,
store: StoreOp::Store,
},
resolve_target: Some(render_target.deref()),
}
Expand All @@ -63,7 +65,7 @@ impl Node for MainPassNode {
view: render_target.deref(),
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::WHITE),
store: true,
store: StoreOp::Store,
},
resolve_target: None,
}
Expand All @@ -79,13 +81,15 @@ impl Node for MainPassNode {
view: &depth_texture.view,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(0.0),
store: true,
store: StoreOp::Store,
}),
stencil_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(0),
store: true,
store: StoreOp::Store,
}),
}),
timestamp_writes: None,
occlusion_query_set: None,
});

let mut tracked_pass = TrackedRenderPass::new(render_pass);
Expand Down
13 changes: 11 additions & 2 deletions maplibre/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ impl Renderer {
{
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu_settings.backends.unwrap_or(wgpu::Backends::all()),
flags: Default::default(),
dx12_shader_compiler: Default::default(),
gles_minor_version: Default::default(),
});

let surface: wgpu::Surface = unsafe { instance.create_surface(window.raw())? };
Expand Down Expand Up @@ -215,7 +217,9 @@ impl Renderer {
{
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu_settings.backends.unwrap_or(wgpu::Backends::all()),
flags: Default::default(),
dx12_shader_compiler: Default::default(),
gles_minor_version: Default::default(),
});

let (adapter, device, queue) = Self::request_device(
Expand Down Expand Up @@ -252,11 +256,11 @@ impl Renderer {
instance: &wgpu::Instance,
settings: &WgpuSettings,
request_adapter_options: &wgpu::RequestAdapterOptions<'_>,
) -> Result<(wgpu::Adapter, wgpu::Device, wgpu::Queue), wgpu::RequestDeviceError> {
) -> Result<(wgpu::Adapter, wgpu::Device, wgpu::Queue), RenderError> {
let adapter = instance
.request_adapter(request_adapter_options)
.await
.ok_or(wgpu::RequestDeviceError)?;
.ok_or(RenderError::RequestAdaptor)?;

let adapter_info = adapter.get_info();

Expand Down Expand Up @@ -386,6 +390,9 @@ impl Renderer {
max_buffer_size: limits
.max_buffer_size
.min(constrained_limits.max_buffer_size),
max_non_sampler_bindings: limits
.max_non_sampler_bindings
.min(constrained_limits.max_non_sampler_bindings),
};
}

Expand Down Expand Up @@ -468,7 +475,9 @@ mod tests {
let backends = wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all());
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends,
flags: Default::default(),
dx12_shader_compiler: Default::default(),
gles_minor_version: Default::default(),
});
let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None)
.await
Expand Down
16 changes: 16 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,27 @@ pkgs.mkShell {
# System dependencies
unstable.flatbuffers
unstable.protobuf

unstable.xorg.libXrandr
unstable.xorg.libXi
unstable.xorg.libXcursor
unstable.xorg.libX11
unstable.libxkbcommon
unstable.sqlite
unstable.wayland
unstable.pkg-config
]
++ lib.optionals stdenv.isDarwin [
unstable.libiconv
pkgs.darwin.apple_sdk.frameworks.ApplicationServices
pkgs.darwin.apple_sdk.frameworks.CoreVideo
pkgs.darwin.apple_sdk.frameworks.AppKit
];
shellHook = ''
# Vulkan
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${ pkgs.lib.makeLibraryPath [ pkgs.vulkan-loader ] }";
# EGL
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${ pkgs.lib.makeLibraryPath [ pkgs.libglvnd ] }";
'';

}
2 changes: 1 addition & 1 deletion web/src/platform/http_client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use async_trait::async_trait;
use js_sys::{ArrayBuffer, Uint8Array};
use maplibre::io::source_client::{HttpClient, SourceFetchError};
use wasm_bindgen::{prelude::*, JsCast};
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;
use web_sys::{Request, RequestInit, Response, WorkerGlobalScope};

Expand Down
2 changes: 1 addition & 1 deletion web/src/platform/multithreaded/pool_scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::future::Future;

use maplibre::{benchmarking::io::scheduler::ScheduleError, io::scheduler::Scheduler};
use wasm_bindgen::{prelude::*, JsCast};
use wasm_bindgen::prelude::*;
use web_sys::Worker;

use super::pool::WorkerPool;
Expand Down
2 changes: 1 addition & 1 deletion web/src/platform/singlethreaded/wasm_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use maplibre::{
io::apc::CallError,
};
use thiserror::Error;
use wasm_bindgen::{prelude::*, JsCast};
use wasm_bindgen::prelude::*;
use web_sys::DedicatedWorkerGlobalScope;

use crate::{
Expand Down

0 comments on commit c974e22

Please sign in to comment.