7 #include "flutter/fml/file.h"
14 "flutter.impeller.vkcache";
17 const VkPhysicalDeviceProperties& props,
18 const vk::UniquePipelineCache& cache) {
19 if (!cache_directory.is_valid()) {
22 size_t data_size = 0u;
23 if (cache.getOwner().getPipelineCacheData(*cache, &data_size,
nullptr) !=
24 vk::Result::eSuccess) {
28 if (data_size == 0u) {
31 auto allocation = std::make_shared<Allocation>();
32 if (!allocation->Truncate(
Bytes{sizeof(PipelineCacheHeaderVK) + data_size},
34 VALIDATION_LOG <<
"Could not allocate pipeline cache data staging buffer.";
38 std::memcpy(allocation->GetBuffer(), &header,
sizeof(header));
39 if (cache.getOwner().getPipelineCacheData(
40 *cache, &data_size, allocation->GetBuffer() +
sizeof(header)) !=
41 vk::Result::eSuccess) {
47 if (!allocation_mapping) {
51 *allocation_mapping)) {
59 const fml::UniqueFD& cache_directory,
60 const VkPhysicalDeviceProperties& props) {
61 if (!cache_directory.is_valid()) {
64 std::shared_ptr<fml::FileMapping> on_disk_data =
74 std::memcpy(&on_disk_header,
75 on_disk_data->GetMapping(),
76 sizeof(on_disk_header)
79 if (!on_disk_header.IsCompatibleWith(current_header)) {
81 <<
"Persisted pipeline cache is not compatible with current "
82 "Vulkan context. Ignoring.";
86 if (on_disk_header.data_size == 0u) {
89 return std::make_unique<fml::NonOwnedMapping>(
90 on_disk_data->GetMapping() +
sizeof(on_disk_header),
91 on_disk_header.data_size, [on_disk_data](
auto,
auto) {});
97 const VkPhysicalDeviceProperties& props,
99 : driver_version(props.driverVersion),
100 vendor_id(props.vendorID),
101 device_id(props.deviceID),
102 data_size(p_data_size) {
103 std::memcpy(
uuid, props.pipelineCacheUUID, VK_UUID_SIZE);
114 std::memcmp(
uuid, o.
uuid, VK_UUID_SIZE) == 0;