Skip to content

Commit 03f0b4c

Browse files
authored
Adds Vulkan sync validation test run (flutter#195596)
Adds new test run that just runs a handful of tests with vulkan synchronization validation layers on. The synchronization layers are heavy so we opted for this instead of running every tests with them on. fixes flutter#195502 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 755e579 commit 03f0b4c

7 files changed

Lines changed: 122 additions & 9 deletions

File tree

‎engine/src/flutter/ci/builders/linux_unopt.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@
147147
"impeller",
148148
"--engine-capture-core-dump"
149149
]
150+
},
151+
{
152+
"language": "python3",
153+
"name": "Impeller Vulkan synchronization validation tests",
154+
"script": "flutter/testing/run_tests.py",
155+
"parameters": [
156+
"--variant",
157+
"ci/host_debug_unopt_impeller_tests",
158+
"--type",
159+
"impeller-vulkan-sync-validation",
160+
"--engine-capture-core-dump"
161+
]
150162
}
151163
]
152164
},

‎engine/src/flutter/impeller/playground/backend/vulkan/playground_impl_vk.cc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ PlaygroundImplVK::PlaygroundImplVK(const PlaygroundSwitches& switches)
9393
context_settings.shader_libraries_data = ShaderLibraryMappingsForPlayground();
9494
context_settings.cache_directory = fml::paths::GetCachesDirectory();
9595
context_settings.enable_validation = switches_.enable_vulkan_validation;
96+
context_settings.enable_sync_validation =
97+
switches_.enable_vulkan_sync_validation;
9698
context_settings.fatal_missing_validations =
9799
switches_.enable_vulkan_validation;
98100
context_settings.flags = switches_.flags;

‎engine/src/flutter/impeller/playground/switches.cc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ PlaygroundSwitches::PlaygroundSwitches(const fml::CommandLine& args) {
2121
enable_playground = true;
2222
}
2323
enable_vulkan_validation = args.HasOption("enable_vulkan_validation");
24+
enable_vulkan_sync_validation =
25+
args.HasOption("enable_vulkan_sync_validation");
26+
if (enable_vulkan_sync_validation) {
27+
// Synchronization validation is a feature of the validation layers.
28+
enable_vulkan_validation = true;
29+
}
2430
use_swiftshader = args.HasOption("use_swiftshader");
2531
use_angle = args.HasOption("use_angle");
2632
#if FML_OS_MACOSX

