Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 7 additions & 8 deletions templates/apps/wgpu/Cargo.toml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ name = "{{app.name}}-desktop"
path = "gen/bin/desktop.rs"

[dependencies]
futures = "0.3.8"
mobile-entry-point = "0.1.0"
wgpu = "0.6.0"
winit = "0.23.0"
log = "0.4.29"
pollster = "0.4.0"
wgpu = { version = "29.0.3", features = ["spirv"] }

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.9.0"
log = "0.4.11"
ndk-glue = "0.2.1"
winit = { version = "0.30.13", features = ["android-native-activity"] }
android_logger = "0.15.1"

[target.'cfg(not(target_os = "android"))'.dependencies]
wgpu-subscriber = "0.1.0"
winit = "0.30.13"
simple_logger = "5.2.0"
12 changes: 6 additions & 6 deletions templates/apps/wgpu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

This is just the [`wgpu-rs` triangle example](https://github.com/gfx-rs/wgpu-rs/blob/v0.6/examples/hello-triangle/main.rs) with a handful of small changes, which I'll outline below:

- Annotated `main` with `#[mobile_entry_point]`, which generates all the `extern` functions we need for mobile. Note that the name of the function doesn't actually matter for this.
- Changes conditionally compiled on Android:
- Use `android_logger` instead of `wgpu-subscriber`
- Use `Rgba8UnormSrgb` instead of `Bgra8UnormSrgb` (ideally, the supported format would be detected dynamically instead)
- Use `std::thread::sleep` to shoddily workaround [`raw_window_handle` requirements](https://github.com/rust-windowing/winit/issues/1588)
- Render directly upon `MainEventsCleared` instead of calling `request_redraw`, since [winit doesn't implement that method on Android yet](https://github.com/rust-windowing/winit/issues/1723)
- Render a red triangle instead of just clearing the screen green.
- Add the entry points `android_main` for android
- Annotate `start_app` as extern, so that i can be used via FFI on iOS
- Add logging via [`simple_logger`](https://crates.io/crates/simple_logger) and [`android_logger`](https://crates.io/crates/android_logger)
- Reduce the limit `max_inter_stage_shader_variables` from 16 to 15 as a tempory fix for [this issue](https://github.com/gfx-rs/wgpu/issues/9386 is fixed
)

To run this on desktop, just do `cargo run` like normal! For mobile, use `cargo android run` and `cargo apple run` respectively (or use `cargo android open`/`cargo apple open` to open in Android Studio and Xcode respectively).
Loading