Skip to content

Commit 8b6980b

Browse files
committed
Revert "[android]: prewarms shaders when the context is created (flutter#196069)"
This reverts commit b1ea363.
1 parent 215858f commit 8b6980b

9 files changed

Lines changed: 224 additions & 669 deletions

File tree

‎engine/src/flutter/impeller/entity/BUILD.gn‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ impeller_component("entity_unittests") {
287287

288288
sources = [
289289
"clip_stack_unittests.cc",
290-
"contents/content_context_unittests.cc",
291290
"contents/filters/blend_filter_contents_unittests.cc",
292291
"contents/filters/gaussian_blur_filter_contents_unittests.cc",
293292
"contents/filters/inputs/filter_input_unittests.cc",

‎engine/src/flutter/impeller/entity/contents/content_context.cc‎

Lines changed: 223 additions & 242 deletions
Large diffs are not rendered by default.

‎engine/src/flutter/impeller/entity/contents/content_context.h‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,6 @@ class ContentContext {
129129

130130
~ContentContext();
131131

132-
//----------------------------------------------------------------------------
133-
/// @brief Requests the default pipelines that every `ContentContext`
134-
/// creates, without creating a `ContentContext`.
135-
///
136-
/// The pipelines are requested asynchronously from the pipeline
137-
/// library of `context`, which keeps them for the life of the
138-
/// context. `ContentContext`s created with `context` afterwards
139-
/// find them there, compiled or in flight, instead of compiling
140-
/// them again. This lets embedders start compiling pipelines as
141-
/// soon as a context is available, before there is a surface to
142-
/// render to.
143-
///
144-
/// This must be called on the thread that the `ContentContext`s
145-
/// for `context` are used on, since some pipeline libraries
146-
/// (OpenGL ES) are not thread-safe.
147-
///
148-
/// @param[in] context The context whose pipeline library to warm.
149-
///
150-
static void WarmDefaultPipelines(const Context& context);
151-
152132
bool IsValid() const;
153133

154134
Tessellator& GetTessellator() const;
@@ -382,14 +362,6 @@ class ContentContext {
382362
struct Pipelines;
383363
std::unique_ptr<Pipelines> pipelines_;
384364

385-
/// Requests the default variant of every pipeline from the pipeline library
386-
/// of `context`.
387-
///
388-
/// @return The pipelines holding the default variants, or nullptr if a
389-
/// default pipeline descriptor could not be created.
390-
static std::unique_ptr<Pipelines> CreateDefaultPipelines(
391-
const Context& context);
392-
393365
bool is_valid_ = false;
394366
std::shared_ptr<Tessellator> tessellator_;
395367
std::shared_ptr<RenderTargetAllocator> render_target_cache_;

‎engine/src/flutter/impeller/entity/contents/content_context_unittests.cc‎

Lines changed: 0 additions & 141 deletions
This file was deleted.

‎engine/src/flutter/impeller/renderer/testing/mocks.h‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include "impeller/renderer/render_pass.h"
2020
#include "impeller/renderer/render_target.h"
2121
#include "impeller/renderer/sampler_library.h"
22-
#include "impeller/renderer/shader_function.h"
23-
#include "impeller/renderer/shader_library.h"
2422

2523
#define FLT_FORWARD(mock, real, method) \
2624
EXPECT_CALL(*mock, method()) \
@@ -345,25 +343,6 @@ class MockSampler : public Sampler {
345343
explicit MockSampler(const SamplerDescriptor& desc) : Sampler(desc) {}
346344
};
347345

348-
class MockShaderFunction : public ShaderFunction {
349-
public:
350-
MockShaderFunction(std::string name, ShaderStage stage)
351-
: ShaderFunction(UniqueID{}, std::move(name), stage) {}
352-
};
353-
354-
class MockShaderLibrary : public ShaderLibrary {
355-
public:
356-
MOCK_METHOD(bool, IsValid, (), (const, override));
357-
MOCK_METHOD(std::shared_ptr<const ShaderFunction>,
358-
GetFunction,
359-
(std::string_view name, ShaderStage stage),
360-
(override));
361-
MOCK_METHOD(void,
362-
UnregisterFunction,
363-
(std::string name, ShaderStage stage),
364-
(override));
365-
};
366-
367346
} // namespace testing
368347
} // namespace impeller
369348

‎engine/src/flutter/shell/platform/android/BUILD.gn‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ executable("flutter_shell_native_unittests") {
6262
deps = [
6363
":flutter_shell_native_src",
6464
"//flutter/fml",
65-
"//flutter/impeller/renderer/testing:mocks",
6665
"//flutter/shell/platform/android/jni:jni_mock",
6766
"//flutter/shell/platform/android/jni:mock_jni_env",
6867
"//flutter/third_party/googletest:gmock",

‎engine/src/flutter/shell/platform/android/platform_view_android.cc‎

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
#include "fml/logging.h"
3636
#include "impeller/display_list/aiks_context.h"
37-
#include "impeller/entity/contents/content_context.h"
3837
#if IMPELLER_ENABLE_VULKAN // b/258506856 for why this is behind an if
3938
#include "flutter/shell/platform/android/android_surface_vk_impeller.h"
4039
#include "flutter/shell/platform/android/image_external_texture_vk_impeller.h"
@@ -436,34 +435,8 @@ std::unique_ptr<Surface> PlatformViewAndroid::CreateRenderingSurface() {
436435
if (!android_surface_) {
437436
return nullptr;
438437
}
439-
std::unique_ptr<Surface> surface = android_surface_->CreateGPUSurface(
438+
return android_surface_->CreateGPUSurface(
440439
android_context_->GetMainSkiaContext().get());
441-
// Creating the GPU surface sets up the swapchain, which is what may change
442-
// the context's default color format.
443-
CheckWarmedColorFormat();
444-
return surface;
445-
}
446-
447-
void PlatformViewAndroid::CheckWarmedColorFormat() const {
448-
if (!warmed_color_format_.has_value()) {
449-
return;
450-
}
451-
std::shared_ptr<impeller::Context> impeller_context =
452-
android_context_->GetImpellerContext();
453-
if (!impeller_context) {
454-
return;
455-
}
456-
// Only read by the DCHECK below, which compiles out of release builds.
457-
[[maybe_unused]] const impeller::PixelFormat surface_color_format =
458-
impeller_context->GetCapabilities()->GetDefaultColorFormat();
459-
FML_DCHECK(surface_color_format == warmed_color_format_.value())
460-
<< "The default pipelines were warmed for "
461-
<< impeller::PixelFormatToString(warmed_color_format_.value())
462-
<< " but the surface renders to "
463-
<< impeller::PixelFormatToString(surface_color_format)
464-
<< ", so they will be compiled again. Reevaluate the call to "
465-
"ContentContext::WarmDefaultPipelines in "
466-
"PlatformViewAndroid::SetupImpellerContext.";
467440
}
468441

469442
// |PlatformView|
@@ -602,23 +575,6 @@ bool PlatformViewAndroid::IsSurfaceControlEnabled() const {
602575
void PlatformViewAndroid::SetupImpellerContext() {
603576
android_context_->SetupImpellerContext();
604577
android_surface_->SetupImpellerSurface();
605-
606-
// Start compiling the default pipelines now, on the raster thread where the
607-
// surface's ContentContext will later look them up, instead of waiting for
608-
// the first surface to be created. Compilation happens off this thread (on
609-
// the IO thread for OpenGL ES, on worker threads for Vulkan), so no rendering
610-
// context needs to be current here.
611-
//
612-
// The pipelines are keyed on the context's default color format, which the
613-
// Vulkan swapchain may change once a surface exists. On Android it is always
614-
// R8G8B8A8, so the pipelines warmed here are the ones the surface uses.
615-
// |CheckWarmedColorFormat| asserts that this stays true.
616-
if (std::shared_ptr<impeller::Context> impeller_context =
617-
android_context_->GetImpellerContext()) {
618-
warmed_color_format_ =
619-
impeller_context->GetCapabilities()->GetDefaultColorFormat();
620-
impeller::ContentContext::WarmDefaultPipelines(*impeller_context);
621-
}
622578
}
623579

624580
} // namespace flutter

‎engine/src/flutter/shell/platform/android/platform_view_android.h‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
#define FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_
77

88
#include <memory>
9-
#include <optional>
109
#include <string>
1110
#include <vector>
1211

1312
#include <android/hardware_buffer_jni.h>
1413
#include "flutter/fml/platform/android/scoped_java_ref.h"
15-
#include "flutter/impeller/core/formats.h"
1614
#include "flutter/lib/ui/window/platform_message.h"
1715
#include "flutter/shell/common/platform_view.h"
1816
#include "flutter/shell/common/snapshot_surface_producer.h"
@@ -145,14 +143,6 @@ class PlatformViewAndroid final : public PlatformView {
145143
std::unique_ptr<AndroidSurface> android_surface_;
146144
std::shared_ptr<PlatformMessageHandlerAndroid> platform_message_handler_;
147145
bool android_meets_hcpp_criteria_ = false;
148-
// The color format that |SetupImpellerContext| warmed the default pipelines
149-
// for, if it warmed them. Raster thread only.
150-
std::optional<impeller::PixelFormat> warmed_color_format_;
151-
152-
// Asserts that the surface renders to the color format that the default
153-
// pipelines were warmed for. Otherwise the warm-up was wasted. Raster thread
154-
// only.
155-
void CheckWarmedColorFormat() const;
156146

157147
// |PlatformView|
158148
void UpdateSemantics(

0 commit comments

Comments
 (0)