Vulkan/ShaderCache: Skip writing pipeline cache when size matches

Comparing all the data wasn't working, at least for Intel. I'm guessing
there's some modification time field in there which keeps changing.
This commit is contained in:
Connor McLaughlin 2020-06-22 15:58:10 +10:00
parent eaca5eca07
commit 9265dd72ba
1 changed files with 3 additions and 4 deletions

View File

@ -344,9 +344,8 @@ bool ShaderCache::FlushPipelineCache()
data.resize(data_size); data.resize(data_size);
// Save disk writes if it hasn't changed, think of the poor SSDs. // Save disk writes if it hasn't changed, think of the poor SSDs.
std::optional<std::vector<u8>> existing_data = FileSystem::ReadBinaryFile(m_pipeline_cache_filename.c_str()); FILESYSTEM_STAT_DATA sd;
if (!existing_data.has_value() || existing_data->size() != data_size || if (!FileSystem::StatFile(m_pipeline_cache_filename.c_str(), &sd) || sd.Size != static_cast<u64>(data_size))
std::memcmp(existing_data->data(), data.data(), data_size) != 0)
{ {
Log_InfoPrintf("Writing %zu bytes to '%s'", data_size, m_pipeline_cache_filename.c_str()); Log_InfoPrintf("Writing %zu bytes to '%s'", data_size, m_pipeline_cache_filename.c_str());
if (!FileSystem::WriteBinaryFile(m_pipeline_cache_filename.c_str(), data.data(), data.size())) if (!FileSystem::WriteBinaryFile(m_pipeline_cache_filename.c_str(), data.data(), data.size()))
@ -357,7 +356,7 @@ bool ShaderCache::FlushPipelineCache()
} }
else else
{ {
Log_WarningPrintf("Skipping updating pipeline cache '%s' due to no changes.", m_pipeline_cache_filename.c_str()); Log_InfoPrintf("Skipping updating pipeline cache '%s' due to no changes.", m_pipeline_cache_filename.c_str());
} }
m_pipeline_cache_dirty = false; m_pipeline_cache_dirty = false;