mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
Android support (#625)
This commit is contained in:
parent
29fe9a935a
commit
f35dd741aa
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
@ -17,6 +17,7 @@ jobs:
|
||||
iOS Stable,
|
||||
MacOS Stable,
|
||||
MacOS Nightly,
|
||||
Android Stable,
|
||||
Ubuntu Stable,
|
||||
Ubuntu Nightly,
|
||||
Windows Stable,
|
||||
@ -41,6 +42,12 @@ jobs:
|
||||
build_command: cargo test
|
||||
additional_core_features:
|
||||
additional_player_features:
|
||||
- os: ubuntu-18.04
|
||||
name: Android Stable
|
||||
channel: stable
|
||||
build_command: rustup target add aarch64-linux-android; cargo clippy --target aarch64-linux-android
|
||||
additional_core_features: trace
|
||||
additional_player_features:
|
||||
- os: ubuntu-18.04
|
||||
name: Ubuntu Stable
|
||||
channel: stable
|
||||
@ -67,13 +74,20 @@ jobs:
|
||||
additional_player_features:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- if: matrix.name == 'Android Stable'
|
||||
run: |
|
||||
curl -LO https://dl.google.com/android/repository/android-ndk-r21b-linux-x86_64.zip
|
||||
unzip -qq android-ndk-r21b-linux-x86_64.zip -d $GITHUB_WORKSPACE
|
||||
export NDK_HOME_BIN=$GITHUB_WORKSPACE/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin
|
||||
ln -s $NDK_HOME_BIN/aarch64-linux-android21-clang $NDK_HOME_BIN/aarch64-linux-android-clang
|
||||
echo "::add-path::$NDK_HOME_BIN"
|
||||
- if: matrix.channel == 'nightly'
|
||||
name: Install latest nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
- if: contains(matrix.build_command, 'clippy')
|
||||
- if: matrix.channel == 'stable'
|
||||
run: rustup component add clippy
|
||||
- name: cargo clippy/test
|
||||
run: ${{ matrix.build_command }}
|
||||
|
@ -25,7 +25,7 @@ If you are looking for the native implementation or bindings to the API in other
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
API | Windows | Linux | macOS & iOS |
|
||||
API | Windows 7/10 | Linux & Android | macOS & iOS |
|
||||
----- | ------------------ | ------------------ | ------------------ |
|
||||
DX11 | :white_check_mark: | | |
|
||||
DX12 | :heavy_check_mark: | | |
|
||||
|
@ -2,6 +2,7 @@ status = [
|
||||
"iOS Stable",
|
||||
"MacOS Stable",
|
||||
"MacOS Nightly",
|
||||
"Android Stable",
|
||||
"Ubuntu Stable",
|
||||
"Ubuntu Nightly",
|
||||
"Windows Stable",
|
||||
|
@ -241,7 +241,7 @@ impl Trace {
|
||||
pub(crate) fn add(&mut self, action: Action) {
|
||||
match ron::ser::to_string_pretty(&action, self.config.clone()) {
|
||||
Ok(string) => {
|
||||
let _ = write!(self.file, "{},\n", string);
|
||||
let _ = writeln!(self.file, "{},", string);
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("RON serialization failure: {:?}", e);
|
||||
|
@ -248,15 +248,25 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.create_surface_from_nsview(h.ns_view, cfg!(debug_assertions)),
|
||||
}
|
||||
}
|
||||
#[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))]
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(target_os = "android"),
|
||||
not(target_os = "ios"),
|
||||
not(target_os = "macos")
|
||||
))]
|
||||
Rwh::Xlib(h) => Surface {
|
||||
vulkan: self
|
||||
.instance
|
||||
.vulkan
|
||||
.as_ref()
|
||||
.map(|inst| inst.create_surface_from_xlib(h.display as _, h.window as _)),
|
||||
.map(|inst| inst.create_surface_from_xlib(h.display as _, h.window)),
|
||||
},
|
||||
#[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))]
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(target_os = "android"),
|
||||
not(target_os = "ios"),
|
||||
not(target_os = "macos")
|
||||
))]
|
||||
Rwh::Wayland(h) => Surface {
|
||||
vulkan: self
|
||||
.instance
|
||||
@ -264,6 +274,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.as_ref()
|
||||
.map(|inst| inst.create_surface_from_wayland(h.display, h.surface)),
|
||||
},
|
||||
#[cfg(target_os = "android")]
|
||||
Rwh::Android(h) => Surface {
|
||||
vulkan: self
|
||||
.instance
|
||||
.vulkan
|
||||
.as_ref()
|
||||
.map(|inst| inst.create_surface_android(h.a_native_window)),
|
||||
},
|
||||
#[cfg(windows)]
|
||||
Rwh::Windows(h) => Surface {
|
||||
vulkan: self
|
||||
|
@ -121,13 +121,13 @@ pub fn read_spirv<R: io::Read + io::Seek>(mut x: R) -> io::Result<Vec<u32>> {
|
||||
))?;
|
||||
result.set_len(words);
|
||||
}
|
||||
const MAGIC_NUMBER: u32 = 0x07230203;
|
||||
if result.len() > 0 && result[0] == MAGIC_NUMBER.swap_bytes() {
|
||||
const MAGIC_NUMBER: u32 = 0x0723_0203;
|
||||
if !result.is_empty() && result[0] == MAGIC_NUMBER.swap_bytes() {
|
||||
for word in &mut result {
|
||||
*word = word.swap_bytes();
|
||||
}
|
||||
}
|
||||
if result.len() == 0 || result[0] != MAGIC_NUMBER {
|
||||
if result.is_empty() || result[0] != MAGIC_NUMBER {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"input missing SPIR-V magic number",
|
||||
|
Loading…
Reference in New Issue
Block a user