[Impeller] attempt to get validation errors from CI unittests. (flutter/engine#51341)

Enables Vulkan validation layers for macOS and linux builds, enables macOS validation for macOS builds.

Fixes https://github.com/flutter/flutter/issues/144967

There may still be remaining issues with macOS validation, I need to verify I can reproduce https://github.com/flutter/flutter/issues/143324 . I plan to do that separately
This commit is contained in:
Jonah Williams
2024-03-13 10:35:58 -07:00
committed by GitHub
parent 38d2c40d8d
commit 674874e613
17 changed files with 171 additions and 161 deletions

View File

@@ -121,7 +121,8 @@
"--target-dir",
"host_debug_unopt_impeller_tests",
"--rbe",
"--no-goma"
"--no-goma",
"--use-glfw-swiftshader"
],
"name": "host_debug_unopt_impeller_tests",
"ninja": {

View File

@@ -135,7 +135,8 @@
"arm64",
"--rbe",
"--no-goma",
"--xcode-symlinks"
"--xcode-symlinks",
"--use-glfw-swiftshader"
],
"name": "host_debug_unopt_arm64",
"ninja": {
@@ -157,7 +158,7 @@
"--variant",
"host_debug_unopt_arm64",
"--type",
"dart,dart-host,engine",
"dart,dart-host,engine,impeller-golden",
"--engine-capture-core-dump"
]
}

View File

@@ -34,10 +34,6 @@ config("impeller_public_config") {
defines += [ "IMPELLER_ENABLE_VULKAN=1" ]
}
if (impeller_enable_vulkan_playgrounds) {
defines += [ "IMPELLER_ENABLE_VULKAN_PLAYGROUNDS=1" ]
}
if (impeller_trace_all_gl_calls) {
defines += [ "IMPELLER_TRACE_ALL_GL_CALLS" ]
}

View File

