Skip to content

Commit

Permalink
[Impeller] starts running vulkan golden image tests with swiftshader (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
gaaclarke authored May 12, 2023
1 parent 2ac8552 commit 502e1eb
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ci/builders/mac_host_engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@
"release",
"--no-lto",
"--prebuilt-dart-sdk",
"--build-embedder-examples"
"--build-embedder-examples",
"--enable-impeller-vulkan"
],
"name": "host_release",
"ninja": {
Expand Down
1 change: 1 addition & 0 deletions impeller/golden_tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ if (is_mac) {
"//flutter/impeller/aiks:aiks_unittests_golden",
"//flutter/impeller/fixtures",
"//third_party/googletest:gtest",
"//third_party/swiftshader",
]
}
}
2 changes: 2 additions & 0 deletions impeller/golden_tests/golden_playground_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class GoldenPlaygroundTest

void SetUp();

void TearDown();

PlaygroundBackend GetBackend() const;

bool OpenPlaygroundHere(const Picture& picture);
Expand Down
31 changes: 30 additions & 1 deletion impeller/golden_tests/golden_playground_test_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <dlfcn.h>
#include <filesystem>

#include "flutter/impeller/golden_tests/golden_playground_test.h"

#include "flutter/impeller/aiks/picture.h"
Expand All @@ -14,18 +17,30 @@ namespace impeller {
// to also be a golden test, then add the test name here.
static const std::vector<std::string> kSkipTests = {
"impeller_Play_AiksTest_CanRenderLinearGradientManyColorsUnevenStops_Metal",
"impeller_Play_AiksTest_CanRenderLinearGradientManyColorsUnevenStops_"
"Vulkan",
"impeller_Play_AiksTest_CanRenderRadialGradient_Metal",
"impeller_Play_AiksTest_CanRenderRadialGradient_Vulkan",
"impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Metal",
"impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Vulkan",
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Metal",
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Vulkan",
"impeller_Play_AiksTest_ColorWheel_Metal",
"impeller_Play_AiksTest_ColorWheel_Vulkan",
"impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Metal",
"impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Vulkan",
"impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Metal",
"impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Vulkan",
"impeller_Play_AiksTest_CoverageOriginShouldBeAccountedForInSubpasses_"
"Metal",
"impeller_Play_AiksTest_CoverageOriginShouldBeAccountedForInSubpasses_"
"Vulkan",
"impeller_Play_AiksTest_SceneColorSource_Metal",
"impeller_Play_AiksTest_SceneColorSource_Vulkan",
// TextRotated is flakey and we can't seem to get it to stabilize on Skia
// Gold.
"impeller_Play_AiksTest_TextRotated_Metal",
"impeller_Play_AiksTest_TextRotated_Vulkan",
};

namespace {
Expand Down Expand Up @@ -68,8 +83,22 @@ struct GoldenPlaygroundTest::GoldenPlaygroundTestImpl {
GoldenPlaygroundTest::GoldenPlaygroundTest()
: pimpl_(new GoldenPlaygroundTest::GoldenPlaygroundTestImpl()) {}

void GoldenPlaygroundTest::TearDown() {
ASSERT_FALSE(dlopen("/usr/local/lib/libMoltenVK.dylib", RTLD_NOLOAD));
}

void GoldenPlaygroundTest::SetUp() {
if (GetBackend() != PlaygroundBackend::kMetal) {
std::filesystem::path testing_assets_path =
flutter::testing::GetTestingAssetsPath();
std::filesystem::path target_path = testing_assets_path.parent_path()
.parent_path()
.parent_path()
.parent_path();
std::filesystem::path icd_path = target_path / "vk_swiftshader_icd.json";
setenv("VK_ICD_FILENAMES", icd_path.c_str(), 1);

if (GetBackend() != PlaygroundBackend::kMetal &&
GetBackend() != PlaygroundBackend::kVulkan) {
GTEST_SKIP_("GoldenPlaygroundTest doesn't support this backend type.");
return;
}
Expand Down
2 changes: 2 additions & 0 deletions impeller/golden_tests/golden_playground_test_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace impeller {

GoldenPlaygroundTest::GoldenPlaygroundTest() {}

void GoldenPlaygroundTest::TearDown() {}

void GoldenPlaygroundTest::SetUp() {
GTEST_SKIP_("GoldenPlaygroundTest doesn't support this backend type.");
}
Expand Down
5 changes: 3 additions & 2 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,10 @@ def make_test(name, flags=None, extra_env=None):
'1', # Validates accesses to threadgroup memory.
'MTL_SHADER_VALIDATION_TEXTURE_USAGE':
'1', # Validates that texture references are not nil.
'VK_ICD_FILENAMES': os.path.join(build_dir, 'vk_swiftshader_icd.json'),
}
if is_aarm64():
extra_env.append({
extra_env.update({
'METAL_DEBUG_ERROR_MODE': '0', # Enables metal validation.
'METAL_DEVICE_WRAPPER_TYPE': '1', # Enables metal validation.
})
Expand All @@ -498,7 +499,7 @@ def make_test(name, flags=None, extra_env=None):
build_dir,
'impeller_unittests',
executable_filter,
shuffle_flags,
['--gtest_filter=-*/Vulkan'] + shuffle_flags,
coverage=coverage,
extra_env=extra_env,
# TODO(117122): Remove this allowlist.
Expand Down

0 comments on commit 502e1eb

Please sign in to comment.