17 const VkPhysicalDeviceProperties& props,
18 const vk::UniquePipelineCache& cache) {
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.";
40 vk::Result lookup_result = cache.getOwner().getPipelineCacheData(
46 if (lookup_result != vk::Result::eSuccess &&
47 lookup_result != vk::Result::eIncomplete) {
53 std::memcpy(allocation->GetBuffer(), &header,
sizeof(header));
58 allocation_mapping)) {
67 const VkPhysicalDeviceProperties& props) {
71 std::shared_ptr<fml::FileMapping> on_disk_data =
81 std::memcpy(&on_disk_header,
82 on_disk_data->GetMapping(),
83 sizeof(on_disk_header)
86 if (!on_disk_header.IsCompatibleWith(current_header)) {
88 <<
"Persisted pipeline cache is not compatible with current "
89 "Vulkan context. Ignoring.";
93 if (on_disk_header.data_size == 0u) {
96 return std::make_unique<fml::NonOwnedMapping>(
97 on_disk_data->GetMapping() +
sizeof(on_disk_header),
98 on_disk_header.data_size, [on_disk_data](
auto,
auto) {});
104 const VkPhysicalDeviceProperties& props,
105 uint64_t p_data_size)
106 : driver_version(props.driverVersion),
107 vendor_id(props.vendorID),
108 device_id(props.deviceID),
109 data_size(p_data_size) {
110 std::memcpy(
uuid, props.pipelineCacheUUID, VK_UUID_SIZE);
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...