Bug 1666404 - Invalidate depth attachments at end of render passes. r=gw

This must be done before the draw framebuffer is unbound, to allow
tiled GPUs to avoid writing the contents back to memory.

Differential Revision: https://phabricator.services.mozilla.com/D91261
This commit is contained in:
Jamie Nicol 2020-09-24 20:20:36 +00:00
Родитель 02627ab09c
Коммит 53c582e49b
2 изменённых файлов: 16 добавлений и 3 удалений

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

@ -2396,9 +2396,6 @@ impl Device {
/// Notifies the device that the contents of a render target are no longer
/// needed.
///
/// FIXME(bholley): We could/should invalidate the depth targets earlier
/// than the color targets, i.e. immediately after each pass.
pub fn invalidate_render_target(&mut self, texture: &Texture) {
let (fbos, attachments) = if texture.supports_depth() {
(&texture.fbos_with_depth,
@ -2418,6 +2415,16 @@ impl Device {
self.bind_external_draw_target(original_bound_fbo);
}
/// Notifies the device that the contents of the current framebuffer's depth
/// attachment is no longer needed. Unlike invalidate_render_target, this can
/// be called even when the contents of the colour attachment is still required.
/// This should be called before unbinding the framebuffer at the end of a pass,
/// to allow tiled GPUs to avoid writing the contents back to memory.
pub fn invalidate_depth_target(&mut self) {
assert!(self.depth_available);
self.gl.invalidate_framebuffer(gl::DRAW_FRAMEBUFFER, &[gl::DEPTH_ATTACHMENT]);
}
/// Notifies the device that a render target is about to be reused.
///
/// This method adds or removes a depth target as necessary.

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

@ -4512,6 +4512,8 @@ impl Renderer {
render_tasks,
stats,
);
self.device.invalidate_depth_target();
}
/// Draw an alpha batch container into a given draw target. This is used
@ -5409,6 +5411,10 @@ impl Renderer {
stats,
);
}
if clear_depth.is_some() {
self.device.invalidate_depth_target();
}
}
/// Draw all the instances in a clip batcher list to the current target.