From 18818009497c581ede5d8a3b8b833b81d00cebb7 Mon Sep 17 00:00:00 2001 From: flutteractionsbot <154381524+flutteractionsbot@users.noreply.github.com> Date: Mon, 19 May 2025 10:54:07 -0700 Subject: [PATCH] [CP-beta][Impeller] separate immutable sampler descriptors. (#169074) This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? #168114 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples This cherry pick fixes an issue with video flickering after a user scroll event in the package video_player on devices using Vulkan for rendering. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) Visual jank on devices using Vulkan rendering and the video_player package. ### Workaround: Is there a workaround for this issue? No. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? pixel diffing is difficult to do without being flakey, video rendering pixel diffing is even harder. Was tested manually in the initial pr. ### Validation Steps: What are the steps to validate that this fix works? Using a device that utilizes Vulkan rendering, start the video_player example app, press play on the video, then scroll up or down - the visual flickering should be evident. --- .../flutter/impeller/renderer/backend/vulkan/pipeline_vk.cc | 4 +++- engine/src/flutter/impeller/renderer/pipeline.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_vk.cc index d02956cd2b..72ba5b99be 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_vk.cc @@ -582,8 +582,10 @@ std::shared_ptr PipelineVK::CreateVariantForImmutableSamplers( if (!device_holder) { return nullptr; } + // Note: immutable sampler variant of a pipeline is the negation of the + // existing pipeline key. This keeps the descriptors separate. return (immutable_sampler_variants_[cache_key] = - Create(desc_, device_holder, library_, pipeline_key_, + Create(desc_, device_holder, library_, -1 * pipeline_key_, immutable_sampler)); } diff --git a/engine/src/flutter/impeller/renderer/pipeline.h b/engine/src/flutter/impeller/renderer/pipeline.h index 0bb5c7c475..2dec9431bc 100644 --- a/engine/src/flutter/impeller/renderer/pipeline.h +++ b/engine/src/flutter/impeller/renderer/pipeline.h @@ -18,7 +18,7 @@ namespace impeller { -using PipelineKey = uint64_t; +using PipelineKey = int64_t; class PipelineLibrary; template