diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2022-07-28 10:31:16 -0700 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2022-08-02 22:23:49 -0700 |
| commit | d71797154ab3db04c02363f1538c805d9aa95429 (patch) | |
| tree | 89a67e0875801530f8b8929faeef4a7f24fcada5 /Source/Core/DiscIO/VolumeVerifier.cpp | |
| parent | 7d2d5d914bf3cacbecbb0bf8a642b616744aad54 (diff) | |
VolumeVerifier: enable fast hash functions by default
sets defaults based on cpu support.
Diffstat (limited to 'Source/Core/DiscIO/VolumeVerifier.cpp')
| -rw-r--r-- | Source/Core/DiscIO/VolumeVerifier.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/Core/DiscIO/VolumeVerifier.cpp b/Source/Core/DiscIO/VolumeVerifier.cpp index 1e5f6515f0..c4c5539fe2 100644 --- a/Source/Core/DiscIO/VolumeVerifier.cpp +++ b/Source/Core/DiscIO/VolumeVerifier.cpp @@ -18,6 +18,7 @@ #include "Common/Align.h" #include "Common/Assert.h" +#include "Common/CPUDetect.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" #include "Common/Crypto/SHA1.h" @@ -374,6 +375,24 @@ VolumeVerifier::~VolumeVerifier() WaitForAsyncOperations(); } +Hashes<bool> VolumeVerifier::GetDefaultHashesToCalculate() +{ + Hashes<bool> hashes_to_calculate{.crc32 = true, .md5 = true, .sha1 = true}; + // If the system can compute certain hashes faster than others, only default-enable the fast ones. + const bool sha1_hw_accel = Common::SHA1::CreateContext()->HwAccelerated(); + // For crc32, we assume zlib-ng will be fast if cpu supports crc32 + const bool crc32_hw_accel = cpu_info.bCRC32; + if (crc32_hw_accel || sha1_hw_accel) + { + hashes_to_calculate.crc32 = crc32_hw_accel; + // md5 has no accelerated implementation at the moment, always default to off + hashes_to_calculate.md5 = false; + // Always enable SHA1, to avoid situation where only crc32 is computed + hashes_to_calculate.sha1 = true; + } + return hashes_to_calculate; +} + void VolumeVerifier::Start() { ASSERT(!m_started); |
