| 206 | } |
| 207 | |
| 208 | void VulkanPipeline::Dump(VkDevice device) |
| 209 | { |
| 210 | if (!m_isChanged) |
| 211 | return; |
| 212 | |
| 213 | size_t constexpr kMaxCacheSizeInBytes = 1024 * 1024; |
| 214 | |
| 215 | size_t cacheSize; |
| 216 | VkResult statusCode; |
| 217 | statusCode = vkGetPipelineCacheData(device, m_vulkanPipelineCache, &cacheSize, nullptr); |
| 218 | if (statusCode == VK_SUCCESS && cacheSize > 0) |
| 219 | { |
| 220 | if (cacheSize <= kMaxCacheSizeInBytes) |
| 221 | { |
| 222 | std::vector<uint8_t> dumpData(cacheSize); |
| 223 | statusCode = vkGetPipelineCacheData(device, m_vulkanPipelineCache, &cacheSize, dumpData.data()); |
| 224 | if (statusCode == VK_SUCCESS) |
| 225 | { |
| 226 | auto const dumpFilePath = GetDumpFilePath(); |
| 227 | try |
| 228 | { |
| 229 | FileWriter w(dumpFilePath); |
| 230 | WriteToSink(w, m_appVersionCode); |
| 231 | w.Write(dumpData.data(), dumpData.size()); |
| 232 | } |
| 233 | catch (FileWriter::Exception const & exception) |
| 234 | { |
| 235 | LOG(LWARNING, ("Exception while writing file:", dumpFilePath, "reason:", exception.what())); |
| 236 | } |
| 237 | m_isChanged = false; |
| 238 | } |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | LOG(LWARNING, ("Maximum pipeline cache size exceeded (", cacheSize, "/", kMaxCacheSizeInBytes, "bytes)")); |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | void VulkanPipeline::ResetCache(VkDevice device) |
| 248 | { |
no test coverage detected