5 #include "flutter/fml/build_config.h"
6 #include "flutter/fml/file.h"
7 #include "flutter/testing/testing.h"
16 TEST(PipelineCacheDataVKTest, CanTestHeaderCompatibility) {
20 EXPECT_EQ(a.
abi,
sizeof(
void*));
21 #ifdef FML_ARCH_CPU_64_BITS
23 #elif FML_ARCH_CPU_32_BITS
45 b.driver_version = 100;
69 for (
size_t i = 0; i < VK_UUID_SIZE; i++) {
70 b.uuid[i] = a.
uuid[i] + 1;
76 TEST(PipelineCacheDataVKTest, CanCreateFromDeviceProperties) {
77 vk::PhysicalDeviceProperties props;
78 std::array<uint8_t, 16> uuid{
79 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
81 props.pipelineCacheUUID = uuid;
84 props.driverVersion = 12;
86 EXPECT_EQ(uuid.size(), std::size(header.
uuid));
87 EXPECT_EQ(props.deviceID, header.
device_id);
88 EXPECT_EQ(props.vendorID, header.
vendor_id);
90 for (
size_t i = 0; i < uuid.size(); i++) {
91 EXPECT_EQ(header.
uuid[i], uuid.at(i));
99 fml::ScopedTemporaryDirectory temp_dir;
101 const auto& context_vk =
ContextVK::Cast(*surface_context.GetParent());
105 auto cache = context_vk.GetDevice().createPipelineCacheUnique({});
106 ASSERT_EQ(cache.result, vk::Result::eSuccess);
107 ASSERT_FALSE(fml::FileExists(temp_dir.fd(),
"flutter.impeller.vkcache"));
109 temp_dir.fd(), caps.GetPhysicalDeviceProperties(), cache.value));
111 ASSERT_TRUE(fml::FileExists(temp_dir.fd(),
"flutter.impeller.vkcache"));
114 caps.GetPhysicalDeviceProperties());
115 ASSERT_NE(mapping,
nullptr);
118 vk::PipelineCacheHeaderVersionOne vk_cache_header;
119 ASSERT_GE(mapping->GetSize(),
sizeof(vk_cache_header));
120 std::memcpy(&vk_cache_header, mapping->GetMapping(),
sizeof(vk_cache_header));
121 ASSERT_EQ(vk_cache_header.headerVersion,
122 vk::PipelineCacheHeaderVersion::eOne);
126 IntegrityChecksArePerformedOnPersistedData) {
127 fml::ScopedTemporaryDirectory temp_dir;
129 const auto& context_vk =
ContextVK::Cast(*surface_context.GetParent());
133 auto cache = context_vk.GetDevice().createPipelineCacheUnique({});
134 ASSERT_EQ(cache.result, vk::Result::eSuccess);
135 ASSERT_FALSE(fml::FileExists(temp_dir.fd(),
"flutter.impeller.vkcache"));
137 temp_dir.fd(), caps.GetPhysicalDeviceProperties(), cache.value));
139 ASSERT_TRUE(fml::FileExists(temp_dir.fd(),
"flutter.impeller.vkcache"));
140 auto incompatible_caps = caps.GetPhysicalDeviceProperties();
142 incompatible_caps.driverVersion =
143 caps.GetPhysicalDeviceProperties().driverVersion + 1u;
145 ASSERT_EQ(mapping,
nullptr);
static SurfaceContextVK & Cast(Context &base)
TEST(AllocationSizeTest, CanCreateTypedAllocations)
TEST_P(AiksTest, DrawAtlasNoColor)
INSTANTIATE_VULKAN_PLAYGROUND_SUITE(DriverInfoVKTest)
std::unique_ptr< fml::Mapping > PipelineCacheDataRetrieve(const fml::UniqueFD &cache_directory, const VkPhysicalDeviceProperties &props)
Retrieve the previously persisted pipeline cache data. This function provides integrity checks the Vu...
bool PipelineCacheDataPersist(const fml::UniqueFD &cache_directory, const VkPhysicalDeviceProperties &props, const vk::UniquePipelineCache &cache)
Persist the pipeline cache to a file in the given cache directory. This function performs integrity c...