GPUDevice: Use CompressHelpers

And compress the pipeline cache. Saves a fair bit of disk space.
This commit is contained in:
Stenzek
2024-08-26 21:33:28 +10:00
parent f243dc075d
commit 667d1bf7c8
15 changed files with 143 additions and 102 deletions

View File

@ -2242,28 +2242,20 @@ void VulkanDevice::FillPipelineCacheHeader(VK_PIPELINE_CACHE_HEADER* header)
std::memcpy(header->uuid, m_device_properties.pipelineCacheUUID, VK_UUID_SIZE);
}
bool VulkanDevice::ReadPipelineCache(const std::string& filename)
bool VulkanDevice::ReadPipelineCache(std::optional<DynamicHeapArray<u8>> data)
{
std::optional<DynamicHeapArray<u8>> data;
auto fp = FileSystem::OpenManagedCFile(filename.c_str(), "rb");
if (fp)
if (data.has_value())
{
data = FileSystem::ReadBinaryFile(fp.get());
if (data.has_value())
if (data->size() < sizeof(VK_PIPELINE_CACHE_HEADER))
{
if (data->size() < sizeof(VK_PIPELINE_CACHE_HEADER))
{
ERROR_LOG("Pipeline cache at '{}' is too small", Path::GetFileName(filename));
return false;
}
VK_PIPELINE_CACHE_HEADER header;
std::memcpy(&header, data->data(), sizeof(header));
if (!ValidatePipelineCacheHeader(header))
data.reset();
ERROR_LOG("Pipeline cache is too small, ignoring.");
data.reset();
}
VK_PIPELINE_CACHE_HEADER header;
std::memcpy(&header, data->data(), sizeof(header));
if (!ValidatePipelineCacheHeader(header))
data.reset();
}
const VkPipelineCacheCreateInfo ci{VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, nullptr, 0,