mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Merge branch 'main' into refactor-structure
This commit is contained in:
commit
5a61862008
58
.github/actions/cargo-install/action.yml
vendored
58
.github/actions/cargo-install/action.yml
vendored
@ -9,9 +9,61 @@ inputs:
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Setup default toolchain
|
||||
- name: Install binstall
|
||||
run: |
|
||||
if command -v cargo-binstall &> /dev/null; then
|
||||
echo "binstall already found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
FILE=""
|
||||
|
||||
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||
FILE="cargo-binstall-x86_64-unknown-linux-gnu.tgz"
|
||||
elif [ "$RUNNER_OS" == "Windows" ]; then
|
||||
FILE="cargo-binstall-x86_64-pc-windows-msvc.zip"
|
||||
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||
if [ "$RUNNER_ARCH" == "ARM64" ]; then
|
||||
FILE="cargo-binstall-aarch64-apple-darwin.zip"
|
||||
elif [ "$RUNNER_ARCH" == "X64" ]; then
|
||||
FILE="cargo-binstall-x86_64-apple-darwin.zip"
|
||||
else
|
||||
echo "Unable to install on arch: $RUNNER_ARCH"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Install with debug profile -> faster compilation
|
||||
cargo install --debug cargo-binstall
|
||||
fi
|
||||
|
||||
if [ "$FILE" != "" ]; then
|
||||
URL="https://github.com/cargo-bins/cargo-binstall/releases/download/v0.16.0/$FILE"
|
||||
|
||||
echo "Downloading binstall: $URL"
|
||||
|
||||
curl -L -o /tmp/binstall.bin "$URL"
|
||||
|
||||
echo "Installing binstall"
|
||||
INSTALL_PATH="~/.binstall/"
|
||||
mkdir -p "$INSTALL_PATH"
|
||||
if [[ $FILE == *"zip"* ]]; then
|
||||
unzip /tmp/binstall.bin -d "$INSTALL_PATH"
|
||||
elif [[ $FILE == *"tgz"* ]]; then
|
||||
tar xf /tmp/binstall.bin -C "$INSTALL_PATH"
|
||||
else
|
||||
echo "Unknown format: $FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Temporary include binstall in path
|
||||
export PATH="$INSTALL_PATH:$PATH"
|
||||
else
|
||||
echo "Skipping binary install"
|
||||
fi
|
||||
|
||||
# Upgrade
|
||||
cargo binstall --no-confirm --force cargo-binstall
|
||||
shell: bash
|
||||
run: rustup show # Installs toolchain specified in rust-toolchain.toml
|
||||
- name: Install ${{ inputs.name }}
|
||||
shell: bash
|
||||
run: cargo binstall --no-confirm ${{ inputs.name }}
|
||||
run: cargo binstall --no-confirm --force ${{ inputs.name }}
|
||||
|
||||
11
.github/actions/setup-binstall/action.yml
vendored
11
.github/actions/setup-binstall/action.yml
vendored
@ -1,11 +0,0 @@
|
||||
name: setup-binstall
|
||||
description: Setup binstall
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install binstall
|
||||
shell: bash
|
||||
run: |
|
||||
# Install with debug profile -> faster compilation
|
||||
cargo install --debug cargo-binstall
|
||||
56
.github/actions/setup/action.yml
vendored
Normal file
56
.github/actions/setup/action.yml
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
name: setup
|
||||
description: Setup
|
||||
|
||||
|
||||
inputs:
|
||||
nightly:
|
||||
required: false
|
||||
description: If true stable will be installed, if false nightly
|
||||
targets:
|
||||
required: false
|
||||
description: space separated list of rustc targets
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
# The Rust version from rust-toolchain.toml is used for the first steps. Later the Rust version is changed
|
||||
# by setting another version in "Set XYZ toolchain".
|
||||
- name: Setup default toolchain
|
||||
shell: bash
|
||||
run: rustup show # Installs toolchain specified in rust-toolchain.toml
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
with:
|
||||
name: just
|
||||
- name: Install stable toolchain
|
||||
if: ${{ !inputs.nightly }}
|
||||
shell: bash
|
||||
run: just stable-toolchain
|
||||
- name: Install nightly toolchain
|
||||
if: ${{ inputs.nightly }}
|
||||
shell: bash
|
||||
run: just nightly-toolchain
|
||||
# We are now setting the toolchains using override. That way e.g. Swatinem/rust-cache will pick up the right rustc
|
||||
# version
|
||||
- name: Set stable toolchain
|
||||
if: ${{ !inputs.nightly }}
|
||||
shell: bash
|
||||
run: just stable-override-toolchain
|
||||
- name: Set nightly toolchain
|
||||
if: ${{ inputs.nightly }}
|
||||
shell: bash
|
||||
run: just nightly-override-toolchain
|
||||
- name: Install targets
|
||||
if: ${{ inputs.targets && !inputs.nightly }}
|
||||
shell: bash
|
||||
run: just stable-targets ${{ inputs.targets }}
|
||||
- name: Install targets
|
||||
if: ${{ inputs.targets && inputs.nightly }}
|
||||
shell: bash
|
||||
run: just nightly-targets ${{ inputs.targets }}
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
# Install just again because Swatinem/rust-cache might removed it while restoring the cache
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
with:
|
||||
name: just
|
||||
12
.github/workflows/build-deploy-docs.yml
vendored
12
.github/workflows/build-deploy-docs.yml
vendored
@ -14,16 +14,8 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
with:
|
||||
name: just
|
||||
- name: Install toolchain
|
||||
shell: bash
|
||||
run: just stable-toolchain
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
- name: Install mdbook
|
||||
uses: ./.github/actions/cargo-install
|
||||
with:
|
||||
|
||||
14
.github/workflows/demo-linux.yml
vendored
14
.github/workflows/demo-linux.yml
vendored
@ -9,18 +9,10 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
name: just
|
||||
- name: Install toolchain
|
||||
shell: bash
|
||||
run: |
|
||||
just stable-toolchain
|
||||
just stable-targets x86_64-unknown-linux-gnu
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
targets: x86_64-unknown-linux-gnu
|
||||
- name: Install Dependencies
|
||||
shell: bash
|
||||
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
|
||||
|
||||
14
.github/workflows/demo-macos.yml
vendored
14
.github/workflows/demo-macos.yml
vendored
@ -9,18 +9,10 @@ jobs:
|
||||
runs-on: macos-12
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
name: just
|
||||
- name: Install toolchain
|
||||
shell: bash
|
||||
run: |
|
||||
just stable-toolchain
|
||||
just stable-targets x86_64-apple-darwin
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
targets: x86_64-apple-darwin
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: cd apple/xcode && xcodebuild -scheme "example (macOS)" build CODE_SIGNING_ALLOWED=NO MACOSX_DEPLOYMENT_TARGET=10.9 -derivedDataPath build
|
||||
|
||||
25
.github/workflows/demo-windows.yml
vendored
25
.github/workflows/demo-windows.yml
vendored
@ -8,20 +8,21 @@ jobs:
|
||||
name: Build
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
with:
|
||||
name: just
|
||||
- name: Install toolchain
|
||||
- name: Switch to msys2
|
||||
run: echo "C:\msys64\usr\bin" >> $GITHUB_PATH
|
||||
shell: bash
|
||||
run: |
|
||||
just stable-toolchain
|
||||
just stable-targets x86_64-pc-windows-msvc
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Install mysys2 dependencies
|
||||
run: pacman -S --noconfirm unzip
|
||||
shell: bash
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
targets: x86_64-pc-windows-msvc
|
||||
- uses: ilammy/msvc-dev-cmd@v1 # Provide access to lib.exe
|
||||
- name: Show PATH
|
||||
shell: bash
|
||||
run: echo $PATH
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: cargo build -p maplibre-demo --release --target x86_64-pc-windows-msvc
|
||||
|
||||
15
.github/workflows/library-android.yml
vendored
15
.github/workflows/library-android.yml
vendored
@ -9,18 +9,11 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
name: just
|
||||
- name: Install nightly toolchain
|
||||
shell: bash
|
||||
run: |
|
||||
just nightly-toolchain
|
||||
just nightly-targets x86_64-linux-android aarch64-linux-android i686-linux-android
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
nightly: true
|
||||
targets: x86_64-linux-android aarch64-linux-android i686-linux-android
|
||||
- name: Set NDK Version
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
18
.github/workflows/library-apple.yml
vendored
18
.github/workflows/library-apple.yml
vendored
@ -10,18 +10,10 @@ jobs:
|
||||
runs-on: macos-12
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
name: just
|
||||
- name: Install toolchain
|
||||
shell: bash
|
||||
run: |
|
||||
just stable-toolchain
|
||||
just stable-targets x86_64-apple-darwin aarch64-apple-darwin x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
targets: x86_64-apple-darwin aarch64-apple-darwin x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim
|
||||
- name: Swift Version
|
||||
shell: bash
|
||||
run: swift --version
|
||||
@ -34,10 +26,10 @@ jobs:
|
||||
- name: Check x86_64 darwin
|
||||
shell: bash
|
||||
run: just check apple x86_64-apple-darwin
|
||||
- name: Check x86_64 darwin
|
||||
- name: Check aarch64 darwin
|
||||
shell: bash
|
||||
# TODO: Additional clippy checks for different targets (iOS)
|
||||
run: just check apple x86_64-apple-darwin
|
||||
run: just check apple aarch64-apple-darwin
|
||||
- name: Test x86_64 darwin
|
||||
shell: bash
|
||||
# TODO: Additional test runs for different targets (Different targets might require emulation)
|
||||
|
||||
15
.github/workflows/library-web.yml
vendored
15
.github/workflows/library-web.yml
vendored
@ -27,17 +27,11 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
name: just
|
||||
- name: Install nightly toolchain
|
||||
shell: bash
|
||||
run: |
|
||||
just nightly-toolchain
|
||||
just nightly-targets wasm32-unknown-unknown
|
||||
nightly: true
|
||||
targets: wasm32-unknown-unknown
|
||||
- name: Install rust sources (build-std)
|
||||
if: inputs.multithreaded
|
||||
shell: bash
|
||||
@ -49,7 +43,6 @@ jobs:
|
||||
# We want the latest version, as Cargo uses the latest version of wasm-bindgen
|
||||
with:
|
||||
name: wasm-bindgen-cli
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Build lib
|
||||
shell: bash
|
||||
run: just web-lib build --release ${{ inputs.webgl && '--webgl' || '' }} ${{ inputs.multithreaded && '--multithreaded' || '' }}
|
||||
|
||||
14
.github/workflows/run-benchmarks.yml
vendored
14
.github/workflows/run-benchmarks.yml
vendored
@ -9,18 +9,10 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
name: just
|
||||
- name: Install toolchain
|
||||
shell: bash
|
||||
run: |
|
||||
just stable-toolchain
|
||||
just stable-targets x86_64-unknown-linux-gnu
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
targets: x86_64-unknown-linux-gnu
|
||||
- name: Install GPU Drivers
|
||||
uses: ./.github/actions/install-driver
|
||||
- name: Download test data
|
||||
|
||||
12
.github/workflows/run-checks.yml
vendored
12
.github/workflows/run-checks.yml
vendored
@ -9,16 +9,8 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
with:
|
||||
name: just
|
||||
- name: Install toolchain
|
||||
shell: bash
|
||||
run: just stable-toolchain
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
- name: Format
|
||||
shell: bash
|
||||
run: just fmt-check
|
||||
|
||||
14
.github/workflows/run-tests.yml
vendored
14
.github/workflows/run-tests.yml
vendored
@ -9,18 +9,10 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup binstall
|
||||
uses: ./.github/actions/setup-binstall
|
||||
- name: Install just
|
||||
uses: ./.github/actions/cargo-install
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
name: just
|
||||
- name: Install toolchain
|
||||
shell: bash
|
||||
run: |
|
||||
just stable-toolchain
|
||||
just stable-targets x86_64-unknown-linux-gnu
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
targets: x86_64-unknown-linux-gnu
|
||||
- name: Install GPU Drivers
|
||||
uses: ./.github/actions/install-driver
|
||||
- name: Test Vulkan
|
||||
|
||||
11
justfile
11
justfile
@ -14,6 +14,9 @@ export RUST_BACKTRACE := "1"
|
||||
stable-toolchain:
|
||||
rustup toolchain install $STABLE_TOOLCHAIN
|
||||
|
||||
stable-override-toolchain:
|
||||
rustup override set $STABLE_TOOLCHAIN
|
||||
|
||||
stable-targets *FLAGS:
|
||||
rustup toolchain install $STABLE_TOOLCHAIN --target {{FLAGS}}
|
||||
|
||||
@ -24,6 +27,9 @@ stable-install-clippy:
|
||||
nightly-toolchain:
|
||||
rustup toolchain install $NIGHTLY_TOOLCHAIN
|
||||
|
||||
nightly-override-toolchain:
|
||||
rustup override set $NIGHTLY_TOOLCHAIN
|
||||
|
||||
nightly-targets *FLAGS:
|
||||
rustup toolchain install $NIGHTLY_TOOLCHAIN --target {{FLAGS}}
|
||||
|
||||
@ -125,6 +131,7 @@ xcodebuild-archive-fat EXISTING_ARCH EXISTING_PLATFORM ARCH: (xcodebuild-archive
|
||||
archive="{{BUILD_DIR}}/{{ARCH}}-apple-{{EXISTING_PLATFORM}}.xcarchive"
|
||||
existing_archive="{{BUILD_DIR}}/{{EXISTING_ARCH}}-apple-{{EXISTING_PLATFORM}}.xcarchive"
|
||||
fat_archive="{{BUILD_DIR}}/{{EXISTING_ARCH}}-{{ARCH}}-apple-{{EXISTING_PLATFORM}}.xcarchive"
|
||||
|
||||
cp -R "$existing_archive" "$fat_archive"
|
||||
inner="$archive/{{INNER_FRAMEWORK_PATH}}"
|
||||
existing_inner="$existing_archive/{{INNER_FRAMEWORK_PATH}}"
|
||||
@ -152,8 +159,8 @@ xcodebuild-xcframework: xcodebuild-clean (xcodebuild-archive "arm64" "iOS") (xc
|
||||
"arm64-x86_64,macOS"
|
||||
)
|
||||
framework_args=$(for i in "${tuples[@]}"; do IFS=","; set -- $i; echo -n "-framework \"{{BUILD_DIR}}/$1-apple-$2.xcarchive/{{INNER_FRAMEWORK_PATH}}\" "; done)
|
||||
echo "$framework_args"
|
||||
echo "$XC_FRAMEWORK_PATH"
|
||||
echo "framework_args: $framework_args"
|
||||
echo "XC_FRAMEWORK_PATH: $XC_FRAMEWORK_PATH"
|
||||
echo "$framework_args" | xargs xcodebuild -create-xcframework -output "$XC_FRAMEWORK_PATH"
|
||||
cat "$XC_FRAMEWORK_PATH/Info.plist"
|
||||
|
||||
|
||||
@ -1,31 +1,6 @@
|
||||
//! Handles platform specific code. Depending on the compilation target, different
|
||||
//! parts of this module are used.
|
||||
|
||||
// WebGPU
|
||||
#[cfg(all(target_arch = "wasm32", not(feature = "web-webgl")))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8Unorm;
|
||||
|
||||
// WebGL
|
||||
#[cfg(all(target_arch = "wasm32", feature = "web-webgl"))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
|
||||
|
||||
// Vulkan Android
|
||||
#[cfg(target_os = "android")]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;
|
||||
|
||||
/// MacOS and iOS (Metal).
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
|
||||
|
||||
/// For Vulkan/OpenGL
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "macos",
|
||||
any(target_os = "macos", target_os = "ios"),
|
||||
target_arch = "wasm32"
|
||||
)))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod noweb;
|
||||
|
||||
@ -53,4 +28,4 @@ pub use noweb::run_multithreaded;
|
||||
///
|
||||
/// FIXME: This limit is enforced by WebGL. Actually this makes sense!
|
||||
/// FIXME: This can also be achieved by _pad attributes in shader_ffi.rs
|
||||
pub const MIN_BUFFER_SIZE: u64 = 32;
|
||||
pub const MIN_WEBGL_BUFFER_SIZE: u64 = 32;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
use std::{cmp, mem::size_of};
|
||||
|
||||
use crate::{platform::MIN_BUFFER_SIZE, render::shaders::ShaderGlobals};
|
||||
use crate::{platform::MIN_WEBGL_BUFFER_SIZE, render::shaders::ShaderGlobals};
|
||||
|
||||
pub struct Globals {
|
||||
pub uniform_buffer: wgpu::Buffer,
|
||||
@ -11,7 +11,8 @@ pub struct Globals {
|
||||
|
||||
impl Globals {
|
||||
pub fn from_device(device: &wgpu::Device, group: &wgpu::BindGroupLayout) -> Self {
|
||||
let globals_buffer_byte_size = cmp::max(MIN_BUFFER_SIZE, size_of::<ShaderGlobals>() as u64);
|
||||
let globals_buffer_byte_size =
|
||||
cmp::max(MIN_WEBGL_BUFFER_SIZE, size_of::<ShaderGlobals>() as u64);
|
||||
|
||||
let uniform_buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some("Globals ubo"),
|
||||
|
||||
@ -4,8 +4,6 @@ use std::borrow::Cow;
|
||||
|
||||
pub use wgpu::{Backends, Features, Limits, PowerPreference, TextureFormat};
|
||||
|
||||
use crate::platform::COLOR_TEXTURE_FORMAT;
|
||||
|
||||
/// Provides configuration for renderer initialization. Use [`Device::features`](crate::renderer::Device::features),
|
||||
/// [`Device::limits`](crate::renderer::Device::limits), and the [`WgpuAdapterInfo`](crate::render_resource::WgpuAdapterInfo)
|
||||
/// resource to get runtime information about the actual adapter, backend, features, and limits.
|
||||
@ -30,7 +28,7 @@ pub struct WgpuSettings {
|
||||
|
||||
impl Default for WgpuSettings {
|
||||
fn default() -> Self {
|
||||
let backends = Some(wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()));
|
||||
let backends = Some(wgpu::util::backend_bits_from_env().unwrap_or(Backends::all()));
|
||||
|
||||
let limits = if cfg!(feature = "web-webgl") {
|
||||
Limits {
|
||||
@ -54,11 +52,15 @@ impl Default for WgpuSettings {
|
||||
}
|
||||
};
|
||||
|
||||
let mut features = Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES;
|
||||
|
||||
features |= Features::DEPTH32FLOAT_STENCIL8;
|
||||
|
||||
Self {
|
||||
device_label: Default::default(),
|
||||
backends,
|
||||
power_preference: PowerPreference::HighPerformance,
|
||||
features: Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
|
||||
features,
|
||||
disabled_features: None,
|
||||
limits,
|
||||
constrained_limits: None,
|
||||
@ -99,17 +101,39 @@ impl Default for Msaa {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct RendererSettings {
|
||||
pub msaa: Msaa,
|
||||
pub texture_format: TextureFormat,
|
||||
pub depth_texture_format: TextureFormat,
|
||||
}
|
||||
|
||||
impl Default for RendererSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
msaa: Msaa::default(),
|
||||
texture_format: COLOR_TEXTURE_FORMAT,
|
||||
// WebGPU
|
||||
#[cfg(all(target_arch = "wasm32", not(feature = "web-webgl")))]
|
||||
texture_format: wgpu::TextureFormat::Bgra8Unorm,
|
||||
// WebGL
|
||||
#[cfg(all(target_arch = "wasm32", feature = "web-webgl"))]
|
||||
texture_format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
||||
// Vulkan Android
|
||||
#[cfg(target_os = "android")]
|
||||
texture_format: wgpu::TextureFormat::Rgba8Unorm,
|
||||
/// MacOS and iOS (Metal).
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
texture_format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||
/// For Vulkan/OpenGL
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "macos",
|
||||
any(target_os = "macos", target_os = "ios"),
|
||||
target_arch = "wasm32"
|
||||
)))]
|
||||
texture_format: TextureFormat::Bgra8UnormSrgb,
|
||||
|
||||
depth_texture_format: TextureFormat::Depth32FloatStencil8,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ impl Stage for ResourceStage {
|
||||
Texture::new(
|
||||
Some("depth texture"),
|
||||
device,
|
||||
wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
settings.depth_texture_format,
|
||||
size.width(),
|
||||
size.height(),
|
||||
settings.msaa,
|
||||
@ -100,7 +100,7 @@ impl Stage for ResourceStage {
|
||||
};
|
||||
|
||||
let pipeline = TilePipeline::new(
|
||||
settings.msaa,
|
||||
*settings,
|
||||
tile_shader.describe_vertex(),
|
||||
tile_shader.describe_fragment(),
|
||||
true,
|
||||
@ -125,7 +125,7 @@ impl Stage for ResourceStage {
|
||||
};
|
||||
|
||||
TilePipeline::new(
|
||||
settings.msaa,
|
||||
*settings,
|
||||
mask_shader.describe_vertex(),
|
||||
mask_shader.describe_fragment(),
|
||||
false,
|
||||
|
||||
@ -3,12 +3,13 @@
|
||||
use std::cmp;
|
||||
|
||||
use crate::{
|
||||
platform::MIN_BUFFER_SIZE,
|
||||
platform::MIN_WEBGL_BUFFER_SIZE,
|
||||
render::{
|
||||
resource::{FragmentState, RenderPipeline, RenderPipelineDescriptor, VertexState},
|
||||
settings::Msaa,
|
||||
shaders::ShaderGlobals,
|
||||
},
|
||||
RendererSettings,
|
||||
};
|
||||
|
||||
pub struct TilePipeline {
|
||||
@ -16,7 +17,7 @@ pub struct TilePipeline {
|
||||
update_stencil: bool,
|
||||
debug_stencil: bool,
|
||||
wireframe: bool,
|
||||
msaa: Msaa,
|
||||
settings: RendererSettings,
|
||||
|
||||
vertex_state: VertexState,
|
||||
fragment_state: FragmentState,
|
||||
@ -24,7 +25,7 @@ pub struct TilePipeline {
|
||||
|
||||
impl TilePipeline {
|
||||
pub(crate) fn new(
|
||||
msaa: Msaa,
|
||||
settings: RendererSettings,
|
||||
vertex_state: VertexState,
|
||||
fragment_state: FragmentState,
|
||||
bind_globals: bool,
|
||||
@ -37,7 +38,7 @@ impl TilePipeline {
|
||||
update_stencil,
|
||||
debug_stencil,
|
||||
wireframe,
|
||||
msaa,
|
||||
settings,
|
||||
vertex_state,
|
||||
fragment_state,
|
||||
}
|
||||
@ -66,8 +67,10 @@ impl RenderPipeline for TilePipeline {
|
||||
}
|
||||
};
|
||||
|
||||
let globals_buffer_byte_size =
|
||||
cmp::max(MIN_BUFFER_SIZE, std::mem::size_of::<ShaderGlobals>() as u64);
|
||||
let globals_buffer_byte_size = cmp::max(
|
||||
MIN_WEBGL_BUFFER_SIZE,
|
||||
std::mem::size_of::<ShaderGlobals>() as u64,
|
||||
);
|
||||
|
||||
RenderPipelineDescriptor {
|
||||
label: None,
|
||||
@ -103,7 +106,7 @@ impl RenderPipeline for TilePipeline {
|
||||
unclipped_depth: false,
|
||||
},
|
||||
depth_stencil: Some(wgpu::DepthStencilState {
|
||||
format: wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
format: self.settings.depth_texture_format,
|
||||
depth_write_enabled: !self.update_stencil,
|
||||
depth_compare: wgpu::CompareFunction::Greater,
|
||||
stencil: wgpu::StencilState {
|
||||
@ -115,7 +118,7 @@ impl RenderPipeline for TilePipeline {
|
||||
bias: wgpu::DepthBiasState::default(),
|
||||
}),
|
||||
multisample: wgpu::MultisampleState {
|
||||
count: self.msaa.samples,
|
||||
count: self.settings.msaa.samples,
|
||||
mask: !0,
|
||||
alpha_to_coverage_enabled: false,
|
||||
},
|
||||
|
||||
@ -1,2 +1,6 @@
|
||||
[toolchain]
|
||||
# This library version should match the $STABLE_TOOLCHAIN version of the justfile. The CI will not use
|
||||
# the rust-toolchain.toml file to build this project. The CI might use it though to build other Rust binaries, required
|
||||
# for building maplibre-rs.
|
||||
# This file is here to give IDEs a hint about which Rust version to use.
|
||||
channel = "1.64"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user