Bug 1530242 - Enable some picture caching invalidation tests in wrench. r=emilio

A number of small tweaks to enable the picture caching invalidation
tests. With this in place, we can start adding more test coverage
for various invalidation scenarios.

- Make the reference image render after the test images, so that dirty
  region tracking is more intuitive.
- Instead of replaying the same frame in wrench to ensure frames are
  caching, try to cache tiles every frame when testing mode is enabled.
- Add a basic invalidation test for a rectangle with color that changes
  each frame.
- Make the dirty region index implicit and rename dirty_region to dirty
  in reftest format.
- Fix an underflow error when moving to next frame in wrench.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Glenn Watson 2019-02-25 22:25:22 +00:00
Родитель 0a37fab475
Коммит 1500229636
6 изменённых файлов: 59 добавлений и 39 удалений

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

@ -210,7 +210,6 @@ pub use device::{build_shader_strings, ReadPixelsFormat, UploadMethod, VertexUsa
pub use device::{ProgramBinary, ProgramCache, ProgramCacheObserver};
pub use device::Device;
pub use frame_builder::ChasePrimitive;
pub use picture::FRAMES_BEFORE_PICTURE_CACHING;
pub use profiler::{ProfilerHooks, set_profiler_hooks};
pub use renderer::{AsyncPropertySampler, CpuProfile, DebugFlags, OutputImageHandler, RendererKind};
pub use renderer::{ExternalImage, ExternalImageHandler, ExternalImageSource, GpuProfile};

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

@ -104,7 +104,7 @@ const TILE_SIZE_WIDTH: i32 = 1024;
const TILE_SIZE_HEIGHT: i32 = 256;
const TILE_SIZE_TESTING: i32 = 64;
pub const FRAMES_BEFORE_PICTURE_CACHING: usize = 2;
const FRAMES_BEFORE_PICTURE_CACHING: usize = 2;
const MAX_DIRTY_RECTS: usize = 3;
/// The maximum size per axis of a surface,
@ -1535,7 +1535,9 @@ impl TileCache {
// Only cache tiles that have had the same content for at least two
// frames. This skips caching on pages / benchmarks that are changing
// every frame, which is wasteful.
if tile.same_frames >= FRAMES_BEFORE_PICTURE_CACHING {
// When we are testing invalidation, we want WR to try to cache tiles each
// frame, to make it simpler to define the expected dirty rects.
if tile.same_frames >= FRAMES_BEFORE_PICTURE_CACHING || frame_context.config.testing {
// Ensure that this texture is allocated.
if !resource_cache.texture_cache.is_allocated(&tile.handle) {
resource_cache.texture_cache.update_picture_cache(

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

@ -0,0 +1,17 @@
---
root:
items:
-
bounds: 0 0 1000 1000
type: stacking-context
cache: true
items:
- type: clip
bounds: [50, 50, 200, 200]
complex:
- rect: [50, 50, 200, 200]
radius: 8
items:
- type: rect
bounds: 50 50 200 200
color: green

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

@ -1 +1,2 @@
== one-rounded-rect.yaml two-rounded-rects.yaml rounded-rects.yaml rounded-rects.yaml
# Test that a red -> green -> red rect correctly invalidates each frame
dirty([(50,50):256x256]) one-rounded-rect.yaml dirty([(50,50):256x256]) one-rounded-rect-green.yaml dirty([(50,50):256x256]) one-rounded-rect.yaml == one-rounded-rect.yaml

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

@ -86,8 +86,9 @@ impl ExtraCheck {
x == results.last().unwrap().stats.alpha_target_count,
ExtraCheck::ColorTargets(x) =>
x == results.last().unwrap().stats.color_target_count,
ExtraCheck::DirtyRegion { index, ref region } =>
*region == format!("{}", results[index].recorded_dirty_regions[0]),
ExtraCheck::DirtyRegion { index, ref region } => {
*region == format!("{}", results[index].recorded_dirty_regions[0])
}
}
}
}
@ -221,6 +222,7 @@ impl ReftestManifest {
let mut disable_dual_source_blending = false;
let mut zoom_factor = 1.0;
let mut allow_mipmaps = false;
let mut dirty_region_index = 0;
let mut paths = vec![];
for (i, token) in tokens.iter().enumerate() {
@ -263,11 +265,14 @@ impl ReftestManifest {
let (_, args, _) = parse_function(function);
extra_checks.push(ExtraCheck::ColorTargets(args[0].parse().unwrap()));
}
function if function.starts_with("dirty_region") => {
function if function.starts_with("dirty") => {
let (_, args, _) = parse_function(function);
let index: usize = args[0].parse().unwrap();
let region: String = args[1].parse().unwrap();
extra_checks.push(ExtraCheck::DirtyRegion { index, region });
let region: String = args[0].parse().unwrap();
extra_checks.push(ExtraCheck::DirtyRegion {
index: dirty_region_index,
region,
});
dirty_region_index += 1;
}
options if options.starts_with("options") => {
let (_, args, _) = parse_function(options);
@ -403,21 +408,12 @@ impl<'a> ReftestHarness<'a> {
}
let window_size = self.window.get_inner_size();
let reference = match t.reference.extension().unwrap().to_str().unwrap() {
"yaml" => {
let output = self.render_yaml(
&t.reference,
window_size,
t.font_render_mode,
t.allow_mipmaps,
);
output.image
}
"png" => {
self.load_image(t.reference.as_path(), ImageFormat::PNG)
}
let reference_image = match t.reference.extension().unwrap().to_str().unwrap() {
"yaml" => None,
"png" => Some(self.load_image(t.reference.as_path(), ImageFormat::PNG)),
other => panic!("Unknown reftest extension: {}", other),
};
let test_size = reference_image.as_ref().map_or(window_size, |img| img.size);
// The reference can be smaller than the window size, in which case
// we only compare the intersection.
@ -428,26 +424,31 @@ impl<'a> ReftestHarness<'a> {
// a row, we need to render the scene multiple times.
let mut images = vec![];
let mut results = vec![];
let num_iterations = if t.test.len() > 1 {
webrender::FRAMES_BEFORE_PICTURE_CACHING
} else {
1
};
for filename in t.test.iter() {
let mut output = None;
for _ in 0..num_iterations {
output = Some(self.render_yaml(
&filename,
reference.size,
t.font_render_mode,
t.allow_mipmaps,
));
}
let output = output.unwrap();
let output = self.render_yaml(
&filename,
test_size,
t.font_render_mode,
t.allow_mipmaps,
);
images.push(output.image);
results.push(output.results);
}
let reference = match reference_image {
Some(image) => image,
None => {
let output = self.render_yaml(
&t.reference,
test_size,
t.font_render_mode,
t.allow_mipmaps,
);
output.image
}
};
if t.disable_dual_source_blending {
self.wrench
.api

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

@ -1899,7 +1899,7 @@ impl WrenchThing for YamlFrameReader {
max_frame_count = max_frame_count.max(values.as_vec().unwrap().len());
}
}
if self.requested_frame < max_frame_count - 1 {
if self.requested_frame + 1 < max_frame_count {
self.requested_frame += 1;
}
}