[Impeller] add opt in flag for SurfaceControl testing. (#161353)
Adds an opt in flag for the Android surface control based swapchain. This is off by default, but added for the sake of bug reports and investigation of the functionality.
This commit is contained in:
parent
5f77df9269
commit
6bda88b61b
@ -234,8 +234,8 @@ struct Settings {
|
|||||||
bool enable_impeller = false;
|
bool enable_impeller = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Force disable the android surface control even where supported.
|
// Enable android surface control swapchains where supported.
|
||||||
bool disable_surface_control = false;
|
bool enable_surface_control = false;
|
||||||
|
|
||||||
// Log a warning during shell initialization if Impeller is not enabled.
|
// Log a warning during shell initialization if Impeller is not enabled.
|
||||||
bool warn_on_impeller_opt_out = false;
|
bool warn_on_impeller_opt_out = false;
|
||||||
|
@ -483,7 +483,7 @@ void ContextVK::Setup(Settings settings) {
|
|||||||
descriptor_pool_recycler_ = std::move(descriptor_pool_recycler);
|
descriptor_pool_recycler_ = std::move(descriptor_pool_recycler);
|
||||||
device_name_ = std::string(physical_device_properties.deviceName);
|
device_name_ = std::string(physical_device_properties.deviceName);
|
||||||
command_queue_vk_ = std::make_shared<CommandQueueVK>(weak_from_this());
|
command_queue_vk_ = std::make_shared<CommandQueueVK>(weak_from_this());
|
||||||
should_disable_surface_control_ = settings.disable_surface_control;
|
should_enable_surface_control_ = settings.enable_surface_control;
|
||||||
should_batch_cmd_buffers_ = !workarounds_.batch_submit_command_buffer_timeout;
|
should_batch_cmd_buffers_ = !workarounds_.batch_submit_command_buffer_timeout;
|
||||||
is_valid_ = true;
|
is_valid_ = true;
|
||||||
|
|
||||||
@ -729,8 +729,8 @@ const std::unique_ptr<DriverInfoVK>& ContextVK::GetDriverInfo() const {
|
|||||||
return driver_info_;
|
return driver_info_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContextVK::GetShouldDisableSurfaceControlSwapchain() const {
|
bool ContextVK::GetShouldEnableSurfaceControlSwapchain() const {
|
||||||
return should_disable_surface_control_;
|
return should_enable_surface_control_;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeStageBackend ContextVK::GetRuntimeStageBackend() const {
|
RuntimeStageBackend ContextVK::GetRuntimeStageBackend() const {
|
||||||
|
@ -82,7 +82,7 @@ class ContextVK final : public Context,
|
|||||||
fml::UniqueFD cache_directory;
|
fml::UniqueFD cache_directory;
|
||||||
bool enable_validation = false;
|
bool enable_validation = false;
|
||||||
bool enable_gpu_tracing = false;
|
bool enable_gpu_tracing = false;
|
||||||
bool disable_surface_control = false;
|
bool enable_surface_control = false;
|
||||||
/// If validations are requested but cannot be enabled, log a fatal error.
|
/// If validations are requested but cannot be enabled, log a fatal error.
|
||||||
bool fatal_missing_validations = false;
|
bool fatal_missing_validations = false;
|
||||||
|
|
||||||
@ -227,8 +227,8 @@ class ContextVK final : public Context,
|
|||||||
void DisposeThreadLocalCachedResources() override;
|
void DisposeThreadLocalCachedResources() override;
|
||||||
|
|
||||||
/// @brief Whether the Android Surface control based swapchain should be
|
/// @brief Whether the Android Surface control based swapchain should be
|
||||||
/// disabled, even if the device is capable of supporting it.
|
/// enabled
|
||||||
bool GetShouldDisableSurfaceControlSwapchain() const;
|
bool GetShouldEnableSurfaceControlSwapchain() const;
|
||||||
|
|
||||||
// | Context |
|
// | Context |
|
||||||
bool EnqueueCommandBuffer(
|
bool EnqueueCommandBuffer(
|
||||||
@ -292,7 +292,7 @@ class ContextVK final : public Context,
|
|||||||
mutable Mutex desc_pool_mutex_;
|
mutable Mutex desc_pool_mutex_;
|
||||||
mutable DescriptorPoolMap IPLR_GUARDED_BY(desc_pool_mutex_)
|
mutable DescriptorPoolMap IPLR_GUARDED_BY(desc_pool_mutex_)
|
||||||
cached_descriptor_pool_;
|
cached_descriptor_pool_;
|
||||||
bool should_disable_surface_control_ = false;
|
bool should_enable_surface_control_ = false;
|
||||||
bool should_batch_cmd_buffers_ = false;
|
bool should_batch_cmd_buffers_ = false;
|
||||||
std::vector<std::shared_ptr<CommandBuffer>> pending_command_buffers_;
|
std::vector<std::shared_ptr<CommandBuffer>> pending_command_buffers_;
|
||||||
|
|
||||||
|
@ -56,6 +56,26 @@ std::shared_ptr<SwapchainVK> SwapchainVK::Create(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use AHB Swapchains if they are opted in.
|
||||||
|
if (ContextVK::Cast(*context).GetShouldEnableSurfaceControlSwapchain() &&
|
||||||
|
AHBSwapchainVK::IsAvailableOnPlatform()) {
|
||||||
|
FML_LOG(WARNING) << "Using Android SurfaceControl Swapchain.";
|
||||||
|
auto ahb_swapchain = std::shared_ptr<AHBSwapchainVK>(new AHBSwapchainVK(
|
||||||
|
context, //
|
||||||
|
window.GetHandle(), //
|
||||||
|
surface, //
|
||||||
|
window.GetSize(), //
|
||||||
|
enable_msaa //
|
||||||
|
));
|
||||||
|
|
||||||
|
if (ahb_swapchain->IsValid()) {
|
||||||
|
return ahb_swapchain;
|
||||||
|
} else {
|
||||||
|
VALIDATION_LOG
|
||||||
|
<< "Could not create AHB swapchain. Falling back to KHR variant.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fallback to KHR swapchains if AHB swapchains aren't available.
|
// Fallback to KHR swapchains if AHB swapchains aren't available.
|
||||||
return Create(context, std::move(surface), window.GetSize(), enable_msaa);
|
return Create(context, std::move(surface), window.GetSize(), enable_msaa);
|
||||||
}
|
}
|
||||||
|
@ -526,8 +526,8 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
|
|||||||
settings.enable_platform_isolates =
|
settings.enable_platform_isolates =
|
||||||
command_line.HasOption(FlagForSwitch(Switch::EnablePlatformIsolates));
|
command_line.HasOption(FlagForSwitch(Switch::EnablePlatformIsolates));
|
||||||
|
|
||||||
settings.disable_surface_control = command_line.HasOption(
|
settings.enable_surface_control = command_line.HasOption(
|
||||||
FlagForSwitch(Switch::DisableAndroidSurfaceControl));
|
FlagForSwitch(Switch::EnableAndroidSurfaceControl));
|
||||||
|
|
||||||
settings.merged_platform_ui_thread = !command_line.HasOption(
|
settings.merged_platform_ui_thread = !command_line.HasOption(
|
||||||
FlagForSwitch(Switch::DisableMergedPlatformUIThread));
|
FlagForSwitch(Switch::DisableMergedPlatformUIThread));
|
||||||
|
@ -297,9 +297,9 @@ DEF_SWITCH(EnablePlatformIsolates,
|
|||||||
DEF_SWITCH(DisableMergedPlatformUIThread,
|
DEF_SWITCH(DisableMergedPlatformUIThread,
|
||||||
"no-enable-merged-platform-ui-thread",
|
"no-enable-merged-platform-ui-thread",
|
||||||
"Merge the ui thread and platform thread.")
|
"Merge the ui thread and platform thread.")
|
||||||
DEF_SWITCH(DisableAndroidSurfaceControl,
|
DEF_SWITCH(EnableAndroidSurfaceControl,
|
||||||
"disable-surface-control",
|
"enable-surface-control",
|
||||||
"Disable the SurfaceControl backed swapchain even when supported.")
|
"Enable the SurfaceControl backed swapchain when supported.")
|
||||||
DEF_SWITCHES_END
|
DEF_SWITCHES_END
|
||||||
|
|
||||||
void PrintUsage(const std::string& executable_name);
|
void PrintUsage(const std::string& executable_name);
|
||||||
|
@ -47,7 +47,7 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
|
|||||||
settings.cache_directory = fml::paths::GetCachesDirectory();
|
settings.cache_directory = fml::paths::GetCachesDirectory();
|
||||||
settings.enable_validation = p_settings.enable_validation;
|
settings.enable_validation = p_settings.enable_validation;
|
||||||
settings.enable_gpu_tracing = p_settings.enable_gpu_tracing;
|
settings.enable_gpu_tracing = p_settings.enable_gpu_tracing;
|
||||||
settings.disable_surface_control = p_settings.disable_surface_control;
|
settings.enable_surface_control = p_settings.enable_surface_control;
|
||||||
|
|
||||||
auto context = impeller::ContextVK::Create(std::move(settings));
|
auto context = impeller::ContextVK::Create(std::move(settings));
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class AndroidContext {
|
|||||||
struct ContextSettings {
|
struct ContextSettings {
|
||||||
bool enable_validation = false;
|
bool enable_validation = false;
|
||||||
bool enable_gpu_tracing = false;
|
bool enable_gpu_tracing = false;
|
||||||
bool disable_surface_control = false;
|
bool enable_surface_control = false;
|
||||||
bool quiet = false;
|
bool quiet = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ public class FlutterLoader {
|
|||||||
"io.flutter.embedding.android.EnableVulkanGPUTracing";
|
"io.flutter.embedding.android.EnableVulkanGPUTracing";
|
||||||
private static final String DISABLE_MERGED_PLATFORM_UI_THREAD_KEY =
|
private static final String DISABLE_MERGED_PLATFORM_UI_THREAD_KEY =
|
||||||
"io.flutter.embedding.android.DisableMergedPlatformUIThread";
|
"io.flutter.embedding.android.DisableMergedPlatformUIThread";
|
||||||
private static final String DISABLE_SURFACE_CONTROL =
|
private static final String ENABLE_SURFACE_CONTROL =
|
||||||
"io.flutter.embedding.android.DisableSurfaceControl";
|
"io.flutter.embedding.android.EnableSurfaceControl";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether leave or clean up the VM after the last shell shuts down. It can be set from app's
|
* Set whether leave or clean up the VM after the last shell shuts down. It can be set from app's
|
||||||
@ -369,8 +369,8 @@ public class FlutterLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaData.getBoolean(DISABLE_SURFACE_CONTROL, false)) {
|
if (metaData.getBoolean(ENABLE_SURFACE_CONTROL, false)) {
|
||||||
shellArgs.add("--disable-surface-control");
|
shellArgs.add("--enable-surface-control");
|
||||||
}
|
}
|
||||||
|
|
||||||
String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY);
|
String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY);
|
||||||
|
@ -44,7 +44,7 @@ AndroidContext::ContextSettings CreateContextSettings(
|
|||||||
AndroidContext::ContextSettings settings;
|
AndroidContext::ContextSettings settings;
|
||||||
settings.enable_gpu_tracing = p_settings.enable_vulkan_gpu_tracing;
|
settings.enable_gpu_tracing = p_settings.enable_vulkan_gpu_tracing;
|
||||||
settings.enable_validation = p_settings.enable_vulkan_validation;
|
settings.enable_validation = p_settings.enable_vulkan_validation;
|
||||||
settings.disable_surface_control = p_settings.disable_surface_control;
|
settings.enable_surface_control = p_settings.enable_surface_control;
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -237,11 +237,11 @@ public class FlutterLoaderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void itSetsDisableSurfaceControlFromMetaData() {
|
public void itSetsEnableSurfaceControlFromMetaData() {
|
||||||
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
|
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
|
||||||
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
|
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
|
||||||
Bundle metaData = new Bundle();
|
Bundle metaData = new Bundle();
|
||||||
metaData.putBoolean("io.flutter.embedding.android.DisableSurfaceControl", true);
|
metaData.putBoolean("io.flutter.embedding.android.EnableSurfaceControl", true);
|
||||||
ctx.getApplicationInfo().metaData = metaData;
|
ctx.getApplicationInfo().metaData = metaData;
|
||||||
|
|
||||||
FlutterLoader.Settings settings = new FlutterLoader.Settings();
|
FlutterLoader.Settings settings = new FlutterLoader.Settings();
|
||||||
@ -250,7 +250,7 @@ public class FlutterLoaderTest {
|
|||||||
flutterLoader.ensureInitializationComplete(ctx, null);
|
flutterLoader.ensureInitializationComplete(ctx, null);
|
||||||
shadowOf(getMainLooper()).idle();
|
shadowOf(getMainLooper()).idle();
|
||||||
|
|
||||||
final String disabledControlArg = "--disable-surface-control";
|
final String disabledControlArg = "--enable-surface-control";
|
||||||
ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
|
ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
|
||||||
verify(mockFlutterJNI, times(1))
|
verify(mockFlutterJNI, times(1))
|
||||||
.init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
|
.init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user