@@ -72,11 +72,15 @@ fml::StatusOr<Scalar> CalculateSigmaForBlurRadius(
class GaussianBlurFilterContentsTest : public EntityPlayground {
public:
std::shared_ptr<Texture> MakeTexture(const TextureDescriptor& desc) {
return GetContentContext()
->GetContext()
->GetResourceAllocator()
->CreateTexture(desc);
/// Create a texture that has been cleared to transparent black.
std::shared_ptr<Texture> MakeTexture(ISize size) {
auto render_target = GetContentContext()->MakeSubpass(
"Clear Subpass", size,
[](const ContentContext&, RenderPass&) { return true; });
if (render_target.ok()) {
return render_target.value().GetRenderTargetTexture();
}
return nullptr;
}
};
INSTANTIATE_PLAYGROUND_SUITE(GaussianBlurFilterContentsTest);
@@ -109,6 +113,7 @@ TEST(GaussianBlurFilterContentsTest, CoverageSimple) {
Entity entity;
std::optional<Rect> coverage =
contents.GetFilterCoverage(inputs, entity, /*effect_transform=*/Matrix());
ASSERT_EQ(coverage, Rect::MakeLTRB(10, 10, 110, 110));
}
@@ -125,6 +130,7 @@ TEST(GaussianBlurFilterContentsTest, CoverageWithSigma) {
Entity entity;
std::optional<Rect> coverage =
contents.GetFilterCoverage(inputs, entity, /*effect_transform=*/Matrix());
EXPECT_TRUE(coverage.has_value());
if (coverage.has_value()) {
EXPECT_RECT_NEAR(coverage.value(), Rect::MakeLTRB(99, 99, 201, 201));
@@ -132,11 +138,6 @@ TEST(GaussianBlurFilterContentsTest, CoverageWithSigma) {
}
TEST_P(GaussianBlurFilterContentsTest, CoverageWithTexture) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(100, 100),
};
fml::StatusOr<Scalar> sigma_radius_1 =
CalculateSigmaForBlurRadius(1.0, Matrix());
ASSERT_TRUE(sigma_radius_1.ok());
@@ -144,14 +145,13 @@ TEST_P(GaussianBlurFilterContentsTest, CoverageWithTexture) {
/*sigma_X=*/sigma_radius_1.value(),
/*sigma_y=*/sigma_radius_1.value(), Entity::TileMode::kDecal,
FilterContents::BlurStyle::kNormal, /*mask_geometry=*/nullptr);
std::shared_ptr<Texture> texture =
GetContentContext()->GetContext()->GetResourceAllocator()->CreateTexture(
desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
FilterInput::Vector inputs = {FilterInput::Make(texture)};
Entity entity;
entity.SetTransform(Matrix::MakeTranslation({100, 100, 0}));
std::optional<Rect> coverage =
contents.GetFilterCoverage(inputs, entity, /*effect_transform=*/Matrix());
EXPECT_TRUE(coverage.has_value());
if (coverage.has_value()) {
EXPECT_RECT_NEAR(coverage.value(), Rect::MakeLTRB(99, 99, 201, 201));
@@ -159,11 +159,6 @@ TEST_P(GaussianBlurFilterContentsTest, CoverageWithTexture) {
}
TEST_P(GaussianBlurFilterContentsTest, CoverageWithEffectTransform) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(100, 100),
};
Matrix effect_transform = Matrix::MakeScale({2.0, 2.0, 1.0});
fml::StatusOr<Scalar> sigma_radius_1 =
CalculateSigmaForBlurRadius(1.0, effect_transform);
@@ -172,9 +167,7 @@ TEST_P(GaussianBlurFilterContentsTest, CoverageWithEffectTransform) {
/*sigma_x=*/sigma_radius_1.value(),
/*sigma_y=*/sigma_radius_1.value(), Entity::TileMode::kDecal,
FilterContents::BlurStyle::kNormal, /*mask_geometry=*/nullptr);
std::shared_ptr<Texture> texture =
GetContentContext()->GetContext()->GetResourceAllocator()->CreateTexture(
desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
FilterInput::Vector inputs = {FilterInput::Make(texture)};
Entity entity;
entity.SetTransform(Matrix::MakeTranslation({100, 100, 0}));
@@ -218,12 +211,7 @@ TEST(GaussianBlurFilterContentsTest, CalculateSigmaValues) {
}
TEST_P(GaussianBlurFilterContentsTest, RenderCoverageMatchesGetCoverage) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(100, 100),
};
std::shared_ptr<Texture> texture = MakeTexture(desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
fml::StatusOr<Scalar> sigma_radius_1 =
CalculateSigmaForBlurRadius(1.0, Matrix());
ASSERT_TRUE(sigma_radius_1.ok());
@@ -254,12 +242,7 @@ TEST_P(GaussianBlurFilterContentsTest, RenderCoverageMatchesGetCoverage) {
TEST_P(GaussianBlurFilterContentsTest,
RenderCoverageMatchesGetCoverageTranslate) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(100, 100),
};
std::shared_ptr<Texture> texture = MakeTexture(desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
fml::StatusOr<Scalar> sigma_radius_1 =
CalculateSigmaForBlurRadius(1.0, Matrix());
ASSERT_TRUE(sigma_radius_1.ok());
@@ -292,12 +275,7 @@ TEST_P(GaussianBlurFilterContentsTest,
TEST_P(GaussianBlurFilterContentsTest,
RenderCoverageMatchesGetCoverageRotated) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(400, 300),
};
std::shared_ptr<Texture> texture = MakeTexture(desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(400, 300));
fml::StatusOr<Scalar> sigma_radius_1 =
CalculateSigmaForBlurRadius(1.0, Matrix());
auto contents = std::make_unique<GaussianBlurFilterContents>(
@@ -329,12 +307,7 @@ TEST_P(GaussianBlurFilterContentsTest,
}
TEST_P(GaussianBlurFilterContentsTest, CalculateUVsSimple) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(100, 100),
};
std::shared_ptr<Texture> texture = MakeTexture(desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
auto filter_input = FilterInput::Make(texture);
Entity entity;
Quad uvs = GaussianBlurFilterContents::CalculateUVs(
@@ -347,13 +320,7 @@ TEST_P(GaussianBlurFilterContentsTest, CalculateUVsSimple) {
}
TEST_P(GaussianBlurFilterContentsTest, TextureContentsWithDestinationRect) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(100, 100),
};
std::shared_ptr<Texture> texture = MakeTexture(desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
auto texture_contents = std::make_shared<TextureContents>();
texture_contents->SetSourceRect(Rect::MakeSize(texture->GetSize()));
texture_contents->SetTexture(texture);
@@ -388,13 +355,7 @@ TEST_P(GaussianBlurFilterContentsTest, TextureContentsWithDestinationRect) {
TEST_P(GaussianBlurFilterContentsTest,
TextureContentsWithDestinationRectScaled) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(100, 100),
};
std::shared_ptr<Texture> texture = MakeTexture(desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
auto texture_contents = std::make_shared<TextureContents>();
texture_contents->SetSourceRect(Rect::MakeSize(texture->GetSize()));
texture_contents->SetTexture(texture);
@@ -429,14 +390,8 @@ TEST_P(GaussianBlurFilterContentsTest,
}
TEST_P(GaussianBlurFilterContentsTest, TextureContentsWithEffectTransform) {
TextureDescriptor desc = {
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kB8G8R8A8UNormInt,
.size = ISize(100, 100),
};
Matrix effect_transform = Matrix::MakeScale({2.0, 2.0, 1.0});
std::shared_ptr<Texture> texture = MakeTexture(desc);
std::shared_ptr<Texture> texture = MakeTexture(ISize(100, 100));
auto texture_contents = std::make_shared<TextureContents>();
texture_contents->SetSourceRect(Rect::MakeSize(texture->GetSize()));
texture_contents->SetTexture(texture);

View File

@@ -2167,7 +2167,6 @@ TEST_P(EntityTest, RuntimeEffect) {
auto contents = std::make_shared<RuntimeEffectContents>();
contents->SetGeometry(Geometry::MakeCover());
contents->SetRuntimeStage(runtime_stage);
struct FragUniforms {
@@ -2643,13 +2642,15 @@ TEST_P(EntityTest, AdvancedBlendCoverageHintIsNotResetByEntityPass) {
}
TEST_P(EntityTest, SpecializationConstantsAreAppliedToVariants) {
auto content_context =
ContentContext(GetContext(), TypographerContextSkia::Make());
auto content_context = GetContentContext();
auto default_color_burn = content_context.GetBlendColorBurnPipeline(
{.has_depth_stencil_attachments = false});
auto alt_color_burn = content_context.GetBlendColorBurnPipeline(
{.has_depth_stencil_attachments = true});
auto default_color_burn = content_context->GetBlendColorBurnPipeline({
.color_attachment_pixel_format = PixelFormat::kR8G8B8A8UNormInt,
.has_depth_stencil_attachments = false,
});
auto alt_color_burn = content_context->GetBlendColorBurnPipeline(
{.color_attachment_pixel_format = PixelFormat::kR8G8B8A8UNormInt,
.has_depth_stencil_attachments = true});
ASSERT_NE(default_color_burn, alt_color_burn);
ASSERT_EQ(default_color_burn->GetDescriptor().GetSpecializationConstants(),
@@ -2663,10 +2664,10 @@ TEST_P(EntityTest, SpecializationConstantsAreAppliedToVariants) {
}
TEST_P(EntityTest, DecalSpecializationAppliedToMorphologyFilter) {
auto content_context =
ContentContext(GetContext(), TypographerContextSkia::Make());
auto default_color_burn = content_context.GetMorphologyFilterPipeline({});
auto content_context = GetContentContext();
auto default_color_burn = content_context->GetMorphologyFilterPipeline({
.color_attachment_pixel_format = PixelFormat::kR8G8B8A8UNormInt,
});
auto decal_supported = static_cast<Scalar>(
GetContext()->GetCapabilities()->SupportsDecalSamplerAddressMode());

View File

@@ -4,6 +4,7 @@
#include "impeller/entity/geometry/point_field_geometry.h"
#include "impeller/geometry/color.h"
#include "impeller/renderer/command_buffer.h"
namespace impeller {
@@ -157,7 +158,8 @@ GeometryResult PointFieldGeometry::GetPositionBufferGPU(
DefaultUniformAlignment());
BufferView geometry_buffer =
host_buffer.Emplace(nullptr, total * sizeof(Point), alignof(Point));
host_buffer.Emplace(nullptr, total * sizeof(Point),
std::max(DefaultUniformAlignment(), alignof(Point)));
BufferView output;
{
@@ -185,8 +187,9 @@ GeometryResult PointFieldGeometry::GetPositionBufferGPU(
}
if (texture_coverage.has_value() && effect_transform.has_value()) {
BufferView geometry_uv_buffer =
host_buffer.Emplace(nullptr, total * sizeof(Vector4), alignof(Vector4));
BufferView geometry_uv_buffer = host_buffer.Emplace(
nullptr, total * sizeof(Vector4),
std::max(DefaultUniformAlignment(), alignof(Vector4)));
using UV = UvComputeShader;

View File

@@ -7,7 +7,6 @@
#include <memory>
#include "flutter/fml/macros.h"
#include "flutter/impeller/aiks/aiks_context.h"
#include "flutter/impeller/playground/playground.h"
#include "flutter/impeller/renderer/render_target.h"

View File

@@ -69,8 +69,6 @@ static const std::vector<std::string> kSkipTests = {
"impeller_Play_AiksTest_CanRenderClippedRuntimeEffects_Vulkan",
};
static const std::vector<std::string> kVulkanDenyValidationTests = {};
namespace {
std::string GetTestName() {
std::string suite_name =

View File

@@ -53,6 +53,7 @@ impeller_component("playground") {
"image:image_skia_backend",
"imgui:imgui_impeller_backend",
"//flutter/fml",
"//flutter/testing:testing_lib",
"//flutter/third_party/glfw",
"//flutter/third_party/imgui:imgui_glfw",
]

View File

@@ -60,18 +60,7 @@ void PlaygroundImplVK::DestroyWindowHandle(WindowHandle handle) {
PlaygroundImplVK::PlaygroundImplVK(PlaygroundSwitches switches)
: PlaygroundImpl(switches), handle_(nullptr, &DestroyWindowHandle) {
if (!::glfwVulkanSupported()) {
#ifdef TARGET_OS_MAC
VALIDATION_LOG << "Attempted to initialize a Vulkan playground on macOS "
"where Vulkan cannot be found. It can be installed via "
"MoltenVK and make sure to install it globally so "
"dlopen can find it.";
#else
VALIDATION_LOG << "Attempted to initialize a Vulkan playground on a system "
"that does not support Vulkan.";
#endif
return;
}
FML_CHECK(IsVulkanDriverPresent());
InitGlobalVulkanInstance();
@@ -224,4 +213,20 @@ fml::Status PlaygroundImplVK::SetCapabilities(
"PlaygroundImplVK doesn't support setting the capabilities.");
}
bool PlaygroundImplVK::IsVulkanDriverPresent() {
if (::glfwVulkanSupported()) {
return true;
}
#ifdef TARGET_OS_MAC
FML_LOG(ERROR) << "Attempting to initialize a Vulkan playground on macOS "
"where Vulkan cannot be found. It can be installed via "
"MoltenVK and make sure to install it globally so "
"dlopen can find it.";
#else // TARGET_OS_MAC
FML_LOG(ERROR) << "Attempting to initialize a Vulkan playground on a system "
"that does not support Vulkan.";
#endif // TARGET_OS_MAC
return false;
}
} // namespace impeller

View File

@@ -5,7 +5,6 @@
#ifndef FLUTTER_IMPELLER_PLAYGROUND_BACKEND_VULKAN_PLAYGROUND_IMPL_VK_H_
#define FLUTTER_IMPELLER_PLAYGROUND_BACKEND_VULKAN_PLAYGROUND_IMPL_VK_H_
#include "flutter/fml/macros.h"
#include "impeller/playground/playground_impl.h"
#include "impeller/renderer/backend/vulkan/vk.h"
@@ -13,6 +12,8 @@ namespace impeller {
class PlaygroundImplVK final : public PlaygroundImpl {
public:
static bool IsVulkanDriverPresent();
explicit PlaygroundImplVK(PlaygroundSwitches switches);
~PlaygroundImplVK();

View File

@@ -33,7 +33,11 @@
#if FML_OS_MACOSX
#include "fml/platform/darwin/scoped_nsautorelease_pool.h"
#endif
#endif // FML_OS_MACOSX
#if IMPELLER_ENABLE_VULKAN
#include "impeller/playground/backend/vulkan/playground_impl_vk.h"
#endif // IMPELLER_ENABLE_VULKAN
namespace impeller {
@@ -107,8 +111,8 @@ bool Playground::SupportsBackend(PlaygroundBackend backend) {
return false;
#endif // IMPELLER_ENABLE_OPENGLES
case PlaygroundBackend::kVulkan:
#if IMPELLER_ENABLE_VULKAN && IMPELLER_ENABLE_VULKAN_PLAYGROUNDS
return true;
#if IMPELLER_ENABLE_VULKAN
return PlaygroundImplVK::IsVulkanDriverPresent();
#else // IMPELLER_ENABLE_VULKAN
return false;
#endif // IMPELLER_ENABLE_VULKAN

View File

@@ -32,6 +32,22 @@ enum class PlaygroundBackend {
kVulkan,
};
// TODO(https://github.com/flutter/flutter/issues/145039)
// clang-format off
static const std::vector<std::string> kVulkanDenyValidationTests = {
"impeller_Play_SceneTest_FlutterLogo_Vulkan",
"impeller_Play_SceneTest_CuboidUnlit_Vulkan",
"impeller_Play_RuntimeStageTest_CanCreatePipelineFromRuntimeStage_Vulkan",
"impeller_Play_RuntimeEffectSetsRightSizeWhenUniformIsStruct_Vulkan",
"impeller_Play_RuntimeEffectCanSuccessfullyRender_Vulkan",
"impeller_Play_RuntimeEffect_Vulkan",
"impeller_Play_EntityTest_RuntimeStageTest_CanCreatePipelineFromRuntimeStage_Vulkan",
"impeller_Play_EntityTest_RuntimeEffectSetsRightSizeWhenUniformIsStruct_Vulkan",
"impeller_Play_EntityTest_RuntimeEffectCanSuccessfullyRender_Vulkan",
"impeller_Play_EntityTest_RuntimeEffect_Vulkan",
};
// clang-format on
constexpr inline RuntimeStageBackend PlaygroundBackendToRuntimeStageBackend(
PlaygroundBackend backend) {
switch (backend) {

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "impeller/playground/playground_impl.h"
#include "flutter/testing/testing.h"
#define GLFW_INCLUDE_NONE
#include "third_party/glfw/include/GLFW/glfw3.h"
@@ -19,6 +20,29 @@
#include "impeller/playground/backend/vulkan/playground_impl_vk.h"
#endif // IMPELLER_ENABLE_VULKAN
namespace {
std::string GetTestName() {
std::string suite_name =
::testing::UnitTest::GetInstance()->current_test_suite()->name();
std::string test_name =
::testing::UnitTest::GetInstance()->current_test_info()->name();
std::stringstream ss;
ss << "impeller_" << suite_name << "_" << test_name;
std::string result = ss.str();
// Make sure there are no slashes in the test name.
std::replace(result.begin(), result.end(), '/', '_');
return result;
}
bool ShouldTestHaveVulkanValidations() {
std::string test_name = GetTestName();
return std::find(impeller::kVulkanDenyValidationTests.begin(),
impeller::kVulkanDenyValidationTests.end(),
test_name) == impeller::kVulkanDenyValidationTests.end();
}
} // namespace
namespace impeller {
std::unique_ptr<PlaygroundImpl> PlaygroundImpl::Create(
@@ -35,6 +59,12 @@ std::unique_ptr<PlaygroundImpl> PlaygroundImpl::Create(
#endif // IMPELLER_ENABLE_OPENGLES
#if IMPELLER_ENABLE_VULKAN
case PlaygroundBackend::kVulkan:
if (!PlaygroundImplVK::IsVulkanDriverPresent()) {
FML_CHECK(false) << "Attempted to create playground with backend that "
"isn't available or was disabled on this platform: "
<< PlaygroundBackendToString(backend);
}
switches.enable_vulkan_validation = ShouldTestHaveVulkanValidations();
return std::make_unique<PlaygroundImplVK>(switches);
#endif // IMPELLER_ENABLE_VULKAN
default:

View File

@@ -18,20 +18,13 @@ declare_args() {
impeller_enable_metal = (is_mac || is_ios) && target_os != "fuchsia"
# Whether the OpenGLES backend is enabled.
impeller_enable_opengles =
(is_linux || is_win || is_android) && target_os != "fuchsia"
impeller_enable_opengles = (is_linux || is_win || is_android || is_mac ||
enable_unittests) && target_os != "fuchsia"
# Whether the Vulkan backend is enabled.
impeller_enable_vulkan = (is_linux || is_win || is_android ||
impeller_enable_vulkan = (is_linux || is_win || is_android || is_mac ||
enable_unittests) && target_os != "fuchsia"
# Whether playgrounds should run with Vulkan.
#
# impeller_enable_vulkan may be true in build environments that run tests but
# do not have a Vulkan ICD present.
impeller_enable_vulkan_playgrounds =
(is_linux || is_win || is_android) && target_os != "fuchsia"
# Whether to use a prebuilt impellerc.
# If this is the empty string, impellerc will be built.
# If it is non-empty, it should be the absolute path to impellerc.

View File

@@ -172,6 +172,37 @@ def find_executable_path(path):
raise Exception('Executable %s does not exist!' % path)
def vulkan_validation_env(build_dir):
extra_env = {
# pylint: disable=line-too-long
# Note: built from //third_party/swiftshader
'VK_ICD_FILENAMES': os.path.join(build_dir, 'vk_swiftshader_icd.json'),
# Note: built from //third_party/vulkan_validation_layers:vulkan_gen_json_files
# and //third_party/vulkan_validation_layers.
'VK_LAYER_PATH': os.path.join(build_dir, 'vulkan-data'),
'VK_INSTANCE_LAYERS': 'VK_LAYER_KHRONOS_validation',
}
return extra_env
def metal_validation_env():
extra_env = {
# pylint: disable=line-too-long
# See https://developer.apple.com/documentation/metal/diagnosing_metal_programming_issues_early?language=objc
'MTL_SHADER_VALIDATION': '1', # Enables all shader validation tests.
'MTL_SHADER_VALIDATION_GLOBAL_MEMORY':
'1', # Validates accesses to device and constant memory.
'MTL_SHADER_VALIDATION_THREADGROUP_MEMORY': '1', # Validates accesses to threadgroup memory.
'MTL_SHADER_VALIDATION_TEXTURE_USAGE': '1', # Validates that texture references are not nil.
}
if is_aarm64():
extra_env.update({
'METAL_DEBUG_ERROR_MODE': '0', # Enables metal validation.
'METAL_DEVICE_WRAPPER_TYPE': '1', # Enables metal validation.
})
return extra_env
def build_engine_executable_command(
build_dir, executable_name, flags=None, coverage=False, gtest=False
):
@@ -474,28 +505,8 @@ def run_cc_tests(build_dir, executable_filter, coverage, capture_core_dump):
shuffle_flags,
coverage=coverage
)
extra_env = {
# pylint: disable=line-too-long
# See https://developer.apple.com/documentation/metal/diagnosing_metal_programming_issues_early?language=objc
'MTL_SHADER_VALIDATION': '1', # Enables all shader validation tests.
'MTL_SHADER_VALIDATION_GLOBAL_MEMORY':
'1', # Validates accesses to device and constant memory.
'MTL_SHADER_VALIDATION_THREADGROUP_MEMORY':
'1', # Validates accesses to threadgroup memory.
'MTL_SHADER_VALIDATION_TEXTURE_USAGE':
'1', # Validates that texture references are not nil.
# Note: built from //third_party/swiftshader
'VK_ICD_FILENAMES': os.path.join(build_dir, 'vk_swiftshader_icd.json'),
# Note: built from //third_party/vulkan_validation_layers:vulkan_gen_json_files
# and //third_party/vulkan_validation_layers.
'VK_LAYER_PATH': os.path.join(build_dir, 'vulkan-data'),
'VK_INSTANCE_LAYERS': 'VK_LAYER_KHRONOS_validation',
}
if is_aarm64():
extra_env.update({
'METAL_DEBUG_ERROR_MODE': '0', # Enables metal validation.
'METAL_DEVICE_WRAPPER_TYPE': '1', # Enables metal validation.
})
extra_env = metal_validation_env()
extra_env.update(vulkan_validation_env(build_dir))
mac_impeller_unittests_flags = shuffle_flags + [
'--enable_vulkan_validation',
'--gtest_filter=-*OpenGLES' # These are covered in the golden tests.
@@ -542,8 +553,9 @@ def run_cc_tests(build_dir, executable_filter, coverage, capture_core_dump):
executable_filter,
shuffle_flags + [
'--enable_vulkan_validation',
# TODO(https://github.com/flutter/flutter/issues/142642): Remove this.
'--gtest_filter=-*OpenGLES',
# TODO(https://github.com/flutter/flutter/issues/145036)
# TODO(https://github.com/flutter/flutter/issues/142642)
'--gtest_filter=*Metal',
],
coverage=coverage,
extra_env=extra_env,
@@ -1035,8 +1047,11 @@ def run_impeller_golden_tests(build_dir: str):
)
harvester_path: Path = Path(SCRIPT_DIR).parent.joinpath('tools'
).joinpath('golden_tests_harvester')
with tempfile.TemporaryDirectory(prefix='impeller_golden') as temp_dir:
run_cmd([tests_path, f'--working_dir={temp_dir}'], cwd=build_dir)
extra_env = metal_validation_env()
extra_env.update(vulkan_validation_env(build_dir))
run_cmd([tests_path, f'--working_dir={temp_dir}'], cwd=build_dir, env=extra_env)
dart_bin = os.path.join(build_dir, 'dart-sdk', 'bin', 'dart')
golden_path = os.path.join('testing', 'impeller_golden_tests_output.txt')
script_path = os.path.join('tools', 'dir_contents_diff', 'bin', 'dir_contents_diff.dart')
@@ -1236,8 +1251,14 @@ Flutter Wiki page on the subject: https://github.com/flutter/flutter/wiki/Testin
build_name = args.variant
try:
xvfb.start_virtual_x(build_name, build_dir)
extra_env = vulkan_validation_env(build_dir)
run_engine_executable(
build_dir, 'impeller_unittests', engine_filter, shuffle_flags, coverage=args.coverage
build_dir,
'impeller_unittests',
engine_filter,
shuffle_flags,
coverage=args.coverage,
extra_env=extra_env
)
finally:
xvfb.stop_virtual_x(build_name)

View File

@@ -788,15 +788,6 @@ def to_gn_args(args):
if args.enable_impeller_trace_canvas:
gn_args['impeller_trace_canvas'] = True
if args.enable_impeller_vulkan:
gn_args['impeller_enable_vulkan'] = True
if args.enable_impeller_vulkan_playgrounds:
gn_args['impeller_enable_vulkan_playgrounds'] = True
if args.enable_impeller_opengles:
gn_args['impeller_enable_opengles'] = True
if args.prebuilt_impellerc is not None:
gn_args['impeller_use_prebuilt_impellerc'] = args.prebuilt_impellerc
@@ -810,6 +801,8 @@ def to_gn_args(args):
if args.use_glfw_swiftshader:
if get_host_os() == 'mac':
gn_args['glfw_vulkan_library'] = r'\"libvulkan.dylib\"'
elif get_host_os() == 'linux':
gn_args['glfw_vulkan_library'] = r'\"libvulkan.so.1\"'
# ANGLE is exclusively used for:
# - Windows at runtime
@@ -1246,22 +1239,14 @@ def parse_args(args):
# Impeller flags.
parser.add_argument(
'--enable-impeller-vulkan',
default=False,
default=True,
action='store_true',
help='Enable the Impeller Vulkan backend.'
)
parser.add_argument(
'--enable-impeller-vulkan-playgrounds',
default=False,
action='store_true',
help='Enable the Impeller Vulkan Playgrounds. ' +
'The Impeller Vulkan backend needs to be enabled.'
)
parser.add_argument(
'--enable-impeller-opengles',
default=False,
default=True,
action='store_true',
help='Enable the Impeller OpenGL ES backend.'
)