‎engine/src/flutter/impeller/playground/switches.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ struct PlaygroundSwitches {
2121
std::optional<std::chrono::milliseconds> timeout;
2222
bool enable_vulkan_validation = false;
2323
//----------------------------------------------------------------------------
24+
/// Enable the synchronization validation feature of the Vulkan validation
25+
/// layers. This implies `enable_vulkan_validation`. Synchronization
26+
/// validation adds significant CPU overhead so it is only intended to be
27+
/// enabled for a select set of tests.
28+
///
29+
bool enable_vulkan_sync_validation = false;
30+
//----------------------------------------------------------------------------
2431
/// Seek a SwiftShader library in known locations and use it when running
2532
/// Vulkan. It is a fatal error to provide this option and not have the test
2633
/// find a SwiftShader implementation.

‎engine/src/flutter/impeller/renderer/backend/vulkan/context_vk.cc‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,22 @@ absl::StatusOr<ContextVK::DeviceSelection> ContextVK::SelectDevice(
238238
vk::StructureChain<vk::InstanceCreateInfo, vk::ValidationFeaturesEXT>
239239
instance_chain;
240240

241-
if (!caps->AreValidationsEnabled()) {
242-
instance_chain.unlink<vk::ValidationFeaturesEXT>();
241+
// Synchronization validation adds significant CPU overhead so it is only
242+
// enabled when explicitly requested.
243+
std::vector<vk::ValidationFeatureEnableEXT> enabled_validations;
244+
if (caps->AreValidationsEnabled() && settings.enable_sync_validation) {
245+
enabled_validations.push_back(
246+
vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
243247
}
244248

245-
std::vector<vk::ValidationFeatureEnableEXT> enabled_validations = {
246-
vk::ValidationFeatureEnableEXT::eSynchronizationValidation,
247-
};
248-
249-
auto validation = instance_chain.get<vk::ValidationFeaturesEXT>();
250-
validation.setEnabledValidationFeatures(enabled_validations);
249+
if (enabled_validations.empty()) {
250+
instance_chain.unlink<vk::ValidationFeaturesEXT>();
251+
} else {
252+
auto& validation = instance_chain.get<vk::ValidationFeaturesEXT>();
253+
validation.setEnabledValidationFeatures(enabled_validations);
254+
}
251255

252-
auto instance_info = instance_chain.get<vk::InstanceCreateInfo>();
256+
auto& instance_info = instance_chain.get<vk::InstanceCreateInfo>();
253257
instance_info.setPEnabledLayerNames(enabled_layers_c);
254258
instance_info.setPEnabledExtensionNames(enabled_extensions_c);
255259
instance_info.setPApplicationInfo(&application_info);

‎engine/src/flutter/impeller/renderer/backend/vulkan/context_vk.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ class ContextVK final : public Context,
9191
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries_data;
9292
fml::UniqueFD cache_directory;
9393
bool enable_validation = false;
94+
/// If validations are enabled, also enable the synchronization validation
95+
/// feature of the validation layers. This detects missing or incorrect
96+
/// barriers but adds significant CPU overhead.
97+
bool enable_sync_validation = false;
9498
bool enable_gpu_tracing = false;
9599
bool enable_surface_control = false;
96100
/// If validations are requested but cannot be enabled, log a fatal error.

‎engine/src/flutter/testing/run_tests.py‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,52 @@ def vulkan_validation_env(build_dir: str) -> typing.Dict[str, str]:
205205
return extra_env
206206

207207

208+
# A small, hand picked set of Vulkan `impeller_unittests` that are run with the
209+
# synchronization validation feature of the Vulkan validation layers enabled.
210+
# Synchronization validation is too expensive to run against the entire suite,
211+
# so these are selected to cover the broadest set of synchronization scenarios
212+
# (blits, readbacks, mipmap generation, MSAA resolves, depth/stencil
213+
# attachments, subpasses, compute, offscreen layers, backdrop filters, advanced
214+
# blends, and glyph atlas uploads).
215+
#
216+
# See https://github.com/flutter/flutter/issues/195502.
217+
VULKAN_SYNC_VALIDATION_TESTS = [
218+
# Blits, readbacks and mipmap generation.
219+
'Play/BlitPassTest.CanBlitSmallRegionToUninitializedTexture/Vulkan',
220+
## TODO(https://github.com/flutter/flutter/issues/195598):
221+
## BlitPassVK::ResizeTexture barrier.
222+
# 'Play/BlitPassTest.CanResizeTextures/Vulkan',
223+
## TODO(https://github.com/flutter/flutter/issues/194987):
224+
## BlitPassVK::OnCopyTextureToBufferCommand barrier.
225+
# 'Play/RendererTest.CanBlitTextureToBuffer/Vulkan',
226+
## TODO(https://github.com/flutter/flutter/issues/194987):
227+
## BlitPassVK::OnGenerateMipmapCommand barrier.
228+
# 'Play/RendererTest.CanGenerateMipmaps/Vulkan',
229+
# Render passes, offscreen targets, MSAA, depth/stencil and subpasses.
230+
## TODO(https://github.com/flutter/flutter/issues/194987):
231+
## RenderPassBuilderVK depth/stencil loadOp.
232+
# 'Play/RendererTest.CanRenderToTexture/Vulkan',
233+
'Play/RendererTest.CanSepiaToneWithSubpasses/Vulkan',
234+
'Play/EntityPassTargetTest.SwapWithMSAAImplicitResolve/Vulkan',
235+
# Compute.
236+
'Compute/ComputeTest.MultiStageInputAndOutput/Vulkan',
237+
# End-to-end rendering through Aiks/DisplayList.
238+
## TODO(https://github.com/flutter/flutter/issues/194987):
239+
## RenderPassBuilderVK depth/stencil loadOp.
240+
# 'Play/AiksTest.CanRenderImage/Vulkan',
241+
# 'Play/AiksTest.CanRenderClips/Vulkan',
242+
# 'Play/AiksTest.CanRenderTextFrame/Vulkan',
243+
# 'Play/AiksTest.CanRenderBackdropBlur/Vulkan',
244+
# 'Play/AiksTest.CanRenderAdvancedBlendColorFilterWithSaveLayer/Vulkan',
245+
## TODO(https://github.com/flutter/flutter/issues/194987):
246+
## RenderPassBuilderVK depth/stencil loadOp.
247+
## TODO(https://github.com/flutter/flutter/issues/195599):
248+
## RenderPassBuilderVK depth/stencil storeOp.
249+
# 'Play/AiksTest.CanRenderNestedBackdropBlur/Vulkan',
250+
# 'Play/AiksTest.GaussianBlurBackdropTinyMipMap/Vulkan',
251+
]
252+
253+
208254
def metal_validation_env() -> typing.Dict[str, str]:
209255
extra_env = {
210256
# pylint: disable=line-too-long
@@ -625,6 +671,35 @@ def make_test(
625671
)
626672

627673

674+
def run_impeller_vulkan_sync_validation_tests(
675+
build_dir: str, build_name: str, executable_filter: typing.Optional[typing.List[str]],
676+
coverage: bool
677+
) -> None:
678+
"""
679+
Runs `VULKAN_SYNC_VALIDATION_TESTS` with Vulkan synchronization validation.
680+
"""
681+
flags = [
682+
'--gtest_filter=' + ':'.join(VULKAN_SYNC_VALIDATION_TESTS),
683+
'--',
684+
'--enable_vulkan_sync_validation',
685+
]
686+
try:
687+
if is_linux():
688+
xvfb.start_virtual_x(build_name, build_dir)
689+
run_engine_executable(
690+
build_dir,
691+
'impeller_unittests',
692+
executable_filter,
693+
flags,
694+
coverage=coverage,
695+
gtest=True,
696+
extra_env=vulkan_validation_env(build_dir),
697+
)
698+
finally:
699+
if is_linux():
700+
xvfb.stop_virtual_x(build_name)
701+
702+
628703
def run_engine_benchmarks(
629704
build_dir: str, executable_filter: typing.Optional[typing.List[str]]
630705
) -> None:
@@ -1452,6 +1527,9 @@ def main() -> int:
14521527
finally:
14531528
xvfb.stop_virtual_x(build_name)
14541529

1530+
if 'impeller-vulkan-sync-validation' in types:
1531+
run_impeller_vulkan_sync_validation_tests(build_dir, args.variant, engine_filter, args.coverage)
1532+
14551533
if 'dart' in types:
14561534
dart_filter = args.dart_filter.split(',') if args.dart_filter else None
14571535
tasks = list(gather_dart_smoke_test(build_dir, dart_filter))

0 commit comments

Comments
 (0)