77TEST(PipelineCacheDataVKTest, CanCreateFromDeviceProperties) {
78 vk::PhysicalDeviceProperties props;
79 std::array<uint8_t, 16> uuid{
80 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
82 props.pipelineCacheUUID = uuid;
85 props.driverVersion = 12;
87 EXPECT_EQ(uuid.size(), std::size(header.
uuid));
88 EXPECT_EQ(props.deviceID, header.
device_id);
89 EXPECT_EQ(props.vendorID, header.
vendor_id);
91 for (
size_t i = 0;
i < uuid.size();
i++) {
92 EXPECT_EQ(header.
uuid[
i], uuid.at(
i));
96TEST(PipelineCacheDataVKTest, WritesIncompleteCacheData) {
99 auto cache = context->GetDevice().createPipelineCacheUnique({});
103 temp_dir.
fd(), caps.GetPhysicalDeviceProperties(), cache.value));
106 temp_dir.
fd(),
"flutter.impeller.vkcache");
107 ASSERT_TRUE(mapping);
109 ASSERT_GE(mapping->GetSize(),
sizeof(header));
110 std::memcpy(&header, mapping->GetMapping(),
sizeof(header));
111 ASSERT_EQ(mapping->GetSize(),
sizeof(header) + header.
data_size);
120 const auto& context_vk =
ContextVK::Cast(*surface_context.GetParent());
124 auto cache = context_vk.GetDevice().createPipelineCacheUnique({});
125 ASSERT_EQ(cache.result, vk::Result::eSuccess);
128 temp_dir.
fd(), caps.GetPhysicalDeviceProperties(), cache.value));
133 caps.GetPhysicalDeviceProperties());
134 ASSERT_NE(mapping,
nullptr);
137 vk::PipelineCacheHeaderVersionOne vk_cache_header;
138 ASSERT_GE(mapping->GetSize(),
sizeof(vk_cache_header));
139 std::memcpy(&vk_cache_header, mapping->GetMapping(),
sizeof(vk_cache_header));
140 ASSERT_EQ(vk_cache_header.headerVersion,
141 vk::PipelineCacheHeaderVersion::eOne);
145 IntegrityChecksArePerformedOnPersistedData) {
148 const auto& context_vk =
ContextVK::Cast(*surface_context.GetParent());
152 auto cache = context_vk.GetDevice().createPipelineCacheUnique({});
153 ASSERT_EQ(cache.result, vk::Result::eSuccess);
156 temp_dir.
fd(), caps.GetPhysicalDeviceProperties(), cache.value));
159 auto incompatible_caps = caps.GetPhysicalDeviceProperties();
161 incompatible_caps.driverVersion =
162 caps.GetPhysicalDeviceProperties().driverVersion + 1u;
164 ASSERT_EQ(mapping,
nullptr);
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
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...