| Flutter Impeller |

driver_info_vk_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/playground/playground_test.h"
6 #include "impeller/renderer/backend/vulkan/context_vk.h"
7 #include "impeller/renderer/backend/vulkan/driver_info_vk.h"
8 #include "impeller/renderer/backend/vulkan/surface_context_vk.h"
9 #include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"
10
11 namespace impeller::testing {
12
13 using DriverInfoVKTest = PlaygroundTest;
14 INSTANTIATE_VULKAN_PLAYGROUND_SUITE(DriverInfoVKTest);
15
16 TEST_P(DriverInfoVKTest, CanQueryDriverInfo) {
17 ASSERT_TRUE(GetContext());
18 const auto& driver_info =
19 SurfaceContextVK::Cast(*GetContext()).GetParent()->GetDriverInfo();
20 ASSERT_NE(driver_info, nullptr);
21 // 1.1 is the base Impeller version. The driver can't be lower than that.
22 ASSERT_TRUE(driver_info->GetAPIVersion().IsAtLeast(Version{1, 1, 0}));
23 ASSERT_NE(driver_info->GetVendor(), VendorVK::kUnknown);
24 ASSERT_NE(driver_info->GetDeviceType(), DeviceTypeVK::kUnknown);
25 ASSERT_NE(driver_info->GetDriverName(), "");
26 EXPECT_FALSE(driver_info->IsKnownBadDriver());
27 }
28
29 TEST_P(DriverInfoVKTest, CanDumpToLog) {
30 ASSERT_TRUE(GetContext());
31 const auto& driver_info =
32 SurfaceContextVK::Cast(*GetContext()).GetParent()->GetDriverInfo();
33 ASSERT_NE(driver_info, nullptr);
34 fml::testing::LogCapture log;
35 driver_info->DumpToLog();
36 EXPECT_TRUE(log.str().find("Driver Information") != std::string::npos);
37 }
38
39 TEST(DriverInfoVKTest, CanIdentifyBadMaleoonDriver) {
40 auto const context =
41 MockVulkanContextBuilder()
42 .SetPhysicalPropertiesCallback(
43 [](VkPhysicalDevice device, VkPhysicalDeviceProperties* prop) {
44 prop->vendorID = 0x19E5; // Huawei
45 prop->deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
46 })
47 .Build();
48
49 EXPECT_TRUE(context->GetDriverInfo()->IsKnownBadDriver());
50 }
51
52 bool IsBadVersionTest(std::string_view driver_name, bool qc = true) {
53 auto const context =
54 MockVulkanContextBuilder()
55 .SetPhysicalPropertiesCallback(
56 [&driver_name, qc](VkPhysicalDevice device,
57 VkPhysicalDeviceProperties* prop) {
58 if (qc) {
59 prop->vendorID = 0x168C; // Qualcomm
60 } else {
61 prop->vendorID = 0x13B5; // ARM
62 }
63 driver_name.copy(prop->deviceName, driver_name.size());
64 prop->deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
65 })
66 .Build();
67 return context->GetDriverInfo()->IsKnownBadDriver();
68 }
69
70 TEST(DriverInfoVKTest, DriverParsingMali) {
71 EXPECT_EQ(GetMaliVersion("Mali-G51-MORE STUFF"), MaliGPU::kG51);
72 EXPECT_EQ(GetMaliVersion("Mali-G51"), MaliGPU::kG51);
73 EXPECT_EQ(GetMaliVersion("Mali-111111"), MaliGPU::kUnknown);
74 }
75
76 TEST(DriverInfoVKTest, DriverParsingArm) {
77 EXPECT_EQ(GetAdrenoVersion("Adreno (TM) 540"), AdrenoGPU::kAdreno540);
78 EXPECT_EQ(GetAdrenoVersion("Foo Bar"), AdrenoGPU::kUnknown);
79 }
80
81 TEST(DriverInfoVKTest, DisabledDevices) {
82 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 630"));
83 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 620"));
84 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 610"));
85 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 530"));
86 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 512"));
87 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 509"));
88 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 508"));
89 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 506"));
90 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 505"));
91 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 504"));
92 EXPECT_TRUE(IsBadVersionTest("Adreno (TM) 640"));
93
94 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 650"));
95 }
96
97 TEST(DriverInfoVKTest, EnabledDevicesMali) {
98 EXPECT_FALSE(IsBadVersionTest("Mali-G52", /*qc=*/false));
99 EXPECT_FALSE(IsBadVersionTest("Mali-G54-MORE STUFF", /*qc=*/false));
100 }
101
102 TEST(DriverInfoVKTest, EnabledDevicesAdreno) {
103 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 750"));
104 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 740"));
105 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 732"));
106 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 730"));
107 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 725"));
108 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 720"));
109 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 710"));
110 EXPECT_FALSE(IsBadVersionTest("Adreno (TM) 702"));
111 }
112
113 } // namespace impeller::testing
impeller::MaliGPU::kG51
@ kG51
impeller::SurfaceContextVK::GetParent
const std::shared_ptr< ContextVK > & GetParent() const
Definition: surface_context_vk.cc:110
playground_test.h
surface_context_vk.h
impeller::GetMaliVersion
MaliGPU GetMaliVersion(std::string_view version)
Definition: driver_info_vk.cc:122
impeller::Version
Definition: version.h:16
impeller::testing
Definition: allocation_size_unittests.cc:8
impeller::AdrenoGPU::kUnknown
@ kUnknown
impeller::MaliGPU::kUnknown
@ kUnknown
driver_info_vk.h
impeller::testing::TEST_P
TEST_P(AiksTest, DrawAtlasNoColor)
Definition: aiks_dl_atlas_unittests.cc:78
impeller::testing::INSTANTIATE_VULKAN_PLAYGROUND_SUITE
INSTANTIATE_VULKAN_PLAYGROUND_SUITE(DriverInfoVKTest)
impeller::VendorVK::kUnknown
@ kUnknown
impeller::BackendCast< SurfaceContextVK, Context >::Cast
static SurfaceContextVK & Cast(Context &base)
Definition: backend_cast.h:13
impeller::GetAdrenoVersion
AdrenoGPU GetAdrenoVersion(std::string_view version)
Definition: driver_info_vk.cc:108
impeller::DeviceTypeVK::kUnknown
@ kUnknown
impeller::PlaygroundTest
Definition: playground_test.h:21
context_vk.h
impeller::testing::TEST
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Definition: allocation_size_unittests.cc:10
impeller::AdrenoGPU::kAdreno540
@ kAdreno540
impeller::testing::IsBadVersionTest
bool IsBadVersionTest(std::string_view driver_name, bool qc=true)
Definition: driver_info_vk_unittests.cc:52