Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3b5e72c

Browse files
bderojonahwilliams
authored andcommitted
[Impeller] Round out subpass coverage. (#52973)
Resolves flutter/flutter#146967 I added a detailed comment inline explaining why we need this. The visual issues in the reported issue were due to nearest sampling while straddling a half pixel offset. Before: ![image](https://github.com/flutter/engine/assets/919017/ccd89a87-4643-4e4d-9e24-56f28f317e2f) After: <img width="964" alt="image" src="https://github.com/flutter/engine/assets/919017/0be88453-1014-443b-bc80-6df459adb075">
1 parent 1a948ed commit 3b5e72c

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎impeller/entity/entity_pass.cc‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,22 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
735735
// right thing.
736736
return EntityPass::EntityResult::Failure();
737737
}
738+
739+
// Round the subpass texture position for pixel alignment with the parent
740+
// pass render target. By default, we draw subpass textures with nearest
741+
// sampling, so aligning here is important for avoiding visual nearest
742+
// sampling errors caused by limited floating point precision when
743+
// straddling a half pixel boundary.
744+
//
745+
// We do this in lieu of expanding/rounding out the subpass coverage in
746+
// order to keep the bounds wrapping consistently tight around subpass
747+
// elements. Which is necessary to avoid intense flickering in cases
748+
// where a subpass texture has a large blur filter with clamp sampling.
749+
//
750+
// See also this bug: https://github.com/flutter/flutter/issues/144213
751+
Point subpass_texture_position =
752+
(subpass_coverage->GetOrigin() - global_pass_position).Round();
753+
738754
Entity element_entity;
739755
Capture subpass_texture_capture =
740756
capture.CreateChild("Entity (Subpass texture)");
@@ -743,10 +759,8 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
743759
element_entity.SetContents(std::move(offscreen_texture_contents));
744760
element_entity.SetClipDepth(subpass->clip_depth_);
745761
element_entity.SetBlendMode(subpass->blend_mode_);
746-
element_entity.SetTransform(subpass_texture_capture.AddMatrix(
747-
"Transform",
748-
Matrix::MakeTranslation(
749-
Vector3(subpass_coverage->GetOrigin() - global_pass_position))));
762+
element_entity.SetTransform(
763+
Matrix::MakeTranslation(Vector3(subpass_texture_position)));
750764

751765
return EntityPass::EntityResult::Success(std::move(element_entity));
752766
}

0 commit comments

Comments
 (0)