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

Commit 8047058

Browse files
author
Jonah Williams
authored
[Impeller] eagerly bootstrap content context. (#52590)
![image](https://github.com/flutter/engine/assets/8975114/5238d169-a68b-4905-848b-3ee7a7972de8) Work around for flutter/flutter#143540 by running shader bootstrap as early as possible. I was looking at this code for unrelated reasons (include removal) and realized it would be a trivial change. If we're using the KHR swapchain instead of the AHB swapchain, in theory the pixel format could change but since we hash the pixel format the only bad thing would be the wasted work.
1 parent b7bfd94 commit 8047058

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

shell/platform/android/android_surface_vulkan_impeller.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ AndroidSurfaceVulkanImpeller::AndroidSurfaceVulkanImpeller(
2424
auto& context_vk =
2525
impeller::ContextVK::Cast(*android_context->GetImpellerContext());
2626
surface_context_vk_ = context_vk.CreateSurfaceContext();
27+
eager_gpu_surface_ =
28+
std::make_unique<GPUSurfaceVulkanImpeller>(surface_context_vk_);
2729
}
2830

2931
AndroidSurfaceVulkanImpeller::~AndroidSurfaceVulkanImpeller() = default;
@@ -46,6 +48,14 @@ std::unique_ptr<Surface> AndroidSurfaceVulkanImpeller::CreateGPUSurface(
4648
return nullptr;
4749
}
4850

51+
if (eager_gpu_surface_) {
52+
auto gpu_surface = std::move(eager_gpu_surface_);
53+
if (!gpu_surface->IsValid()) {
54+
return nullptr;
55+
}
56+
return gpu_surface;
57+
}
58+
4959
std::unique_ptr<GPUSurfaceVulkanImpeller> gpu_surface =
5060
std::make_unique<GPUSurfaceVulkanImpeller>(surface_context_vk_);
5161

shell/platform/android/android_surface_vulkan_impeller.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "flutter/shell/platform/android/android_context_vulkan_impeller.h"
1212
#include "flutter/shell/platform/android/surface/android_native_window.h"
1313
#include "flutter/shell/platform/android/surface/android_surface.h"
14+
#include "shell/gpu/gpu_surface_vulkan_impeller.h"
1415

1516
namespace flutter {
1617

@@ -49,6 +50,11 @@ class AndroidSurfaceVulkanImpeller : public AndroidSurface {
4950
private:
5051
std::shared_ptr<impeller::SurfaceContextVK> surface_context_vk_;
5152
fml::RefPtr<AndroidNativeWindow> native_window_;
53+
// The first GPU Surface is initialized as soon as the
54+
// AndroidSurfaceVulkanImpeller is created. This ensures that the pipelines
55+
// are bootstrapped as early as possible.
56+
std::unique_ptr<GPUSurfaceVulkanImpeller> eager_gpu_surface_;
57+
5258
bool is_valid_ = false;
5359

5460
FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceVulkanImpeller);

0 commit comments

Comments
 (0)