Bug 1541078 - Add pre/post frames hooks into save_capture r=kvark

There's two ways we could get around this. We could add a path
around the prepared_for_frames assertion in GpuCache::end_frame,
or we can do this, and leave the TODO explicit with the
assertion. I took the latter approach because we can clear
the GpuCache / TextureCache through other routes than frame
building anyway, so we could hit this failure path before
any of the patches in this bug landed.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Doug Thayer 2019-05-06 17:21:22 +00:00
parent 2f3c20a88f
commit 8efbd9be96
2 changed files with 13 additions and 0 deletions

View File

@ -728,6 +728,7 @@ impl GpuCache {
let mut cache = Self::new();
let mut now = FrameStamp::first(DocumentId::new(IdNamespace(1), 1));
now.advance();
cache.prepared_for_frames = true;
cache.begin_frame(now);
cache
}

View File

@ -1665,6 +1665,10 @@ impl RenderBackend {
}
let config = CaptureConfig::new(root, bits);
if config.bits.contains(CaptureBits::FRAME) {
self.prepare_for_frames();
}
for (&id, doc) in &mut self.documents {
debug!("\tdocument {:?}", id);
if config.bits.contains(CaptureBits::SCENE) {
@ -1706,6 +1710,14 @@ impl RenderBackend {
config.serialize(&doc.data_stores, data_stores_name);
}
if config.bits.contains(CaptureBits::FRAME) {
// TODO: there is no guarantee that we won't hit this case, but we want to
// report it here if we do. If we don't, it will simply crash in
// Renderer::render_impl and give us less information about the source.
assert!(!self.requires_frame_build(), "Caches were cleared during a capture.");
self.bookkeep_after_frames();
}
debug!("\tscene builder");
self.scene_tx.send(SceneBuilderRequest::SaveScene(config.clone())).unwrap();