Make adjustments for running on metal/apple

This commit is contained in:
Max Ammann 2021-12-20 19:31:43 +01:00
parent c2ff3f75f7
commit d4a6e288b0
5 changed files with 34 additions and 7 deletions

View File

@ -16,7 +16,7 @@ resolver = "2"
build = "build.rs"
[lib]
crate-type = [ "rlib", "cdylib"]
crate-type = [ "rlib", "cdylib", "staticlib" ] # staticlib is used for apple
[package.metadata.wasm-pack.profile.release]
wasm-opt = true
@ -36,7 +36,7 @@ winit = { version = "0.26", default-features = false }
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
winit = { version = "0.26" }
winit = { version = "0.26", default-features = false }
web-sys = { version = "0.3", features = ["Worker", "WorkerOptions", "WorkerType", "MessageEvent"] }
js-sys = "0.3"
wasm-bindgen = "0.2"
@ -44,11 +44,15 @@ wasm-bindgen-futures = "0.4"
console_log = { version = "0.2", features = ["color"] }
instant = { version = "0.1", features = ["stdweb"] }
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
# Futures
[target.'cfg(any(target_arch = "aarch64", target_os = "linux", target_os = "android"))'.dependencies]
futures = "0.3.5"
pollster = "0.2"
env_logger = "0.9"
[target.'cfg(target_arch = "aarch64")'.dependencies]
winit = { version = "0.26", default-features = false }
[target.'cfg(target_os = "linux")'.dependencies]
winit = { version = "0.26", default-features = false, features = ["x11", "wayland"] }
[dependencies]

15
src/apple/mod.rs Normal file
View File

@ -0,0 +1,15 @@
#[no_mangle]
fn mapr_apple_main() {
use winit::event_loop::EventLoop;
use winit::window::WindowBuilder;
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
let event_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_title("A fantastic window!")
.build(&event_loop)
.unwrap();
pollster::block_on(crate::setup::setup(window, event_loop));
}

View File

@ -7,5 +7,8 @@ mod setup;
#[cfg(target_arch = "wasm32")]
mod web;
#[cfg(target_arch = "aarch64")]
mod apple;
#[cfg(target_os = "android")]
mod android;

View File

@ -8,6 +8,9 @@ pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8
#[cfg(target_os = "linux")]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
#[cfg(target_arch = "aarch64")]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
#[cfg(target_os = "android")]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;

View File

@ -631,10 +631,12 @@ impl State {
INDEX_FORMAT,
);
pass.set_vertex_buffer(0, self.vertex_uniform_buffer.slice(..));
pass.draw_indexed(self.tile_fill_range.clone(), 0, 0..1);
if (self.tile_fill_range.len() > 0) {
pass.draw_indexed(self.tile_fill_range.clone(), 0, 0..1);
}
pass.draw_indexed(self.tile_stroke_range.clone(), 0, 0..1);
}
{
/*{
// Increment stencil
pass.set_pipeline(&self.mask_pipeline);
pass.set_stencil_reference(2);
@ -655,7 +657,7 @@ impl State {
pass.set_vertex_buffer(0, self.vertex_uniform_buffer.slice(..));
pass.draw_indexed(self.tile2_fill_range.clone(), 0, 0..1);
pass.draw_indexed(self.tile2_stroke_range.clone(), 0, 0..1);
}
}*/
}
self.queue.submit(Some(encoder.finish()));