зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1531524 - Support running wrench on Android. r=kvark
Differential Revision: https://phabricator.services.mozilla.com/D21881 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
87e0946053
Коммит
31fb2275a2
|
@ -874,6 +874,8 @@ impl UniformLocation {
|
|||
|
||||
pub struct Capabilities {
|
||||
pub supports_multisampling: bool,
|
||||
/// Whether the function glCopyImageSubData is available.
|
||||
pub supports_copy_image_sub_data: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -959,9 +961,6 @@ pub struct Device {
|
|||
/// format, we fall back to glTexImage*.
|
||||
texture_storage_usage: TexStorageUsage,
|
||||
|
||||
/// Whether the function glCopyImageSubData is available.
|
||||
supports_copy_image_sub_data: bool,
|
||||
|
||||
optimal_pbo_stride: NonZeroUsize,
|
||||
|
||||
// GL extensions
|
||||
|
@ -1218,6 +1217,7 @@ impl Device {
|
|||
|
||||
capabilities: Capabilities {
|
||||
supports_multisampling: false, //TODO
|
||||
supports_copy_image_sub_data,
|
||||
},
|
||||
|
||||
bgra_format_internal,
|
||||
|
@ -1243,7 +1243,6 @@ impl Device {
|
|||
frame_id: GpuFrameId(0),
|
||||
extensions,
|
||||
texture_storage_usage,
|
||||
supports_copy_image_sub_data,
|
||||
optimal_pbo_stride,
|
||||
}
|
||||
}
|
||||
|
@ -1809,7 +1808,7 @@ impl Device {
|
|||
debug_assert!(dst.size.height >= src.size.height);
|
||||
debug_assert!(dst.layer_count >= src.layer_count);
|
||||
|
||||
if self.supports_copy_image_sub_data {
|
||||
if self.capabilities.supports_copy_image_sub_data {
|
||||
assert_ne!(src.id, dst.id,
|
||||
"glCopyImageSubData's behaviour is undefined if src and dst images are identical and the rectangles overlap.");
|
||||
unsafe {
|
||||
|
|
|
@ -1110,7 +1110,19 @@ impl GpuCacheTexture {
|
|||
// Create the new texture.
|
||||
assert!(height >= 2, "Height is too small for ANGLE");
|
||||
let new_size = DeviceIntSize::new(MAX_VERTEX_TEXTURE_WIDTH as _, height);
|
||||
let rt_info = Some(RenderTargetInfo { has_depth: false });
|
||||
// If glCopyImageSubData is supported, this texture doesn't need
|
||||
// to be a render target. This prevents GL errors due to framebuffer
|
||||
// incompleteness on devices that don't support RGBAF32 render targets.
|
||||
// TODO(gw): We still need a proper solution for the subset of devices
|
||||
// that don't support glCopyImageSubData *OR* rendering to a
|
||||
// RGBAF32 render target. These devices will currently fail
|
||||
// to resize the GPU cache texture.
|
||||
let supports_copy_image_sub_data = device.get_capabilities().supports_copy_image_sub_data;
|
||||
let rt_info = if supports_copy_image_sub_data {
|
||||
None
|
||||
} else {
|
||||
Some(RenderTargetInfo { has_depth: false })
|
||||
};
|
||||
let mut texture = device.create_texture(
|
||||
TextureTarget::Default,
|
||||
ImageFormat::RGBAF32,
|
||||
|
|
|
@ -25,7 +25,7 @@ time = "0.1"
|
|||
crossbeam = "0.2"
|
||||
osmesa-sys = { version = "0.1.2", optional = true }
|
||||
osmesa-src = { git = "https://github.com/servo/osmesa-src", optional = true }
|
||||
webrender = {path = "../webrender", features=["capture","replay","debugger","png","profiler"]}
|
||||
webrender = {path = "../webrender", features=["capture","replay","debugger","png","profiler","no_static_freetype"]}
|
||||
webrender_api = {path = "../webrender_api", features=["serialize","deserialize"]}
|
||||
winit = "0.16"
|
||||
serde = {version = "1.0", features = ["derive"] }
|
||||
|
@ -44,3 +44,21 @@ mozangle = {version = "0.1.5", features = ["egl"]}
|
|||
|
||||
[target.'cfg(all(unix, not(target_os = "android")))'.dependencies]
|
||||
font-loader = "0.7"
|
||||
|
||||
# Configuration information used when building wrench as an APK.
|
||||
[package.metadata.android]
|
||||
package_name = "org.mozilla.wrench"
|
||||
label = "Wrench"
|
||||
assets = "reftests"
|
||||
android_version = 26
|
||||
target_sdk_version = 18
|
||||
min_sdk_version = 18
|
||||
fullscreen = true
|
||||
build_targets = [ "armv7-linux-androideabi" ]
|
||||
opengles_version_major = 3
|
||||
opengles_version_minor = 0
|
||||
[package.metadata.android.application_attributes]
|
||||
"android:hardwareAccelerated" = "true"
|
||||
[package.metadata.android.activity_attributes]
|
||||
"android:screenOrientation" = "unspecified"
|
||||
"android:uiOptions" = "none"
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
Running Wrench on Android devices.
|
||||
==================================
|
||||
|
||||
Setting up the environment:
|
||||
---------------------------
|
||||
|
||||
Follow the steps at https://github.com/tomaka/android-rs-glue#setting-up-your-environment, with exceptions:
|
||||
- Instead of downloading the NDK and SDK, reference the ones downloaded by Gecko in ~/.mozbuild/
|
||||
|
||||
- Don't install cargo-apk (currently published version has a bug related to SDK versions, hopefully 0.4.2+ will be published soon).
|
||||
Instead, build it from source:
|
||||
git clone https://github.com/tomaka/android-rs-glue
|
||||
cd android-rs-glue/cargo-apk
|
||||
cargo build
|
||||
|
||||
- Consider adding ~/.mozbuild/android-sdk-linux/platform-tools to your path, for the adb commands below.
|
||||
|
||||
Compiling and running:
|
||||
----------------------
|
||||
|
||||
Compile wrench:
|
||||
cd wrench
|
||||
<cargo-apk dir>/target/cargo-apk build
|
||||
|
||||
Install the APK:
|
||||
adb install -r ../target/android-artifacts/app/build/outputs/apk/app-debug.apk
|
||||
|
||||
Set command line arguments:
|
||||
adb shell
|
||||
echo "load reftests/aa/rounded-rects.yaml" >/sdcard/wrench_args
|
||||
exit
|
||||
|
||||
Run the application:
|
||||
adb shell am start -n org.mozilla.wrench/rust.wrench.MainActivity
|
||||
(or click the icon in the launcher)
|
||||
|
||||
Release mode:
|
||||
-------------
|
||||
|
||||
Building in release does work, but you need to sign and align the APK manually. We will automate this in future. For now,
|
||||
|
||||
Generate a signing key (once):
|
||||
keytool -genkey -v -keystore wrench-release-key.keystore -alias wrench_key -keyalg RSA -keysize 2048 -validity 10000
|
||||
|
||||
Sign the APK:
|
||||
jarsigner -verbose -keystore wrench-release-key.keystore <apk path>/app-release-unsigned.apk wrench_key
|
||||
|
||||
Align the APK:
|
||||
zipalign -f -v 4 <apk path>/app-release-unsigned.apk <apk path>/app-release.apk
|
||||
|
||||
Now the signed APK can be installed - you will probably need to uninstall the debug APK if you have that installed first.
|
|
@ -67,6 +67,7 @@ use perf::PerfHarness;
|
|||
use png::save_flipped;
|
||||
use rawtest::RawtestHarness;
|
||||
use reftest::{ReftestHarness, ReftestOptions};
|
||||
use std::fs;
|
||||
#[cfg(feature = "headless")]
|
||||
use std::ffi::CString;
|
||||
#[cfg(feature = "headless")]
|
||||
|
@ -395,9 +396,24 @@ fn main() {
|
|||
env_logger::init();
|
||||
|
||||
let args_yaml = load_yaml!("args.yaml");
|
||||
let args = clap::App::from_yaml(args_yaml)
|
||||
.setting(clap::AppSettings::ArgRequiredElseHelp)
|
||||
.get_matches();
|
||||
let clap = clap::App::from_yaml(args_yaml)
|
||||
.setting(clap::AppSettings::ArgRequiredElseHelp);
|
||||
|
||||
// On android devices, attempt to read command line arguments
|
||||
// from a text file located at /sdcard/wrench_args.
|
||||
let args = if cfg!(target_os = "android") {
|
||||
let mut args = vec!["wrench".to_string()];
|
||||
|
||||
if let Ok(wrench_args) = fs::read_to_string("/sdcard/wrench_args") {
|
||||
for arg in wrench_args.split_whitespace() {
|
||||
args.push(arg.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
clap.get_matches_from(&args)
|
||||
} else {
|
||||
clap.get_matches()
|
||||
};
|
||||
|
||||
// handle some global arguments
|
||||
let res_path = args.value_of("shaders").map(|s| PathBuf::from(s));
|
||||
|
@ -570,6 +586,13 @@ fn render<'a>(
|
|||
thing.do_frame(wrench);
|
||||
|
||||
let mut debug_flags = DebugFlags::empty();
|
||||
|
||||
// Default the profile overlay on for android.
|
||||
if cfg!(target_os = "android") {
|
||||
debug_flags.toggle(DebugFlags::PROFILER_DBG);
|
||||
wrench.api.send_debug_cmd(DebugCommand::SetFlags(debug_flags));
|
||||
}
|
||||
|
||||
let mut body = |wrench: &mut Wrench, events: Vec<winit::Event>| {
|
||||
let mut do_frame = false;
|
||||
let mut do_render = false;
|
||||
|
@ -782,16 +805,26 @@ fn render<'a>(
|
|||
let mut pending_events = Vec::new();
|
||||
|
||||
// Block the thread until at least one event arrives
|
||||
events_loop.run_forever(|event| {
|
||||
pending_events.push(event);
|
||||
winit::ControlFlow::Break
|
||||
});
|
||||
// On Android, we are generally profiling when running
|
||||
// wrench, and don't want to block on UI events.
|
||||
if cfg!(not(target_os = "android")) {
|
||||
events_loop.run_forever(|event| {
|
||||
pending_events.push(event);
|
||||
winit::ControlFlow::Break
|
||||
});
|
||||
}
|
||||
|
||||
// Collect any other pending events that are also available
|
||||
events_loop.poll_events(|event| {
|
||||
pending_events.push(event);
|
||||
});
|
||||
|
||||
// Ensure there is at least one event present so that the
|
||||
// frame gets rendered.
|
||||
if pending_events.is_empty() {
|
||||
pending_events.push(winit::Event::Awakened);
|
||||
}
|
||||
|
||||
// Process all of those pending events in the next vsync period
|
||||
if body(wrench, pending_events) == winit::ControlFlow::Break {
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче