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

Commit

Permalink
[Impeller] eagerly bootstrap content context. (#52590)
Browse files Browse the repository at this point in the history
![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.
  • Loading branch information
jonahwilliams authored May 7, 2024
1 parent b7bfd94 commit 8047058
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions shell/platform/android/android_surface_vulkan_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ AndroidSurfaceVulkanImpeller::AndroidSurfaceVulkanImpeller(
auto& context_vk =
impeller::ContextVK::Cast(*android_context->GetImpellerContext());
surface_context_vk_ = context_vk.CreateSurfaceContext();
eager_gpu_surface_ =
std::make_unique<GPUSurfaceVulkanImpeller>(surface_context_vk_);
}

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

if (eager_gpu_surface_) {
auto gpu_surface = std::move(eager_gpu_surface_);
if (!gpu_surface->IsValid()) {
return nullptr;
}
return gpu_surface;
}

std::unique_ptr<GPUSurfaceVulkanImpeller> gpu_surface =
std::make_unique<GPUSurfaceVulkanImpeller>(surface_context_vk_);

Expand Down
6 changes: 6 additions & 0 deletions shell/platform/android/android_surface_vulkan_impeller.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "flutter/shell/platform/android/android_context_vulkan_impeller.h"
#include "flutter/shell/platform/android/surface/android_native_window.h"
#include "flutter/shell/platform/android/surface/android_surface.h"
#include "shell/gpu/gpu_surface_vulkan_impeller.h"

namespace flutter {

Expand Down Expand Up @@ -49,6 +50,11 @@ class AndroidSurfaceVulkanImpeller : public AndroidSurface {
private:
std::shared_ptr<impeller::SurfaceContextVK> surface_context_vk_;
fml::RefPtr<AndroidNativeWindow> native_window_;
// The first GPU Surface is initialized as soon as the
// AndroidSurfaceVulkanImpeller is created. This ensures that the pipelines
// are bootstrapped as early as possible.
std::unique_ptr<GPUSurfaceVulkanImpeller> eager_gpu_surface_;

bool is_valid_ = false;

FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceVulkanImpeller);
Expand Down

0 comments on commit 8047058

Please sign in to comment.