Bug 1562788 - Add support for benchmarking llvmpipe and swiftshader in wrench. r=nical

* Add a script for running wrench under various software rasterizers.
* Add support to wrench for non-blocking event loop.
* Add support to wrench for selecting GL/ES rendering API.
* Update x11 bindings for wrench, to fix a release only crash.

Differential Revision: https://phabricator.services.mozilla.com/D36551

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Glenn Watson 2019-07-02 17:15:18 +00:00
Родитель b459034009
Коммит 861fa49918
4 изменённых файлов: 101 добавлений и 11 удалений

8
gfx/wr/Cargo.lock сгенерированный
Просмотреть файл

@ -604,7 +604,7 @@ dependencies = [
"wayland-client 0.20.10 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winit 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)",
"x11-dl 2.17.5 (registry+https://github.com/rust-lang/crates.io-index)",
"x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1898,7 +1898,7 @@ dependencies = [
"smithay-client-toolkit 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-client 0.20.10 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"x11-dl 2.17.5 (registry+https://github.com/rust-lang/crates.io-index)",
"x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1971,7 +1971,7 @@ dependencies = [
[[package]]
name = "x11-dl"
version = "2.17.5"
version = "2.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2221,7 +2221,7 @@ dependencies = [
"checksum winit 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ec43db5991cc509f5b0c68cb0a0d3614f697c888999990a186a2e895c7f723c0"
"checksum ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ec91ea61b83ce033c43c06c52ddc7532f465c0153281610d44c58b74083aee1a"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
"checksum x11-dl 2.17.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3235540540fde1ae074c8df49054166c0e070407f1c6e1ee17b8c87c2c7bcc7d"
"checksum x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "940586acb859ea05c53971ac231685799a7ec1dee66ac0bccc0e6ad96e06b4e3"
"checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2"
"checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5"
"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"

Просмотреть файл

@ -0,0 +1,52 @@
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
import subprocess
import sys
def is_linux():
return sys.platform.startswith('linux')
if is_linux():
requested_renderer = sys.argv[1]
renderer = "default"
if requested_renderer == 'hardware':
pass
elif requested_renderer == 'llvmpipe':
os.environ["LIBGL_ALWAYS_SOFTWARE"] = "1"
os.environ["GALLIUM_DRIVER"] = "llvmpipe"
elif requested_renderer == 'softpipe':
os.environ["LIBGL_ALWAYS_SOFTWARE"] = "1"
os.environ["GALLIUM_DRIVER"] = "softpipe"
elif requested_renderer == 'swiftshader':
# TODO: Set up LD_LIBRARY_PATH to SwiftShader libraries automatically.
renderer = 'es3'
else:
print('Unknown renderer ' + requested_renderer)
sys.exit(1)
cmd = [
'cargo',
'run',
'--release',
'--',
'--no-block', # Run as fast as possible, for benchmarking
'--no-picture-caching', # Disable picture caching, to test rasterization performance
'--no-subpixel-aa', # SwiftShader doesn't support dual source blending, disable subpixel AA for fairer comparisons
'--renderer', # Select GL3/ES3 renderer API
renderer,
'load'
]
cmd += sys.argv[2:]
print('Running: ' + ' '.join(cmd))
subprocess.check_call(cmd)
else:
print('This script is only supported on Linux')

Просмотреть файл

@ -79,6 +79,14 @@ args:
help: Dump the source of the specified shader
takes_value: true
global: true
- renderer:
long: renderer
help: Select rendering API (gl3, es3)
takes_value: true
global: true
- no_block:
long: no-block
help: Don't block on UI events - run event loop as fast as possible.
subcommands:
- png:

Просмотреть файл

@ -246,14 +246,12 @@ fn make_window(
vsync: bool,
events_loop: &Option<winit::EventsLoop>,
angle: bool,
gl_request: glutin::GlRequest,
) -> WindowWrapper {
let wrapper = match *events_loop {
Some(ref events_loop) => {
let context_builder = glutin::ContextBuilder::new()
.with_gl(glutin::GlRequest::GlThenGles {
opengl_version: (3, 2),
opengles_version: (3, 0),
})
.with_gl(gl_request)
.with_vsync(vsync);
let window_builder = winit::WindowBuilder::new()
.with_title("WRench")
@ -484,8 +482,31 @@ fn main() {
Some(winit::EventsLoop::new())
};
let gl_request = match args.value_of("renderer") {
Some("es3") => {
glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (3, 0))
}
Some("gl3") => {
glutin::GlRequest::Specific(glutin::Api::OpenGl, (3, 2))
}
Some("default") | None => {
glutin::GlRequest::GlThenGles {
opengl_version: (3, 2),
opengles_version: (3, 0),
}
}
Some(api) => {
panic!("Unexpected renderer string {}", api);
}
};
let mut window = make_window(
size, dp_ratio, args.is_present("vsync"), &events_loop, args.is_present("angle"),
size,
dp_ratio,
args.is_present("vsync"),
&events_loop,
args.is_present("angle"),
gl_request,
);
let dp_ratio = dp_ratio.unwrap_or(window.hidpi_factor());
let dim = window.get_inner_size();
@ -528,7 +549,15 @@ fn main() {
}
if let Some(subargs) = args.subcommand_matches("show") {
render(&mut wrench, &mut window, size, &mut events_loop, subargs);
let no_block = args.is_present("no_block");
render(
&mut wrench,
&mut window,
size,
&mut events_loop,
subargs,
no_block,
);
} else if let Some(subargs) = args.subcommand_matches("png") {
let surface = match subargs.value_of("surface") {
Some("screen") | None => png::ReadSurface::Screen,
@ -571,6 +600,7 @@ fn render<'a>(
size: DeviceIntSize,
events_loop: &mut Option<winit::EventsLoop>,
subargs: &clap::ArgMatches<'a>,
no_block: bool,
) {
let input_path = subargs.value_of("INPUT").map(PathBuf::from).unwrap();
@ -835,7 +865,7 @@ fn render<'a>(
// Block the thread until at least one event arrives
// On Android, we are generally profiling when running
// wrench, and don't want to block on UI events.
if cfg!(not(target_os = "android")) {
if !no_block && cfg!(not(target_os = "android")) {
events_loop.run_forever(|event| {
pending_events.push(event);
winit::ControlFlow::Break