Commit 6a6de594 authored by Glenn Watson's avatar Glenn Watson
Browse files

Bug 1780877 - Fix regression in shared surface allocs by render task graph...

Bug 1780877 - Fix regression in shared surface allocs by render task graph r=gfx-reviewers,lsalzman, a=dsmith

The patch from 1780321 relaxes shared surface allocation, by allowing
surfaces to be shared even if they exist for >1 pass. However, it has
a logic bug - _non shared_ surfaces that are created may then be
allocated from as a shared surface if the `free_after` matches. This
restores the `is_shared` logic that used to exist, which fixes this
edge case (and still allows the performance optimization on the cases
that were fixed by 1780321).

Differential Revision: https://phabricator.services.mozilla.com/D152707
parent c5b12eb1
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ struct Surface {
    kind: RenderTargetKind,
    /// Allocator for this surface texture
    allocator: GuillotineAllocator,
    /// We can only allocate into this for reuse if it's a shared surface
    is_shared: bool,
    /// The pass that we can free this surface after (guaranteed
    /// to be the same for all tasks assigned to this surface)
    free_after: PassId,
@@ -103,9 +105,10 @@ impl Surface {
        &mut self,
        size: DeviceIntSize,
        kind: RenderTargetKind,
        is_shared: bool,
        free_after: PassId,
    ) -> Option<DeviceIntPoint> {
        if self.kind == kind && self.free_after == free_after {
        if self.kind == kind && self.is_shared == is_shared && self.free_after == free_after {
            self.allocator
                .allocate(&size)
                .map(|(_slice, origin)| origin)
@@ -412,7 +415,7 @@ impl RenderTaskGraphBuilder {
                            for sub_pass in &mut pass.sub_passes {
                                if let SubPassSurface::Dynamic { texture_id, ref mut used_rect, .. } = sub_pass.surface {
                                    let surface = self.active_surfaces.get_mut(&texture_id).unwrap();
                                    if let Some(p) = surface.alloc_rect(size, kind, task.free_after) {
                                    if let Some(p) = surface.alloc_rect(size, kind, true, task.free_after) {
                                        location = Some((texture_id, p));
                                        *used_rect = used_rect.union(&DeviceIntRect::from_origin_and_size(p, size));
                                        sub_pass.task_ids.push(*task_id);
@@ -461,6 +464,7 @@ impl RenderTaskGraphBuilder {
                            let mut surface = Surface {
                                kind,
                                allocator: GuillotineAllocator::new(Some(surface_size)),
                                is_shared: can_use_shared_surface,
                                free_after: task.free_after,
                            };

@@ -468,6 +472,7 @@ impl RenderTaskGraphBuilder {
                            let p = surface.alloc_rect(
                                size,
                                kind,
                                can_use_shared_surface,
                                task.free_after,
                            ).expect("bug: alloc must succeed!");