mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Use embedded glslang for runtime glsl-to-spirv and add Android example (#740)
Use embedded glslang for runtime glsl-to-spirv and add Android example
This commit is contained in:
parent
f81ecddafc
commit
53c4c45eca
4 changed files with 46 additions and 7 deletions
34
Cargo.toml
34
Cargo.toml
|
@ -29,6 +29,22 @@ default = [
|
|||
"mp3",
|
||||
"x11",
|
||||
]
|
||||
|
||||
supported_android_features = [
|
||||
# cpal is not supported yet
|
||||
# "bevy_audio",
|
||||
"bevy_dynamic_plugin",
|
||||
"bevy_gilrs",
|
||||
"bevy_gltf",
|
||||
"bevy_wgpu",
|
||||
"bevy_winit",
|
||||
"render",
|
||||
"png",
|
||||
"hdr",
|
||||
# "mp3",
|
||||
"x11",
|
||||
]
|
||||
|
||||
profiler = ["bevy_ecs/profiler", "bevy_diagnostic/profiler"]
|
||||
wgpu_trace = ["bevy_wgpu/trace"]
|
||||
|
||||
|
@ -90,6 +106,11 @@ log = "0.4"
|
|||
ron = "0.6"
|
||||
anyhow = "1.0"
|
||||
|
||||
# bevy (Android)
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
ndk-glue = { version = "0.2", features = ["logger"] }
|
||||
android_logger = "0.9"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
||||
console_error_panic_hook = "0.1.6"
|
||||
console_log = { version = "0.2", features = ["color"] }
|
||||
|
@ -314,3 +335,16 @@ name = "assets_wasm"
|
|||
path = "examples/wasm/assets_wasm.rs"
|
||||
required-features = ["bevy_winit"]
|
||||
|
||||
[[example]]
|
||||
name = "bevy_android"
|
||||
path = "examples/android/bevy_android.rs"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[package.metadata.android]
|
||||
build_targets = [ "aarch64-linux-android", "armv7-linux-androideabi" ]
|
||||
target_sdk_version = 28
|
||||
min_sdk_version = 28
|
||||
|
||||
[[package.metadata.android.feature]]
|
||||
name = "android.hardware.vulkan.level"
|
||||
version = "1"
|
||||
|
|
|
@ -48,7 +48,7 @@ parking_lot = "0.11.0"
|
|||
spirv-reflect = "0.2.3"
|
||||
|
||||
[target.'cfg(all(not(target_os = "ios"), not(target_arch = "wasm32")))'.dependencies]
|
||||
bevy-glsl-to-spirv = "0.1.7"
|
||||
bevy-glsl-to-spirv = "0.2.0"
|
||||
|
||||
[target.'cfg(target_os = "ios")'.dependencies]
|
||||
shaderc = "0.6.3"
|
||||
|
|
|
@ -28,12 +28,7 @@ fn glsl_to_spirv(
|
|||
stage: ShaderStage,
|
||||
shader_defs: Option<&[String]>,
|
||||
) -> Vec<u32> {
|
||||
use std::io::Read;
|
||||
|
||||
let mut output = bevy_glsl_to_spirv::compile(glsl_source, stage.into(), shader_defs).unwrap();
|
||||
let mut spv_bytes = Vec::new();
|
||||
output.read_to_end(&mut spv_bytes).unwrap();
|
||||
bytes_to_words(&spv_bytes)
|
||||
bevy_glsl_to_spirv::compile(glsl_source, stage.into(), shader_defs).unwrap()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "ios")]
|
||||
|
|
10
examples/android/bevy_android.rs
Normal file
10
examples/android/bevy_android.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Edit to run any single file example from Bevy.
|
||||
include!("../3d/3d_scene.rs");
|
||||
|
||||
#[cfg_attr(
|
||||
target_os = "android",
|
||||
ndk_glue::main(logger(level = "trace", tag = "bevy_android"), backtrace = "full")
|
||||
)]
|
||||
pub fn android_main() {
|
||||
main();
|
||||
}
|
Loading…
Reference in a new issue