mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +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,
|
iOS Stable,
|
||||||
MacOS Stable,
|
MacOS Stable,
|
||||||
MacOS Nightly,
|
MacOS Nightly,
|
||||||
|
Android Stable,
|
||||||
Ubuntu Stable,
|
Ubuntu Stable,
|
||||||
Ubuntu Nightly,
|
Ubuntu Nightly,
|
||||||
Windows Stable,
|
Windows Stable,
|
||||||
@ -41,6 +42,12 @@ jobs:
|
|||||||
build_command: cargo test
|
build_command: cargo test
|
||||||
additional_core_features:
|
additional_core_features:
|
||||||
additional_player_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
|
- os: ubuntu-18.04
|
||||||
name: Ubuntu Stable
|
name: Ubuntu Stable
|
||||||
channel: stable
|
channel: stable
|
||||||
@ -67,13 +74,20 @@ jobs:
|
|||||||
additional_player_features:
|
additional_player_features:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- 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'
|
- if: matrix.channel == 'nightly'
|
||||||
name: Install latest nightly
|
name: Install latest nightly
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
override: true
|
override: true
|
||||||
- if: contains(matrix.build_command, 'clippy')
|
- if: matrix.channel == 'stable'
|
||||||
run: rustup component add clippy
|
run: rustup component add clippy
|
||||||
- name: cargo clippy/test
|
- name: cargo clippy/test
|
||||||
run: ${{ matrix.build_command }}
|
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
|
## Supported Platforms
|
||||||
|
|
||||||
API | Windows | Linux | macOS & iOS |
|
API | Windows 7/10 | Linux & Android | macOS & iOS |
|
||||||
----- | ------------------ | ------------------ | ------------------ |
|
----- | ------------------ | ------------------ | ------------------ |
|
||||||
DX11 | :white_check_mark: | | |
|
DX11 | :white_check_mark: | | |
|
||||||
DX12 | :heavy_check_mark: | | |
|
DX12 | :heavy_check_mark: | | |
|
||||||
|
|||||||
@ -2,6 +2,7 @@ status = [
|
|||||||
"iOS Stable",
|
"iOS Stable",
|
||||||
"MacOS Stable",
|
"MacOS Stable",
|
||||||
"MacOS Nightly",
|
"MacOS Nightly",
|
||||||
|
"Android Stable",
|
||||||
"Ubuntu Stable",
|
"Ubuntu Stable",
|
||||||
"Ubuntu Nightly",
|
"Ubuntu Nightly",
|
||||||
"Windows Stable",
|
"Windows Stable",
|
||||||
|
|||||||
@ -241,7 +241,7 @@ impl Trace {
|
|||||||
pub(crate) fn add(&mut self, action: Action) {
|
pub(crate) fn add(&mut self, action: Action) {
|
||||||
match ron::ser::to_string_pretty(&action, self.config.clone()) {
|
match ron::ser::to_string_pretty(&action, self.config.clone()) {
|
||||||
Ok(string) => {
|
Ok(string) => {
|
||||||
let _ = write!(self.file, "{},\n", string);
|
let _ = writeln!(self.file, "{},", string);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!("RON serialization failure: {:?}", 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)),
|
.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 {
|
Rwh::Xlib(h) => Surface {
|
||||||
vulkan: self
|
vulkan: self
|
||||||
.instance
|
.instance
|
||||||
.vulkan
|
.vulkan
|
||||||
.as_ref()
|
.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 {
|
Rwh::Wayland(h) => Surface {
|
||||||
vulkan: self
|
vulkan: self
|
||||||
.instance
|
.instance
|
||||||
@ -264,6 +274,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|inst| inst.create_surface_from_wayland(h.display, h.surface)),
|
.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)]
|
#[cfg(windows)]
|
||||||
Rwh::Windows(h) => Surface {
|
Rwh::Windows(h) => Surface {
|
||||||
vulkan: self
|
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);
|
result.set_len(words);
|
||||||
}
|
}
|
||||||
const MAGIC_NUMBER: u32 = 0x07230203;
|
const MAGIC_NUMBER: u32 = 0x0723_0203;
|
||||||
if result.len() > 0 && result[0] == MAGIC_NUMBER.swap_bytes() {
|
if !result.is_empty() && result[0] == MAGIC_NUMBER.swap_bytes() {
|
||||||
for word in &mut result {
|
for word in &mut result {
|
||||||
*word = word.swap_bytes();
|
*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(
|
return Err(io::Error::new(
|
||||||
io::ErrorKind::InvalidData,
|
io::ErrorKind::InvalidData,
|
||||||
"input missing SPIR-V magic number",
|
"input missing SPIR-V magic number",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user